From 43773ff735efa6e83b5d0a437de032210b4b5761 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 7 Apr 2015 21:11:03 -0700 Subject: [PATCH] Formatting and lcd contrast masking --- Marlin/dogm_lcd_implementation.h | 29 ++++++------ Marlin/ultralcd.cpp | 80 ++++++++++++++++---------------- 2 files changed, 55 insertions(+), 54 deletions(-) diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index f940a89755..627bbc8c57 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -198,16 +198,16 @@ static void lcd_implementation_init() u8g.setContrast(lcd_contrast); // FIXME: remove this workaround // Uncomment this if you have the first generation (V1.10) of STBs board - // pinMode(17, OUTPUT); // Enable LCD backlight - // digitalWrite(17, HIGH); - -#ifdef LCD_SCREEN_ROT_90 - u8g.setRot90(); // Rotate screen by 90° -#elif defined(LCD_SCREEN_ROT_180) - u8g.setRot180(); // Rotate screen by 180° -#elif defined(LCD_SCREEN_ROT_270) - u8g.setRot270(); // Rotate screen by 270° -#endif + // pinMode(17, OUTPUT); // Enable LCD backlight + // digitalWrite(17, HIGH); + + #ifdef LCD_SCREEN_ROT_90 + u8g.setRot90(); // Rotate screen by 90° + #elif defined(LCD_SCREEN_ROT_180) + u8g.setRot180(); // Rotate screen by 180° + #elif defined(LCD_SCREEN_ROT_270) + u8g.setRot270(); // Rotate screen by 270° + #endif // Show splashscreen int offx = (u8g.getWidth() - START_BMPWIDTH) / 2; @@ -220,7 +220,7 @@ static void lcd_implementation_init() int txt1X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE1) - 1)*DOG_CHAR_WIDTH) / 2; u8g.firstPage(); - do { + do { if (show_splashscreen) { u8g.drawBitmapP(offx, offy, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp); lcd_setFont(FONT_MENU); @@ -232,7 +232,7 @@ static void lcd_implementation_init() u8g.drawStr(txt2X, u8g.getHeight() - DOG_CHAR_HEIGHT*1/2, STRING_SPLASH_LINE2); #endif } - } while (u8g.nextPage()); + } while (u8g.nextPage()); show_splashscreen = false; } @@ -295,20 +295,19 @@ static void lcd_implementation_status_screen() { lcd_printPGM(PSTR("--:--")); } #endif - + // Extruders for (int i=0; i 63) lcd_contrast = 63; - encoderPosition = 0; - lcdDrawUpdate = 1; - u8g.setContrast(lcd_contrast); + static void lcd_set_contrast() { + if (encoderPosition != 0) { + lcd_contrast -= encoderPosition; + lcd_contrast &= 0x3F; + encoderPosition = 0; + lcdDrawUpdate = 1; + u8g.setContrast(lcd_contrast); + } + if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_CONTRAST), itostr2(lcd_contrast)); + if (LCD_CLICKED) lcd_goto_menu(lcd_control_menu); } - if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_CONTRAST), itostr2(lcd_contrast)); - if (LCD_CLICKED) lcd_goto_menu(lcd_control_menu); -} -#endif //DOGLCD +#endif // DOGLCD #ifdef FWRETRACT -static void lcd_control_retract_menu() { - START_MENU(); - MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); - MENU_ITEM_EDIT(bool, MSG_AUTORETRACT, &autoretract_enabled); - MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT, &retract_length, 0, 100); - #if EXTRUDERS > 1 - MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_SWAP, &retract_length_swap, 0, 100); - #endif - MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACTF, &retract_feedrate, 1, 999); - MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_ZLIFT, &retract_zlift, 0, 999); - MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_RECOVER, &retract_recover_length, 0, 100); - #if EXTRUDERS > 1 - MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_RECOVER_SWAP, &retract_recover_length_swap, 0, 100); - #endif - MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVERF, &retract_recover_feedrate, 1, 999); - END_MENU(); -} + static void lcd_control_retract_menu() { + START_MENU(); + MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); + MENU_ITEM_EDIT(bool, MSG_AUTORETRACT, &autoretract_enabled); + MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT, &retract_length, 0, 100); + #if EXTRUDERS > 1 + MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_SWAP, &retract_length_swap, 0, 100); + #endif + MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACTF, &retract_feedrate, 1, 999); + MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_ZLIFT, &retract_zlift, 0, 999); + MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_RECOVER, &retract_recover_length, 0, 100); + #if EXTRUDERS > 1 + MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_RECOVER_SWAP, &retract_recover_length_swap, 0, 100); + #endif + MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVERF, &retract_recover_feedrate, 1, 999); + END_MENU(); + } -#endif //FWRETRACT +#endif // FWRETRACT #if SDCARDDETECT == -1 + static void lcd_sd_refresh() { card.initsd(); currentMenuViewOffset = 0; } + #endif static void lcd_sd_updir() { @@ -1029,13 +1030,14 @@ void lcd_sdcard_menu() { MENU_ITEM(function, LCD_STR_FOLDER "..", lcd_sd_updir); } - for(uint16_t i = 0; i < fileCnt; i++) { + for (uint16_t i = 0; i < fileCnt; i++) { if (_menuItemNr == _lineNr) { - #ifndef SDCARD_RATHERRECENTFIRST - card.getfilename(i); - #else - card.getfilename(fileCnt-1-i); - #endif + card.getfilename( + #ifdef SDCARD_RATHERRECENTFIRST + fileCnt-1 - + #endif + i + ); if (card.filenameIsDir) MENU_ITEM(sddirectory, MSG_CARD_MENU, card.filename, card.longFilename); else @@ -1456,7 +1458,7 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; } #ifdef DOGLCD void lcd_setcontrast(uint8_t value) { - lcd_contrast = value & 63; + lcd_contrast = value & 0x3F; u8g.setContrast(lcd_contrast); } #endif