123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493 |
- #ifndef _STATUS_SCREEN_DOGM_H_
- #define _STATUS_SCREEN_DOGM_H_
- FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t x, const uint8_t y) {
- const char * const str = itostr3(temp);
- u8g.setPrintPos(x - (str[0] != ' ' ? 0 : str[1] != ' ' ? 1 : 2) * DOG_CHAR_WIDTH / 2, y);
- lcd_print(str);
- lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
- }
- #ifndef HEAT_INDICATOR_X
- #define HEAT_INDICATOR_X 8
- #endif
- FORCE_INLINE void _draw_heater_status(const uint8_t x, const int8_t heater, const bool blink) {
- #if !HEATER_IDLE_HANDLER
- UNUSED(blink);
- #endif
- #if HAS_HEATED_BED
- const bool isBed = heater < 0;
- #else
- constexpr bool isBed = false;
- #endif
- if (PAGE_UNDER(7)) {
- #if HEATER_IDLE_HANDLER
- const bool is_idle = (
- #if HAS_HEATED_BED
- isBed ? thermalManager.is_bed_idle() :
- #endif
- thermalManager.is_heater_idle(heater)
- );
- if (blink || !is_idle)
- #endif
- _draw_centered_temp(0.5f + (
- #if HAS_HEATED_BED
- isBed ? thermalManager.degTargetBed() :
- #endif
- thermalManager.degTargetHotend(heater)
- ), x, 7
- );
- }
- if (PAGE_CONTAINS(21, 28)) {
- _draw_centered_temp(0.5f + (
- #if HAS_HEATED_BED
- isBed ? thermalManager.degBed() :
- #endif
- thermalManager.degHotend(heater)
- ), x, 28
- );
- if (PAGE_CONTAINS(17, 20)) {
- const uint8_t h = isBed ? 7 : HEAT_INDICATOR_X,
- y = isBed ? 18 : 17;
- if (
- #if HAS_HEATED_BED
- isBed ? thermalManager.isHeatingBed() :
- #endif
- thermalManager.isHeatingHotend(heater)
- ) {
- u8g.setColorIndex(0);
- u8g.drawBox(x + h, y, 2, 2);
- u8g.setColorIndex(1);
- }
- else
- u8g.drawBox(x + h, y, 2, 2);
- }
- }
- }
- FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink) {
- if (blink)
- lcd_print(value);
- else {
- if (!TEST(axis_homed, axis))
- while (const char c = *value++) lcd_print(c <= '.' ? c : '?');
- else {
- #if DISABLED(HOME_AFTER_DEACTIVATE) && DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
- if (!TEST(axis_known_position, axis))
- lcd_printPGM(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
- else
- #endif
- lcd_print(value);
- }
- }
- }
- inline void lcd_implementation_status_message(const bool blink) {
- #if ENABLED(STATUS_MESSAGE_SCROLLING)
- static bool last_blink = false;
-
- uint8_t slen = utf8_strlen(lcd_status_message);
-
- if (slen <= LCD_WIDTH) {
-
- lcd_print_utf(lcd_status_message);
-
- while (slen < LCD_WIDTH) {
- u8g.print(' ');
- ++slen;
- }
- }
- else {
-
-
- const char *stat = lcd_status_message + status_scroll_offset;
-
- const uint8_t rlen = utf8_strlen(stat);
-
- if (rlen >= LCD_WIDTH) {
-
- lcd_print_utf(stat, LCD_WIDTH);
- }
- else {
-
- lcd_print_utf(stat, LCD_WIDTH);
- uint8_t chars = LCD_WIDTH - rlen;
- u8g.print('.');
- if (--chars) {
- u8g.print('.');
- if (--chars)
- lcd_print_utf(lcd_status_message, LCD_WIDTH - (rlen + 2));
- }
- }
- if (last_blink != blink) {
- last_blink = blink;
-
- if (status_scroll_offset < slen) {
- status_scroll_offset++;
- while (!START_OF_UTF8_CHAR(lcd_status_message[status_scroll_offset]))
- status_scroll_offset++;
- }
- else
- status_scroll_offset = 0;
- }
- }
- #else
- UNUSED(blink);
-
- uint8_t slen = utf8_strlen(lcd_status_message);
-
- lcd_print_utf(lcd_status_message, LCD_WIDTH);
-
- while (slen < LCD_WIDTH) {
- u8g.print(' ');
- ++slen;
- }
- #endif
- }
- static void lcd_implementation_status_screen() {
- const bool blink = lcd_blink();
- #if FAN_ANIM_FRAMES > 2
- static bool old_blink;
- static uint8_t fan_frame;
- if (old_blink != blink) {
- old_blink = blink;
- if (!fanSpeeds[0] || ++fan_frame >= FAN_ANIM_FRAMES) fan_frame = 0;
- }
- #endif
-
- lcd_setFont(FONT_STATUSMENU);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if (PAGE_UNDER(STATUS_SCREENHEIGHT + 1)) {
- u8g.drawBitmapP(
- STATUS_SCREEN_X, STATUS_SCREEN_Y,
- (STATUS_SCREENWIDTH + 7) / 8, STATUS_SCREENHEIGHT,
- #if HAS_FAN0
- #if FAN_ANIM_FRAMES > 2
- fan_frame == 1 ? status_screen1_bmp :
- fan_frame == 2 ? status_screen2_bmp :
- #if FAN_ANIM_FRAMES > 3
- fan_frame == 3 ? status_screen3_bmp :
- #endif
- #else
- blink && fanSpeeds[0] ? status_screen1_bmp :
- #endif
- #endif
- status_screen0_bmp
- );
- }
-
-
-
- if (PAGE_UNDER(28)) {
-
- HOTEND_LOOP() _draw_heater_status(STATUS_SCREEN_HOTEND_TEXT_X(e), e, blink);
-
- #if HOTENDS < 4 && HAS_HEATED_BED
- _draw_heater_status(STATUS_SCREEN_BED_TEXT_X, -1, blink);
- #endif
- #if HAS_FAN0
- if (PAGE_CONTAINS(STATUS_SCREEN_FAN_TEXT_Y - 7, STATUS_SCREEN_FAN_TEXT_Y)) {
-
- const int16_t per = ((fanSpeeds[0] + 1) * 100) / 256;
- if (per) {
- u8g.setPrintPos(STATUS_SCREEN_FAN_TEXT_X, STATUS_SCREEN_FAN_TEXT_Y);
- lcd_print(itostr3(per));
- u8g.print('%');
- }
- }
- #endif
- }
- #if ENABLED(SDSUPPORT)
-
-
-
- if (card.isFileOpen() && PAGE_CONTAINS(42 - (TALL_FONT_CORRECTION), 51 - (TALL_FONT_CORRECTION))) {
-
- u8g.drawBox(42, 42 - (TALL_FONT_CORRECTION), 8, 7);
-
- u8g.drawBox(50, 44 - (TALL_FONT_CORRECTION), 2, 5);
-
- u8g.drawFrame(42, 49 - (TALL_FONT_CORRECTION), 10, 4);
-
- u8g.drawPixel(50, 43 - (TALL_FONT_CORRECTION));
- }
- #endif // SDSUPPORT
- #if ENABLED(SDSUPPORT) || ENABLED(LCD_SET_PROGRESS_MANUALLY)
-
-
-
- #define PROGRESS_BAR_X 54
- #define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X)
- if (PAGE_CONTAINS(49, 52 - (TALL_FONT_CORRECTION)))
- u8g.drawFrame(
- PROGRESS_BAR_X, 49,
- PROGRESS_BAR_WIDTH, 4 - (TALL_FONT_CORRECTION)
- );
- #if DISABLED(LCD_SET_PROGRESS_MANUALLY)
- const uint8_t progress_bar_percent = card.percentDone();
- #endif
- if (progress_bar_percent > 1) {
-
-
-
- if (PAGE_CONTAINS(50, 51 - (TALL_FONT_CORRECTION)))
- u8g.drawBox(
- PROGRESS_BAR_X + 1, 50,
- (uint16_t)((PROGRESS_BAR_WIDTH - 2) * progress_bar_percent * 0.01), 2 - (TALL_FONT_CORRECTION)
- );
-
-
-
- #if ENABLED(DOGM_SD_PERCENT)
- if (PAGE_CONTAINS(41, 48)) {
-
- u8g.setPrintPos(55, 48);
- u8g.print(itostr3(progress_bar_percent));
- u8g.print('%');
- }
- #endif
- }
-
-
-
- #if DISABLED(DOGM_SD_PERCENT)
- #define SD_DURATION_X (PROGRESS_BAR_X + (PROGRESS_BAR_WIDTH / 2) - len * (DOG_CHAR_WIDTH / 2))
- #else
- #define SD_DURATION_X (LCD_PIXEL_WIDTH - len * DOG_CHAR_WIDTH)
- #endif
- if (PAGE_CONTAINS(41, 48)) {
- char buffer[10];
- duration_t elapsed = print_job_timer.duration();
- bool has_days = (elapsed.value >= 60*60*24L);
- uint8_t len = elapsed.toDigital(buffer, has_days);
- u8g.setPrintPos(SD_DURATION_X, 48);
- lcd_print(buffer);
- }
- #endif // SDSUPPORT || LCD_SET_PROGRESS_MANUALLY
-
-
-
- #define XYZ_BASELINE (30 + INFO_FONT_HEIGHT)
- #define X_LABEL_POS 3
- #define X_VALUE_POS 11
- #define XYZ_SPACING 40
- #if ENABLED(XYZ_HOLLOW_FRAME)
- #define XYZ_FRAME_TOP 29
- #define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 3
- #else
- #define XYZ_FRAME_TOP 30
- #define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 1
- #endif
- static char xstring[5], ystring[5], zstring[7];
- #if ENABLED(FILAMENT_LCD_DISPLAY)
- static char wstring[5], mstring[4];
- #endif
-
- if (page.page == 0) {
- strcpy(xstring, ftostr4sign(LOGICAL_X_POSITION(current_position[X_AXIS])));
- strcpy(ystring, ftostr4sign(LOGICAL_Y_POSITION(current_position[Y_AXIS])));
- strcpy(zstring, ftostr52sp(LOGICAL_Z_POSITION(current_position[Z_AXIS])));
- #if ENABLED(FILAMENT_LCD_DISPLAY)
- strcpy(wstring, ftostr12ns(filament_width_meas));
- strcpy(mstring, itostr3(100.0 * (
- parser.volumetric_enabled
- ? planner.volumetric_area_nominal / planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]
- : planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]
- )
- ));
- #endif
- }
- if (PAGE_CONTAINS(XYZ_FRAME_TOP, XYZ_FRAME_TOP + XYZ_FRAME_HEIGHT - 1)) {
- #if ENABLED(XYZ_HOLLOW_FRAME)
- u8g.drawFrame(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT);
- #else
- u8g.drawBox(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT);
- #endif
- if (PAGE_CONTAINS(XYZ_BASELINE - (INFO_FONT_HEIGHT - 1), XYZ_BASELINE)) {
- #if DISABLED(XYZ_HOLLOW_FRAME)
- u8g.setColorIndex(0);
- #endif
- u8g.setPrintPos(0 * XYZ_SPACING + X_LABEL_POS, XYZ_BASELINE);
- lcd_printPGM(PSTR(MSG_X));
- u8g.setPrintPos(0 * XYZ_SPACING + X_VALUE_POS, XYZ_BASELINE);
- _draw_axis_value(X_AXIS, xstring, blink);
- u8g.setPrintPos(1 * XYZ_SPACING + X_LABEL_POS, XYZ_BASELINE);
- lcd_printPGM(PSTR(MSG_Y));
- u8g.setPrintPos(1 * XYZ_SPACING + X_VALUE_POS, XYZ_BASELINE);
- _draw_axis_value(Y_AXIS, ystring, blink);
- u8g.setPrintPos(2 * XYZ_SPACING + X_LABEL_POS, XYZ_BASELINE);
- lcd_printPGM(PSTR(MSG_Z));
- u8g.setPrintPos(2 * XYZ_SPACING + X_VALUE_POS, XYZ_BASELINE);
- _draw_axis_value(Z_AXIS, zstring, blink);
- #if DISABLED(XYZ_HOLLOW_FRAME)
- u8g.setColorIndex(1);
- #endif
- }
- }
-
-
-
- if (PAGE_CONTAINS(51 - INFO_FONT_HEIGHT, 49)) {
- lcd_setFont(FONT_MENU);
- u8g.setPrintPos(3, 50);
- lcd_print(LCD_STR_FEEDRATE[0]);
- lcd_setFont(FONT_STATUSMENU);
- u8g.setPrintPos(12, 50);
- lcd_print(itostr3(feedrate_percentage));
- u8g.print('%');
-
-
-
- #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT)
- u8g.setPrintPos(56, 50);
- lcd_print(wstring);
- u8g.setPrintPos(102, 50);
- lcd_print(mstring);
- u8g.print('%');
- lcd_setFont(FONT_MENU);
- u8g.setPrintPos(47, 50);
- lcd_print(LCD_STR_FILAM_DIA);
- u8g.setPrintPos(93, 50);
- lcd_print(LCD_STR_FILAM_MUL);
- #endif
- }
-
-
-
- #define STATUS_BASELINE (55 + INFO_FONT_HEIGHT)
- if (PAGE_CONTAINS(STATUS_BASELINE - (INFO_FONT_HEIGHT - 1), STATUS_BASELINE)) {
- u8g.setPrintPos(0, STATUS_BASELINE);
- #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
- if (PENDING(millis(), previous_lcd_status_ms + 5000UL)) {
- lcd_implementation_status_message(blink);
- }
- else {
- lcd_printPGM(PSTR(LCD_STR_FILAM_DIA));
- u8g.print(':');
- lcd_print(wstring);
- lcd_printPGM(PSTR(" " LCD_STR_FILAM_MUL));
- u8g.print(':');
- lcd_print(mstring);
- u8g.print('%');
- }
- #else
- lcd_implementation_status_message(blink);
- #endif
- }
- }
- #endif // _STATUS_SCREEN_DOGM_H_
|