♻️ Set Progress without LCD (#24767)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
EvilGremlin
2022-10-09 18:30:47 +03:00
committed by Scott Lahteine
parent 0d8a695ea9
commit f595e40ceb
34 changed files with 626 additions and 487 deletions

View File

@@ -25,7 +25,6 @@
#include "../sd/cardreader.h"
#include "../module/motion.h"
#include "../libs/buzzer.h"
#include "buttons.h"
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
@@ -36,7 +35,7 @@
#define MULTI_E_MANUAL 1
#endif
#if HAS_DISPLAY
#if HAS_PRINT_PROGRESS
#include "../module/printcounter.h"
#endif
@@ -86,6 +85,7 @@ typedef bool (*statusResetFunc_t)();
#endif // HAS_WIRED_LCD
#if EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_JYERSUI)
#define LCD_WITH_BLINK 1
#define LCD_UPDATE_INTERVAL TERN(HAS_TOUCH_BUTTONS, 50, 100)
#endif
@@ -303,19 +303,19 @@ public:
#define PROGRESS_SCALE 1U
#define PROGRESS_MASK 0x7F
#endif
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
#if ENABLED(SET_PROGRESS_PERCENT)
static progress_t progress_override;
static void set_progress(const progress_t p) { progress_override = _MIN(p, 100U * (PROGRESS_SCALE)); }
static void set_progress_done() { progress_override = (PROGRESS_MASK + 1U) + 100U * (PROGRESS_SCALE); }
static void progress_reset() { if (progress_override & (PROGRESS_MASK + 1U)) set_progress(0); }
#endif
#if ENABLED(SHOW_REMAINING_TIME)
#if EITHER(SHOW_REMAINING_TIME, SET_PROGRESS_MANUALLY)
static uint32_t _calculated_remaining_time() {
const duration_t elapsed = print_job_timer.duration();
const progress_t progress = _get_progress();
return progress ? elapsed.value * (100 * (PROGRESS_SCALE) - progress) / progress : 0;
}
#if ENABLED(USE_M73_REMAINING_TIME)
#if ENABLED(SET_REMAINING_TIME)
static uint32_t remaining_time;
FORCE_INLINE static void set_remaining_time(const uint32_t r) { remaining_time = r; }
FORCE_INLINE static uint32_t get_remaining_time() { return remaining_time ?: _calculated_remaining_time(); }
@@ -323,12 +323,32 @@ public:
#else
FORCE_INLINE static uint32_t get_remaining_time() { return _calculated_remaining_time(); }
#endif
#if ENABLED(SET_INTERACTION_TIME)
static uint32_t interaction_time;
FORCE_INLINE static void set_interaction_time(const uint32_t r) { interaction_time = r; }
FORCE_INLINE static void reset_interaction_time() { set_interaction_time(0); }
#endif
#endif
static progress_t _get_progress();
#if HAS_PRINT_PROGRESS_PERMYRIAD
FORCE_INLINE static uint16_t get_progress_permyriad() { return _get_progress(); }
#endif
static uint8_t get_progress_percent() { return uint8_t(_get_progress() / (PROGRESS_SCALE)); }
#if LCD_WITH_BLINK
#if ENABLED(SHOW_PROGRESS_PERCENT)
static void drawPercent();
#endif
#if ENABLED(SHOW_ELAPSED_TIME)
static void drawElapsed();
#endif
#if ENABLED(SHOW_REMAINING_TIME)
static void drawRemain();
#endif
#if ENABLED(SHOW_INTERACTION_TIME)
static void drawInter();
#endif
static void rotate_progress();
#endif
#else
static constexpr uint8_t get_progress_percent() { return 0; }
#endif
@@ -390,7 +410,7 @@ public:
static void poweroff();
#endif
#if EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_JYERSUI)
#if LCD_WITH_BLINK
static bool get_blink();
#endif