diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index 0bfc8c144..ba7b9865b 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -39,7 +39,6 @@ #include "ultralcd.h" #include "ultralcd_st7920_u8glib_rrd.h" - /* Russian language not supported yet, needs custom font #if LANGUAGE_CHOICE == 6 @@ -57,20 +56,18 @@ #define DOG_CHAR_WIDTH_LARGE 9 #define DOG_CHAR_HEIGHT_LARGE 18 - #define START_ROW 0 - /* Custom characters defined in font font_6x10_marlin.c */ -#define LCD_STR_BEDTEMP "\xFE" #define LCD_STR_DEGREE "\xB0" -#define LCD_STR_THERMOMETER "\xFF" -#define LCD_STR_UPLEVEL "\xFB" #define LCD_STR_REFRESH "\xF8" #define LCD_STR_FOLDER "\xF9" -#define LCD_STR_FEEDRATE "\xFD" -#define LCD_STR_CLOCK "\xFC" #define LCD_STR_ARROW_RIGHT "\xFA" +#define LCD_STR_UPLEVEL "\xFB" +#define LCD_STR_CLOCK "\xFC" +#define LCD_STR_FEEDRATE "\xFD" +#define LCD_STR_BEDTEMP "\xFE" +#define LCD_STR_THERMOMETER "\xFF" #define FONT_STATUSMENU u8g_font_6x9 @@ -167,6 +164,25 @@ static void lcd_printPGM(const char* str) } } +static void _draw_heater_status(int x, int heater) { + bool isBed = heater < 0; + int y = 17 + (isBed ? 1 : 0); + u8g.setFont(FONT_STATUSMENU); + u8g.setPrintPos(x,6); + u8g.print(itostr3(int((heater >= 0 ? degTargetHotend(heater) : degTargetBed()) + 0.5))); + lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); + u8g.setPrintPos(x,27); + u8g.print(itostr3(int(heater >= 0 ? degHotend(heater) : degBed()) + 0.5)); + lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); + if (!isHeatingHotend(0)) { + u8g.drawBox(x+7,y,2,2); + } + else { + u8g.setColorIndex(0); // white on black + u8g.drawBox(x+7,y,2,2); + u8g.setColorIndex(1); // black on white + } +} static void lcd_implementation_status_screen() { @@ -176,8 +192,7 @@ static void lcd_implementation_status_screen() u8g.setColorIndex(1); // black on white // Symbols menu graphics, animated fan - if ((blink % 2) && fanSpeed ) u8g.drawBitmapP(9,1,STATUS_SCREENBYTEWIDTH,STATUS_SCREENHEIGHT,status_screen0_bmp); - else u8g.drawBitmapP(9,1,STATUS_SCREENBYTEWIDTH,STATUS_SCREENHEIGHT,status_screen1_bmp); + u8g.drawBitmapP(9,1,STATUS_SCREENBYTEWIDTH,STATUS_SCREENHEIGHT, (blink % 2) && fanSpeed ? status_screen0_bmp : status_screen1_bmp); #ifdef SDSUPPORT //SD Card Symbol @@ -213,73 +228,17 @@ static void lcd_implementation_status_screen() } #endif - // Extruder 1 - u8g.setFont(FONT_STATUSMENU); - u8g.setPrintPos(6,6); - u8g.print(itostr3(int(degTargetHotend(0) + 0.5))); - lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); - u8g.setPrintPos(6,27); - u8g.print(itostr3(int(degHotend(0) + 0.5))); - lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); - if (!isHeatingHotend(0)) u8g.drawBox(13,17,2,2); - else - { - u8g.setColorIndex(0); // white on black - u8g.drawBox(13,17,2,2); - u8g.setColorIndex(1); // black on white - } - - // Extruder 2 - u8g.setFont(FONT_STATUSMENU); - #if EXTRUDERS > 1 - u8g.setPrintPos(31,6); - u8g.print(itostr3(int(degTargetHotend(1) + 0.5))); - lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); - u8g.setPrintPos(31,27); - u8g.print(itostr3(int(degHotend(1) + 0.5))); - lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); - if (!isHeatingHotend(1)) u8g.drawBox(38,17,2,2); - else - { - u8g.setColorIndex(0); // white on black - u8g.drawBox(38,17,2,2); - u8g.setColorIndex(1); // black on white - } - #endif - - // Extruder 3 - u8g.setFont(FONT_STATUSMENU); - # if EXTRUDERS > 2 - u8g.setPrintPos(55,6); - u8g.print(itostr3(int(degTargetHotend(2) + 0.5))); - lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); - u8g.setPrintPos(55,27); - u8g.print(itostr3(int(degHotend(2) + 0.5))); - lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); - if (!isHeatingHotend(2)) u8g.drawBox(62,17,2,2); - else - { - u8g.setColorIndex(0); // white on black - u8g.drawBox(62,17,2,2); - u8g.setColorIndex(1); // black on white - } - #endif - - // Heatbed - u8g.setFont(FONT_STATUSMENU); - u8g.setPrintPos(81,6); - u8g.print(itostr3(int(degTargetBed() + 0.5))); - lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); - u8g.setPrintPos(81,27); - u8g.print(itostr3(int(degBed() + 0.5))); - lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); - if (!isHeatingBed()) u8g.drawBox(88,18,2,2); - else - { - u8g.setColorIndex(0); // white on black - u8g.drawBox(88,18,2,2); - u8g.setColorIndex(1); // black on white - } + // Extruders + _draw_heater_status(6, 0); + #if EXTRUDERS > 1 + _draw_heater_status(31, 1); + #if EXTRUDERS > 2 + _draw_heater_status(55, 2); + #endif + #endif + + // Heatbed + _draw_heater_status(81, -1); // Fan u8g.setFont(FONT_STATUSMENU); @@ -360,7 +319,7 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c } else u8g.setColorIndex(1); // unmarked text is black on white u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); - if (pre_char != '>') u8g.print(pre_char); else u8g.print(' '); // Row selector is obsolete + u8g.print(pre_char == '>' ? ' ' : pre_char); // Row selector is obsolete while( (c = pgm_read_byte(pstr)) != '\0' ) @@ -378,57 +337,29 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c u8g.setColorIndex(1); // restore settings to black on white } -static void lcd_implementation_drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, char* data) -{ - static unsigned int fkt_cnt = 0; - char c; - uint8_t n = LCD_WIDTH - 1 - 2 - strlen(data); - - u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); - u8g.print(pre_char); - - while( (c = pgm_read_byte(pstr)) != '\0' ) - { - u8g.print(c); +static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, char* data, bool pgm) { + char c; + uint8_t n = LCD_WIDTH - 1 - 2 - (pgm ? strlen_P(data) : strlen(data)); - pstr++; - n--; - } - - u8g.print(':'); - - while(n--){ - u8g.print(' '); - } + u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); + u8g.print(pre_char); - u8g.print(data); -} - -static void lcd_implementation_drawmenu_setting_edit_generic_P(uint8_t row, const char* pstr, char pre_char, const char* data) -{ - char c; - uint8_t n= LCD_WIDTH - 1 - 2 - strlen_P(data); + while( (c = pgm_read_byte(pstr)) != '\0' ) { + u8g.print(c); + pstr++; + n--; + } - u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); - u8g.print(pre_char); - - while( (c = pgm_read_byte(pstr)) != '\0' ) - { - u8g.print(c); - - pstr++; - n--; - } + u8g.print(':'); - u8g.print(':'); - - while(n--){ - u8g.print(' '); - } + while(n--) u8g.print(' '); - lcd_printPGM(data); + if (pgm) { lcd_printPGM(data); } else { u8g.print(data); } } +#define lcd_implementation_drawmenu_setting_edit_generic(row, pstr, pre_char, data) _drawmenu_setting_edit_generic(row, pstr, pre_char, data, false) +#define lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, pre_char, data) _drawmenu_setting_edit_generic(row, pstr, pre_char, data, true) + #define lcd_implementation_drawmenu_setting_edit_int3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data))) #define lcd_implementation_drawmenu_setting_edit_int3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', itostr3(*(data))) #define lcd_implementation_drawmenu_setting_edit_float3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr3(*(data))) @@ -474,118 +405,40 @@ void lcd_implementation_drawedit(const char* pstr, char* value) u8g.print(value); } -static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename) -{ - char c; - uint8_t n = LCD_WIDTH - 1; +static void _drawmenu_sd(uint8_t row, const char* pstr, const char* filename, char * const longFilename, bool isDir, bool isSelected) { + char c; + uint8_t n = LCD_WIDTH - 1; - if (longFilename[0] != '\0') - { - filename = longFilename; - longFilename[LCD_WIDTH-1] = '\0'; - } + if (longFilename[0] != '\0') { + filename = longFilename; + longFilename[n] = '\0'; + } - u8g.setColorIndex(1); // black on white - u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT); - u8g.setColorIndex(0); // following text must be white on black - u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); - u8g.print(' '); // Indent by 1 char - - while((c = *filename) != '\0') - { - u8g.print(c); - filename++; - n--; - } - while(n--){ - u8g.print(' '); - } - u8g.setColorIndex(1); // black on white -} - -static void lcd_implementation_drawmenu_sdfile(uint8_t row, const char* pstr, const char* filename, char* longFilename) -{ - char c; - uint8_t n = LCD_WIDTH - 1; + if (isSelected) { + u8g.setColorIndex(1); // black on white + u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT); + u8g.setColorIndex(0); // following text must be white on black + } - if (longFilename[0] != '\0') - { - filename = longFilename; - longFilename[LCD_WIDTH-1] = '\0'; - } + u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); + u8g.print(' '); // Indent by 1 char - u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); - u8g.print(' '); - -while((c = *filename) != '\0') - { - u8g.print(c); - - filename++; - n--; - } - while(n--){ - u8g.print(' '); - } + if (isDir) u8g.print(LCD_STR_FOLDER[0]); -} + while((c = *filename) != '\0') { + u8g.print(c); + filename++; + n--; + } + while(n--) u8g.print(' '); -static void lcd_implementation_drawmenu_sddirectory_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename) -{ - char c; - uint8_t n = LCD_WIDTH - 2; - - if (longFilename[0] != '\0') - { - filename = longFilename; - longFilename[LCD_WIDTH-2] = '\0'; - } - u8g.setColorIndex(1); // black on white - u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT); - u8g.setColorIndex(0); // following text must be white on black - u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); - u8g.print(' '); // Indent by 1 char - u8g.print(LCD_STR_FOLDER[0]); - - while((c = *filename) != '\0') - { - u8g.print(c); - - filename++; - n--; - } - while(n--){ - u8g.print(' '); - } - u8g.setColorIndex(1); // black on white + if (isSelected) u8g.setColorIndex(1); // black on white } -static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pstr, const char* filename, char* longFilename) -{ - char c; - uint8_t n = LCD_WIDTH - 2; - - if (longFilename[0] != '\0') - { - filename = longFilename; - longFilename[LCD_WIDTH-2] = '\0'; - } - - u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); - u8g.print(' '); - u8g.print(LCD_STR_FOLDER[0]); - - while((c = *filename) != '\0') - { - u8g.print(c); - - filename++; - n--; - } - while(n--){ - u8g.print(' '); - } -} +#define lcd_implementation_drawmenu_sdfile_selected(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, false, true) +#define lcd_implementation_drawmenu_sdfile(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, false, false) +#define lcd_implementation_drawmenu_sddirectory_selected(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, true, true) +#define lcd_implementation_drawmenu_sddirectory(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, true, false) #define lcd_implementation_drawmenu_back_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]) #define lcd_implementation_drawmenu_back(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_UPLEVEL[0]) diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index 652693ce8..339955e59 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -105,7 +105,8 @@ #define LCD_MESSAGEPGM(x) #define LCD_ALERTMESSAGEPGM(x) -#endif + +#endif //ULTRA_LCD char *itostr2(const uint8_t &x); char *itostr31(const int &xx); @@ -122,4 +123,4 @@ char *ftostr5(const float &x); char *ftostr51(const float &x); char *ftostr52(const float &x); -#endif //ULTRALCD +#endif //ULTRALCD_H