DCC-EX / CommandStation-EX

EX-CommandStation firmware from DCC-EX. Includes support for WiFi and a standalone WiThrottle server. A complete re-write of the original DCC++.
https://dcc-ex.github.io/
GNU General Public License v3.0
155 stars 107 forks source link

Customizable LCD display #86

Closed davidcutting42 closed 3 years ago

davidcutting42 commented 3 years ago

From #66

5chufti commented 3 years ago

at least solve contradiction between configurable lines/columns in config.h (user) and fixed settings in LCDDisplay.h, most 4 line displays have 20 columns... best would be to take over definitions from config.h

Neil-McK commented 3 years ago

Whilst the 4-line LCD has 20 characters, and 128-column OLED displays are capable of 21 characters, 2-line LCDs are only 16 characters long. So to avoid losing the end of messages off some screens, we limit the length of the messages to 16 characters. A second option would be to drop support for the LCD1602 display, allowing messages of up to 20 characters. A third option might be to code short and long versions of messages so that they can be abbreviated when on a 16-character screen, e.g. by marking optional characters with a prefix character. Alternative messages could also be substituted by conditional compilation. A fourth option is to increase the buffer size to 21 characters per line but retain all standard messages at 16 characters max. This would allow tinkerers to add longer messages if desired.

5chufti commented 3 years ago

as I allready wrote: best would be to take over the setting from config.h as there the user has to/is expected to put the actual values of his display after all... then it is up to the implementation of the "LCD" macro to prevent buffer overflows (cut chars/lines) if the passed text would exeed the defined chars/lines

Neil-McK commented 3 years ago

As of v3.0.5, parameter MAX_MSG_SIZE can be used to allocate buffers for longer lines. This defaults to 16 since all existing messages are designed to fit on a 16 character LCD, so longer buffers would be wasted RAM, particularly on an Uno.

Example for a 132x64 SH1106-based I2C OLED display:

#define MAX_MSG_SIZE 22

Note that this resolves the immediate request by enabling longer messages. However, the wider issue remains, of how to benefit from longer messages without losing information on smaller screens.