33#include < stdint.h>
44#include < string.h>
55
6+ // MarqueeScroller: Handles text scrolling for small displays (e.g., 64x48 OLED)
7+ // Used by companion radio UI to display long messages that don't fit on screen
68struct MarqueeScroller {
7- int offset = 0 ;
8- unsigned long next_time = 0 ;
9- bool paused = true ;
9+ int offset = 0 ; // Current scroll offset in pixels
10+ unsigned long next_time = 0 ; // Next scroll update time (millis)
11+ bool paused = true ; // Scroll paused state
1012
13+ // Reset scroller to initial state
1114 void reset () {
1215 offset = 0 ;
1316 next_time = 0 ;
1417 paused = true ;
1518 }
1619
17- // Call once per loop iteration to advance the scroll.
18- // textW/displayW in pixels, now = millis().
20+ // Update scroll position - call once per loop iteration
21+ // Parameters:
22+ // textW - width of text in pixels
23+ // displayW - width of display in pixels
24+ // now - current time from millis()
25+ // speed_ms - milliseconds between scroll steps (default: 150ms)
26+ // pause_ms - milliseconds to pause before scrolling starts (default: 2000ms)
1927 void update (int textW, int displayW, unsigned long now,
2028 unsigned long speed_ms = 150 , unsigned long pause_ms = 2000 ) {
2129 int maxScroll = textW - displayW;
@@ -35,13 +43,32 @@ struct MarqueeScroller {
3543 }
3644};
3745
46+ // UIColor framework: Provides consistent color definitions across different display types
47+ // Each display driver defines its own UIColor values based on its color capabilities
48+ // For monochrome displays: 0 = BLACK, 1 = WHITE
49+ // For color displays: 16-bit RGB values
50+ using ColorVal = uint16_t ;
51+
52+ class UIColor {
53+ public:
54+ // UI element color definitions
55+ // Each display driver implements these with appropriate values for its display
56+ static ColorVal window_bkg; // Background color for windows/panels
57+ static ColorVal title_bkg; // Background color for title bars
58+ static ColorVal title_txt; // Text color for titles
59+ static ColorVal primary_txt; // Primary text color (main content)
60+ static ColorVal secondary_txt; // Secondary text color (metadata, timestamps)
61+ static ColorVal warning_txt; // Warning/alert text color
62+ static ColorVal popup_bkg; // Background color for popups/dialogs
63+ static ColorVal popup_txt; // Text color for popups/dialogs
64+ static ColorVal corp_blue; // Corporate/brand color (blue)
65+ };
66+
3867class DisplayDriver {
3968 int _w, _h;
4069protected:
4170 DisplayDriver (int w, int h) { _w = w; _h = h; }
4271public:
43- enum Color { DARK =0 , LIGHT , RED , GREEN , BLUE , YELLOW , ORANGE }; // on b/w screen, colors will be !=0 synonym of light
44-
4572 int width () const { return _w; }
4673 int height () const { return _h; }
4774
@@ -50,9 +77,9 @@ class DisplayDriver {
5077 virtual void turnOn () = 0;
5178 virtual void turnOff () = 0;
5279 virtual void clear () = 0;
53- virtual void startFrame (Color bkg = DARK ) = 0;
80+ virtual void startFrame (ColorVal bkg = UIColor::window_bkg ) = 0;
5481 virtual void setTextSize (int sz) = 0;
55- virtual void setColor (Color c) = 0;
82+ virtual void setColor (ColorVal c) = 0;
5683 virtual void setCursor (int x, int y) = 0;
5784 virtual void print (const char * str) = 0;
5885 virtual void printWordWrap (const char * str, int max_width) { print (str); } // fallback to basic print() if no override
@@ -83,7 +110,7 @@ class DisplayDriver {
83110 if (c >= 32 && c <= 126 ) {
84111 dest[j++] = c; // ASCII printable
85112 } else if (c >= 0x80 ) {
86- dest[j++] = ' \xDB ' ; // CP437 full block ¦
113+ dest[j++] = ' \xDB ' ; // CP437 full block �
87114 while (src[i+1 ] && (src[i+1 ] & 0xC0 ) == 0x80 )
88115 i++; // skip UTF-8 continuation bytes
89116 }
0 commit comments