#ESP32 based G5 PFD and HSI

1 messages · Page 2 of 1

hard flint
#

@swift latch could you make a pull request for your reworked readme how to set up a custom device?

swift latch
hard flint
stray gazelle
#

you really went all the way with this. All the shadings and all, I am just speechless 😻

swift latch
stray gazelle
#

I was honestly wondering if you are trolling with the actual unit screenshot

hard flint
swift latch
stray gazelle
#

I flashed my guition with this and oh boy is it gorgeous

swift latch
#

I need to finish the write up and testing, especially the HSI. I’ve added a couple new device settings so you can control the bearing pointers without buttons on the device.

#

But my dev laptop needs to go into the shop again. Every six months like clockwork it starts to overheat. I’m sure it’s poor thermal compound used by dell, but it’s still under warranty so I’m torn between just fixing it myself and letting them take one more crack at it. I’ve ordered that ptc thermal pad from LTT, and if it gets here soon I’ll try that first.

#

The one thing I think I’m going to finally give up on is determining the CDI Scaling mode the unit is in (E.g. the “TERM” “DEP” “ENR” etc annunciated at the 2:00 position inside the HSI compass). I cannot find reliable simvars to tell me which phase of flight I’m in. I’ll just use “TERM” or “ENR” if not on an approach.

#

I even wrote an entire Simvar monitoring program that lists all the A, L, B, simvars and their current values to the screen real-time to hunt down anything I could use. I’ll publish that soon.

stray gazelle
#

which mfproj / mcc should one use for dual config?

stray gazelle
#

also looks like I have to bump maxclients in simconnect xml to have it all work, hmm

stray gazelle
#

I get zeros for some configs

swift latch
#

And, just so you know, i have not finished testing the new modules yet!

stray gazelle
#

I will try again, it could also be that I am just using a wrong config

swift latch
#

Could be that it just doesn't work yet either 😉

stray gazelle
#

yeah 🙂

swift latch
#

I've tested modules on my dev machine so they're not completely broken

#

But not on my "production" machine yet

stray gazelle
#

I am still trying to ponder the encoder stuff

swift latch
#

Oh yeah, i haven't tested buttons/encoders at all

stray gazelle
#

3 gpio is just enough for the encoder if one uses the back connector but then the power button is not there

swift latch
#

My dev machine just has a bare Guition

stray gazelle
#

the confg also makes MF UI super sluggy

#

maybe something @noble galleon to look into (trying the G5 AIO mfproj)

#

oh

#

Error 03/08/2026 16:59:52 ConfigItemExecutor.Execute(): Error during execution (Bank): ConfigErrorException_SetCustomDevice
Error 03/08/2026 16:59:52 ConfigItemExecutor.Execute(): Error during execution (Turn): ConfigErrorException_SetCustomDevice
Error 03/08/2026 16:59:52 ConfigItemExecutor.Execute(): Error during execution (Ball): ConfigErrorException_SetCustomDevice
Error 03/08/2026 16:59:52 ConfigItemExecutor.Execute(): Error during execution (Ball): ConfigErrorException_SetCustomDevice
Error 03/08/2026 16:59:52 ConfigItemExecutor.Execute(): Error during execution (Ball): ConfigErrorException_SetCustomDevice

#

that would explain it

#

but maybe the configs are not fully working, need to see, at least that has a lot of the things twice, not sure if that is intentional

#

oh wait it has preconditions based on device type

stray gazelle
#

btw

#

the g5 shows 270 and 4kt

#

for wind

#

oh I updated weather and now g1000 shows 279 and 26kt, and the g5 shows 280 26kt

#

will keep an eye at this and see if there is some pattern

#

no wait

#

the thing is not updating, dang

#

controller mapping is annoying when you have two identical devices

#

but the config reads the AMBIENT WIND DIRECTION and shows that, so its sim then

#

hmm, there is a bit of an interesting situation with the HSI btw

#

if you have also a g1000 for example

#

it kinda should sync with the sim's CRS display

#

wait it was OBS mode in g1000

#

oh there is a separate GPS OBS VALUE

#

heh the unit is a bit surprised about that 🙂

#

so yeah, depending on the value of GPS OBS ACTIVE the hsi needs to follow either the GPS OBS VALUE or NAV OBS:n

#

man this is quite a state machine

swift latch
#

I also agree about the double device config. I’ve had multiple second thoughts about combining the devices into one to support the “real-time swap from menu” feature.

#

It was the only way to support that, but I think I could just drop the feature and make the MF configuration a lot cleaner.

swift latch
# stray gazelle

Oh that’s interesting. I wonder if I added a smoothing value I shouldn’t have.

stray gazelle
#

it seems the hsi deviation bar and the arrow are drawn at a different time and the update lags

#

or yeah, the arrow might have smoothing

#

and the same smoothing is not used for the deviation part

swift latch
#

Hope to get the dev machine back working soon!

stray gazelle
#

I am vibing some python in #1447919735185604722

swift latch
#

I'm considering switching back to two separate MobiFlight device setup. Currently, you can switch between HSI and PFD "on the fly". However supporting this makes it a little more difficult for people who don't have the buttons, and it greatly complicates the MobiFlight configuration, as you have to keep all variables populated for both devices to support the swap. I'm thinking the "cool" factor of this feature isn't worth the "PITA" factor of maintaining the configuration. Before I remove it and re-work the MF Configs, does anyone have any thoughts? @stray gazelle

stray gazelle
#

yeah

torpid mural
#

I think it would be most popular if this becomes a very cheap and quite generic hardware instrument that is easily flashable and configurable. That being said, is there no easy way to make different definitions in MF that preconfigure the display for one trick and hide not needed parameters for that mode? So that there is one firmware, and three front end definitions for either mode or both? Maybe with multiple mcc files?

swift latch
stray gazelle
#

hmm, so I am trying to understand how the mfproj and the device config works

#

I have this now

#

using the G5 ROOT PFD.mfproj

#

it shows up as hsi though

#

and I am pondering if I somehow fundamentally think this wrong way around

swift latch
#

I'm working on the configs now. I just uploaded what I think is darn near complete on the firmware side.

#

But i need to beef up the "after install" instructions. "COnfigure device in MobiFlight Connector after flashing" is doing a lot of heavy lifting.

#

Ok, so right now in the CC_GT/MF directory there are some mfproj files.

#

The current ones i'm messing with are G5 ROOT PFD.mfproj and G5 ROOT HSI.mfproj

#

With the latest firmware you should pick either PFD or HSI custom device in MF.

#

Then use the appropriate mfproj

#

The biggest snag i have right now are the CDI Scale labels, (TERM/ENR/LPV etc.) but I'm working on cleaning and simplifying those.

#

Actually...the pfd in the repo now has two projects in it. Once i get them all finalized i'll clean up that folder and get them named properly.

#

But should be close.

swift latch
#

Ok, I've now updated the installer and it's working well. I fixed a core issue where setting up the first device worked really well, but if you wanted to delete one and change to another the virtual devices would get duplicated. If you see that in your config, best bet is to use the "erase device first" option on the web installer. https://ccrawford.github.io/CC_G5/web-installer/

#

I'm going to spend some time flying and fine-tuning the .mfproj files. They're still "good, not great"

torpid mural
#

Hmmm, I flashed with the web installer, and droppped the config files in the community folder. Screen stays black, and MF 11 only shows this....

pale phoenix
#

Might be necessary to kill the efuse for the bootloader debug output?

torpid mural
#

Tried this: #1433279689878798336 message

Burning eFuses:
    - 'UART_PRINT_CONTROL' (Set the default UART boot message output mode) 0b00 -> 0b11


Check all blocks for burn...
idx, BLOCK_NAME,          Conclusion
[00] BLOCK0               is not empty
        (written ): 0x0000000000000100000000000000d1f50000000000000000
        (to write): 0x00000000000000c000000000000000000000000000000000
        (coding scheme = NONE)
.
This is an irreversible operation!
Type 'BURN' (all capitals) to continue.
BURN
BURN BLOCK0  - OK (all write block bits are set)
Burn postponed eFuses from BLOCK0.
Reading updated eFuses...
Checking eFuses...
Successful.

However, still same result

#

python3 -m espefuse --chip esp32s3 --port COM5 summary

UART_PRINT_CONTROL (BLOCK0) Set the default UART boot message output mode = Disable R/W (0b11)

swift latch
#

It's an issue with the overlap of PID/VID of the CH340 chip that is used on both the Mega and your display.

#

Let me find the full instructions.

#

Assuming you've installed MF into the default directory: Find this file: %USERPROFILE%\AppData\Local\MobiFlight\MobiFlight Connector\Boards\arduino_mega.board.json

#

On line 14, change this line:
"DtrEnable": true,
to
"DtrEnable": false,

That will fix it. HOWEVER, you have to update that line whenever MF updates itself. I have a issue raised with the main maintainers. I'll check in on it now.

torpid mural
#

Success, thanks!

swift latch
torpid mural
swift latch
#

Nice! There's a mfproj in the repo for your MF install

torpid mural
#

What might be useful is a setting to set the vertical position top/center/bottom and users can hide the excess display. I thought about making a little console with displays sticking out from the top.

swift latch
#

It's a variable in the code, i just haven't exposed it. I can add it to the list of things you can set in MF useful.

swift latch
#

Maybe I should throw an always on garmin logo up in the top 40 px.

pale phoenix
#

give it an option to make it say Mobiflight instead 😛

#

like on Tuomas's GNC255

stray gazelle
#

yeah the logo would work on top. could be just a logo.png that you convert at build time?

#

or a .h

torpid mural
noble galleon
#

G4RMIN

#

It is like there are copies for Specalized bike apparel, they are spelled SPECIAUZED

pale phoenix
noble galleon
#

the U looks like LI

pale phoenix
stray gazelle
#

I would not put anything there that looks like an existing trademark, because trademark owners need to protect them legally, as far as I know.

Maybe make it a flag in the .ini to add 40 pixels tall logo graphic, and shift the display to bottom of the screen and we could have a default MOBIFLIGHT logo there in .h format, one could replace with another graphic exported from GIMP, using the "Export as C header" plug-in.

https://www.youtube.com/watch?v=pThSBrl3Bsk

has some good footage of the button / encoder functions.

I was searching for a G5 intro video to share with my clients. Garmin's look at the G5 in combination with the GFC500 autopilot but I was looking for one which is much more basic. I found this.

Thanks to Hodge Aviation Services in Concord, California for this simple into into the G5's basic layout and functions.
https://www.hodgeflightservices...

▶ Play video
stray gazelle
#

so I need to look into the encoders stuff still. @swift latch I have been thinking that I want to redesign the "piggypack" PCB a bit more, to add 4 solder pads to the pcb back side, so that we can solder a flat cable that goes into the relay connector, so we would get 3 more IO pins, and it would still be pretty clean design.

That would give us GPIO 1, 2 and 40 on the relay, and by luck GPIO 1 and 2 are also analog pins, if I found the right pinout on google.

#

so we could have:

SD card connector, 4 io pins:

  • IO42 power button
  • IO41, IO48 encoder A/B
  • IO47 encoder push button

Relay header, 3 IO pins:

  • IO1 - ambient light sensor?
  • IO2
  • IO40 - PWM for the backlight?
#

I think it would be quite clean setup, a click-on pcb to the sd card slot, and a small flat cable to push into the backside header.

#

We could also design a case that replaces the black protective board on top of the PCB and holds everything in place using the PCB mount screws.

#

Would it be possible to optionally support the on-board IO pins for this? I could of course also make a RP2040 board to fit in there but it is kind of waste when the IO pins do exist if I understood this right.

swift latch
# stray gazelle I would not put anything there that looks like an existing trademark, because tr...

Oh yeah. I have a whole playlist of G5 videos. There are actually a lot out there. That was a good one. The thing is, there are multiple versions of the G5 code. It went through a decent update around 2022 that moved some information around, and different installations turn on-and-off different features as well. Early on I was totally confused when I'd code something, and then see a video with the field missing or in a different place! Even in the manuals they sometimes show old screen shots. I eventually settled on the version described in this edition of the manual: https://static.garmin.com/pumac/190-01112-12_j.pdf

swift latch
#

I really like the idea of making the encoder/button easier to connect than the RP2040 as i2c device method.

#

I think we need 4 IO (encoder a/b/sw, power button). If a 5th is availabe, we could add a power LED, but that's not essential and/or could just be hard wired to vcc/ground.

#

I originally used the RP2040 because I didn't have an i2c io expander in my parts drawer, so i coded the rp to act as one. I think if we're making a custom board for this, just add a pcf8574 to the design.

#

(Dang it. just placed an AliExpress order. I should have gotten some of those.)

pale phoenix
swift latch
# stray gazelle so we could have: SD card connector, 4 io pins: - IO42 power button - IO41, IO4...

I loved the SD card idea, but i'm concerned it's going to be fragile/unreliable if the intent is to sell these in the store. I think using the 2x4 header with io1 and io2 for i2c and io40 for interrupt (so we're not polling) is going to be a more reliable solution. I like your idea of a custom back lid that could integrate with the buttons/connector. Maybe a custom board that would hold the pcf8574 and resistors and the encoder, then headers for wires to the power button/ring light and header?

stray gazelle
#

hmm actually

#

since it is a custom firmware

#

it could likely do the encoder in the mux or expander too?

#

and I do agree the sd card is a cool hack but might be something that might oxidise or something later

noble galleon
#

i think it would make sense to stay inside the MF ecosystem and use components that are already supported

stray gazelle
#

it is a custom device to begin with though

#

if we use the pin header we are down to 3 IO pins

#

those are robust to interface to

noble galleon
#

yeah. but that code is thouroughly tested

stray gazelle
#

yep

#

but we cannot have the encoder in a shifter and we can only fit one

noble galleon
#

and i like to drink my own champagne

#

not so much eating the dog food.

#

😄

stray gazelle
#

but if we screw the sd-card hack on a pcb that is exactly the right size and anchors to the frame

noble galleon
#

but yeah. it would be a motiviation to add encoder support to shifters

stray gazelle
#

it should be quite firmly in place though

#

so maybe it would work

#

wait there was some other way of putting this, "eating our own dogshit" or how someone put it at work after a bit of a nasty debugging day

noble galleon
#

but don't confuse that someone with me

#

😄

stray gazelle
#

but hmm

noble galleon
#

so you are saying that none of the pins on the ESP32 are available anymore for hooking up stuff?

stray gazelle
#

on the other hand the i2c bus is an interesting way to do stuff

#

well

noble galleon
#

Ralf found a screen version with a pico2

stray gazelle
#

we have 4 in the SD card connector

noble galleon
#

i meant really available... not hijacked

stray gazelle
#

and 3 in the relay header

#

then some small 1.5mm pitch jst connectors that I would need to look up but they are likely wired to peripherals

#

see red text

#

most pins go to the screen

#

I wonder what that top right UART header is

pale phoenix
#

speaker header compromises the relay, battery header is hardwired into a battery management IC. UART is shared with the CH340.

#

so none of those are usable, sadly

#

Same with the P2 debug header. Just have pins that are already used by other components

#

Maybe the three GPIOs of the touch panel could be repurposed, depends on how things are wired inside the LCD

#

two GPIOs, apparently they decided to just shunt the interrupt to ground

#

the 40-pin RGB connector just breaks the touch panel I2C stuff out to solder pads on the FPC

swift latch
#

So today I use IO1, IO2, and IO40 from that header to connect to my RP2040 acting as an I2C slave. However right now I have the 2040 not just multiplexing the IO but managing the encoder. It sends the delta of the encoder changes since it was last updated, not just the pulses, if that makes sense. Basically I just use the interrupt line to signal to the ESP32 that there's data available and continue to accumulate the pulse changes on the rp2040 until they get picked up by the ESP32 at which time i reset it.

#

I use that one RP2040 to monitor both encoders+sw and both buttons on my PFD/HSI dual screen. Never had any issues.

#

There are so many "modes" for that encoder, realistically it's pulses have to be managed locally by the custom device, and not by MF. (the encoder could be changing any of a handful of values or it could be manipulating the menus).

stray gazelle
#

yeah the modal UI makes it really hard to do that from the custom device messages

#

because you would have to break out all those preconditions into the MF config I guess

#

its a bit the same dilemma like what I would have to do if I would implement for example the stored frequencies or settings menus etc in the GNC255

#

because the firmware could do it, but then its the same situation, the knob does different things depending on where in the UI you are

#

like if you have the menu open, it does not adjust the frequency anymore

#

I guess you would need to have "outer knob" encoder device, but there is no way for MobiFlight to know if you are in settings menu or tuning the radio

#

ie, the dilemma you asked on the other channel

#

hmm

#

but yea this is actually quite specific topic related to custom devices and one limit is they are output only

#

there is no "custom input device" so that you could just send sim events from the code for example

#

you'd have to fake button events or such

stray gazelle
#

@swift latch seems you committed some iomux things?

#

let me see if my tree is up to date

s_RGB.cpp:98:5: error: 'gpio_hal_iomux_func_sel' was not declared in this scope; did you mean 'gpio_hal_func_sel'?
   98 |     gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[pin], PIN_FUNC_GPIO);     
      |     ^~~~~~~~~~~~~~~~~~~~~~~
      |     gpio_hal_func_sel
*** [.pio\build\ccrawford_cc_g5_esp32s3\lib56b\LovyanGFX\lgfx\v1\platforms\esp32s3\Bus_RGB.cpp.o] Error 1
#

oof I thin my environment has some issues now

#

oh I think its some python issue, I downgraded my python for esphome which doesnt support the latest version or something

stray gazelle
#

oh it was my environment

#

works now

#

I had a new idea for the screen + pcb mechanics

#

what if there was a smoked acrylic "glass" on top, 3mm thick, that has a cutout for a low profile encoder and button? Could we have it on top of the display?

stray gazelle
#

that way it would maybe look like it is flush with the display

#

the screen would be a bit "sunken in" but might still work ok

swift latch
#

This is my first (and last so far) attempt at an enclosure

#

it was done when i was using more of the screen

#

Now, I'd be tempted to make the bezels cover some of the dead space

#

Any my code does do "virtual input device" in that I send encoder and button messages for encoders that don't really exist. That way I can support using one encoder for course/heading/altitude/kohlsman depending on which menu item is active (just like the real G5)

stray gazelle
#

yea, I am also rotating to (2) to test, when the usb is on bottom, the left side of screen margin is wider

#

and pondering offsets on where to place the image

#

in relation to the frame to get this thought out

swift latch
#

My latest firmware has X_OFFSET and Y_OFFSET constants that my layout should respect, but I'll admit i haven't tested different values yet.

stray gazelle
#

oh, perfect way to test then

#

what would X offset do?

#

isnt it full width?

swift latch
#

Correct. It's 0. But it's there!

stray gazelle
#

so did one need to create a custom device? I am trying to remember how to do this new one

#

flash firmware, choose by custom device type what it is?

swift latch
#

Now there are three devices in the file. One called PFD one called HSI and one that is just G5 (that should still be configurable, but I need to test that one!)

#

So, add a different custom device rather than fuss with the MF setting.

#

In general I don't think the ability to switch it with the menu was worth the gross complications and redundancies that were necessay with the MF config.

stray gazelle
#

yea, I would assume most people just run one

#

I mean, to switch it on the fly is a feature in the unit of course

#

but yeah, maybe a lot of hassle for a very little thing in practice

#

there is an interesting edge case in the dual config I think @noble galleon

#

because

#

oh there was a glitch

#

but in this case

#

you probably should name your devices when you save the config

#

it is hard to know which is which and then stuff dont work if you map the HSI to PFD and vice versa, because the custom devices dont add up

#

also if I click "bind controllers" I dont get the dialog, need to do it form menu, hmm

#

so I need to look that C4 is attitude indicator

#

right side is way nicer now

#

maybe it would autobind if the names were unique

#

I dont want to make a PR because it would anyways screw up your serial numbers then

#

this needs a courtesy lens cloth 🙂

noble galleon
#

it looks very nice

swift latch
#

The biggest thing with the on-the-fly switching is that you have to have a complete MF config for both device types. So you end up sending a lot of data that the device will never use.

stray gazelle
#

oh btw, there is this feature in the board.json:

#

I will test this out and will make a PR

#

this would allow us set a predefined name

#

the only problem I see is it looks like config upload suffers from this, that we have seen on many custom devices

#

@hard flint I wonder if you have an idea why this happens?

#

the upload works though

#

but it just fails when it reads it back I think

#

if I right click -> reload config it shows the arduino logo and doesnt show any devices, but works if I unplug and plug it back

swift latch
#

I have that “failed to upload “ problem a lot on my community projects. I haven’t hunted down the issue yet. Sometimes you can just have the connector re-read and it’s ok.

swift latch
stray gazelle
#

we had that in the gnc255 too, maybe @hard flint has an idea what could cause it

#

it seems always in custom devices

swift latch
#

Yeah, i've gotten too used to it not working to the point where i don't worry about it. I already have Ralf actively working on two other things for me right now. Not going to add a third 😉

stray gazelle
#

the new thing in this one, is when I right click to "reload config" after the failed config upload, it shows up with the arduino icon, and requres unplugging to work again but oddly retains the name I gave it. The upload worked though but something messes up after the upload.

Not sure if this is some odd clue for @noble galleon regarding the recent "device shows up as compatible" case - maybe not, but this is new behavior that I have not seen before.

swift latch
#

If so, it's the "dtr puts esp32 into firmware upload mode" issue. I've entered an issue on the github, and ralf is considering it.

#

The resolution is to change the mega-board.json dtrEnable setting to false. There are more detailed instructions on my github repo for the project.

stray gazelle
#

hmm it might be but I think I edited the mega json

#

I need to check that

#

migth have been on my laptop where I did it because it was what I had at fsweekend

swift latch
#

And, you'll need to re-edit after every MF update (like the one from yesterday)

stray gazelle
#

yes, actually true!

#

it could actually be just that

#

let me see

stray gazelle
#

actually let me just make a branch and a PR

#

the dtr to false didnt fix it unfortunately it seems, will test a bit more

#

the upload works though, you just need to unplug and plug back in

hard flint
#

I had this issue in the past too. Can't remember what I did, even if I did something.
I think it's a timing issue, the board info is requested before the board has booted up, might be to a to long initializing of the custom device. It happens also if the board sends some status messages and the connector thinks it's the answer of the requested board info.

Changing the time in the board.json for connecting could help.

stray gazelle
#

let me try

hard flint
#

Oh sorry, too early this morning. I mean when the connector expects the successful upload message...

hard flint
#

@stray gazelle @swift latch you could test the following:

  • enable debug logging
  • upload your config, it will show up like:
Debug    03/29/2026 10:52:49    MobiFlightModule.SaveConfig(): Uploading config part 8.0.1.1.Encoder:1.2.Button:7.39.16.2.LcdDisplay:
Debug    03/29/2026 10:52:49    MobiFlightModule.SaveConfig(): Uploading config part 11.28.10.Analog Input:7.38.20.4.LcdDisplay 1:
Debug    03/29/2026 10:52:49    MobiFlightModule.SaveConfig(): Uploading config part 16.0.6.7.8.15.2.LedModule:6.3.Servo:
Debug    03/29/2026 10:52:49    MobiFlightModule.SaveConfig(): Uploading config part 11.27.10.Analog Input 1:
Debug    03/29/2026 10:52:49    MobiFlightModule.SaveConfig(): Uploading config part 15.10.11.12.13.0.0.0.0.0.Stepper:
Debug    03/29/2026 10:52:49    MobiFlightModule.SaveConfig(): Uploading config part 12.14.15.9.4.InputShifter:3.16.Output:
Debug    03/29/2026 10:52:49    MobiFlightModule.SaveConfig(): Uploading config part 14.17.18.19.20.21.2.Multiplexer:
Debug    03/29/2026 10:52:49    MobiFlightModule.SaveConfig(): Saving config.
Debug    03/29/2026 10:52:50    MobiFlightModule.SaveConfig(): Config activated.```
* copy this to a text editor, delete all text from each row, add a `11,` before the config part and a `;` at the end. It should look like:
```11,8.0.1.1.Encoder:1.2.Button:7.39.16.2.LcdDisplay:;
11,11.28.10.Analog Input:7.38.20.4.LcdDisplay 1:;
11,16.0.6.7.8.15.2.LedModule:6.3.Servo:;
11,11.27.10.Analog Input 1:;
11,15.10.11.12.13.0.0.0.0.0.Stepper:;
11,12.14.15.9.4.InputShifter:3.16.Output:;
11,14.17.18.19.20.21.2.Multiplexer:;```
#
  • now open a terminal session to this board (Connector must be closed!)
  • type 9; and 12; into the terminal (it's not shown up in terminal), the board reports it's info and config.
  • next type 13;, the config gets resettet
  • next copy each of your modified row, e.g. 11,8.0.1.1.Encoder:1.2.Button:7.39.16.2.LcdDisplay:; into the terminal
  • after each copied row the board responds with 5,48; (48 is length of the copied string).
  • at least type 14; and 16;, this saves and activates the config.

The only messages you must see is like:

5,48;
5,93;
15,OK;
17,OK;```
No other messages must show up (I copied only rows, so for each row you will get a `5,xy;`)
#

If this is the case, it's most likely a timing issue. Loading and activating the config could take too much time so the message 17,OK; comes too late.

stray gazelle
#

lets see

#

will test

#

this is the log so far

#

so it looks like timeout

#

I wonder what that one lowercase "s" is

#

but maybe its part of the device name, will try

#

the gnc255 has the same issue now hmm

#

I think it is if you only have one custom device and nothing more

#

seem to recall this from earlier

#

hm, but this is not reproduceable always, now it worked with the gnc255

#

hm, I get a crash in Connector when I try to rename the custom device

#

"index 0 is out of range" - maybe this is somehow related, But I will try with the terminal now

#

ok now we get somewhere

#
15,OK;
[ 59620][E][esp32-hal-ledc.c:206] ledcAttachChannel(): Pin 38 is already attache                               d to LEDC (channel 0, resolution 9)
[ 59630][E][esp32-hal-ledc.c:321] ledcAttach(): No free timers available for fre                               q=1200, resolution=9. To attach a new channel, use the same frequency and resolu                               tion as an already attached channel to share its timer.
E (59644) lcd_panel.io.i80: esp_lcd_new_i80_bus(173): no free i80 bus slot
Failed to allocate DMA-capable internal SRAM buffer!

#

so it is very chatty for a reason, it seems

#

at this point the board does not respond anymore until you reconnect (reboot)

#

that lowercase "s" is part of the custom device name

#

I think the problem might be that since the G5 custom device has no settings at all, Connector expects a pin to be defined, in addition to the device name, and that causes the index out of range segfault

#

just a theory but it is what is different to for example compared to the GNC255 custom device

stray gazelle
#

@swift latch PR incoming for the stuff

#

for now there is no way to differentiate by the variant, only mobiflight device type, that is the same for both custom devices. Might not make sense to have two firmware binaries just for this.

#

Rather we should perhaps match for the default board name for custom icons, with fallback to board-logo.png but this is not implemented yet as far as I know.

hard flint
#

Yes, a custom device needs at least one pin.
The connector can't handle a custom device without pin.

hard flint
#

But I am pretty sure that it's the reason for the failure message after uploading. Not really what the connector expects 😉

swift latch
#

I thought that need for a dummy pin was fixed in the connector.

stray gazelle
#

that message though looks like something that comes from tbe esp32 core framework maybe?

swift latch
#

I’ll step through some of it this morning. I’m not sure what all that device upload stuff was doing in your config, Thomas.

#

(Autocorrect…apologies)

stray gazelle
#

I think the resource stuff might be some pin allocation conflict in the firmware side?

#

not sure, everything seems to work though

#

this project is an interesting test case again btw

#
  • no pins in custom device
  • two different (well, three, if you count the combined) custom devices per MobiFlightType
    • would be interesting to set unique icons for each board + custom device combination
  • for autoload of profiles (planned later) there is a combined mfproj project file that spans both devices (though if we had auto-matching of configs, they could well be split into their own files and thus would show up in two tabs which would be actually even better)
hard flint
hard flint
#

I haven't found anything in the release notes that no pins defined for custom devices leads to an exception is fixed...

stray gazelle
#

the way it crashes sounds exactly like it expects a pin to exist in the data structure

#

to my totally untrained eye 🙂

swift latch
#

Tuomas, can you tell me what exactly is crashing? I'm not having any issues

#

Or, are you just trying to fix the error message after uploading device profile?

#

Also, i've never seen a screen like the one you link above with the thumbnails and the "Upload board's default config:" option. Is that a beta version i don't have?

#

Honestly, i'm doing so much shady stuff on this device with respect to configuration that I always blamed the errors on the firmware.

#

I have hooked the read and save functions to inject my pseudo devices back in the response, and to block the core firmware from seeing my pseudo devices when the connector tries to write them back when the HSI/PFD is removed from the board.

#

I use "virtual" pins >100 for these pseudo device, and the hooks filter those out before it hits the core firmware

noble galleon
#

shouldnt the config simply be stored on flash and read from there? there is a flag for that in the firmware

#

ah. ok.

noble galleon
swift latch
#

The device uses the encoder to do a lot of things: adjust menu and change different sim values depending on which menu is visible.

#

So, my firmware just sends the necessary cmdMessenger messages when it needs to. But the profile on the pc must know about those messages so they can be assigned in the connector.

stray gazelle
#

@swift latch it is connector that crashes if I try to rename the custom device

#

because it only has a name

#

no pins defined

swift latch
#

So you'll see that when you add a PFD device to the custom board, you get about five or six other devices when you reload. @stray gazelle i now see what you're saying about the lockup/dead screen when you first assign the PFD. Let me look at that

noble galleon
#

right now we only have three types of messages from the firmware to MF. Button, Encoder, AnalogInput event. You are saying that some of these events gotta make it to MobiFlight while other events are processed in your firmware directly.

stray gazelle
#

@swift latch the "upload config" only shows if you have a matching board, and the board json has an entry for a mfmc file

swift latch
#

oh wow. i didn't know about that afeature

stray gazelle
#

yeah, checkout my PR branch and deploy

#

it should just work

#

and use the pattched mfproj also in the PR, it should match your devices even if you regenerate serials

#

that button shows up only if its configured for the board

swift latch
#

Looking now

stray gazelle
#

but there is that other pin allocation / dma message that comes on serial console when you upload a config

#

that is a different thing, and likely why Connector does not recognize the board after config upload

#

because it expects "config uploaded" reply and gets some other debug stuff

swift latch
#

I see one of your mfmc has a pin def and the other doesn't. Should I add a dummy pin to both devices?

stray gazelle
#

oh

#

if so, that is accidental

#

let me check

#

it might have a button that I tested, left over by accident

#

it doesnt have any here though, hmm

stray gazelle
#

interesting, yeah

swift latch
#

If the lack of a pin is causing an issue, i can add a dummy one easy enough

stray gazelle
#

actually there is a discrepancy here

#

how did I manage to save that mfmc is a good question

#

I wonder if the firmware on one of these is from some older commit that created stuff differently?

swift latch
# noble galleon right now we only have three types of messages from the firmware to MF. Button, ...

Not quite. The board/device doesn't have enough GPIO for the user to add any other devices to the board. However there is a feature that I use (and I'm probably the only one!) that allows you to connect an i2c device to the screen and i use that i2c device to run the physical controls. The encoder on that i2c device is used to manipulate menus and change settings (like the heading bug or the CDI course heading or the altitude bug or the kohlsman setting). My firmware knows what menu is visible or not and sends the appropriate encoder message back to MF using raw cmdMessenger text.

#

I (and @dapper fjord ) have tried other strategies that are more in-line with what MF expects (i.e. swapping around the devices to make my i2c device the only thing that talks to MF and having it send the display commands to the screen) and that works for simple devices but for the G5 there's just way too much data and I was losing commands left and right. I took a half-hearted attempt at a queue, but eventualy reverted back to the scheme I use now where MF talks to the display device and I have my own button/encoder handlers.

swift latch
swift latch
noble galleon
stray gazelle
#

if it is not hard to add a method to use local pins, I can try to figure out hardware options

#

there are 4 + 3 pins available

#

but like you said not exactly super robust or easy, but would work for a demo nicely

swift latch
#

Four more could be soldered, or use Tuomas's SD card interface

stray gazelle
#

yeah, but its also solderable on the sd card connector, its not impossibly small

#

but I think if I even want to try to make it more actual size I need 2 pieces of pcb

#

one sd card insert that has a pin header, and another that connects to the header pins on the back,

#

and then a wire to the front pcb with encoder, leds, button and photosensor 🙂

swift latch
stray gazelle
#

it is doable but just needs a bit of CAD and head scratching

swift latch
#

Then you can just add those as input devices in your .mfproj

stray gazelle
#

@swift latch I dont ever see those encoders though, is it a matter of activating also the i2c stuff?

swift latch
#

to "do the needful" as my indian friends say

stray gazelle
#

oh wait

swift latch
#

Correct. @stray gazelle

#

You will only get those messages in response to the physical controls

#

Of course, if you have other hardware that changes the current heading in the sim, the G5 gets it

#

The G5 always changes the pressure, target alt, track, etc in response to the sim, never the physical control

#

So a heading change (default use of the HSI encoder) follows this path: encoder->rp2040 (as i2c)->ESP32->G5 firmware->MF Connector->Sim->MF Connector->G5 firmware->Display

stray gazelle
#

yeah, but you wouldnt access the other functions with the button unless it is a in-device handled encoder

#

although hmm

#

what if there was just a "encoder" and "button" event?

#

and power button event

#

in the custom device messages?

#

would that work?

#

or did you already try that?

swift latch
#

If you want to write all the logic that would have to sync up the menu display and MF. Total non-starter

#

for me at least 🙂

stray gazelle
#

but we cannot send button events to custom device

#

I think

swift latch
#

I'm not

stray gazelle
#

hold on, let me think

#

no I mean

#

if there was a custom device message type "encoder up"

#

and "encoder down" and "power button pressed" and "encoder button press"

#

would that work?

#

no idea of the performance

swift latch
#

I'm recalling a convo we had on this about 1000 messages back

stray gazelle
#

yeah hmm

swift latch
#

Bottom line: My scheme works really well and is very maintainable in my firmware

#

and doesn't rely on the MF connector knowing what menu/screen/mode the G5 is in

#

very clean

stray gazelle
#

yea and it would be a nightmare of sorts trying to sync the state to MF Connector side

swift latch
#

For a generic "encoder" message to work MF would have to know what mode the screen is in. And only way it could do that would be to count button presses and encoder clicks which would be a nightmare

stray gazelle
#

it is a matter of architecture here: do custom devices handle their state or not

swift latch
#

Device controls its own state and the sim controls all the data.

stray gazelle
#

no I mean, maybe I am thinking this wrong

#

if MF sends just "knob turned right"

swift latch
#

and MF facilitates the communication between them

stray gazelle
#

just like MF would say "heading bug in sim turned right"

noble galleon
#

i think you just explained to me the need for a custom input device

#

😊

swift latch
#

oh, i see. I've not had good luck doing that @stray gazelle

swift latch
noble galleon
#

i think you could send mobiflight the context

#

and then use only one encoder

swift latch
#

Basically, input devices that are divorced from pins on the device.

#

Certainly, and people do that today, right?

noble galleon
#

the virtual pins make sense

#

but the context would be different

swift latch
#

Yes, you can certainly have an encoder change the standby com or the standby nav radio

#

today

#

What I needed here was "an encoder that has no physical analog"

noble galleon
#

no. today. you could send the state by using analog inlut

#

analog input = 0 > HDG

#

ablog inout = 1 > QNH

swift latch
#

Ah

noble galleon
#

and then you can decide on mobiflight side how to interpret the encoder event

#

your virtual encoder combines context with encoder event

swift latch
#

I see now. Yes. Instead of sending 3 different virtual encoders i could send one with a mode switch.

noble galleon
#

or this together could also be modeled by a real custom input device.

#

simply sending a message type to mobiflight with some payload

swift latch
#

I think my virtual encoder simplifies the MF programming, but that's just me

noble galleon
#

i think it does.

#

but the context sensitive action is not complicated

swift latch
#

agree

noble galleon
#

it just could get out of sync

#

so the virtual encoders are more reliable

#

i think its ok.

stray gazelle
#

hm are esp32 gpios differently named?

swift latch
#

What do you mean?

stray gazelle
#

I am trying to add just regular MF encoder to pins 48 and 41

#

on the sd connector pcb

#

is there a reason it should not work?

#

it works in the gnc255, just the LCD device is a custom device

swift latch
#

electrically or MF?

stray gazelle
#

and the buttons and encoders are regular encoders wired in gpio pins (its a RP2040) and added as regular devices in MF

swift latch
#

I may not have all the pins properly config'ed in the board.json tbh. Those need attention

#

I've lost you

stray gazelle
#

I added the pins

#

to json

swift latch
#

ok

#

Oh...are you trying to get my setup workin?

stray gazelle
#

testing this

#

it has pin 48 and 41

swift latch
#

yeah. not going to work

stray gazelle
#

the firmware does its own thing I guess?

swift latch
#

For a while, i was filtering all the button and encoder assignments

#

I thought i took that code out

#

and replaced with the config hooks that now filter out where pin# > 100

#

but tbh i never tested to see if adding encoders works

stray gazelle
#

maybe I will test your setup also

swift latch
#

again

#

but that setup won't get you menus

#

you have to use my RP2040 i2c slave software and wire in as the device expects

#

to the pins on the back.

stray gazelle
#

in the relay pins I guess?

swift latch
#

right. SCL, SDA and INT

#

It ain't pretty, but it works

stray gazelle
#

I also still think playing with the Garmin RS232 message frames over espnow would be a worthwhile experiment at some point, and for that the state needs to be in the device

swift latch
#

In the photo (and the firmware in the repo) i'm using one RP2040 to run 2 encoders, 4 buttons, 2 LEDs functioning as 2 different i2c slave devices

stray gazelle
#

so it connects to both guition units' over i2c

swift latch
#

right. Grounds to both, 5v from one

#

and that RP2040 obviously has no serial/USB connection to anything

stray gazelle
#

yea

#

so it would not need an extra usb, which is nice

#

it could also be a esp32 supermini I guess

#

if there are enough pins

swift latch
#

It might be able to be replaced with a simple i2c multiplexer, but i'd be just a tiny bit concerned about dropping encoder pulses given how busy that ESP32 is

stray gazelle
#

yea

#

if this works its good

swift latch
#

I just have a lot of those rp2040s lying around, it fit, and they're like $2 each.

stray gazelle
#

one option is to do a pcb for this that plugs to the back of one guition, hosts the pico and has a cable to the other relay header

#

or for a completely standalone unit of course could use two picos I guess

swift latch
#

I think the whole thing could work cleanly with some headers and built cabling.

#

or even a pcb with headers for jst wiring or something. There's nothing tricky here, just point to point wiring.

#

An rp2040 is like $3 now, and two TCA9548 i2c multiplexer modules are about $2. I'd just do the RP.

stray gazelle
#

or this

#

I got a few

#

the 26 and 27 are broken out, the i2c0 (20,21) is on the bottom solderpads but I guess they would work on any of those i2c0 pin pairs too?

#

this is a nice form factor

hard flint
#

@stray gazelle @swift latch could you please shortly summarize how many pins on the ESP32 are available and how many LED's, buttons and encoders must be connected?

swift latch
#

Yeah, those would be just fine

#

On the Guition 4" screen there are 3 pins (

#

There are three pins on the 8-pin header: io1, io2, io40. Very easily accessed and ready to be used.

stray gazelle
#

yea though there are not enough pins on the pi zero I am afraid

swift latch
#

The SD Card interface has 4 pins: 41, 42, 47, 48

stray gazelle
#

the regular pi is filling quite much up

swift latch
#

That need some small soldering skills

#

The device needs 1 encoder with push button. One power button. (4 pins total) would be nice to have a configurable LED pin for the ring light around the power button, but not essential, or could just be wired to power.

stray gazelle
#

I think it has enough pins if we want to go that way

swift latch
#

So, ideally 5 pins, but 4 for sure. 3 would be better than none.

stray gazelle
#

it has just a bit awkward connections on the sd card connector

#

4 + 3 is enough

swift latch
#

8 pin header in upper right. SD connector in lower left

stray gazelle
#

we can do

  • encoder with push, and power switch on the SD card slot
  • backlight (ring light) led on the relay connector
  • photocell on the relay connector
  • one pin is free
#

so it can work, its just mechanical issue to solve

#

what I thought of in the sd card connector track, is to make a sd connector with pin header and another pcb on the back, that plugs to the relay pins and screws on the back

#

and then some wire to the button / encoder pcb in front

swift latch
#

There are three buttons on the device, but none attached to gpio. There are other headers but they are for power/battery and UART breakout.

stray gazelle
#

I do think the sd card socket is fine as long as we just secure it well in the design. If it is soldered on the backside PCB with pin socket + header, it likely will work ok

#

I will draw something

#

but I will also try this pico route

#

but I think the esp32 gpios are analog capable, at least those in the relay connector should be

#

I am noting this down here, its a nice way to visualize the prototyping board stuff too, because the pico has the pin labels on the bottom

#

actually the rp2040 zero mini board has way more pins that I thought 🙂 it should be fine

pale phoenix
#

Just ordered some Picos to use that panel the intended way this weekend

hard flint
#

The 8 pin header is the relay connector? 3 pins are fine for an InputShifter 😉

stray gazelle
#

@swift latch what pin order in the 8 pin header?

pale phoenix
#

Personally, while encoders on shifters are definitely a useful potential addition, I kind of like the idea of having a separate processor for encoder readout, particularly in the context of custom devices where the µC core might be heavily loaded by the display output

#

pin 1/2 = GND, pin 3 = GPIO40, pin 5 = GPIO2, pin 7 = GPIO1, pin 8 = +5V

stray gazelle
#

yes, that is known

pale phoenix
#

GND, +5V and the RX/TX lines are labeled on the board

stray gazelle
#

but sda, scl and int

#

need to look at the code, its there

pale phoenix
stray gazelle
#

#1433279689878798336 message

#

disreg

#

got all info, just jumping around

swift latch
#

For me, the 5v was the important one not to mistake! Didn't want to send 5v to a i2c gpio.

#

I could have done a better job labeling 1 2 3 there.

stray gazelle
#

hmm

swift latch
#

If we're doing this "for real" i would use a keyed header to prevent pluggin it in upside down.

stray gazelle
#

erm

#

sorry

#

UnknownBoard: Unknown board ID 'generic'

#

keyboard is full of wires

#

missing platform I think, hold on

#

I nuked my platformio install since I changed my python version earlier I think

#

ok now it might build

#

automated build frameworks are great until they are not

#

I think the framework doesnt work on a new installation, copied the ini environment from the mf firmware RP pico section and now platformio installs a ton of stuff

#

and now it built

#

@swift latch care to share the .uf2 for the pico?

#

I just want to test it in action first

swift latch
#

Sure. it hasn't changed for a long time. lemme find it

stray gazelle
#

lovely mess

swift latch
#

I think it has a lot of Serial.printf for you to watch

hard flint
swift latch
#

I tried that. Killed my performance. Didn't try to debug, just reverted

stray gazelle
#

ok it works, I will do a proper quick pcb I think, I hate wiring 😄

#

especially these dupont wires

#

should get proper silicone ones

swift latch
#

Note that I’m just now committing some changes to the menu drawing. Z order of a few elements were messed up after the big display refactor

#

Yeah, I love those small gauge, stranded silicon wires

#

I just found this on AliExpress: | (5 Colors Mix Kit)Heat Resistant Flexible Silicone Wire 30/28/26/24/22/20/18/16AWG Stranded Cable Electrical Tinned Copper Wires
https://a.aliexpress.com/_mO7ogvF

stray gazelle
#

yea

#

you can also find silicone prototype wires

#

searching for "gold plated contacts" is not gold for sure, but rumor is, thicker metal pins

#

so they supposedly are holding better on the prototyping board holed

swift latch
#

Ok. Just committed some fixes to the menu drawing and updated the binary in the web installer.

#

Gotta go get outside now!

stray gazelle
#

@swift latch any feedback on the PR?

swift latch
#

Haven't loaded it up yet. Where did we land on the pins issue?

stray gazelle
#

not sure really

#

kinda two options, either the rp2040 approach for pcb, or native pins

#

I like the lifehack vibe of the microsd connector but then again it will need a pcb anyways, the rp2040 is kinda self contained thing, if on a back side pcb, we can then live with the 3 pins. Though, can we dim the led output along with backlight adjustment or is it already doing that?

swift latch
#

Sorry. i meant on the "one of your mfmc's has a pin defined" No worries. I'll take a look and revise/review

swift latch
#

Wow, didn't realize those features were there. I've made some adjustments and incorporated them into the main branch. (I suck at Git...please don't take this as me being dismissive of your work!)

#

Am I not setting up these values properly?

      "Project": "CC G5",
      "Website": "https://github.com/ccrawford/CC_G5",
      "Docs": "https://github.com/ccrawford/CC_G5/blob/main/README.md",
      "Support": "https://github.com/ccrawford/CC_G5/issues"
    }, ```

Or is there something broken on the mf.com site?
stray gazelle
#

yea totally no worries

#

I find vscode git tab to be nice for git

#

yeah the redirect is currently broken, I noticed that too

#

came accross this when I was making the PR

#

I hope you are ok with me butchering your photos for the logo 🙂

#

I also wish we could differentiate the device icons per installed custom device, but I guess we are a very very special case with this

swift latch
#

Agree on the logos. I used your big logo and added an un-tilted one for the little board logo. I had no idea all that was possible! Is it documented somewhere I missed?

swift latch
#

Ok, published new version to the web installer. I added a logo option as well, configurable from MF. Also updated the available pins on the device. I just noticed there are three more unused pins (35, 36, 37) the are right there, but would need fine soldering to the esp32s3 pins to break them out. Doable for a one off for sure.

#

I may try cutting the TX/RX/GND traces on the 8 pin header and running some wires.

swift latch
#

Oh crap. Just remembered 35, 36, 37 are used for SPRAM communication on the ESP32 S3. Never mind.

pale phoenix
#

Just had inputs configured for those and started wondering why I was not getting video anymore

stray gazelle
#

I think its documented in the source code and existing examples

#

that stuff has grown kinda organically and "we'll do it more once the new UI is done"

swift latch
#

There are a lot of obscure rules about what pins can be used for what

stray gazelle
#

so did we have like 4 scenarios for the encoder and other peripherals?

#
  • the rp2040 thingy via i2c on the relay header, do peripherals on RP2040, ESP32 drives it
  • the sdcard connector + relay header, run encoder and photocell and led light on esp32, virtual encoders based on device state
  • port expander on relay header to run all on esp32
  • encoders and buttons on esp32 as regular MF devices, send encoder and button events as custom device messages back to ESP32, handle them based on device state
swift latch
#

The IO is there but only 3 pins are readily available. 4 more on the SD card. Could either run jumpers from those pins to the 8-pin header, or perfect the SD card solution. I love that hack, but I'm concerned about it's longevity.

stray gazelle
#

I am not sure if #4 is feasible, but it is a thought I had one day

#

I think the sd card hack works if the board AND the unit casing is anchored together well

swift latch
#

I could give #4 one more chance. I think the buttons would be ok, but the encoder will feel bad.

stray gazelle
#

yeah I am also concerned about responsiveness

#

because its a heck of a loop

swift latch
#

Yeah. I mean you can always "click one more time" if a transition is lost, but if you're spinning the encoder to change heading and it's only inching along that would be irritating

stray gazelle
#

one thought

#

if the "basic" stuff was handled so,

#

crap no, custom devices cannot communicate back

#

unless it fakes it

#

what I was thinking is

#

we do the menu nav etc via "G5 encoder right" and "G5 encoder left" events etc

#

and then the device sends virtual buttons as state flags

#

but it gets just weird easily but could work

#

so that if HDG-mode-button = 1

swift latch
#

I think the coding on the MF Connector side would be a nightmare

stray gazelle
#

we enable precondition to drive heading directly

#

yea it would add complexity

#

and there is that garmin messaging idea that I hope to try one day

swift latch
#

These are all things i played with early on before the 2040 approach

stray gazelle
#

so that these guitions could talk in a mesh if it would work

#

yeah

#

I can see how it could get hairy

#

this is how I anchored the pcb - would be good to have another screw on the other side of encoder too

swift latch
#

Oh wow. That looks pretty solid though

stray gazelle
#

and then it would need a back lid that screws on those guition case holes

swift latch
#

Why not just use the stock lid?

#

Do you have tabs on the print to mae with the slots in the guition?

stray gazelle
#

I mean hold a sec

swift latch
#

(Just below your thumb in pic)

stray gazelle
#

not yet

#

but I was planning to, but I think screws are good too

swift latch
#

screws absolutely necessary

#

But your idea about a mating part that uses the existing screw slots is better

stray gazelle
#

but this is unfinished

swift latch
#

Much nicer than mine

stray gazelle
#

and it is too large too

#

so I am also trying to think how to keep it real size

swift latch
#

But my pushbutton is only panel mount...i like it because it's close to the real thing

#

I'm going for a run. I'll think while im out

stray gazelle
#

have fun!

#

then again, I dont know if it really matters that it is so tall - it might make the black bars on the screen stand out though

pale phoenix
#

I think I lost the screws by now, but the screw holes are also flimsy as hell

stray gazelle
#

yeah

#

the claws might work better

#

or just do screws through the claw holes

pale phoenix
#

Very much favor the idea of an over-frame to hold the screen in place

#

could also be used to conceal the asymmetry in the original bezel

#

my idea would be to have a back panel on the entire combo and use that to retain the screen, like the cross brace on cacrawf's design

swift latch
#

@stray gazelle
I'm re-trying the "completely external, standard MF device to manage physical controls" approach. Tell me if this approach makes sense:
I have a standard, stand alone RP2040 with encoder+switch and another momentary switch. In the Controller I have the rp2040 devices set mobiflight variables and then I send the value of that variable to the G5. Button: no problem, as the state changes are there in press and release. Works well.
But the encoder I set my mfVariable to -5, -1, 1, or 5 (left/right, fast slow), but i need the variable to go back to 0 after the value is sent to the g5. I tried different ways to accomplish this, but nothing is working for me. As a result, i cannot send multiple encoder pulses to the device. I tried using preconditions but no luck.
Any brilliant ideas?

pale phoenix
#

have a variable count the running total. Increase/decrease by 1 for slow turn, N for fast turn. Do the internal processing on the difference between an internal counter and the incoming signal

swift latch
#

Oooh.

#

Should this work?

#

oh, i should use $

#

nm

swift latch
#

Well, the good news is this approach seems to work great. The bad news is I'm not sure why I resisted this approach when about three people recommended it earlier.

#

Only bad part is it needs another USB connection, but that's not the end of the world and infinitely preferrable to having to open up the device and solder.

#

So if anyone wants to design a case/mount/support, go for it. I need to clean up code and do some more testing.

pale phoenix
#

Transmitting position changes since last reset is a rather common way of communicating encoder states. Professionally I work with ISO 11783-6, which uses that method, and I had suggested a similar interface to VKB when I requested a direct encoder API (that I later integrated in MF connector). I would assume that this was compatible with how their encoder states were handled internally already, since they maintain a queue of pulses.

#

As for USB connections, I was wondering. Your old approach with the I2C slave for the encoders - how much effort would it be to have that RPi also serve as a dual USB-to-UART adapter and bypass the CH340 on the Guitions? With the UART interface available on the relay header, it seems as if you might be able to avoid relying on having to squeeze an angled USB connector between the panels like that

swift latch
#

Hmmm. That's an interesting idea. TX/RX and 5v, gnd are on that 8 pin header already. So, could do that without having to mod the Guition.

pale phoenix
#

Not sure how well the CH340G is safe against being backdriven though, sadly the schematic does not seem to have resistors between the USB UART and the ESP and the headers

swift latch
#

I'm concerned about power as well. I think i've measured the Guition at around 300ma so two on one USB power line would be way over.

#

240ma right now

#

I guess we could try using io1 and 2 as uart lines to side-step the ch340, but that would require surgery on the core mf Firmware.

#

But i think the power requirement is the real issue here. I think we're almost exactly at 500ma for two screens + rp2040

pale phoenix
#

Some companies play rather fast and loose with USB power specs. On a self-powered hub, or if you have few devices plugged into your machine you can usually get away with more than the spec allows

stray gazelle
#

and the button, on those free pins ?

#

or is it the difficulty of ports?

#

If we had encoders on input shifters that'd be it

#

except the led

swift latch
#

For me? sure. But if it's just for me I'll stick with my i2c solution. I was trying to make it "plug and play" if you and Sebastian wanted to sell it in the store.

pale phoenix
swift latch
#

Much cleaner to tell someone "if you want to mimic the rotary and power button on the devices, here's what you need to add to either a new or existing standard MF device.

#

I'm just saying: for me the project is done 🙂

#

If we want to make it more accessible, and doesn't require more than the usual MF soldering/assembly skills, this is a clean solution.

stray gazelle
#

yeah I willl try the regular encoder on the SD slot, it just needs to accept the default devices on extra pins

swift latch
#

Go for it!

stray gazelle
#

yeah and you can easily do it so that you have a prototyping board and encoder and button

#

need to test if the encoder works on the piggyback board, I think it did t at o e pount

#

will test soon

swift latch
#

In the code, the "G5Hardware" class is fairly well encapsulated. You could add hard-wired devices there very easily.

stray gazelle
#

ok and the code would process them? that would be nicest for a PCB kit

swift latch
#

And the code as it exsits right now works with either solution (i2c or MF signals)...no switches or compiler settings.

#

It doesn't work with directly conencted encoder/button now, but i think it would be trivial to add it. If you're just going to wire them up and add them via the connector as regular MF devices, that would work from a configuration/setup angle, but that's the approach that didn't work well with me.

#

The G5 hardware processes based on button state and encoder deltas.

#

You could either wire them in directly or try to round-trip them. It's that round trip that I had issues with when i tried initially, but maybe you'll have better luck.

#

I was dropping too many encoder pulses

#

but i honestly don't remember how hard i worked to fix that

#

Either way, i've set the actual pins available correctly in the board.json now. Oh, and I see that Ralf has a patch in for the dtrEnable=false waiting for Sebastian to approve which will make life a lot easier!

#

Sorry. That string of messages could be a bit confusing. What I'm trying to say is if you wired the physical controls directly to the Guition (either through the SD and header pins or via a multiplexer) you have two options then to hook them up to my G5 code:

  1. Treat them like normal MF devices and use the MF interface I just added, but use with a stand alone board.
  2. Handle them directly in the firmware, bypassing the Connector similar to the way I process i2c buttons/encoders today. This would require mods to the firmware, but I believe would have better results and fewer dropped encoder pulses.
stray gazelle
#

you said it worked ok when separate Arduino had the encoder and passed the events to the custom device though?

swift latch
#

Correct.

#

I'm worried about the G5 that is doing all the heavy lifting on the display dropping encoder pulses

#

seen it in the past when the core firmware doesn't get enough time

#

and believe that's what was happening to me early in the project. (I started this about a year ago, so my memory of what i was doing then is hazy. I originally had the RP2040 acting as the MF front end and the display as the slave.

stray gazelle
#

@swift latch so did you already commit the "regular encoder anywhere in MF" variant?

#

could try that out with the encoders on the sd connector and see how it is in practice

#

but yea it might be a system load issue

#

so does the encEncoderState stuff work in the code yet?

#

sorry my questions but I am not sure 🙂

torpid mural
#

Doesn't the ESP32 have an internal pulse counter so that you don't have to keep track with software? Or is that a problem with the available pins?

swift latch
#

ll add that now

swift latch
swift latch
torpid mural
swift latch
#

Well thank you! I wasn't aware of this.

stray gazelle
#

oh yeah the new "rp2040" hardware events seem to work great

#

heading increments by 2 though, need to look into that, but it seems otherwise great

#

oh heading knob config is twice there, disabled one and it works

#

@swift latch thank you for all the work, this works great - now I need to figure out why it doesnt work if I add the encoders to the guition itself

swift latch
stray gazelle
#

mfproj

#

let me see

swift latch
#

At least that's what I thought I saved to the repo.

#

should be one input from the rp2040 and one output to the ESP32 for each control.

stray gazelle
#

the pfd config

swift latch
#

Yeah, havent' even built an HSI one yet. (but it will look similar)

stray gazelle
swift latch
#

Ahhhhh

#

Yep. Bug. Thanks.

#

(Oh, and remember: if you're on the menu, pick "heading" and twist the knob, the heading value you see will only change if MF is running and connected to the sim!)

#

(because the knob changes the value in the sim, and the display gets it's value from the sim)

stray gazelle
#

yeah

#

hm, the firmware defines config in flash = 1

#

so that means I should be able to add the encoder and buttons with MF?

#

and uploading the config? or does it mean I need to hardcode it in the .h file?

#

no wait exactly the other way

#

reading the customdeviceconfig.h now

swift latch
#

Honest, i've never tried adding.

#

You're in uncharted waters

#

And, since you just cloned my repo, you may not even see the hooks i put in there.

stray gazelle
#

oh wait these are the virtual encoders

swift latch
#

Those, honestly, could be stale. I tried so many different ways to get this working I may not have cleaned up after dead-ends.

#

Also, in my local repo here on my dev machine i'm using Ralf's to-be-deployed memory management routines.

#

(allocateMem.cpp)

stray gazelle
#

yea

swift latch
#

which in turn touches all the MF_xxx devices.

#

Sorry.

stray gazelle
#

no worries

swift latch
#

(Wife wants to go get dinner---gotta run)

stray gazelle
#

the any-mf-encoder approach works well

#

and no worries, I will see

swift latch
#

Yes, despite the extra USB, I think if the objective is to sell these screens as a G5 (or ISIS or SFD) in the store, then the no-solder/just works solution is the best.

stray gazelle
#

yea

#

I tested the encoders on esp32, they work if no custom device is present,

#

or also if I add them first and then the custom device

#

but if I run the thing at the same time the display goes wild when I rotate the encoder

#

not sure if its some memory corruption or just lack of processing cycles, but it puts weird data on the display, so I suspect its something else than just lack of processing cycles

#

like I had numbers in the autopilot mode display at some point

#

but I will see if I get a photo / video

#

I wonder if the second core could process the encoders but it might of course be the overhead of running two cores can cause slowdown.

I also tested the "use second core" definition after you mentioned not having tested it lately and the unit works but it is clearly slower indeed

swift latch
#

Ok, last update for a while. Web installer updated. New .mfproj (cleaned, corrected, incorporates new independent hardware controller). New Community folder with Tuomas's changes and the new controller messages. I need to get back to my JPI engine monitor before my internal memory cache expires on it! And traveling in Europe next week.

noble galleon
#

i understand only half of what you guys are talking 🤣 but on the bright side: my display arrived yesterday.

hard flint
#

Oh yeah, my one arrived also yesterday. The one with RP2350 is scheduled for beginning of next week 😉

swift latch
#

You can now use any generic MF device with an encoder and button to control the menus.

hard flint
#

@swift latch I just had a rough look into your code.
In get_version.py line 21, core_firmware_version = "2.5.1" must be set to 3.0.0! Otherwise outputs will not work.
My ESP32 branch is always based on the latest main branch from the FW repo, and there was a change addressing outputs from 2.5.1 to 3.0.0
So your board reports the version 2.5.1 but requires the commands from 3.0.0.

swift latch
#

Thank you. I will admit, all of the version numbering confuses the (stuff) out of me. I would love to add a definitive guide to it in that developer documentation I did a while ago.

#

What errors should I expect to see from that mis-match?

#

Totally happy to change it, but would like to understand it as well!

#

"Requires the commands from 3.0.0" are those commands from the MF Connector or from the core MF Firmware?

hard flint
#

from the connector to the board

#

only for outputs it has changed

hard flint
#

up to 2.5.1 the pin number was part of the message, from 3.0.0 the x.th output device is send like for all other output devices

#

and the pin number is now saved in the class

swift latch
#

So am i not seeing issues because i don't use any pins? But that doesn't seem right. It seems like my code works?

#

Or is it because all the other code i'm using to build the device is also 2.5.1? I'm confused. Sorry.

hard flint
#

As long as no outputs are used it doesn't care.
If outputs are used, they will not be set to the required status.
Up to 2.5.1 the command was: set pin number 4 to H
Assuming this output is the first configured output, the new command with 3.0.0 is: set the first configured output, which is 0, to H. FW version 2.5.1 interprets this as setting pin number 0 to H.

stray gazelle
#

oh so would this be why the encoder etc didnt work?

#

hmm

hard flint
stray gazelle
#

oh right

stray gazelle
#

I am still a bit confused, since the encoders and buttons work great without the custom device present.

But when I add the custom device for the display, they stop working.

#

this is with the "piggyback" pcb

stray gazelle
#

curiously if I do it so that the custom device is added first (I need to adjust the mfmc to move the custom device blog before the encoder and button devices) it flashes ok and it works but the encoder is not being updated well - I wonder if it is just cpu being too limited, but the buttons do work

#

there is also ESP32Encoder lib that uses interrupts, hm

hard flint
#

I believe the custom device takes too much time. Encoders must be read best every 1ms, but at least every 3ms so far I have tested it.
Using interrupts could be a solution. I have a branch where I tested it, but as far as I remember only for AVR's and Pico.

stray gazelle
#

yeah

#

I get like a sporadic input from encoder but its just one here and there

#

it uses the esp32 pulse counter

stray gazelle
#

just pondering whether it is worth it ot not, and if I should just ditch the piggyback pcb and do a simple encoder + button pcb separately

stray gazelle
#

dont mind my notes 😄

stray gazelle
#

dang, I think I have a plan

#

not ideal, but for a demo unit at least

#

those are conveniently close to the edge

#

so cut them there so the header can be repurposed for USB for the esp32

#

I will need to solder jumpers from the ch340C to the header but it is not super difficult

#

so I can get rid of the usb connector on the side

#

will see if that helps or if it is just easier to do with a angled connector

#

sorry this is pretty chaotic, I am just making notes here (maybe I should just start my own thread on this)

pale phoenix
#

I'd personally look into putting the USB-serial off board. Might still require severing traces though

stray gazelle
#

yeah I am thinking of re-routing it to the eight pin header Rx and tx pins

#

so I could do a PCB that hooks to the header for both USB and i2c

#

and then has the encoder , buttons, and led backlight

#

and connects with the small screw holes

#

nice design excercise

#

it would also have a rp2040 zero

#

it might work nicely

pale phoenix
#

Just did some investigations on the Guition screen, and can confirm that the UART RX pin is driven quite strongly by the CH340 even without USB connected

#

I have no idea why they decided to put the UART signals on three different headers considering nothing can actually drive them without horrifically abusing at least one of the chips

#

I feel like those pins would be infinitely more useful with some resistores between the CH340 and the rest of the board

stray gazelle
#

went to the garmin booth at friedrichshafen

#

some shaky video of me feeling the buttons and encoders

swift latch
#

Whenever I go up in friends' planes and we're in cruise, I always ask if it's ok if i mess with the avionics. Then they laugh at me when I start gushing over how good the buttons and encoders feel.

#

I think that's how i have my buttons wired up: Click of the power button brings up brightness that is then controlled with the encoder.

#

I don't have the setting for the photo-resistor (nor the photoresistor at all!) Would be easy, but hasn't been a priority