|
@@ -191,8 +191,8 @@ u8g_page_t &page = ((u8g_pb_t *)((u8g.getU8g())->dev->dev_mem))->p;
|
191
|
191
|
#define PAGE_UNDER(yb) (u8g.getU8g()->current_page.y0 <= (yb))
|
192
|
192
|
#define PAGE_CONTAINS(ya, yb) (PAGE_UNDER(yb) && u8g.getU8g()->current_page.y1 >= (ya))
|
193
|
193
|
|
194
|
|
-static void lcd_setFont(char font_nr) {
|
195
|
|
- switch(font_nr) {
|
|
194
|
+static void lcd_setFont(const char font_nr) {
|
|
195
|
+ switch (font_nr) {
|
196
|
196
|
case FONT_STATUSMENU : {u8g.setFont(FONT_STATUSMENU_NAME); currentfont = FONT_STATUSMENU;}; break;
|
197
|
197
|
case FONT_MENU : {u8g.setFont(FONT_MENU_NAME); currentfont = FONT_MENU;}; break;
|
198
|
198
|
case FONT_SPECIAL : {u8g.setFont(FONT_SPECIAL_NAME); currentfont = FONT_SPECIAL;}; break;
|
|
@@ -201,7 +201,7 @@ static void lcd_setFont(char font_nr) {
|
201
|
201
|
}
|
202
|
202
|
}
|
203
|
203
|
|
204
|
|
-void lcd_print(char c) {
|
|
204
|
+void lcd_print(const char c) {
|
205
|
205
|
if ((c > 0) && (c <= LCD_STR_SPECIAL_MAX)) {
|
206
|
206
|
u8g.setFont(FONT_SPECIAL_NAME);
|
207
|
207
|
u8g.print(c);
|
|
@@ -210,7 +210,7 @@ void lcd_print(char c) {
|
210
|
210
|
else charset_mapper(c);
|
211
|
211
|
}
|
212
|
212
|
|
213
|
|
-char lcd_print_and_count(char c) {
|
|
213
|
+char lcd_print_and_count(const char c) {
|
214
|
214
|
if ((c > 0) && (c <= LCD_STR_SPECIAL_MAX)) {
|
215
|
215
|
u8g.setFont(FONT_SPECIAL_NAME);
|
216
|
216
|
u8g.print(c);
|
|
@@ -220,7 +220,7 @@ char lcd_print_and_count(char c) {
|
220
|
220
|
else return charset_mapper(c);
|
221
|
221
|
}
|
222
|
222
|
|
223
|
|
-void lcd_print(const char* str) {
|
|
223
|
+void lcd_print(const char* const str) {
|
224
|
224
|
for (uint8_t i = 0; char c = str[i]; ++i) lcd_print(c);
|
225
|
225
|
}
|
226
|
226
|
|
|
@@ -268,15 +268,15 @@ static void lcd_implementation_init() {
|
268
|
268
|
}
|
269
|
269
|
#endif // SHOW_CUSTOM_BOOTSCREEN
|
270
|
270
|
|
271
|
|
- int offx = (u8g.getWidth() - (START_BMPWIDTH)) / 2;
|
|
271
|
+ const uint8_t offx = (u8g.getWidth() - (START_BMPWIDTH)) / 2;
|
272
|
272
|
|
273
|
273
|
#if ENABLED(START_BMPHIGH)
|
274
|
|
- int offy = 0;
|
|
274
|
+ constexpr uint8_t offy = 0;
|
275
|
275
|
#else
|
276
|
|
- int offy = DOG_CHAR_HEIGHT;
|
|
276
|
+ constexpr uint8_t offy = DOG_CHAR_HEIGHT;
|
277
|
277
|
#endif
|
278
|
278
|
|
279
|
|
- int txt1X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE1) - 1) * (DOG_CHAR_WIDTH)) / 2;
|
|
279
|
+ const uint8_t txt1X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE1) - 1) * (DOG_CHAR_WIDTH)) / 2;
|
280
|
280
|
|
281
|
281
|
if (show_bootscreen) {
|
282
|
282
|
u8g.firstPage();
|
|
@@ -286,7 +286,7 @@ static void lcd_implementation_init() {
|
286
|
286
|
#ifndef STRING_SPLASH_LINE2
|
287
|
287
|
u8g.drawStr(txt1X, u8g.getHeight() - (DOG_CHAR_HEIGHT), STRING_SPLASH_LINE1);
|
288
|
288
|
#else
|
289
|
|
- int txt2X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE2) - 1) * (DOG_CHAR_WIDTH)) / 2;
|
|
289
|
+ const uint8_t txt2X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE2) - 1) * (DOG_CHAR_WIDTH)) / 2;
|
290
|
290
|
u8g.drawStr(txt1X, u8g.getHeight() - (DOG_CHAR_HEIGHT) * 3 / 2, STRING_SPLASH_LINE1);
|
291
|
291
|
u8g.drawStr(txt2X, u8g.getHeight() - (DOG_CHAR_HEIGHT) * 1 / 2, STRING_SPLASH_LINE2);
|
292
|
292
|
#endif
|
|
@@ -315,14 +315,14 @@ static void lcd_implementation_clear() { } // Automatically cleared by Picture L
|
315
|
315
|
// Status Screen
|
316
|
316
|
//
|
317
|
317
|
|
318
|
|
-FORCE_INLINE void _draw_centered_temp(int temp, int x, int y) {
|
319
|
|
- int degsize = 6 * (temp >= 100 ? 3 : temp >= 10 ? 2 : 1); // number's pixel width
|
|
318
|
+FORCE_INLINE void _draw_centered_temp(const int temp, const uint8_t x, const uint8_t y) {
|
|
319
|
+ const uint8_t degsize = 6 * (temp >= 100 ? 3 : temp >= 10 ? 2 : 1); // number's pixel width
|
320
|
320
|
u8g.setPrintPos(x - (18 - degsize) / 2, y); // move left if shorter
|
321
|
321
|
lcd_print(itostr3(temp));
|
322
|
322
|
lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
|
323
|
323
|
}
|
324
|
324
|
|
325
|
|
-FORCE_INLINE void _draw_heater_status(int x, int heater) {
|
|
325
|
+FORCE_INLINE void _draw_heater_status(const uint8_t x, const int8_t heater) {
|
326
|
326
|
#if HAS_TEMP_BED
|
327
|
327
|
bool isBed = heater < 0;
|
328
|
328
|
#else
|
|
@@ -336,8 +336,8 @@ FORCE_INLINE void _draw_heater_status(int x, int heater) {
|
336
|
336
|
_draw_centered_temp((isBed ? thermalManager.degBed() : thermalManager.degHotend(heater)) + 0.5, x, 28);
|
337
|
337
|
|
338
|
338
|
if (PAGE_CONTAINS(17, 20)) {
|
339
|
|
- uint8_t h = isBed ? 7 : 8,
|
340
|
|
- y = isBed ? 18 : 17;
|
|
339
|
+ const uint8_t h = isBed ? 7 : 8,
|
|
340
|
+ y = isBed ? 18 : 17;
|
341
|
341
|
if (isBed ? thermalManager.isHeatingBed() : thermalManager.isHeatingHotend(heater)) {
|
342
|
342
|
u8g.setColorIndex(0); // white on black
|
343
|
343
|
u8g.drawBox(x + h, y, 2, 2);
|
|
@@ -349,7 +349,7 @@ FORCE_INLINE void _draw_heater_status(int x, int heater) {
|
349
|
349
|
}
|
350
|
350
|
}
|
351
|
351
|
|
352
|
|
-FORCE_INLINE void _draw_axis_label(AxisEnum axis, const char *pstr, bool blink) {
|
|
352
|
+FORCE_INLINE void _draw_axis_label(const AxisEnum axis, const char* const pstr, const bool blink) {
|
353
|
353
|
if (blink)
|
354
|
354
|
lcd_printPGM(pstr);
|
355
|
355
|
else {
|
|
@@ -611,7 +611,7 @@ static void lcd_implementation_status_screen() {
|
611
|
611
|
uint8_t row_y1, row_y2;
|
612
|
612
|
|
613
|
613
|
// Set the colors for a menu item based on whether it is selected
|
614
|
|
- static void lcd_implementation_mark_as_selected(uint8_t row, bool isSelected) {
|
|
614
|
+ static void lcd_implementation_mark_as_selected(const uint8_t row, const bool isSelected) {
|
615
|
615
|
|
616
|
616
|
row_y1 = row * (DOG_CHAR_HEIGHT) + 1;
|
617
|
617
|
row_y2 = row_y1 + (DOG_CHAR_HEIGHT) - 1;
|
|
@@ -632,7 +632,7 @@ static void lcd_implementation_status_screen() {
|
632
|
632
|
#if ENABLED(LCD_INFO_MENU) || ENABLED(FILAMENT_CHANGE_FEATURE)
|
633
|
633
|
|
634
|
634
|
// Draw a static line of text in the same idiom as a menu item
|
635
|
|
- static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, bool center=true, bool invert=false, const char* valstr=NULL) {
|
|
635
|
+ static void lcd_implementation_drawmenu_static(const uint8_t row, const char* pstr, const bool center=true, const bool invert=false, const char* valstr=NULL) {
|
636
|
636
|
|
637
|
637
|
lcd_implementation_mark_as_selected(row, invert);
|
638
|
638
|
|
|
@@ -659,7 +659,7 @@ static void lcd_implementation_status_screen() {
|
659
|
659
|
#endif // LCD_INFO_MENU || FILAMENT_CHANGE_FEATURE
|
660
|
660
|
|
661
|
661
|
// Draw a generic menu item
|
662
|
|
- static void lcd_implementation_drawmenu_generic(bool isSelected, uint8_t row, const char* pstr, char pre_char, char post_char) {
|
|
662
|
+ static void lcd_implementation_drawmenu_generic(const bool isSelected, const uint8_t row, const char* pstr, const char pre_char, const char post_char) {
|
663
|
663
|
UNUSED(pre_char);
|
664
|
664
|
|
665
|
665
|
lcd_implementation_mark_as_selected(row, isSelected);
|
|
@@ -684,7 +684,7 @@ static void lcd_implementation_status_screen() {
|
684
|
684
|
#define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
|
685
|
685
|
|
686
|
686
|
// Draw a menu item with an editable value
|
687
|
|
- static void _drawmenu_setting_edit_generic(bool isSelected, uint8_t row, const char* pstr, const char* data, bool pgm) {
|
|
687
|
+ static void _drawmenu_setting_edit_generic(const bool isSelected, const uint8_t row, const char* pstr, const char* const data, const bool pgm) {
|
688
|
688
|
|
689
|
689
|
lcd_implementation_mark_as_selected(row, isSelected);
|
690
|
690
|
|
|
@@ -729,9 +729,9 @@ static void lcd_implementation_status_screen() {
|
729
|
729
|
#define lcd_implementation_drawmenu_setting_edit_callback_long5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5rj(*(data)))
|
730
|
730
|
#define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
|
731
|
731
|
|
732
|
|
- void lcd_implementation_drawedit(const char* pstr, const char* value=NULL) {
|
|
732
|
+ void lcd_implementation_drawedit(const char* const pstr, const char* const value=NULL) {
|
|
733
|
+ const uint8_t labellen = lcd_strlen_P(pstr), vallen = lcd_strlen(value);
|
733
|
734
|
uint8_t lcd_width, char_width,
|
734
|
|
- labellen = lcd_strlen_P(pstr), vallen = lcd_strlen(value),
|
735
|
735
|
rows = (labellen > LCD_WIDTH - 2 - vallen) ? 2 : 1;
|
736
|
736
|
|
737
|
737
|
#if ENABLED(USE_BIG_EDIT_FONT)
|
|
@@ -752,8 +752,8 @@ static void lcd_implementation_status_screen() {
|
752
|
752
|
#endif
|
753
|
753
|
|
754
|
754
|
// Center either one or two rows
|
755
|
|
- uint8_t segmentHeight = u8g.getHeight() / (rows + 1), // 1 / (rows+1) = 1/2 or 1/3
|
756
|
|
- baseline = segmentHeight + (DOG_CHAR_HEIGHT_EDIT + 1) / 2;
|
|
755
|
+ const uint8_t segmentHeight = u8g.getHeight() / (rows + 1); // 1 / (rows+1) = 1/2 or 1/3
|
|
756
|
+ uint8_t baseline = segmentHeight + (DOG_CHAR_HEIGHT_EDIT + 1) / 2;
|
757
|
757
|
|
758
|
758
|
if (PAGE_CONTAINS(baseline + 1 - (DOG_CHAR_HEIGHT_EDIT), baseline)) {
|
759
|
759
|
u8g.setPrintPos(0, baseline);
|
|
@@ -772,7 +772,7 @@ static void lcd_implementation_status_screen() {
|
772
|
772
|
|
773
|
773
|
#if ENABLED(SDSUPPORT)
|
774
|
774
|
|
775
|
|
- static void _drawmenu_sd(bool isSelected, uint8_t row, const char* pstr, const char* filename, char* const longFilename, bool isDir) {
|
|
775
|
+ static void _drawmenu_sd(const bool isSelected, const uint8_t row, const char* const pstr, const char* filename, char* const longFilename, const bool isDir) {
|
776
|
776
|
UNUSED(pstr);
|
777
|
777
|
|
778
|
778
|
lcd_implementation_mark_as_selected(row, isSelected);
|