@@ -41,9 +41,55 @@ class drvDispThinkInkGrayscale4Eaamfgn : public dispDrvBase {
41
41
// Clear the display buffer
42
42
_display->clearBuffer ();
43
43
_display->display ();
44
+
44
45
return true ;
45
46
}
46
47
48
+ virtual void writeMessage (const char *message) override {
49
+ if (_display == nullptr )
50
+ return ;
51
+
52
+ // Start with a fresh display buffer
53
+ // and settings
54
+ int16_t y_idx = 0 ;
55
+ _display->clearDisplay ();
56
+ _display->setTextSize (_text_sz);
57
+ _display->setTextColor (EPD_BLACK);
58
+ _display->setCursor (0 , y_idx);
59
+ _display->display ();
60
+
61
+ // Calculate the line height based on the text size (NOTE: base height is
62
+ // 8px)
63
+ int16_t line_height = 8 * _text_sz;
64
+ uint16_t c_idx = 0 ;
65
+ size_t msg_size = strlen (message);
66
+ for (size_t i = 0 ; i < msg_size && c_idx < msg_size; i++) {
67
+ if (message[i] == ' \\ ' && i + 1 < msg_size &&
68
+ (message[i + 1 ] == ' n' || message[i + 1 ] == ' r' )) {
69
+ // Handle \r\n sequence as a single newline
70
+ if (message[i + 1 ] == ' r' && i + 3 < msg_size &&
71
+ message[i + 2 ] == ' \\ ' && message[i + 3 ] == ' n' ) {
72
+ // Skip to the next line
73
+ y_idx += line_height;
74
+ _display->setCursor (0 , y_idx);
75
+ i += 3 ;
76
+ } else if (message[i + 1 ] == ' n' ) {
77
+ // Skip to the next line
78
+ y_idx += line_height;
79
+ _display->setCursor (0 , y_idx);
80
+ i++;
81
+ }
82
+ } else if (message[i] == 0xC2 && message[i + 1 ] == 0xB0 ) {
83
+ _display->write (char (248 ));
84
+ _display->display ();
85
+ i++;
86
+ } else {
87
+ _display->print (message[i]);
88
+ _display->display ();
89
+ }
90
+ }
91
+ }
92
+
47
93
private:
48
94
ThinkInk_290_Grayscale4_EAAMFGN *_display;
49
95
};
0 commit comments