Skip to content

Commit

Permalink
Echo the result onto serial
Browse files Browse the repository at this point in the history
Example:
MMU2:1111111111111110011
1 means filament present (solid block)
0 means otherwise (dash)

Change in memory:
Flash: +94 bytes
SRAM: 0 bytes
  • Loading branch information
gudnimg committed Apr 29, 2023
1 parent e2e09cb commit c7f669f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions Firmware/mmu2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ bool MMU2::VerifyFilamentEnteredPTFE() {
}
}

TryLoadUnloadProgressbarEcho();
TryLoadUnloadProgressbarDeinit();

if (fsensorState) {
Expand Down
11 changes: 11 additions & 0 deletions Firmware/mmu2_reporting.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -285,6 +286,16 @@ void TryLoadUnloadProgressbarDeinit() {
lcd_reset_status_message_timeout();
}

void TryLoadUnloadProgressbarEcho() {
char buf[LCD_WIDTH + 1];
lcd_getstatus(buf);
for (uint8_t i = 0; i < sizeof(buf); i++) {
// Note: (unsigned char)0xFF is -1
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();
Expand Down
3 changes: 3 additions & 0 deletions Firmware/mmu2_reporting.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,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
Expand Down
4 changes: 4 additions & 0 deletions Firmware/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7204,6 +7204,10 @@ void lcd_clearstatus()
lcd_status_message_idx = 0;
}

void lcd_getstatus(char buf[LCD_WIDTH + 1]) {
strncpy(buf, lcd_status_message, sizeof(lcd_status_message));
}

void lcd_setstatuspgm(const char* message)
{
if (lcd_message_check(LCD_STATUS_NONE))
Expand Down
4 changes: 4 additions & 0 deletions Firmware/ultralcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 + 1]);
void lcd_insert_char_into_status(uint8_t position, const char message);
void lcd_setstatus(const char* message);
void lcd_setstatuspgm(const char* message);
Expand Down

0 comments on commit c7f669f

Please sign in to comment.