Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚧 WIP: Steel sheet check #4832

Draft
wants to merge 4 commits into
base: MK3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 51 additions & 26 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5839,6 +5839,14 @@ void process_commands()
extended_capabilities_report();
#endif //EXTENDED_CAPABILITIES_REPORT
}
#ifdef STEEL_SHEET_TYPES
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);
}
}
#endif //STEEL_SHEET_TYPES
break;

/*!
Expand Down Expand Up @@ -7143,22 +7151,27 @@ void process_commands()
Get and Set Sheet parameters
#### Usage

M850 [ S | Z | L | B | P | A ]
M850 [ S | Z | L | T | A ]

#### Parameters
- `S` - Sheet id [0-7]
- `Z` - Z offset
- `L` - Label [aA-zZ, 0-9 max 7 chars]
- `B` - Bed temp
- `P` - PINDA temp
- `T` - Type
- `0` - Smooth
- `1` - Textured
- `2` - Satin
- `3` - PA Nylon
- `4` - PP
- `A` - Active [0|1]
*/
uint8_t iSel = 0;
uint8_t iSel = 0;
int16_t zraw = 0;
float z_val = 0;
char strLabel[8];
uint8_t iBedC = 0;
uint8_t iPindaC = 0;
#ifdef STEEL_SHEET_TYPES
uint8_t iType = 0;
#endif //STEEL_SHEET_TYPES
bool bIsActive=false;
strLabel[7] = '\0'; // null terminate.
size_t max_sheets = sizeof(EEPROM_Sheets_base->s)/sizeof(EEPROM_Sheets_base->s[0]);
Expand Down Expand Up @@ -7207,25 +7220,19 @@ void process_commands()
eeprom_read_block(strLabel, EEPROM_Sheets_base->s[iSel].name, sizeof(Sheet::name));
}

if (code_seen('B'))
#ifdef STEEL_SHEET_TYPES
if (code_seen('T'))
{
iBedC = code_value_uint8();
eeprom_update_byte_notify(&EEPROM_Sheets_base->s[iSel].bed_temp, iBedC);
iType = code_value_uint8();
eeprom_update_byte_notify(&EEPROM_Sheets_base->s[iSel].type, iType);
}
else
{
iBedC = eeprom_read_byte(&EEPROM_Sheets_base->s[iSel].bed_temp);
}

if (code_seen('P'))
{
iPindaC = code_value_uint8();
eeprom_update_byte_notify(&EEPROM_Sheets_base->s[iSel].pinda_temp, iPindaC);
}
else
{
iPindaC = eeprom_read_byte(&EEPROM_Sheets_base->s[iSel].pinda_temp);
iType = eeprom_read_byte(&EEPROM_Sheets_base->s[iSel].type);
}
// Reset Sheet type if out of range
if (iType > STEEL_SHEET_TYPES -1) eeprom_update_byte_notify(&EEPROM_Sheets_base->s[iSel].type, 0);
#endif //STEEL_SHEET_TYPES

if (code_seen('A'))
{
Expand Down Expand Up @@ -7253,10 +7260,10 @@ void process_commands()
SERIAL_PROTOCOL((int)zraw);
SERIAL_PROTOCOLPGM(" L");
SERIAL_PROTOCOL(strLabel);
SERIAL_PROTOCOLPGM(" B");
SERIAL_PROTOCOL((int)iBedC);
SERIAL_PROTOCOLPGM(" P");
SERIAL_PROTOCOL((int)iPindaC);
#ifdef STEEL_SHEET_TYPES
SERIAL_PROTOCOLPGM(" T");
SERIAL_PROTOCOL((int)iType);
#endif //STEEL_SHEET_TYPES
SERIAL_PROTOCOLPGM(" A");
SERIAL_PROTOCOLLN((int)bIsActive);
break;
Expand Down Expand Up @@ -7386,6 +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> | 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 @@ -7461,15 +7469,32 @@ 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'))
SERIAL_PROTOCOLLN(GCODE_LEVEL);
break;
case ClPrintChecking::_Features: // ~ .6 used by 32-bit
break;
#ifdef STEEL_SHEET_TYPES
case ClPrintChecking::_SheetType: // ~ .7
if(code_seen('P'))
{
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));
break;
#endif //STEEL_SHEET_TYPES
default:
break;
}
Expand Down
55 changes: 53 additions & 2 deletions Firmware/eeprom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

#include "eeprom.h"
#include "Marlin.h"
#ifdef STEEL_SHEET_TYPES
#include "messages.h"
#endif //STEEL_SHEET_TYPES

#include <avr/eeprom.h>
#include <stdint.h>
Expand Down Expand Up @@ -46,6 +49,12 @@ void eeprom_init()
}
check_babystep();

#ifdef STEEL_SHEET_TYPES
if (eeprom_read_byte((uint8_t*)EEPROM_CHECK_SHEET_TYPE) == EEPROM_EMPTY_VALUE) {
eeprom_default_sheet_type();
}
#endif //STEEL_SHEET_TPYES

// initialize custom mendel name in eeprom
if (eeprom_read_byte((uint8_t*)EEPROM_CUSTOM_MENDEL_NAME) == EEPROM_EMPTY_VALUE) {
//SERIAL_ECHOLN("Init Custom Mendel Name");
Expand Down Expand Up @@ -83,8 +92,8 @@ void eeprom_adjust_bed_reset() {
//! | 3 | Textur2 |
//! | 4 | Satin |
//! | 5 | NylonPA |
//! | 6 | Custom1 |
//! | 7 | Custom2 |
//! | 6 | PolyPro |
//! | 7 | Custom |
//!
//! @param[in] index
//! @param[out] sheetName
Expand All @@ -94,25 +103,53 @@ void eeprom_default_sheet_name(uint8_t index, SheetName &sheetName)

if (index < 2)
{
#ifdef STEEL_SHEET_TYPES
strcpy_P(sheetName.c, MSG_SHEET_TYPE_SMOOTH);
#else
strcpy_P(sheetName.c, PSTR("Smooth"));
#endif //STEEL_SHEET_TYPES
}
else if (index < 4)
{
#ifdef STEEL_SHEET_TYPES
strcpy_P(sheetName.c, MSG_SHEET_TYPE_TEXTURED);
#else
strcpy_P(sheetName.c, PSTR("Textur"));
#endif //STEEL_SHEET_TYPES
}
else if (index < 5)
{
#ifdef STEEL_SHEET_TYPES
strcpy_P(sheetName.c, MSG_SHEET_TYPE_SATIN);
#else
strcpy_P(sheetName.c, PSTR("Satin "));
#endif //STEEL_SHEET_TYPES
}
else if (index < 6)
{
#ifdef STEEL_SHEET_TYPES
strcpy_P(sheetName.c, MSG_SHEET_TYPE_NYLON_PA);
#else
strcpy_P(sheetName.c, PSTR("NylonPA"));
#endif //STEEL_SHEET_TYPES
}
#ifdef STEEL_SHEET_TYPES
else if (index < 7)
{
strcpy_P(sheetName.c, MSG_SHEET_TYPE_PP);
}
else
{
strcpy_P(sheetName.c, MSG_SHEET_TYPE_CUSTOM);
}
if (index <4)
#else
else
{
strcpy_P(sheetName.c, PSTR("Custom"));
}
if (index <4 || index >5)
#endif //STEEL_SHEET_TYPES
{
sheetName.c[6] = '0' + ((index % 2)+1);
sheetName.c[7] = '\0';
Expand All @@ -137,6 +174,20 @@ int8_t eeprom_next_initialized_sheet(int8_t sheet)
return -1;
}

#ifdef STEEL_SHEET_TYPES
void eeprom_default_sheet_type()
{
eeprom_update_byte_notify(&EEPROM_Sheets_base->s[0].type, 1); //Smooth
eeprom_update_byte_notify(&EEPROM_Sheets_base->s[1].type, 1); //Smooth
eeprom_update_byte_notify(&EEPROM_Sheets_base->s[2].type, 2); //Textur
eeprom_update_byte_notify(&EEPROM_Sheets_base->s[3].type, 2); //Textur
eeprom_update_byte_notify(&EEPROM_Sheets_base->s[4].type, 4); //Satin
eeprom_update_byte_notify(&EEPROM_Sheets_base->s[5].type, 8); //NylonPA
eeprom_update_byte_notify(&EEPROM_Sheets_base->s[6].type, 16); //PolyPro
eeprom_update_byte_notify((uint8_t*)EEPROM_CHECK_SHEET_TYPE,1);
}
#endif //STEEL_SHEET_TYPES

#ifdef DEBUG_EEPROM_CHANGES
static void eeprom_byte_notify(uint8_t *dst, uint8_t previous_value, uint8_t value, bool write) {
printf_P(PSTR("EEPROMChng b %s %u %d -> %d\n"), write ? "write":"", dst , previous_value, value);
Expand Down
Loading
Loading