PS: In the Ardupilot thread you mention that the x positons are between 0 - 27, but as far as I can see they are actually 0 - 26.
PPS: I don't know if this is of any help but regarding the general code structure, it might make sense to split things out a little more and define boundaries between the responsibilities of each area. I have an example from a side project I've been working on. (This isn't intended as something to be used by others, it's just for my own use - But the code structure might help this project, it's very much based on the OSD portion of this project) [See attached]
StandaloneDJIOSD - Initial.zip
You can see in this code that I've tried to give each area a very well defined responsibility. The messages map almost directly onto the Betaflight MSP messages which are consumed by the DJI Air Unit, although only values which are displayed are handled. The DJI OSD class is a facade that then adds a layer on top of that and provides a bit of purpose. For example craft name is changed to text and the battery voltage is passed to both the analog and battery status messages. A layer above this would then use this API, in my case (For an RC car) I'll probably use FrSky Smart Port sensors for the current and voltage, use an analog RSSI input, hardcode armed as true and call it a day.
The OSD positions are currently just numbers, but it would be much easier to follow if they were calculated from x/y coordinates.
The formula is:
2048 + x + (y * 32)
I've attached a PDF and image showing these values: Betaflight OSD Positions.pdf
PS: In the Ardupilot thread you mention that the x positons are between
0 - 27
, but as far as I can see they are actually0 - 26
.PPS: I don't know if this is of any help but regarding the general code structure, it might make sense to split things out a little more and define boundaries between the responsibilities of each area. I have an example from a side project I've been working on. (This isn't intended as something to be used by others, it's just for my own use - But the code structure might help this project, it's very much based on the OSD portion of this project) [See attached] StandaloneDJIOSD - Initial.zip
You can see in this code that I've tried to give each area a very well defined responsibility. The messages map almost directly onto the Betaflight MSP messages which are consumed by the DJI Air Unit, although only values which are displayed are handled. The DJI OSD class is a facade that then adds a layer on top of that and provides a bit of purpose. For example craft name is changed to text and the battery voltage is passed to both the analog and battery status messages. A layer above this would then use this API, in my case (For an RC car) I'll probably use FrSky Smart Port sensors for the current and voltage, use an analog RSSI input, hardcode armed as true and call it a day.