Return try-load reporting to serial
This commit is contained in:
parent
59e49c80f9
commit
a02ff0651c
|
|
@ -300,7 +300,7 @@ bool MMU2::VerifyFilamentEnteredPTFE() {
|
|||
if (!filament_inserted) {
|
||||
IncrementLoadFails();
|
||||
}
|
||||
|
||||
tlur.DumpToSerial();
|
||||
return filament_inserted;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -304,6 +304,7 @@ TryLoadUnloadReporter::TryLoadUnloadReporter(float delta_mm)
|
|||
// Clear the status line
|
||||
lcd_set_cursor(0, 3);
|
||||
lcd_space(LCD_WIDTH);
|
||||
static_assert(LCD_WIDTH < 32); // for progress bits
|
||||
}
|
||||
|
||||
void TryLoadUnloadReporter::Render(uint8_t col, bool sensorState) {
|
||||
|
|
@ -320,9 +321,27 @@ void TryLoadUnloadReporter::Progress(bool sensorState){
|
|||
dpixel0 = dpixel1;
|
||||
if (lcd_cursor_col > (LCD_WIDTH - 1)) lcd_cursor_col = LCD_WIDTH - 1;
|
||||
Render(lcd_cursor_col++, sensorState);
|
||||
progress.dw <<= 1;
|
||||
if(sensorState){
|
||||
progress.bytes[0] |= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TryLoadUnloadReporter::DumpToSerial(){
|
||||
char buf[LCD_WIDTH + 1];
|
||||
PU tmpProgress { progress.dw }; // avoid storing the shifted progress back into the memory - saves 4 instructions ;)
|
||||
|
||||
// fill the buffer from the back - the last recorded fs state shall be printed as the last character
|
||||
// i < 0xff means we go from LCD_WIDTH-1 down to zero included (LCD_WIDTH-1 is less than 0xff)
|
||||
for (uint8_t i = LCD_WIDTH - 1; i < 0xff; --i) {
|
||||
buf[i] = (tmpProgress.bytes[0] & 1) + '0';
|
||||
tmpProgress.dw >>= 1;
|
||||
}
|
||||
buf[LCD_WIDTH] = 0;
|
||||
MMU2_ECHO_MSGLN(buf);
|
||||
}
|
||||
|
||||
void IncrementLoadFails(){
|
||||
eeprom_increment_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL);
|
||||
eeprom_increment_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT);
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ void ReportProgressHook(CommandInProgress cip, ProgressCode ec);
|
|||
struct TryLoadUnloadReporter {
|
||||
TryLoadUnloadReporter(float delta_mm);
|
||||
void Progress(bool sensorState);
|
||||
void DumpToSerial();
|
||||
|
||||
private:
|
||||
/// @brief Add one block to the progress bar
|
||||
|
|
@ -64,6 +65,17 @@ private:
|
|||
// Note: Below is the reciprocal of (2 * delta_mm) / LCD_WIDTH [mm/pixel]
|
||||
float pixel_per_mm;
|
||||
uint8_t lcd_cursor_col;
|
||||
|
||||
// Beware: needs to be a union to optimize for the 8bit better
|
||||
union __attribute__((packed)) PU {
|
||||
uint32_t dw;
|
||||
uint8_t bytes[4];
|
||||
constexpr PU()
|
||||
: dw(0) {}
|
||||
constexpr PU(uint32_t dw)
|
||||
: dw(dw) {}
|
||||
} progress;
|
||||
static_assert(sizeof(PU) == 4);
|
||||
};
|
||||
|
||||
/// Remders the sensor status line. Also used by the "resume temperature" screen.
|
||||
|
|
|
|||
Loading…
Reference in New Issue