@@ -135,7 +135,7 @@ static unsigned char framebuffer[FBSIZE];
135
135
static unsigned char *fb;
136
136
static uint8_t cour_line;
137
137
static uint8_t picBits, ledBits, hotBits;
138
- static uint8_t PanelDetected = 0 ;
138
+ static bool panel_detected = false ;
139
139
140
140
// Different platforms use different SPI methods
141
141
#if ANY(__AVR__, TARGET_LPC1768, __STM32F1__, ARDUINO_ARCH_SAM, __SAMD51__, __MK20DX256__, __MK64FX512__)
@@ -169,13 +169,13 @@ void TFTGLCD::clear_buffer() {
169
169
170
170
// Clear panel's screen
171
171
void TFTGLCD::clr_screen () {
172
- if (!PanelDetected ) return ;
172
+ if (!panel_detected ) return ;
173
173
#if ENABLED(TFTGLCD_PANEL_SPI)
174
174
WRITE (TFTGLCD_CS, LOW);
175
175
SPI_SEND_ONE (CLR_SCREEN);
176
176
WRITE (TFTGLCD_CS, HIGH);
177
177
#else
178
- Wire.beginTransmission (( uint8_t ) LCD_I2C_ADDRESS); // set I2C device address
178
+ Wire.beginTransmission (uint8_t ( LCD_I2C_ADDRESS) ); // set I2C device address
179
179
Wire.write (CLR_SCREEN);
180
180
Wire.endTransmission (); // transmit data
181
181
#endif
@@ -199,15 +199,15 @@ void TFTGLCD::print(const char *line) {
199
199
200
200
// For menu
201
201
void TFTGLCD::print_line () {
202
- if (!PanelDetected ) return ;
202
+ if (!panel_detected ) return ;
203
203
#if ENABLED(TFTGLCD_PANEL_SPI)
204
204
WRITE (TFTGLCD_CS, LOW);
205
205
SPI_SEND_ONE (LCD_PUT);
206
206
SPI_SEND_ONE (cour_line);
207
207
SPI_SEND_SOME (framebuffer, LCD_WIDTH, cour_line * LCD_WIDTH);
208
208
WRITE (TFTGLCD_CS, HIGH);
209
209
#else
210
- Wire.beginTransmission (( uint8_t ) LCD_I2C_ADDRESS); // set I2C device address
210
+ Wire.beginTransmission (uint8_t ( LCD_I2C_ADDRESS) ); // set I2C device address
211
211
Wire.write (LCD_PUT);
212
212
Wire.write (cour_line);
213
213
Wire.write (&framebuffer[cour_line * LCD_WIDTH], LCD_WIDTH); // transfer 1 line to txBuffer
@@ -217,7 +217,7 @@ void TFTGLCD::print_line() {
217
217
}
218
218
219
219
void TFTGLCD::print_screen () {
220
- if (!PanelDetected ) return ;
220
+ if (!panel_detected ) return ;
221
221
framebuffer[FBSIZE - 2 ] = picBits & PIC_MASK;
222
222
framebuffer[FBSIZE - 1 ] = ledBits;
223
223
#if ENABLED(TFTGLCD_PANEL_SPI)
@@ -229,33 +229,33 @@ void TFTGLCD::print_screen() {
229
229
#else
230
230
uint8_t r;
231
231
// Send framebuffer to panel by line
232
- Wire.beginTransmission (( uint8_t ) LCD_I2C_ADDRESS);
232
+ Wire.beginTransmission (uint8_t ( LCD_I2C_ADDRESS) );
233
233
// First line
234
234
Wire.write (LCD_WRITE);
235
235
Wire.write (&framebuffer[0 ], LCD_WIDTH);
236
236
Wire.endTransmission ();
237
237
for (r = 1 ; r < (LCD_HEIGHT - 1 ); r++) {
238
- Wire.beginTransmission (( uint8_t ) LCD_I2C_ADDRESS);
238
+ Wire.beginTransmission (uint8_t ( LCD_I2C_ADDRESS) );
239
239
Wire.write (&framebuffer[r * LCD_WIDTH], LCD_WIDTH);
240
240
Wire.endTransmission ();
241
241
}
242
242
// Last line
243
- Wire.beginTransmission (( uint8_t ) LCD_I2C_ADDRESS);
243
+ Wire.beginTransmission (uint8_t ( LCD_I2C_ADDRESS) );
244
244
Wire.write (&framebuffer[r * LCD_WIDTH], LCD_WIDTH);
245
245
Wire.write (&framebuffer[FBSIZE - 2 ], 2 );
246
246
Wire.endTransmission ();
247
247
#endif
248
248
}
249
249
250
250
void TFTGLCD::setContrast (uint16_t contrast) {
251
- if (!PanelDetected ) return ;
251
+ if (!panel_detected ) return ;
252
252
#if ENABLED(TFTGLCD_PANEL_SPI)
253
253
WRITE (TFTGLCD_CS, LOW);
254
254
SPI_SEND_ONE (CONTRAST);
255
255
SPI_SEND_ONE ((uint8_t )contrast);
256
256
WRITE (TFTGLCD_CS, HIGH);
257
257
#else
258
- Wire.beginTransmission (( uint8_t ) LCD_I2C_ADDRESS);
258
+ Wire.beginTransmission (uint8_t ( LCD_I2C_ADDRESS) );
259
259
Wire.write (CONTRAST);
260
260
Wire.write ((uint8_t )contrast);
261
261
Wire.endTransmission ();
@@ -266,7 +266,7 @@ extern volatile int8_t encoderDiff;
266
266
267
267
// Read buttons and encoder states
268
268
uint8_t MarlinUI::read_slow_buttons () {
269
- if (!PanelDetected ) return 0 ;
269
+ if (!panel_detected ) return 0 ;
270
270
#if ENABLED(TFTGLCD_PANEL_SPI)
271
271
uint8_t b = 0 ;
272
272
WRITE (TFTGLCD_CS, LOW);
@@ -283,13 +283,13 @@ uint8_t MarlinUI::read_slow_buttons() {
283
283
WRITE (TFTGLCD_CS, HIGH);
284
284
return b;
285
285
#else
286
- Wire.beginTransmission (( uint8_t ) LCD_I2C_ADDRESS);
286
+ Wire.beginTransmission (uint8_t ( LCD_I2C_ADDRESS) );
287
287
Wire.write (READ_ENCODER);
288
288
Wire.endTransmission ();
289
289
#ifdef __AVR__
290
- Wire.requestFrom (( uint8_t ) LCD_I2C_ADDRESS, 2 , 0 , 0 , 1 );
290
+ Wire.requestFrom (uint8_t ( LCD_I2C_ADDRESS) , 2 , 0 , 0 , 1 );
291
291
#elif defined(STM32F1)
292
- Wire.requestFrom (( uint8_t ) LCD_I2C_ADDRESS, ( uint8_t ) 2 );
292
+ Wire.requestFrom (uint8_t ( LCD_I2C_ADDRESS), uint8_t ( 2 ) );
293
293
#elif ANY(STM32F4xx, TARGET_LPC1768)
294
294
Wire.requestFrom (LCD_I2C_ADDRESS, 2 );
295
295
#endif
@@ -300,7 +300,7 @@ uint8_t MarlinUI::read_slow_buttons() {
300
300
301
301
// Duration in ms, freq in Hz
302
302
void MarlinUI::buzz (const long duration, const uint16_t freq/* =0*/ ) {
303
- if (!PanelDetected ) return ;
303
+ if (!panel_detected ) return ;
304
304
if (!sound_on) return ;
305
305
#if ENABLED(TFTGLCD_PANEL_SPI)
306
306
WRITE (TFTGLCD_CS, LOW);
@@ -309,20 +309,19 @@ void MarlinUI::buzz(const long duration, const uint16_t freq/*=0*/) {
309
309
SPI_SEND_TWO (freq);
310
310
WRITE (TFTGLCD_CS, HIGH);
311
311
#else
312
- Wire.beginTransmission (( uint8_t ) LCD_I2C_ADDRESS);
312
+ Wire.beginTransmission (uint8_t ( LCD_I2C_ADDRESS) );
313
313
Wire.write (BUZZER);
314
- Wire.write (( uint8_t ) (duration >> 8 ));
315
- Wire.write (( uint8_t ) duration);
316
- Wire.write (( uint8_t ) (freq >> 8 ));
317
- Wire.write (( uint8_t ) freq);
314
+ Wire.write (uint8_t (duration >> 8 ));
315
+ Wire.write (uint8_t ( duration) );
316
+ Wire.write (uint8_t (freq >> 8 ));
317
+ Wire.write (uint8_t ( freq) );
318
318
Wire.endTransmission ();
319
319
#endif
320
320
}
321
321
322
322
void MarlinUI::init_lcd () {
323
- uint8_t t;
324
323
lcd.clear_buffer ();
325
- t = 0 ;
324
+ uint8_t t = 0 ;
326
325
#if ENABLED(TFTGLCD_PANEL_SPI)
327
326
// SPI speed must be less 10MHz
328
327
SET_OUTPUT (TFTGLCD_CS);
@@ -335,43 +334,40 @@ void MarlinUI::init_lcd() {
335
334
#ifdef TARGET_LPC1768
336
335
Wire.begin (); // init twi/I2C
337
336
#else
338
- Wire.begin (( uint8_t ) LCD_I2C_ADDRESS); // init twi/I2C
337
+ Wire.begin (uint8_t ( LCD_I2C_ADDRESS) ); // init twi/I2C
339
338
#endif
340
- Wire.beginTransmission (( uint8_t ) LCD_I2C_ADDRESS);
341
- Wire.write (( uint8_t ) GET_LCD_ROW); // put command to buffer
339
+ Wire.beginTransmission (uint8_t ( LCD_I2C_ADDRESS) );
340
+ Wire.write (uint8_t ( GET_LCD_ROW) ); // put command to buffer
342
341
Wire.endTransmission (); // send buffer
343
342
#ifdef __AVR__
344
- Wire.requestFrom (( uint8_t ) LCD_I2C_ADDRESS, 1 , 0 , 0 , 1 );
343
+ Wire.requestFrom (uint8_t ( LCD_I2C_ADDRESS) , 1 , 0 , 0 , 1 );
345
344
#elif ANY(STM32F1, STM32F4xx, TARGET_LPC1768)
346
345
Wire.requestFrom (LCD_I2C_ADDRESS, 1 );
347
346
#endif
348
347
t = (uint8_t )Wire.read ();
349
348
#endif
350
349
351
- if (t == LCD_HEIGHT) {
352
- PanelDetected = 1 ;
350
+ panel_detected = (t == LCD_HEIGHT);
351
+
352
+ if (panel_detected) {
353
353
#if ENABLED(TFTGLCD_PANEL_SPI)
354
354
SPI_SEND_ONE (INIT_SCREEN);
355
355
SPI_SEND_ONE (Marlin);
356
356
WRITE (TFTGLCD_CS, HIGH);
357
357
#else
358
- Wire.beginTransmission (( uint8_t ) LCD_I2C_ADDRESS);
359
- Wire.write (( uint8_t ) INIT_SCREEN);
358
+ Wire.beginTransmission (uint8_t ( LCD_I2C_ADDRESS) );
359
+ Wire.write (uint8_t ( INIT_SCREEN) );
360
360
Wire.write (Marlin);
361
361
Wire.endTransmission ();
362
362
#endif
363
363
}
364
- else
365
- PanelDetected = 0 ;
366
364
safe_delay (100 );
367
365
}
368
366
369
- bool MarlinUI::detected () {
370
- return PanelDetected;
371
- }
367
+ bool MarlinUI::detected () { return panel_detected; }
372
368
373
369
void MarlinUI::clear_lcd () {
374
- if (!PanelDetected ) return ;
370
+ if (!panel_detected ) return ;
375
371
lcd.clr_screen ();
376
372
lcd.clear_buffer ();
377
373
}
@@ -395,7 +391,7 @@ static void center_text(FSTR_P const fstart, const uint8_t y) {
395
391
#if ENABLED(SHOW_BOOTSCREEN)
396
392
397
393
void MarlinUI::show_bootscreen () {
398
- if (!PanelDetected ) return ;
394
+ if (!panel_detected ) return ;
399
395
//
400
396
// Show the Marlin logo, splash line1, and splash line 2
401
397
//
@@ -418,7 +414,7 @@ static void center_text(FSTR_P const fstart, const uint8_t y) {
418
414
#endif // SHOW_BOOTSCREEN
419
415
420
416
void MarlinUI::draw_kill_screen () {
421
- if (!PanelDetected ) return ;
417
+ if (!panel_detected ) return ;
422
418
lcd.clear_buffer ();
423
419
lcd_moveto (0 , 3 ); lcd.write (COLOR_ERROR);
424
420
lcd_moveto ((LCD_WIDTH - status_message.glyphs ()) / 2 + 1 , 3 );
@@ -655,7 +651,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
655
651
#if ENABLED(LCD_PROGRESS_BAR)
656
652
657
653
void MarlinUI::draw_progress_bar (const uint8_t percent) {
658
- if (!PanelDetected ) return ;
654
+ if (!panel_detected ) return ;
659
655
if (fb == &framebuffer[0 ] + LCD_WIDTH * 2 ) { // For status screen
660
656
lcd.write (' %' ); lcd.write (percent);
661
657
}
@@ -672,7 +668,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
672
668
#endif // LCD_PROGRESS_BAR
673
669
674
670
void MarlinUI::draw_status_message (const bool blink) {
675
- if (!PanelDetected ) return ;
671
+ if (!panel_detected ) return ;
676
672
lcd_moveto (0 , 3 );
677
673
#if ALL(FILAMENT_LCD_DISPLAY, HAS_MEDIA)
678
674
@@ -812,7 +808,7 @@ Equal to 24x10 text LCD
812
808
*/
813
809
814
810
void MarlinUI::draw_status_screen () {
815
- if (!PanelDetected ) return ;
811
+ if (!panel_detected ) return ;
816
812
817
813
const bool blink = get_blink ();
818
814
@@ -959,7 +955,7 @@ void MarlinUI::draw_status_screen() {
959
955
#if ENABLED(ADVANCED_PAUSE_FEATURE)
960
956
961
957
void MarlinUI::draw_hotend_status (const uint8_t row, const uint8_t extruder) {
962
- if (!PanelDetected ) return ;
958
+ if (!panel_detected ) return ;
963
959
lcd_moveto ((LCD_WIDTH - 14 ) / 2 , row + 1 );
964
960
lcd.write (LCD_STR_THERMOMETER[0 ]); lcd_put_u8str (F (" E" )); lcd.write (' 1' + extruder); lcd.write (' ' );
965
961
lcd.print (i16tostr3rj (thermalManager.wholeDegHotend (extruder))); lcd.write (LCD_STR_DEGREE[0 ]); lcd.write (' /' );
@@ -971,7 +967,7 @@ void MarlinUI::draw_status_screen() {
971
967
972
968
// Draw a static item with no left-right margin required. Centered by default.
973
969
void MenuItem_static::draw (const uint8_t row, FSTR_P const ftpl, const uint8_t style/* =SS_DEFAULT*/ , const char *vstr/* =nullptr*/ ) {
974
- if (!PanelDetected ) return ;
970
+ if (!panel_detected ) return ;
975
971
lcd_moveto (0 , row);
976
972
977
973
uint8_t n = LCD_WIDTH;
@@ -1019,7 +1015,7 @@ void MarlinUI::draw_status_screen() {
1019
1015
1020
1016
// Draw a generic menu item with pre_char (if selected) and post_char
1021
1017
void MenuItemBase::_draw (const bool sel, const uint8_t row, FSTR_P const ftpl, const char pre_char, const char post_char) {
1022
- if (!PanelDetected ) return ;
1018
+ if (!panel_detected ) return ;
1023
1019
lcd_moveto (0 , row);
1024
1020
lcd.write (sel ? pre_char : ' ' );
1025
1021
uint8_t n = LCD_WIDTH - 2 ;
@@ -1031,7 +1027,7 @@ void MarlinUI::draw_status_screen() {
1031
1027
1032
1028
// Draw a menu item with a (potentially) editable value
1033
1029
void MenuEditItemBase::draw (const bool sel, const uint8_t row, FSTR_P const ftpl, const char * const inStr, const bool pgm) {
1034
- if (!PanelDetected ) return ;
1030
+ if (!panel_detected ) return ;
1035
1031
const uint8_t vlen = inStr ? (pgm ? utf8_strlen_P (inStr) : utf8_strlen (inStr)) : 0 ;
1036
1032
lcd_moveto (0 , row);
1037
1033
lcd.write (sel ? LCD_STR_ARROW_RIGHT[0 ] : ' ' );
@@ -1048,7 +1044,7 @@ void MarlinUI::draw_status_screen() {
1048
1044
// Low-level draw_edit_screen can be used to draw an edit screen from anyplace
1049
1045
// This line moves to the last line of the screen for UBL plot screen on the panel side
1050
1046
void MenuEditItemBase::draw_edit_screen (FSTR_P const fstr, const char * const value/* =nullptr*/ ) {
1051
- if (!PanelDetected ) return ;
1047
+ if (!panel_detected ) return ;
1052
1048
ui.encoder_direction_normal ();
1053
1049
const uint8_t y = TERN0 (AUTO_BED_LEVELING_UBL, ui.external_control ) ? LCD_HEIGHT - 1 : MIDDLE_Y;
1054
1050
lcd_moveto (0 , y);
@@ -1066,7 +1062,7 @@ void MarlinUI::draw_status_screen() {
1066
1062
1067
1063
// The Select Screen presents a prompt and two "buttons"
1068
1064
void MenuItem_confirm::draw_select_screen (FSTR_P const yes, FSTR_P const no, const bool yesno, FSTR_P const fpre, const char * const string, FSTR_P const fsuf) {
1069
- if (!PanelDetected ) return ;
1065
+ if (!panel_detected ) return ;
1070
1066
ui.draw_select_screen_prompt (fpre, string, fsuf);
1071
1067
lcd.write (COLOR_EDIT);
1072
1068
if (no) {
@@ -1083,7 +1079,7 @@ void MarlinUI::draw_status_screen() {
1083
1079
#if HAS_MEDIA
1084
1080
1085
1081
void MenuItem_sdbase::draw (const bool sel, const uint8_t row, FSTR_P const , CardReader &theCard, const bool isDir) {
1086
- if (!PanelDetected ) return ;
1082
+ if (!panel_detected ) return ;
1087
1083
lcd_moveto (0 , row);
1088
1084
lcd.write (sel ? LCD_STR_ARROW_RIGHT[0 ] : ' ' );
1089
1085
uint8_t n = LCD_WIDTH - 2 ;
@@ -1116,7 +1112,7 @@ void MarlinUI::draw_status_screen() {
1116
1112
* |____________________|
1117
1113
*/
1118
1114
void MarlinUI::ubl_plot (const uint8_t x_plot, const uint8_t y_plot) {
1119
- if (!PanelDetected ) return ;
1115
+ if (!panel_detected ) return ;
1120
1116
1121
1117
#define _LCD_W_POS 12
1122
1118
0 commit comments