How to handle new display types #1978
Replies: 2 comments 4 replies
-
Hello, This is a topic I've known is coming for a loooong time. I've had many issues in the past with C++ interfacing/classes not being a 0 cost abstraction at the end, and we are fairly tight on code size overhead [1]. So I instead leaned towards not adding any more and instead we would make an implementation for each basic screen type (Currently large/small monochrome OLED's). I expect to move the remaining OLED calls that exist outside that folder to instead being functions at are implemented in the UI folder set and so their actual implementation is swapped out at build time. I just haven't yet gotten to moving those calls out. This is effectively option (1) in a slightly more organised manner (I think). It does result in duplicated code per screen, but to be honest so far, its significantly more readable and easier to maintain than when we had #ifdef's or extra abstraction. So I'm leaning towards the duplication as it makes the reading of the code simpler. I actually have a long term goal, (for when I have more than like an hour a week to work on this) to actually machine generate a lot of these implementations at compile time from a yaml/json markup for the screen layout. Since a lot of these is basically the same thing with just different fonts/colours/positioning. Which can be compile-time determined. Flash and RAM usage is absolutely a concern, and honestly is generally more limiting than processing speed. For certain devices (TS80P) we have bounced off being out of flash size more than once and had to get crafty flagging features. In general Miniware devices are often the worst for available flash size as they tend to like to claim large chunks for their bootloader and then not use that space. [1] I do long term intend to remove a lot of the current C++ classes for plain C to re-gain some code size, but haven't had time. |
Beta Was this translation helpful? Give feedback.
-
Just as an update to this; I might try and take a stab at a driver for one of this series of display for some testing in the coming weeks. So if you leave the graphics to last; I might get it done by the time you get there |
Beta Was this translation helpful? Give feedback.
-
I am working on supporting MHP50 (#1872) which has color LCD instead of OLED. I have gone through the codebase and compiled a list of files where is the OLED library hardcoded (excluding port specific files and
UI/drawing
) and what functions are used there:I have two solutions to this problem but I would like to hear opinion of current maintainers because I am not deeply familiar with IronOS codebase (nor do I have experience with larger embedded projects).
a) Each class would implement required common functions. Than we could create a type alias in the configuration files of each port for the required screen class.
b) Or better solution is template class that would be just a wrapper for the screen specific functions. This approach would allow more freedom in the screen driver class but than some screen specific conversion would be needed in the wrapper.
I am not fan of first solution because if there would be another display that would be supported, it would lead to quite messy code IMHO. However, second solution comes with some drawbacks, mainly that the common interface would need to be monochrome in order to not introduce any performance penalty or break compatibility (due to increased RAM usage) for devices with monochrome displays (don't know if this is a real concern).
@Ralim @discip (or someone else) let me know what do you think of suggested solutions or how would you add support to different screen types.
Beta Was this translation helpful? Give feedback.
All reactions