Echo the result onto serial

Example:
MMU2:1111111111111110011
1 means filament present (solid block)
0 means otherwise (dash)

Change in memory:
Flash: +94 bytes
SRAM: 0 bytes
This commit is contained in:
Guðni Már Gilbert 2023-04-29 17:10:33 +00:00
parent 20c6a448fa
commit 7e025894d1
5 changed files with 24 additions and 0 deletions

View File

@ -305,6 +305,7 @@ bool MMU2::VerifyFilamentEnteredPTFE() {
}
Disable_E0();
TryLoadUnloadProgressbarEcho();
TryLoadUnloadProgressbarDeinit();
if (fsensorState) {

View File

@ -1,4 +1,5 @@
#include "mmu2.h"
#include "mmu2_log.h"
#include "mmu2_reporting.h"
#include "mmu2_error_converter.h"
#include "mmu2/error_codes.h"
@ -292,6 +293,17 @@ void TryLoadUnloadProgressbarDeinit() {
lcd_reset_status_message_timeout();
}
void TryLoadUnloadProgressbarEcho() {
char buf[LCD_WIDTH];
lcd_getstatus(buf);
for (uint8_t i = 0; i < sizeof(buf); i++) {
// 0xFF is -1 when converting from unsigned to signed char
// If the number is negative, that means filament is present
buf[i] = (buf[i] < 0) ? '1' : '0';
}
MMU2_ECHO_MSGLN(buf);
}
void TryLoadUnloadProgressbar(uint8_t col, bool sensorState) {
lcd_insert_char_into_status(col, sensorState ? '-' : LCD_STR_SOLID_BLOCK[0]);
if (!lcd_update_enabled) lcdui_print_status_line();

View File

@ -41,6 +41,9 @@ void TryLoadUnloadProgressbarInit();
/// @brief Clear the status line and setup the LCD cursor
void TryLoadUnloadProgressbarDeinit();
/// @brief Report the results to serial
void TryLoadUnloadProgressbarEcho();
/// @brief Add one block to the progress bar
/// @param col pixel position on the LCD status line, should range from 0 to (LCD_WIDTH - 1)
/// @param sensorState if true, filament is not present, else filament is present. This controls which character to render

View File

@ -7079,6 +7079,10 @@ void lcd_clearstatus()
lcd_status_message_idx = 0;
}
void lcd_getstatus(char buf[LCD_WIDTH]) {
strncpy(buf, lcd_status_message, LCD_WIDTH);
}
void lcd_setstatuspgm(const char* message)
{
if (lcd_message_check(LCD_STATUS_NONE))

View File

@ -22,6 +22,10 @@ void ultralcd_init();
// Set the current status message (equivalent to LCD_STATUS_NONE)
void lcdui_print_status_line(void);
void lcd_clearstatus();
/// @brief Copy the contents of lcd_status_message
/// @param buf destination buffer
void lcd_getstatus(char buf[LCD_WIDTH]);
void lcd_insert_char_into_status(uint8_t position, const char message);
void lcd_setstatus(const char* message);
void lcd_setstatuspgm(const char* message);