Add LCD_SET_PROGRESS_MANUALLY
This commit is contained in:
@ -83,6 +83,10 @@ char lcd_status_message[3 * (LCD_WIDTH) + 1] = WELCOME_MSG; // worst case is kan
|
||||
uint8_t status_scroll_pos = 0;
|
||||
#endif
|
||||
|
||||
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
|
||||
uint8_t progress_bar_percent;
|
||||
#endif
|
||||
|
||||
#if ENABLED(DOGLCD)
|
||||
#include "ultralcd_impl_DOGM.h"
|
||||
#include <U8glib.h>
|
||||
@ -604,36 +608,52 @@ void lcd_status_screen() {
|
||||
#endif
|
||||
|
||||
#if ENABLED(LCD_PROGRESS_BAR)
|
||||
millis_t ms = millis();
|
||||
#if DISABLED(PROGRESS_MSG_ONCE)
|
||||
if (ELAPSED(ms, progress_bar_ms + PROGRESS_BAR_MSG_TIME + PROGRESS_BAR_BAR_TIME)) {
|
||||
progress_bar_ms = ms;
|
||||
}
|
||||
|
||||
//
|
||||
// HD44780 implements the following message blinking and
|
||||
// message expiration because Status Line and Progress Bar
|
||||
// share the same line on the display.
|
||||
//
|
||||
|
||||
// Set current percentage from SD when actively printing
|
||||
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
|
||||
if (IS_SD_PRINTING)
|
||||
progress_bar_percent = card.percentDone();
|
||||
#endif
|
||||
|
||||
millis_t ms = millis();
|
||||
|
||||
// If the message will blink rather than expire...
|
||||
#if DISABLED(PROGRESS_MSG_ONCE)
|
||||
if (ELAPSED(ms, progress_bar_ms + PROGRESS_BAR_MSG_TIME + PROGRESS_BAR_BAR_TIME))
|
||||
progress_bar_ms = ms;
|
||||
#endif
|
||||
|
||||
#if PROGRESS_MSG_EXPIRE > 0
|
||||
|
||||
// Handle message expire
|
||||
if (expire_status_ms > 0) {
|
||||
#if ENABLED(SDSUPPORT)
|
||||
if (card.isFileOpen()) {
|
||||
// Expire the message when printing is active
|
||||
if (IS_SD_PRINTING) {
|
||||
if (ELAPSED(ms, expire_status_ms)) {
|
||||
lcd_status_message[0] = '\0';
|
||||
expire_status_ms = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
expire_status_ms += LCD_UPDATE_INTERVAL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
#if DISABLED(LCD_SET_PROGRESS_MANUALLY)
|
||||
const uint8_t progress_bar_percent = card.percentDone();
|
||||
#endif
|
||||
|
||||
// Expire the message if a job is active and the bar has ticks
|
||||
if (progress_bar_percent > 2 && !print_job_timer.isPaused()) {
|
||||
if (ELAPSED(ms, expire_status_ms)) {
|
||||
lcd_status_message[0] = '\0';
|
||||
expire_status_ms = 0;
|
||||
}
|
||||
#else
|
||||
expire_status_ms = 0;
|
||||
#endif // SDSUPPORT
|
||||
}
|
||||
else {
|
||||
// Defer message expiration before bar appears
|
||||
// and during any pause (not just SD)
|
||||
expire_status_ms += LCD_UPDATE_INTERVAL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // PROGRESS_MSG_EXPIRE
|
||||
|
||||
#endif // LCD_PROGRESS_BAR
|
||||
|
||||
#if ENABLED(ULTIPANEL)
|
||||
@ -2860,7 +2880,7 @@ void kill_screen(const char* lcd_msg) {
|
||||
#if ENABLED(MAX_SOFTWARE_ENDSTOP_Z)
|
||||
max = soft_endstop_max[Z_AXIS];
|
||||
#endif
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
#endif // MIN_SOFTWARE_ENDSTOPS || MAX_SOFTWARE_ENDSTOPS
|
||||
|
||||
|
@ -63,6 +63,10 @@
|
||||
void dontExpireStatus();
|
||||
#endif
|
||||
|
||||
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
|
||||
extern uint8_t progress_bar_percent;
|
||||
#endif
|
||||
|
||||
#if ENABLED(ADC_KEYPAD)
|
||||
uint8_t get_ADC_keyValue();
|
||||
#endif
|
||||
|
@ -536,7 +536,7 @@ static void lcd_implementation_status_screen() {
|
||||
// SD Card Symbol
|
||||
//
|
||||
|
||||
if (PAGE_CONTAINS(42 - (TALL_FONT_CORRECTION), 51 - (TALL_FONT_CORRECTION))) {
|
||||
if (card.isFileOpen() && PAGE_CONTAINS(42 - (TALL_FONT_CORRECTION), 51 - (TALL_FONT_CORRECTION))) {
|
||||
// Upper box
|
||||
u8g.drawBox(42, 42 - (TALL_FONT_CORRECTION), 8, 7); // 42-48 (or 41-47)
|
||||
// Right edge
|
||||
@ -560,7 +560,11 @@ static void lcd_implementation_status_screen() {
|
||||
PROGRESS_BAR_WIDTH, 4 - (TALL_FONT_CORRECTION)
|
||||
);
|
||||
|
||||
if (IS_SD_PRINTING) {
|
||||
#if DISABLED(LCD_SET_PROGRESS_MANUALLY)
|
||||
const uint8_t progress_bar_percent = card.percentDone();
|
||||
#endif
|
||||
|
||||
if (progress_bar_percent > 1) {
|
||||
|
||||
//
|
||||
// Progress bar solid part
|
||||
@ -569,7 +573,7 @@ static void lcd_implementation_status_screen() {
|
||||
if (PAGE_CONTAINS(50, 51 - (TALL_FONT_CORRECTION))) // 50-51 (or just 50)
|
||||
u8g.drawBox(
|
||||
PROGRESS_BAR_X + 1, 50,
|
||||
(uint16_t)((PROGRESS_BAR_WIDTH - 2) * card.percentDone() * 0.01), 2 - (TALL_FONT_CORRECTION)
|
||||
(uint16_t)((PROGRESS_BAR_WIDTH - 2) * progress_bar_percent * 0.01), 2 - (TALL_FONT_CORRECTION)
|
||||
);
|
||||
|
||||
//
|
||||
@ -580,7 +584,7 @@ static void lcd_implementation_status_screen() {
|
||||
if (PAGE_CONTAINS(41, 48)) {
|
||||
// Percent complete
|
||||
u8g.setPrintPos(55, 48);
|
||||
u8g.print(itostr3(card.percentDone()));
|
||||
u8g.print(itostr3(progress_bar_percent));
|
||||
u8g.print('%');
|
||||
}
|
||||
#endif
|
||||
|
@ -203,9 +203,9 @@ extern volatile uint8_t buttons; //an extended version of the last checked butt
|
||||
#include "utf_mapper.h"
|
||||
|
||||
#if ENABLED(LCD_PROGRESS_BAR)
|
||||
static millis_t progress_bar_ms = 0;
|
||||
static millis_t progress_bar_ms = 0; // Start millis of the current progress bar cycle
|
||||
#if PROGRESS_MSG_EXPIRE > 0
|
||||
static millis_t expire_status_ms = 0;
|
||||
static millis_t expire_status_ms = 0; // millis at which to expire the status message
|
||||
#endif
|
||||
#define LCD_STR_PROGRESS "\x03\x04\x05"
|
||||
#endif
|
||||
@ -842,12 +842,13 @@ static void lcd_implementation_status_screen() {
|
||||
|
||||
#if ENABLED(LCD_PROGRESS_BAR)
|
||||
|
||||
#if DISABLED(LCD_SET_PROGRESS_MANUALLY)
|
||||
const uint8_t progress_bar_percent = card.percentDone();
|
||||
#endif
|
||||
// Draw the progress bar if the message has shown long enough
|
||||
// or if there is no message set.
|
||||
if (card.isFileOpen() && (ELAPSED(millis(), progress_bar_ms + PROGRESS_BAR_MSG_TIME) || !lcd_status_message[0])) {
|
||||
const uint8_t percent = card.percentDone();
|
||||
if (percent) return lcd_draw_progress_bar(percent);
|
||||
}
|
||||
if (progress_bar_percent > 2 && (ELAPSED(millis(), progress_bar_ms + PROGRESS_BAR_MSG_TIME) || !lcd_status_message[0]))
|
||||
return lcd_draw_progress_bar(progress_bar_percent);
|
||||
|
||||
#elif ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
|
||||
|
||||
|
Reference in New Issue
Block a user