From c5973765e4936b145f894ca9efe6a0c1856d9272 Mon Sep 17 00:00:00 2001 From: Marcio Teixeira Date: Mon, 12 Mar 2018 09:48:02 -0600 Subject: [PATCH] Disabled position display in Hibiscus UI (T1822) - Position display is now disabled as requested by marketing. - Merged upstream Marlin changes to GUI code. --- Marlin/Conditionals_LulzBot.h | 10 +- Marlin/Configuration_adv.h | 18 ++ Marlin/status_screen_lite_ST7920.h | 253 ++++++++++++----------- Marlin/status_screen_lite_ST7920_class.h | 3 +- Marlin/ultralcd.cpp | 2 +- Marlin/ultralcd_impl_DOGM.h | 8 +- Marlin/ultralcd_st7920_u8glib_rrd.h | 2 +- 7 files changed, 163 insertions(+), 133 deletions(-) diff --git a/Marlin/Conditionals_LulzBot.h b/Marlin/Conditionals_LulzBot.h index 6ac73a8e1..8bb45dd13 100644 --- a/Marlin/Conditionals_LulzBot.h +++ b/Marlin/Conditionals_LulzBot.h @@ -13,7 +13,7 @@ * got disabled. */ -#define LULZBOT_FW_VERSION ".15" // Change this with each update +#define LULZBOT_FW_VERSION ".16" // Change this with each update #if ( \ !defined(LULZBOT_Gladiola_Mini) && \ @@ -119,7 +119,7 @@ #define LULZBOT_PRINTCOUNTER #define LULZBOT_USE_32_MICROSTEPS_ON_Z #define LULZBOT_UUID "e5502411-d46d-421d-ba3a-a20126d7930f" - #define LULZBOT_MODERN_UI + #define LULZBOT_LIGHTWEIGHT_UI #define LULZBOT_USE_EXPERIMENTAL_FEATURES #endif @@ -160,7 +160,7 @@ #define LULZBOT_BAUDRATE 250000 #define LULZBOT_PRINTCOUNTER #define LULZBOT_UUID "a952577d-8722-483a-999d-acdc9e772b7b" - #define LULZBOT_MODERN_UI + #define LULZBOT_LIGHTWEIGHT_UI #define LULZBOT_USE_EXPERIMENTAL_FEATURES #endif @@ -1761,7 +1761,7 @@ #define LULZBOT_ENHANCED_TEMP_ERROR_MSG(msg, e) \ ((e == -1) ? PSTR(LULZBOT_STRINGIFY(msg) " BED") : ((e == 0) ? PSTR(LULZBOT_STRINGIFY(msg) " E0") : PSTR(LULZBOT_STRINGIFY(msg) " E1")) ) -#if defined(LULZBOT_MODERN_UI) +#if defined(LULZBOT_LIGHTWEIGHT_UI) #define LULZBOT_ABOUT_TO_DRAW_SCREEN(a,b) \ lcd_in_status(a == b); \ if(a == b) { \ @@ -1775,7 +1775,7 @@ #else #define WELCOME_MSG _UxGT("TAZ 7 ready.") #endif - #define LULZBOT_DELAY_TO_SHOW_POSITION 20 + #define LULZBOT_STATUS_EXPIRE_SECONDS 0 #else #define LULZBOT_ABOUT_TO_DRAW_SCREEN(a) #endif diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 15333b01b..fca13390f 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -643,6 +643,24 @@ // Swap the CW/CCW indicators in the graphics overlay //#define OVERLAY_GFX_REVERSE + #if ENABLED(U8GLIB_ST7920) + /** + * ST7920-based LCDs can emulate a 16 x 4 character display using + * the ST7920 character-generator for very fast screen updates. + * Enable LIGHTWEIGHT_UI to use this special display mode. + * + * Since LIGHTWEIGHT_UI has limited space, the position and status + * message occupy the same line. Set STATUS_EXPIRE_SECONDS to the + * length of time to display the status message before clearing. + */ + #if defined(LULZBOT_LIGHTWEIGHT_UI) + #define LIGHTWEIGHT_UI LULZBOT_LIGHTWEIGHT_UI + #endif + #if ENABLED(LIGHTWEIGHT_UI) + #define STATUS_EXPIRE_SECONDS LULZBOT_STATUS_EXPIRE_SECONDS + #endif + #endif + #endif // DOGLCD // @section safety diff --git a/Marlin/status_screen_lite_ST7920.h b/Marlin/status_screen_lite_ST7920.h index 3b5d28e85..0dc935bdc 100644 --- a/Marlin/status_screen_lite_ST7920.h +++ b/Marlin/status_screen_lite_ST7920.h @@ -360,18 +360,18 @@ const uint16_t fan2_icon[] PROGMEM = { const uint16_t feedrate_icon[] PROGMEM = { 0b0000000000000000, 0b0111111000000000, - 0b0100000000000000, - 0b0100000000000000, - 0b0100000000000000, + 0b0110000000000000, + 0b0110000000000000, + 0b0110000000000000, 0b0111111011111000, - 0b0100000010000100, - 0b0100000010000100, - 0b0100000010000100, - 0b0100000011111000, - 0b0000000010001000, - 0b0000000010000100, - 0b0000000010000100, - 0b0000000010000010, + 0b0110000011001100, + 0b0110000011001100, + 0b0110000011001100, + 0b0110000011111000, + 0b0000000011001100, + 0b0000000011001100, + 0b0000000011001100, + 0b0000000011001100, 0b0000000000000000, 0b0000000000000000 }; @@ -384,7 +384,7 @@ const uint16_t feedrate_icon[] PROGMEM = { // i.e x is [1-16], while the y position is [1-4] void ST7920_Lite_Status_Screen::draw_degree_symbol(uint8_t x, uint8_t y, bool draw) { const uint8_t *p_bytes = degree_symbol; - if(y > 2) { + if (y > 2) { // Handle display folding y -= 2; x += 16; @@ -399,12 +399,12 @@ void ST7920_Lite_Status_Screen::draw_degree_symbol(uint8_t x, uint8_t y, bool dr uint8_t byte = pgm_read_byte_near(p_bytes++); set_gdram_address(x_word,i+y*16); begin_data(); - if(draw) { + if (draw) { write_byte(oddChar ? 0x00 : byte); write_byte(oddChar ? byte : 0x00); - } else { - write_word(0x0000); } + else + write_word(0x0000); } } @@ -442,15 +442,15 @@ void ST7920_Lite_Status_Screen::draw_static_elements() { void ST7920_Lite_Status_Screen::draw_progress_bar(const uint8_t value) { #if EXTRUDERS == 1 // If we have only one extruder, draw a long progress bar on the third line - const int top = 1; // Top in pixels - const int bottom = 13; // Bottom in pixels - const int left = 12; // Left edge, in 16-bit words - const int width = 4; // Width of progress bar, in 16-bit words + const uint8_t top = 1, // Top in pixels + bottom = 13, // Bottom in pixels + left = 12, // Left edge, in 16-bit words + width = 4; // Width of progress bar, in 16-bit words #else - const uint8_t top = 16 + 1, // Top in pixels - bottom = 16 + 13, // Bottom in pixels - left = 5, // Left edge, in 16-bit words - width = 3; // Width of progress bar, in 16-bit words + const uint8_t top = 16 + 1, + bottom = 16 + 13, + left = 5, + width = 3; #endif const uint8_t char_pcnt = 100 / width; // How many percent does each 16-bit word represent? @@ -477,7 +477,6 @@ void ST7920_Lite_Status_Screen::draw_progress_bar(const uint8_t value) { } // Draw the percentage as text in DDRAM - #if EXTRUDERS == 1 set_ddram_address(DDRAM_LINE_3 + 4); begin_data(); @@ -487,6 +486,7 @@ void ST7920_Lite_Status_Screen::draw_progress_bar(const uint8_t value) { begin_data(); #endif + // Draw centered if (value > 9) { write_number(value, 4); write_str(F("% ")); @@ -525,11 +525,18 @@ void ST7920_Lite_Status_Screen::draw_heat_icon(const bool whichIcon, const bool static struct { bool E1_show_target : 1; bool E2_show_target : 1; - bool bed_show_target : 1; -} display_state = {true, true, true}; + #if HAS_HEATER_BED + bool bed_show_target : 1; + #endif +} display_state = { + true, true + #if HAS_HEATER_BED + , true + #endif +}; void ST7920_Lite_Status_Screen::draw_temps(uint8_t line, const int16_t temp, const int16_t target, bool showTarget, bool targetStateChange) { - switch(line) { + switch (line) { case 1: set_ddram_address(DDRAM_LINE_1 + 1); break; case 2: set_ddram_address(DDRAM_LINE_2 + 1); break; case 3: set_ddram_address(DDRAM_LINE_3 + 1); break; @@ -543,45 +550,37 @@ void ST7920_Lite_Status_Screen::draw_temps(uint8_t line, const int16_t temp, con write_number(target); }; - if(targetStateChange) { - if(showTarget) { - draw_degree_symbol(6, line, false); - draw_degree_symbol(10, line, true); - } else { - write_str(F(" ")); - draw_degree_symbol(6, line, true); - draw_degree_symbol(10, line, false); - } + if (targetStateChange) { + if (!showTarget) write_str(F(" ")); + draw_degree_symbol(6, line, !showTarget); + draw_degree_symbol(10, line, showTarget); } } void ST7920_Lite_Status_Screen::draw_extruder_1_temp(const int16_t temp, const int16_t target, bool forceUpdate) { const bool show_target = target && FAR(temp, target); - draw_temps(1, temp, target, show_target, display_state.E1_show_target != show_target || forceUpdate); display_state.E1_show_target = show_target; } void ST7920_Lite_Status_Screen::draw_extruder_2_temp(const int16_t temp, const int16_t target, bool forceUpdate) { const bool show_target = target && FAR(temp, target); - draw_temps(2, temp, target, show_target, display_state.E2_show_target != show_target || forceUpdate); display_state.E2_show_target = show_target; } -void ST7920_Lite_Status_Screen::draw_bed_temp(const int16_t temp, const int16_t target, bool forceUpdate) { - const bool show_target = target && FAR(temp, target); - - draw_temps( - #if EXTRUDERS == 1 - 2, - #else - 3, - #endif - temp, target, show_target, display_state.bed_show_target != show_target || forceUpdate); - - display_state.bed_show_target = show_target; -} +#if HAS_HEATER_BED + void ST7920_Lite_Status_Screen::draw_bed_temp(const int16_t temp, const int16_t target, bool forceUpdate) { + const bool show_target = target && FAR(temp, target); + draw_temps(2 + #if EXTRUDERS > 1 + + 1 + #endif + , temp, target, show_target, display_state.bed_show_target != show_target || forceUpdate + ); + display_state.bed_show_target = show_target; + } +#endif void ST7920_Lite_Status_Screen::draw_fan_speed(const uint8_t value) { set_ddram_address(DDRAM_LINE_1 + 6); @@ -590,19 +589,16 @@ void ST7920_Lite_Status_Screen::draw_fan_speed(const uint8_t value) { write_byte('%'); } -void ST7920_Lite_Status_Screen::draw_print_time(const uint32_t elapsed) { - const uint8_t hrs = elapsed / 3600, - min = (elapsed / 60) % 60; - char str[7]; - sprintf_P(str, hrs > 99 ? PSTR("%03d:%02d") : PSTR("%02d:%02d "), hrs, min); - +void ST7920_Lite_Status_Screen::draw_print_time(const duration_t &elapsed) { #if EXTRUDERS == 1 set_ddram_address(DDRAM_LINE_3); #else set_ddram_address(DDRAM_LINE_3 + 5); #endif + char str[7]; + str[elapsed.toDigital(str)] = ' '; begin_data(); - write_str(str); + write_str(str, 6); } void ST7920_Lite_Status_Screen::draw_feedrate_percentage(const uint8_t percentage) { @@ -680,26 +676,23 @@ bool ST7920_Lite_Status_Screen::indicators_changed() { const bool blink = lcd_blink(); const uint8_t feedrate_perc = feedrate_percentage; const uint8_t fan_speed = ((fanSpeeds[0] + 1) * 100) / 256; - const float extruder_1_target = thermalManager.degTargetHotend(0); + const int16_t extruder_1_target = thermalManager.degTargetHotend(0); #if EXTRUDERS == 2 - const float extruder_2_target = thermalManager.degTargetHotend(1); + const int16_t extruder_2_target = thermalManager.degTargetHotend(1); #endif - const float bed_target = thermalManager.degTargetBed(); - - static uint8_t last_checksum = 0; - - const uint8_t checksum = - uint8_t(blink) ^ - uint8_t(feedrate_perc) ^ - uint8_t(fan_speed) ^ - uint8_t(extruder_1_target) ^ + #if HAS_HEATER_BED + const int16_t bed_target = thermalManager.degTargetBed(); + #endif + static uint16_t last_checksum = 0; + const uint16_t checksum = blink ^ feedrate_perc ^ fan_speed ^ extruder_1_target #if EXTRUDERS == 2 - uint8_t(extruder_2_target) ^ + ^ extruder_2_target #endif - uint8_t(bed_target); - + #if HAS_HEATER_BED + ^ bed_target + #endif + ; if (last_checksum == checksum) return false; - last_checksum = checksum; return true; } @@ -708,33 +701,38 @@ void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) { if (forceUpdate || indicators_changed()) { const bool blink = lcd_blink(); const duration_t elapsed = print_job_timer.duration(); - const uint32_t seconds_elapsed = elapsed.value; const uint8_t feedrate_perc = feedrate_percentage; const uint8_t fan_speed = ((fanSpeeds[0] + 1) * 100) / 256; - const float extruder_1_temp = thermalManager.degHotend(0); - const float extruder_1_target = thermalManager.degTargetHotend(0); + const int16_t extruder_1_temp = thermalManager.degHotend(0), + extruder_1_target = thermalManager.degTargetHotend(0); #if EXTRUDERS == 2 - const float extruder_2_temp = thermalManager.degHotend(1); - const float extruder_2_target = thermalManager.degTargetHotend(1); + const int16_t extruder_2_temp = thermalManager.degHotend(1), + extruder_2_target = thermalManager.degTargetHotend(1); + #endif + #if HAS_HEATER_BED + const int16_t bed_temp = thermalManager.degBed(), + bed_target = thermalManager.degTargetBed(); #endif - const float bed_temp = thermalManager.degBed(); - const float bed_target = thermalManager.degTargetBed(); draw_extruder_1_temp(extruder_1_temp, extruder_1_target, forceUpdate); #if EXTRUDERS == 2 draw_extruder_2_temp(extruder_2_temp, extruder_2_target, forceUpdate); #endif - draw_bed_temp(bed_temp, bed_target, forceUpdate); + #if HAS_HEATER_BED + draw_bed_temp(bed_temp, bed_target, forceUpdate); + #endif draw_fan_speed(fan_speed); - draw_print_time(seconds_elapsed); + draw_print_time(elapsed); draw_feedrate_percentage(feedrate_perc); // Update the fan and bed animations if (fan_speed > 0) draw_fan_icon(blink); - if (bed_target > 0) - draw_heat_icon(blink, true); - else - draw_heat_icon(false, false); + #if HAS_HEATER_BED + if (bed_target > 0) + draw_heat_icon(blink, true); + else + draw_heat_icon(false, false); + #endif } } @@ -753,7 +751,6 @@ bool ST7920_Lite_Status_Screen::position_changed() { bool ST7920_Lite_Status_Screen::status_changed() { uint8_t checksum = 0; for (const char *p = lcd_status_message; *p; p++) checksum ^= *p; - static uint8_t last_checksum = 0; if (last_checksum == checksum) return false; last_checksum = checksum; @@ -769,7 +766,12 @@ bool ST7920_Lite_Status_Screen::blink_changed() { } void ST7920_Lite_Status_Screen::update_status_or_position(bool forceUpdate) { - static uint8_t countdown = 0; + #ifndef STATUS_EXPIRE_SECONDS + #define STATUS_EXPIRE_SECONDS 20 + #endif + #if STATUS_EXPIRE_SECONDS != 0 + static uint8_t countdown = 0; + #endif /** * There is only enough room in the display for either the @@ -782,51 +784,61 @@ void ST7920_Lite_Status_Screen::update_status_or_position(bool forceUpdate) { * countdown > 1 -- Show status * countdown = 1 -- Show status, until movement * countdown = 0 -- Show position + * + * If STATUS_EXPIRE_SECONDS is zero, then the position + * display will be disabled and only the status will be + * shown. */ if (forceUpdate || status_changed()) { #if ENABLED(STATUS_MESSAGE_SCROLLING) status_scroll_pos = 0; #endif - #ifndef STATUS_EXPIRE_SECONDS - #define STATUS_EXPIRE_SECONDS 20 + #if STATUS_EXPIRE_SECONDS != 0 + countdown = lcd_strlen(lcd_status_message) ? STATUS_EXPIRE_SECONDS : 0; #endif - countdown = lcd_strlen(lcd_status_message) ? STATUS_EXPIRE_SECONDS : 0; draw_status_message(lcd_status_message); blink_changed(); // Clear changed flag } - else if (countdown > 1 && blink_changed()) { - countdown--; + #if STATUS_EXPIRE_SECONDS == 0 #if ENABLED(STATUS_MESSAGE_SCROLLING) - draw_status_message(lcd_status_message); + else + draw_status_message(lcd_status_message); #endif - } - else if (countdown > 0 && blink_changed()) { - if (position_changed()) { + #else + else if (countdown > 1 && blink_changed()) { countdown--; - forceUpdate = true; + #if ENABLED(STATUS_MESSAGE_SCROLLING) + draw_status_message(lcd_status_message); + #endif } - #if ENABLED(STATUS_MESSAGE_SCROLLING) - draw_status_message(lcd_status_message); - #endif - } - if (countdown == 0 && (forceUpdate || position_changed() || - #if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING) - blink_changed() - #endif - )) { - draw_position( - current_position[X_AXIS], - current_position[Y_AXIS], - current_position[Z_AXIS], - #if ENABLED(DISABLE_REDUCED_ACCURACY_WARNING) - true - #else - axis_known_position[X_AXIS] && - axis_known_position[Y_AXIS] && - axis_known_position[Z_AXIS] + else if (countdown > 0 && blink_changed()) { + if (position_changed()) { + countdown--; + forceUpdate = true; + } + #if ENABLED(STATUS_MESSAGE_SCROLLING) + draw_status_message(lcd_status_message); #endif - ); - } + } + if (countdown == 0 && (forceUpdate || position_changed() || + #if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING) + blink_changed() + #endif + )) { + draw_position( + current_position[X_AXIS], + current_position[Y_AXIS], + current_position[Z_AXIS], + #if ENABLED(DISABLE_REDUCED_ACCURACY_WARNING) + true + #else + axis_known_position[X_AXIS] && + axis_known_position[Y_AXIS] && + axis_known_position[Z_AXIS] + #endif + ); + } + #endif } void ST7920_Lite_Status_Screen::update_progress(const bool forceUpdate) { @@ -836,8 +848,7 @@ void ST7920_Lite_Status_Screen::update_progress(const bool forceUpdate) { // Set current percentage from SD when actively printing #if ENABLED(SDSUPPORT) - if (IS_SD_PRINTING) - progress_bar_percent = card.percentDone(); + if (IS_SD_PRINTING) progress_bar_percent = card.percentDone(); #endif // Since the progress bar involves writing diff --git a/Marlin/status_screen_lite_ST7920_class.h b/Marlin/status_screen_lite_ST7920_class.h index 5790a5c72..289723479 100644 --- a/Marlin/status_screen_lite_ST7920_class.h +++ b/Marlin/status_screen_lite_ST7920_class.h @@ -18,6 +18,7 @@ #define STATUS_SCREEN_LITE_ST7920_CLASS_H #include "macros.h" +#include "duration_t.h" typedef const __FlashStringHelper *progmem_str; @@ -85,7 +86,7 @@ class ST7920_Lite_Status_Screen { static void draw_extruder_2_temp(const int16_t temp, const int16_t target, bool forceUpdate = false); static void draw_bed_temp(const int16_t temp, const int16_t target, bool forceUpdate = false); static void draw_fan_speed(const uint8_t value); - static void draw_print_time(const uint32_t elapsed); + static void draw_print_time(const duration_t &elapsed); static void draw_feedrate_percentage(const uint8_t percentage); static void draw_status_message(const char *str); static void draw_position(const float x, const float y, const float z, bool position_known = true); diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 71fcbbf0f..c060e8d95 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -4969,7 +4969,7 @@ void lcd_update() { #endif #if ENABLED(DOGLCD) - #if defined(LULZBOT_MODERN_UI) + #if defined(LULZBOT_LIGHTWEIGHT_UI) LULZBOT_ABOUT_TO_DRAW_SCREEN(currentScreen, lcd_status_screen) #endif if (!drawing_screen) { // If not already drawing pages diff --git a/Marlin/ultralcd_impl_DOGM.h b/Marlin/ultralcd_impl_DOGM.h index 738ad86e5..0d1f27c3f 100644 --- a/Marlin/ultralcd_impl_DOGM.h +++ b/Marlin/ultralcd_impl_DOGM.h @@ -44,7 +44,7 @@ */ #include "ultralcd.h" -#if ENABLED(LULZBOT_MODERN_UI) +#if ENABLED(LULZBOT_LIGHTWEIGHT_UI) typedef const __FlashStringHelper *progmem_str; #include "status_screen_lite_ST7920.h" #endif @@ -370,7 +370,7 @@ static void lcd_implementation_init() { // The kill screen is displayed for unrecoverable conditions void lcd_kill_screen() { - #if ENABLED(LULZBOT_MODERN_UI) + #if ENABLED(LULZBOT_LIGHTWEIGHT_UI) ST7920_Lite_Status_Screen::clear_text_buffer(); #endif u8g.firstPage(); @@ -495,7 +495,7 @@ inline void lcd_implementation_status_message(const bool blink) { //#define DOGM_SD_PERCENT -#if !defined(LULZBOT_MODERN_UI) +#if !defined(LULZBOT_LIGHTWEIGHT_UI) static void lcd_implementation_status_screen() { const bool blink = lcd_blink(); @@ -769,7 +769,7 @@ static void lcd_implementation_status_screen() { #endif } } -#endif // LULZBOT_MODERN_UI +#endif // LULZBOT_LIGHTWEIGHT_UI #if ENABLED(ULTIPANEL) diff --git a/Marlin/ultralcd_st7920_u8glib_rrd.h b/Marlin/ultralcd_st7920_u8glib_rrd.h index b3d25abe2..887d00baa 100644 --- a/Marlin/ultralcd_st7920_u8glib_rrd.h +++ b/Marlin/ultralcd_st7920_u8glib_rrd.h @@ -190,7 +190,7 @@ class U8GLIB_ST7920_128X64_RRD : public U8GLIB { U8GLIB_ST7920_128X64_RRD(uint8_t dummy) : U8GLIB(&u8g_dev_st7920_128x64_rrd_sw_spi) { UNUSED(dummy); } }; -#if ENABLED(LULZBOT_MODERN_UI) +#if ENABLED(LULZBOT_LIGHTWEIGHT_UI) typedef const __FlashStringHelper *progmem_str; // We have to include the code for the lightweight UI here