Skip to content

Commit

Permalink
Add Sheet bit check
Browse files Browse the repository at this point in the history
Add Sheet warning bit check
Improve `M115` steel check when `Always` is selected for host connection
Add some debug output
  • Loading branch information
3d-gussner committed Jan 10, 2025
1 parent c065e48 commit a66d5bb
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
21 changes: 13 additions & 8 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5840,8 +5840,8 @@ void process_commands()
#endif //EXTENDED_CAPABILITIES_REPORT
}
#ifdef STEEL_SHEET_TYPES
if (eeprom_read_byte((uint8_t*)EEPROM_CHECK_SHEET_TYPE) == (uint8_t)ClCheckMode::_Always) {
uint8_t result = lcd_show_multiscreen_message_cont_cancel_and_wait_P(_T(MSG_CHECK_SHEET_TYPE), false, LCD_MIDDLE_BUTTON_CHOICE);
if ((eeprom_read_byte((uint8_t*)EEPROM_CHECK_SHEET_TYPE) == (uint8_t)ClCheckMode::_Always) && printer_active()) {
uint8_t result = lcd_show_multiscreen_message_cont_cancel_and_wait_P(_T(MSG_CHECK_SHEET_TYPE), true, LCD_MIDDLE_BUTTON_CHOICE);
if (result == LCD_MIDDLE_BUTTON_CHOICE) {
print_stop(false, true);
}
Expand Down Expand Up @@ -7393,7 +7393,7 @@ void process_commands()
- M862.4 { P<fw_version> | Q }
- M862.5 { P<gcode_level> | Q }
- M862.6 Not used but reserved by 32-bit
- M862.7 { P<sheet type> | Q }
- M862.7 { P<sheet type> | W<warn sheet type>| Q }
When run with P<> argument, the check is performed against the input value.
When run with Q argument, the current value is shown.
Expand Down Expand Up @@ -7469,8 +7469,8 @@ void process_commands()
case ClPrintChecking::_Gcode: // ~ .5
if(code_seen('P'))
{
uint16_t nGcodeLevel;
nGcodeLevel=(uint16_t)code_value_long();
uint8_t nGcodeLevel;
nGcodeLevel=(uint8_t)code_value_uint8();
gcode_level_check(nGcodeLevel);
}
else if(code_seen('Q'))
Expand All @@ -7482,9 +7482,14 @@ void process_commands()
case ClPrintChecking::_SheetType: // ~ .7
if(code_seen('P'))
{
uint16_t nSheetType;
nSheetType=(uint16_t)code_value_long();
sheet_type_check(nSheetType);
uint8_t nSheetType;
uint8_t wSheetType;
nSheetType=(uint8_t)code_value_uint8();
if(code_seen('W'))
{
wSheetType=(uint8_t)code_value_uint8();
}
sheet_type_check(nSheetType, wSheetType);
}
else if(code_seen('Q'))
SERIAL_PROTOCOLLN((int)eeprom_read_byte(&EEPROM_Sheets_base->s[eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet))].type));
Expand Down
25 changes: 17 additions & 8 deletions Firmware/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,10 @@ bool filament_presence_check() {
return true;
}

void gcode_level_check(uint16_t nGcodeLevel) {
void gcode_level_check(uint8_t nGcodeLevel) {
if (oCheckGcode == ClCheckMode::_None)
return;
if (nGcodeLevel <= (uint16_t)GCODE_LEVEL)
if (nGcodeLevel <= (uint8_t)GCODE_LEVEL)
return;

// SERIAL_ECHO_START;
Expand All @@ -433,23 +433,32 @@ void gcode_level_check(uint16_t nGcodeLevel) {
}

#ifdef STEEL_SHEET_TYPES
void sheet_type_check(uint16_t nSheetType) {
uint16_t actualSheetType;
void sheet_type_check(uint8_t nSheetType, uint8_t wSheetType) {
uint8_t actualSheetType;
if (oCheckSheets == ClCheckMode::_None)
return;
actualSheetType = eeprom_read_byte(&EEPROM_Sheets_base->s[eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet))].type);
if (nSheetType == actualSheetType)
return;
bool n_SheetType = (nSheetType & actualSheetType) ? 1 : 0; //Expected sheet found
bool w_SheetType = (wSheetType & actualSheetType) ? 1 : 0; //Warn sheet found
/*
SERIAL_PROTOCOLPGM("Active sheet number: ");
SERIAL_PROTOCOL((int)eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)));
SERIAL_PROTOCOLPGM(" Sheet type differs from actual : ");
SERIAL_PROTOCOLPGM(" actual sheet type: ");
SERIAL_PROTOCOL((int)eeprom_read_byte(&EEPROM_Sheets_base->s[eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet))].type));
SERIAL_PROTOCOLPGM(" expected: ");
SERIAL_PROTOCOLPGM(" expected sheet type: ");
SERIAL_PROTOCOL((int)nSheetType);
SERIAL_PROTOCOLPGM(" warn sheet type: ");
SERIAL_PROTOCOL((int)wSheetType);
SERIAL_PROTOCOLPGM(" n_sheet found: ");
SERIAL_PROTOCOL((int)n_SheetType);
SERIAL_PROTOCOLPGM(" w_sheet not found: ");
SERIAL_PROTOCOL((int)w_SheetType);
SERIAL_PROTOCOLPGM(" oCheckSheets: ");
SERIAL_PROTOCOLLN((int)oCheckSheets);
*/
if (n_SheetType && !w_SheetType && oCheckSheets != ClCheckMode::_Always)
return;

render_M862_warnings(
_T(MSG_CHECK_SHEET_TYPE)
,_T(MSG_CHECK_SHEET_TYPE) //Identical messages
Expand Down
4 changes: 2 additions & 2 deletions Firmware/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ void nozzle_diameter_check(uint16_t nDiameter);
void printer_model_check(uint16_t nPrinterModel, uint16_t actualPrinterModel);
void printer_smodel_check(const char *pStrPos, const char *actualPrinterSModel);
void fw_version_check(const char *pVersion);
void gcode_level_check(uint16_t nGcodeLevel);
void gcode_level_check(uint8_t nGcodeLevel);
#ifdef STEEL_SHEET_TYPES
void sheet_type_check(uint16_t nSheetType);
void sheet_type_check(uint8_t nSheetType, uint8_t wSheetType);
#endif //STEEL_SHEET_TYPES

/// Check if the filament is present before starting a print job.
Expand Down

0 comments on commit a66d5bb

Please sign in to comment.