Browse Source

Split up hotend / bed drawing

pull/1/head
Scott Lahteine 5 years ago
parent
commit
3dc49fd1c6
  1. 3
      Marlin/src/lcd/dogm/dogm_Statusscreen.h
  2. 185
      Marlin/src/lcd/dogm/status_screen_DOGM.cpp

3
Marlin/src/lcd/dogm/dogm_Statusscreen.h

@ -1462,7 +1462,8 @@
#else // HOTENDS == 0 #else // HOTENDS == 0
//#error "Incomplete status header" #define STATUS_HOTEND_TEXT_X(N) 0
#define STATUS_HEATERS_Y 0
#endif #endif

185
Marlin/src/lcd/dogm/status_screen_DOGM.cpp

@ -64,6 +64,7 @@
#define STATUS_BASELINE (LCD_PIXEL_HEIGHT - INFO_FONT_DESCENT) #define STATUS_BASELINE (LCD_PIXEL_HEIGHT - INFO_FONT_DESCENT)
#define DO_DRAW_LOGO (STATUS_LOGO_WIDTH && ENABLED(CUSTOM_STATUS_SCREEN_IMAGE)) #define DO_DRAW_LOGO (STATUS_LOGO_WIDTH && ENABLED(CUSTOM_STATUS_SCREEN_IMAGE))
#define DO_DRAW_HOTENDS (HOTENDS > 0)
#define DO_DRAW_BED (HAS_HEATED_BED && STATUS_BED_WIDTH && HOTENDS <= 4) #define DO_DRAW_BED (HAS_HEATED_BED && STATUS_BED_WIDTH && HOTENDS <= 4)
#define DO_DRAW_CHAMBER (HAS_TEMP_CHAMBER && STATUS_CHAMBER_WIDTH && HOTENDS <= 4) #define DO_DRAW_CHAMBER (HAS_TEMP_CHAMBER && STATUS_CHAMBER_WIDTH && HOTENDS <= 4)
#define DO_DRAW_FAN (HAS_FAN0 && STATUS_FAN_WIDTH && HOTENDS <= 4 && defined(STATUS_FAN_FRAMES)) #define DO_DRAW_FAN (HAS_FAN0 && STATUS_FAN_WIDTH && HOTENDS <= 4 && defined(STATUS_FAN_FRAMES))
@ -102,12 +103,6 @@
#define PROGRESS_BAR_X 54 #define PROGRESS_BAR_X 54
#define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X) #define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X)
#if ENABLED(MARLIN_DEV_MODE)
#define SHOW_ON_STATE READ(X_MIN_PIN)
#else
#define SHOW_ON_STATE false
#endif
FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, const uint8_t ty) { FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, const uint8_t ty) {
const char *str = i16tostr3(temp); const char *str = i16tostr3(temp);
const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1; const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1;
@ -115,38 +110,19 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
lcd_put_wchar(LCD_STR_DEGREE[0]); lcd_put_wchar(LCD_STR_DEGREE[0]);
} }
FORCE_INLINE void _draw_heater_status(const heater_ind_t heater, const bool blink) { #if DO_DRAW_HOTENDS
FORCE_INLINE void _draw_hotend_status(const heater_ind_t heater, const bool blink) {
#if !HEATER_IDLE_HANDLER #if !HEATER_IDLE_HANDLER
UNUSED(blink); UNUSED(blink);
#endif #endif
#if DO_DRAW_BED && DISABLED(STATUS_COMBINE_HEATERS) || (HAS_HEATED_BED && ENABLED(STATUS_COMBINE_HEATERS) && HOTENDS <= 4) const bool isHeat = HOTEND_ALT(heater);
const bool isBed = heater < 0;
#define IFBED(A,B) (isBed ? (A) : (B))
#else
#define IFBED(A,B) (B)
#endif
#if ENABLED(MARLIN_DEV_MODE)
constexpr bool isHeat = true;
#else
const bool isHeat = IFBED(BED_ALT(), HOTEND_ALT(heater));
#endif
#ifndef STATUS_HOTEND_TEXT_X const uint8_t tx = STATUS_HOTEND_TEXT_X(heater);
#define STATUS_HOTEND_TEXT_X(N) 0
#define STATUS_HEATERS_Y 0
#endif
const uint8_t tx = IFBED(STATUS_BED_TEXT_X, STATUS_HOTEND_TEXT_X(heater)); const float temp = thermalManager.degHotend(heater),
target = thermalManager.degTargetHotend(heater);
#if ENABLED(MARLIN_DEV_MODE)
const float temp = 20 + (millis() >> 8) % IFBED(100, 200),
target = IFBED(100, 200);
#else
const float temp = IFBED(thermalManager.degBed(), thermalManager.degHotend(heater)),
target = IFBED(thermalManager.degTargetBed(), thermalManager.degTargetHotend(heater));
#endif
#if DISABLED(STATUS_HOTEND_ANIM) #if DISABLED(STATUS_HOTEND_ANIM)
#define STATIC_HOTEND true #define STATIC_HOTEND true
@ -156,14 +132,6 @@ FORCE_INLINE void _draw_heater_status(const heater_ind_t heater, const bool blin
#define HOTEND_DOT false #define HOTEND_DOT false
#endif #endif
#if DO_DRAW_BED && DISABLED(STATUS_BED_ANIM)
#define STATIC_BED true
#define BED_DOT isHeat
#else
#define STATIC_BED false
#define BED_DOT false
#endif
#if ANIM_HOTEND && BOTH(STATUS_HOTEND_INVERTED, STATUS_HOTEND_NUMBERLESS) #if ANIM_HOTEND && BOTH(STATUS_HOTEND_INVERTED, STATUS_HOTEND_NUMBERLESS)
#define OFF_BMP(N) status_hotend_b_bmp #define OFF_BMP(N) status_hotend_b_bmp
#define ON_BMP(N) status_hotend_a_bmp #define ON_BMP(N) status_hotend_a_bmp
@ -203,7 +171,6 @@ FORCE_INLINE void _draw_heater_status(const heater_ind_t heater, const bool blin
#if ANIM_HOTEND #if ANIM_HOTEND
// Draw hotend bitmap, either whole or split by the heating percent // Draw hotend bitmap, either whole or split by the heating percent
if (IFBED(0, 1)) {
const uint8_t hx = STATUS_HOTEND_X(heater), const uint8_t hx = STATUS_HOTEND_X(heater),
bw = STATUS_HOTEND_BYTEWIDTH(heater); bw = STATUS_HOTEND_BYTEWIDTH(heater);
#if ENABLED(STATUS_HEAT_PERCENT) #if ENABLED(STATUS_HEAT_PERCENT)
@ -215,14 +182,13 @@ FORCE_INLINE void _draw_heater_status(const heater_ind_t heater, const bool blin
else else
#endif #endif
u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, STATUS_HEATERS_HEIGHT, HOTEND_BITMAP(heater, isHeat)); u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, STATUS_HEATERS_HEIGHT, HOTEND_BITMAP(heater, isHeat));
}
#endif #endif
// Draw a heating progress bar, if specified // Draw a heating progress bar, if specified
#if DO_DRAW_BED && ENABLED(STATUS_HEAT_PERCENT) #if DO_DRAW_BED && ENABLED(STATUS_HEAT_PERCENT)
if (IFBED(true, STATIC_HOTEND) && isHeat) { if (STATIC_HOTEND && isHeat) {
const uint8_t bx = IFBED(STATUS_BED_X + STATUS_BED_WIDTH - 1, STATUS_HOTEND_X(heater) + STATUS_HOTEND_WIDTH(heater)) + 1; const uint8_t bx = STATUS_HOTEND_X(heater) + STATUS_HOTEND_WIDTH(heater) + 1;
u8g.drawFrame(bx, STATUS_HEATERS_Y, 3, STATUS_HEATERS_HEIGHT); u8g.drawFrame(bx, STATUS_HEATERS_Y, 3, STATUS_HEATERS_HEIGHT);
if (tall) { if (tall) {
const uint8_t ph = STATUS_HEATERS_HEIGHT - 1 - tall; const uint8_t ph = STATUS_HEATERS_HEIGHT - 1 - tall;
@ -237,7 +203,7 @@ FORCE_INLINE void _draw_heater_status(const heater_ind_t heater, const bool blin
if (PAGE_UNDER(7)) { if (PAGE_UNDER(7)) {
#if HEATER_IDLE_HANDLER #if HEATER_IDLE_HANDLER
const bool is_idle = IFBED(thermalManager.bed_idle.timed_out, thermalManager.hotend_idle[heater].timed_out), const bool is_idle = thermalManager.hotend_idle[heater].timed_out,
dodraw = (blink || !is_idle); dodraw = (blink || !is_idle);
#else #else
constexpr bool dodraw = true; constexpr bool dodraw = true;
@ -248,46 +214,97 @@ FORCE_INLINE void _draw_heater_status(const heater_ind_t heater, const bool blin
if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1)) if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
_draw_centered_temp(temp + 0.5f, tx, 28); _draw_centered_temp(temp + 0.5f, tx, 28);
if (IFBED(STATIC_BED && BED_DOT, STATIC_HOTEND && HOTEND_DOT) && PAGE_CONTAINS(17, 19)) { if (STATIC_HOTEND && HOTEND_DOT && PAGE_CONTAINS(17, 19)) {
u8g.setColorIndex(0); // set to white on black u8g.setColorIndex(0); // set to white on black
u8g.drawBox(tx, IFBED(20-2, 20-3), 2, 2); u8g.drawBox(tx, 20 - 3, 2, 2);
u8g.setColorIndex(1); // restore black on white u8g.setColorIndex(1); // restore black on white
} }
} }
#if DO_DRAW_CHAMBER #endif // HOTENDS
FORCE_INLINE void _draw_chamber_status(const bool blink) { #if DO_DRAW_BED
#if ENABLED(MARLIN_DEV_MODE)
const float temp = 10 + (millis() >> 8) % CHAMBER_MAXTEMP,
target = CHAMBER_MAXTEMP;
#else
const float temp = thermalManager.degChamber();
#if HAS_HEATED_CHAMBER
const float target = thermalManager.degTargetChamber();
#endif
#endif
FORCE_INLINE void _draw_bed_status(const bool blink) {
#if !HEATER_IDLE_HANDLER #if !HEATER_IDLE_HANDLER
UNUSED(blink); UNUSED(blink);
#endif #endif
const bool isHeat = BED_ALT();
const uint8_t tx = STATUS_BED_TEXT_X;
const float temp = thermalManager.degBed(),
target = thermalManager.degTargetBed();
#if DO_DRAW_BED && DISABLED(STATUS_BED_ANIM)
#define STATIC_BED true
#define BED_DOT isHeat
#else
#define STATIC_BED false
#define BED_DOT false
#endif
if (PAGE_CONTAINS(STATUS_HEATERS_Y, STATUS_HEATERS_BOT)) {
#define BAR_TALL (STATUS_HEATERS_HEIGHT - 2)
const float prop = target - 20,
perc = prop > 0 && temp >= 20 ? (temp - 20) / prop : 0;
uint8_t tall = uint8_t(perc * BAR_TALL + 0.5f);
NOMORE(tall, BAR_TALL);
// Draw a heating progress bar, if specified
#if ENABLED(STATUS_HEAT_PERCENT)
if (isHeat) {
const uint8_t bx = STATUS_BED_X + STATUS_BED_WIDTH;
u8g.drawFrame(bx, STATUS_HEATERS_Y, 3, STATUS_HEATERS_HEIGHT);
if (tall) {
const uint8_t ph = STATUS_HEATERS_HEIGHT - 1 - tall;
if (PAGE_OVER(STATUS_HEATERS_Y + ph))
u8g.drawVLine(bx + 1, STATUS_HEATERS_Y + ph, tall);
}
}
#endif
} // PAGE_CONTAINS
if (PAGE_UNDER(7)) { if (PAGE_UNDER(7)) {
#if HEATER_IDLE_HANDLER #if HEATER_IDLE_HANDLER
const bool is_idle = false, // thermalManager.chamber_idle.timed_out, const bool is_idle = thermalManager.bed_idle.timed_out,
dodraw = (blink || !is_idle); dodraw = (blink || !is_idle);
#else #else
constexpr bool dodraw = true; constexpr bool dodraw = true;
#endif #endif
if (dodraw) _draw_centered_temp(target + 0.5, tx, 7);
}
if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
_draw_centered_temp(temp + 0.5f, tx, 28);
if (STATIC_BED && BED_DOT && PAGE_CONTAINS(17, 19)) {
u8g.setColorIndex(0); // set to white on black
u8g.drawBox(tx, 20 - 2, 2, 2);
u8g.setColorIndex(1); // restore black on white
}
}
#endif // DO_DRAW_BED
#if DO_DRAW_CHAMBER
FORCE_INLINE void _draw_chamber_status() {
#if HAS_HEATED_CHAMBER #if HAS_HEATED_CHAMBER
if (dodraw) _draw_centered_temp(target + 0.5, STATUS_CHAMBER_TEXT_X, 7); if (PAGE_UNDER(7))
#else _draw_centered_temp(thermalManager.degTargetChamber() + 0.5f, STATUS_CHAMBER_TEXT_X, 7);
UNUSED(dodraw);
#endif #endif
}
if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1)) if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
_draw_centered_temp(temp + 0.5f, STATUS_CHAMBER_TEXT_X, 28); _draw_centered_temp(thermalManager.degChamber() + 0.5f, STATUS_CHAMBER_TEXT_X, 28);
} }
#endif // DO_DRAW_CHAMBER #endif // DO_DRAW_CHAMBER
@ -323,17 +340,8 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
} }
} }
#if ENABLED(MARLIN_DEV_MODE)
uint16_t count_renders = 0;
uint32_t total_cycles = 0;
#endif
void MarlinUI::draw_status_screen() { void MarlinUI::draw_status_screen() {
#if ENABLED(MARLIN_DEV_MODE)
if (first_page) count_renders++;
#endif
static char xstring[5 static char xstring[5
#if ENABLED(LCD_SHOW_E_TOTAL) #if ENABLED(LCD_SHOW_E_TOTAL)
+ 7 + 7
@ -378,13 +386,13 @@ void MarlinUI::draw_status_screen() {
#if ANIM_HBC #if ANIM_HBC
uint8_t new_bits = 0; uint8_t new_bits = 0;
#if ANIM_HOTEND #if ANIM_HOTEND
HOTEND_LOOP() if (thermalManager.isHeatingHotend(e) ^ SHOW_ON_STATE) SBI(new_bits, e); HOTEND_LOOP() if (thermalManager.isHeatingHotend(e)) SBI(new_bits, e);
#endif #endif
#if ANIM_BED #if ANIM_BED
if (thermalManager.isHeatingBed() ^ SHOW_ON_STATE) SBI(new_bits, 7); if (thermalManager.isHeatingBed()) SBI(new_bits, 7);
#endif #endif
#if DO_DRAW_CHAMBER && HAS_HEATED_CHAMBER #if DO_DRAW_CHAMBER && HAS_HEATED_CHAMBER
if (thermalManager.isHeatingChamber() ^ SHOW_ON_STATE) SBI(new_bits, 6); if (thermalManager.isHeatingChamber()) SBI(new_bits, 6);
#endif #endif
heat_bits = new_bits; heat_bits = new_bits;
#endif #endif
@ -486,10 +494,6 @@ void MarlinUI::draw_status_screen() {
// Status Menu Font // Status Menu Font
set_font(FONT_STATUSMENU); set_font(FONT_STATUSMENU);
#if ENABLED(MARLIN_DEV_MODE)
TCNT5 = 0;
#endif
#if DO_DRAW_LOGO #if DO_DRAW_LOGO
if (PAGE_CONTAINS(STATUS_LOGO_Y, STATUS_LOGO_Y + STATUS_LOGO_HEIGHT - 1)) if (PAGE_CONTAINS(STATUS_LOGO_Y, STATUS_LOGO_Y + STATUS_LOGO_HEIGHT - 1))
u8g.drawBitmapP(STATUS_LOGO_X, STATUS_LOGO_Y, STATUS_LOGO_BYTEWIDTH, STATUS_LOGO_HEIGHT, status_logo_bmp); u8g.drawBitmapP(STATUS_LOGO_X, STATUS_LOGO_Y, STATUS_LOGO_BYTEWIDTH, STATUS_LOGO_HEIGHT, status_logo_bmp);
@ -556,16 +560,16 @@ void MarlinUI::draw_status_screen() {
// Extruders // Extruders
#if HOTENDS #if HOTENDS
for (uint8_t e = 0; e < MAX_HOTEND_DRAW; ++e) for (uint8_t e = 0; e < MAX_HOTEND_DRAW; ++e)
_draw_heater_status((heater_ind_t)e, blink); _draw_hotend_status((heater_ind_t)e, blink);
#endif #endif
// Heated bed // Heated bed
#if DO_DRAW_BED && DISABLED(STATUS_COMBINE_HEATERS) || (HAS_HEATED_BED && ENABLED(STATUS_COMBINE_HEATERS) && HOTENDS <= 4) #if DO_DRAW_BED && DISABLED(STATUS_COMBINE_HEATERS) || (HAS_HEATED_BED && ENABLED(STATUS_COMBINE_HEATERS) && HOTENDS <= 4)
_draw_heater_status(H_BED, blink); _draw_bed_status(blink);
#endif #endif
#if DO_DRAW_CHAMBER #if DO_DRAW_CHAMBER
_draw_chamber_status(blink); _draw_chamber_status();
#endif #endif
// Fan, if a bitmap was provided // Fan, if a bitmap was provided
@ -587,10 +591,6 @@ void MarlinUI::draw_status_screen() {
#endif #endif
} }
#if ENABLED(MARLIN_DEV_MODE)
total_cycles += TCNT5;
#endif
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
// //
// SD Card Symbol // SD Card Symbol
@ -795,17 +795,6 @@ void MarlinUI::draw_status_screen() {
void MarlinUI::draw_status_message(const bool blink) { void MarlinUI::draw_status_message(const bool blink) {
#if ENABLED(MARLIN_DEV_MODE)
if (PAGE_CONTAINS(64-8, 64-1)) {
lcd_put_int(total_cycles);
lcd_put_wchar('/');
lcd_put_int(count_renders);
lcd_put_wchar('=');
lcd_put_int(int(total_cycles / count_renders));
return;
}
#endif
// Get the UTF8 character count of the string // Get the UTF8 character count of the string
uint8_t slen = utf8_strlen(status_message); uint8_t slen = utf8_strlen(status_message);

Loading…
Cancel
Save