@@ -77,27 +77,30 @@ class dispDrvSt7789 : public dispDrvBase {
7777 @return True if the display was initialized successfully, false otherwise.
7878 */
7979 bool begin () override {
80- #if defined(ARDUINO_ARDUINO_NESSO_N1)
81- WS_DEBUG_PRINT (" pin_cs: " ); WS_DEBUG_PRINTLN (_pin_cs);
82- WS_DEBUG_PRINT (" == LCD_CS " ); WS_DEBUG_PRINTLN (_pin_cs == LCD_CS);
80+ #if defined(ARDUINO_ARDUINO_NESSO_N1)
81+ WS_DEBUG_PRINT (" pin_cs: " );
82+ WS_DEBUG_PRINTLN (_pin_cs);
83+ WS_DEBUG_PRINT (" == LCD_CS " );
84+ WS_DEBUG_PRINTLN (_pin_cs == LCD_CS);
8385 if (_pin_cs == LCD_CS)
84- _display = new Adafruit_ST7789 ((int8_t ) _pin_cs, (int8_t ) _pin_dc, &LCD_RESET);
86+ _display =
87+ new Adafruit_ST7789 ((int8_t )_pin_cs, (int8_t )_pin_dc, &LCD_RESET);
8588 else
86- #endif
87- _display = new Adafruit_ST7789 (_pin_cs, _pin_dc, _pin_rst);
89+ #endif
90+ _display = new Adafruit_ST7789 (_pin_cs, _pin_dc, _pin_rst);
8891 if (!_display)
8992 return false ;
9093
9194// Built in displays with custom init / swapped w+h
9295#ifdef ARDUINO_ARDUINO_NESSO_N1
93- if (_pin_cs == LCD_CS) {
94- _display->init (135 , 240 );// Init ST7789 240x135
95- _display->invertDisplay (true );
96- } else {
96+ if (_pin_cs == LCD_CS) {
97+ _display->init (135 , 240 ); // Init ST7789 240x135
98+ _display->invertDisplay (true );
99+ } else {
97100#endif
98- _display->init (_width, _height);
101+ _display->init (_width, _height);
99102#if defined(ARDUINO_ARDUINO_NESSO_N1)
100- }
103+ }
101104#endif
102105 _display->setRotation (_rotation);
103106 _display->fillScreen (ST77XX_BLACK);
@@ -122,33 +125,32 @@ _display->init(_width, _height);
122125 return true ;
123126 }
124127
125-
126128 /* !
127129 @brief Draws the battery icon based on the current battery level.
128130 @param bat
129131 The current battery level as a percentage (0-100).
130132 */
131133 void drawBatteryIcon (uint8_t bat) override {
132134 const unsigned char *bat_icon = epd_bmp_bat_empty;
133- if (bat >= 75 ) {
134- bat_icon = epd_bmp_bat_full;
135- } else if (bat < 75 && bat >= 50 ) {
136- bat_icon = epd_bmp_bat_75;
137- } else if (bat < 50 && bat >= 25 ) {
138- bat_icon = epd_bmp_bat_50;
139- } else if (bat < 25 && bat >= 10 ) {
140- bat_icon = epd_bmp_bat_25;
141- } else {
142- bat_icon = epd_bmp_bat_empty;
143- }
144- // Clear and draw the new battery icon, based on battery level
145- _display->fillRect (_statusbar_icon_battery_x, _statusbar_icons_y,
146- ST7789_STATUSBAR_ICON_SZ, ST7789_STATUSBAR_ICON_SZ,
147- ST77XX_WHITE);
148- _display->drawBitmap (_statusbar_icon_battery_x, _statusbar_icons_y,
149- bat_icon, ST7789_STATUSBAR_ICON_SZ,
150- ST7789_STATUSBAR_ICON_SZ, ST77XX_BLACK);
151- _statusbar_bat = bat;
135+ if (bat >= 75 ) {
136+ bat_icon = epd_bmp_bat_full;
137+ } else if (bat < 75 && bat >= 50 ) {
138+ bat_icon = epd_bmp_bat_75;
139+ } else if (bat < 50 && bat >= 25 ) {
140+ bat_icon = epd_bmp_bat_50;
141+ } else if (bat < 25 && bat >= 10 ) {
142+ bat_icon = epd_bmp_bat_25;
143+ } else {
144+ bat_icon = epd_bmp_bat_empty;
145+ }
146+ // Clear and draw the new battery icon, based on battery level
147+ _display->fillRect (_statusbar_icon_battery_x, _statusbar_icons_y,
148+ ST7789_STATUSBAR_ICON_SZ, ST7789_STATUSBAR_ICON_SZ,
149+ ST77XX_WHITE);
150+ _display->drawBitmap (_statusbar_icon_battery_x, _statusbar_icons_y,
151+ bat_icon, ST7789_STATUSBAR_ICON_SZ,
152+ ST7789_STATUSBAR_ICON_SZ, ST77XX_BLACK);
153+ _statusbar_bat = bat;
152154 }
153155
154156 /* !
@@ -223,7 +225,6 @@ _display->init(_width, _height);
223225 _display->setTextSize (_text_sz);
224226 }
225227
226-
227228 /* !
228229 @brief Updates the status bar with current information (battery level,
229230 connectivity status, etc).
0 commit comments