Update printer's type (MMU/non-MMU) at runtime
+ reformat utils.cpp
This commit is contained in:
parent
5082da78d2
commit
f04d83fc4c
|
|
@ -1621,7 +1621,6 @@ void setup()
|
||||||
#endif //UVLO_SUPPORT
|
#endif //UVLO_SUPPORT
|
||||||
|
|
||||||
fCheckModeInit();
|
fCheckModeInit();
|
||||||
fSetMmuMode(MMU2::mmu2.Enabled());
|
|
||||||
KEEPALIVE_STATE(NOT_BUSY);
|
KEEPALIVE_STATE(NOT_BUSY);
|
||||||
#ifdef WATCHDOG
|
#ifdef WATCHDOG
|
||||||
wdt_enable(WDTO_4S);
|
wdt_enable(WDTO_4S);
|
||||||
|
|
@ -8140,6 +8139,8 @@ Sigma_Exit:
|
||||||
{
|
{
|
||||||
uint16_t nPrinterModel;
|
uint16_t nPrinterModel;
|
||||||
nPrinterModel=(uint16_t)code_value_long();
|
nPrinterModel=(uint16_t)code_value_long();
|
||||||
|
// based on current state of MMU (active/stopped/connecting) perform a runtime update of the printer type
|
||||||
|
fSetMmuMode(MMU2::mmu2.Enabled());
|
||||||
printer_model_check(nPrinterModel);
|
printer_model_check(nPrinterModel);
|
||||||
}
|
}
|
||||||
else if(code_seen('Q'))
|
else if(code_seen('Q'))
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,6 @@ void update_current_firmware_version_to_eeprom()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-//
|
|
||||||
#define MSG_PRINT_CHECKING_FAILED_TIMEOUT 30
|
#define MSG_PRINT_CHECKING_FAILED_TIMEOUT 30
|
||||||
|
|
||||||
ClNozzleDiameter oNozzleDiameter=ClNozzleDiameter::_Diameter_400;
|
ClNozzleDiameter oNozzleDiameter=ClNozzleDiameter::_Diameter_400;
|
||||||
|
|
@ -236,49 +235,41 @@ ClCheckModel oCheckModel=ClCheckModel::_None;
|
||||||
ClCheckVersion oCheckVersion=ClCheckVersion::_None;
|
ClCheckVersion oCheckVersion=ClCheckVersion::_None;
|
||||||
ClCheckGcode oCheckGcode=ClCheckGcode::_None;
|
ClCheckGcode oCheckGcode=ClCheckGcode::_None;
|
||||||
|
|
||||||
void fCheckModeInit()
|
void fCheckModeInit() {
|
||||||
{
|
|
||||||
oCheckMode = (ClCheckMode)eeprom_read_byte((uint8_t *)EEPROM_CHECK_MODE);
|
oCheckMode = (ClCheckMode)eeprom_read_byte((uint8_t *)EEPROM_CHECK_MODE);
|
||||||
if(oCheckMode==ClCheckMode::_Undef)
|
if (oCheckMode == ClCheckMode::_Undef) {
|
||||||
{
|
|
||||||
oCheckMode = ClCheckMode::_Warn;
|
oCheckMode = ClCheckMode::_Warn;
|
||||||
eeprom_update_byte((uint8_t *)EEPROM_CHECK_MODE, (uint8_t)oCheckMode);
|
eeprom_update_byte((uint8_t *)EEPROM_CHECK_MODE, (uint8_t)oCheckMode);
|
||||||
}
|
}
|
||||||
if(farm_mode)
|
if (farm_mode) {
|
||||||
{
|
|
||||||
oCheckMode = ClCheckMode::_Strict;
|
oCheckMode = ClCheckMode::_Strict;
|
||||||
if (eeprom_read_word((uint16_t *)EEPROM_NOZZLE_DIAMETER_uM) == EEPROM_EMPTY_VALUE16)
|
if (eeprom_read_word((uint16_t *)EEPROM_NOZZLE_DIAMETER_uM) == EEPROM_EMPTY_VALUE16)
|
||||||
eeprom_update_word((uint16_t *)EEPROM_NOZZLE_DIAMETER_uM, EEPROM_NOZZLE_DIAMETER_uM_DEFAULT);
|
eeprom_update_word((uint16_t *)EEPROM_NOZZLE_DIAMETER_uM, EEPROM_NOZZLE_DIAMETER_uM_DEFAULT);
|
||||||
}
|
}
|
||||||
oNozzleDiameter = (ClNozzleDiameter)eeprom_read_byte((uint8_t *)EEPROM_NOZZLE_DIAMETER);
|
oNozzleDiameter = (ClNozzleDiameter)eeprom_read_byte((uint8_t *)EEPROM_NOZZLE_DIAMETER);
|
||||||
if((oNozzleDiameter==ClNozzleDiameter::_Diameter_Undef)&& !farm_mode)
|
if ((oNozzleDiameter == ClNozzleDiameter::_Diameter_Undef) && !farm_mode) {
|
||||||
{
|
|
||||||
oNozzleDiameter = ClNozzleDiameter::_Diameter_400;
|
oNozzleDiameter = ClNozzleDiameter::_Diameter_400;
|
||||||
eeprom_update_byte((uint8_t *)EEPROM_NOZZLE_DIAMETER, (uint8_t)oNozzleDiameter);
|
eeprom_update_byte((uint8_t *)EEPROM_NOZZLE_DIAMETER, (uint8_t)oNozzleDiameter);
|
||||||
eeprom_update_word((uint16_t *)EEPROM_NOZZLE_DIAMETER_uM, EEPROM_NOZZLE_DIAMETER_uM_DEFAULT);
|
eeprom_update_word((uint16_t *)EEPROM_NOZZLE_DIAMETER_uM, EEPROM_NOZZLE_DIAMETER_uM_DEFAULT);
|
||||||
}
|
}
|
||||||
oCheckModel = (ClCheckModel)eeprom_read_byte((uint8_t *)EEPROM_CHECK_MODEL);
|
oCheckModel = (ClCheckModel)eeprom_read_byte((uint8_t *)EEPROM_CHECK_MODEL);
|
||||||
if(oCheckModel==ClCheckModel::_Undef)
|
if (oCheckModel == ClCheckModel::_Undef) {
|
||||||
{
|
|
||||||
oCheckModel = ClCheckModel::_Warn;
|
oCheckModel = ClCheckModel::_Warn;
|
||||||
eeprom_update_byte((uint8_t *)EEPROM_CHECK_MODEL, (uint8_t)oCheckModel);
|
eeprom_update_byte((uint8_t *)EEPROM_CHECK_MODEL, (uint8_t)oCheckModel);
|
||||||
}
|
}
|
||||||
oCheckVersion = (ClCheckVersion)eeprom_read_byte((uint8_t *)EEPROM_CHECK_VERSION);
|
oCheckVersion = (ClCheckVersion)eeprom_read_byte((uint8_t *)EEPROM_CHECK_VERSION);
|
||||||
if(oCheckVersion==ClCheckVersion::_Undef)
|
if (oCheckVersion == ClCheckVersion::_Undef) {
|
||||||
{
|
|
||||||
oCheckVersion = ClCheckVersion::_Warn;
|
oCheckVersion = ClCheckVersion::_Warn;
|
||||||
eeprom_update_byte((uint8_t *)EEPROM_CHECK_VERSION, (uint8_t)oCheckVersion);
|
eeprom_update_byte((uint8_t *)EEPROM_CHECK_VERSION, (uint8_t)oCheckVersion);
|
||||||
}
|
}
|
||||||
oCheckGcode = (ClCheckGcode)eeprom_read_byte((uint8_t *)EEPROM_CHECK_GCODE);
|
oCheckGcode = (ClCheckGcode)eeprom_read_byte((uint8_t *)EEPROM_CHECK_GCODE);
|
||||||
if(oCheckGcode==ClCheckGcode::_Undef)
|
if (oCheckGcode == ClCheckGcode::_Undef) {
|
||||||
{
|
|
||||||
oCheckGcode = ClCheckGcode::_Warn;
|
oCheckGcode = ClCheckGcode::_Warn;
|
||||||
eeprom_update_byte((uint8_t *)EEPROM_CHECK_GCODE, (uint8_t)oCheckGcode);
|
eeprom_update_byte((uint8_t *)EEPROM_CHECK_GCODE, (uint8_t)oCheckGcode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void nozzle_diameter_check(uint16_t nDiameter)
|
void nozzle_diameter_check(uint16_t nDiameter) {
|
||||||
{
|
|
||||||
uint16_t nDiameter_um;
|
uint16_t nDiameter_um;
|
||||||
|
|
||||||
if (oCheckMode == ClCheckMode::_None)
|
if (oCheckMode == ClCheckMode::_None)
|
||||||
|
|
@ -292,8 +283,7 @@ if(nDiameter==nDiameter_um)
|
||||||
// SERIAL_ECHOLN((float)(nDiameter_um/1000.0));
|
// SERIAL_ECHOLN((float)(nDiameter_um/1000.0));
|
||||||
// SERIAL_ECHOPGM("expected: ");
|
// SERIAL_ECHOPGM("expected: ");
|
||||||
// SERIAL_ECHOLN((float)(nDiameter/1000.0));
|
// SERIAL_ECHOLN((float)(nDiameter/1000.0));
|
||||||
switch(oCheckMode)
|
switch (oCheckMode) {
|
||||||
{
|
|
||||||
case ClCheckMode::_Warn:
|
case ClCheckMode::_Warn:
|
||||||
// lcd_show_fullscreen_message_and_wait_P(_i("Printer nozzle diameter differs from the G-code. Continue?"));
|
// lcd_show_fullscreen_message_and_wait_P(_i("Printer nozzle diameter differs from the G-code. Continue?"));
|
||||||
lcd_display_message_fullscreen_P(_i("Printer nozzle diameter differs from the G-code. Continue?")); ////MSG_NOZZLE_DIFFERS_CONTINUE c=20 r=5
|
lcd_display_message_fullscreen_P(_i("Printer nozzle diameter differs from the G-code. Continue?")); ////MSG_NOZZLE_DIFFERS_CONTINUE c=20 r=5
|
||||||
|
|
@ -302,22 +292,21 @@ lcd_wait_for_click_delay(MSG_PRINT_CHECKING_FAILED_TIMEOUT);
|
||||||
lcd_update_enable(true); // display / status-line recovery
|
lcd_update_enable(true); // display / status-line recovery
|
||||||
break;
|
break;
|
||||||
case ClCheckMode::_Strict:
|
case ClCheckMode::_Strict:
|
||||||
lcd_show_fullscreen_message_and_wait_P(_i("Printer nozzle diameter differs from the G-code. Please check the value in settings. Print cancelled."));////MSG_NOZZLE_DIFFERS_CANCELLED c=20 r=9
|
lcd_show_fullscreen_message_and_wait_P(_i(
|
||||||
|
"Printer nozzle diameter differs from the G-code. Please check the value in settings. Print cancelled.")); ////MSG_NOZZLE_DIFFERS_CANCELLED c=20 r=9
|
||||||
lcd_print_stop();
|
lcd_print_stop();
|
||||||
break;
|
break;
|
||||||
case ClCheckMode::_None:
|
case ClCheckMode::_None:
|
||||||
case ClCheckMode::_Undef:
|
case ClCheckMode::_Undef:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(!farm_mode)
|
if (!farm_mode) {
|
||||||
{
|
|
||||||
bSettings = false; // flag ('fake parameter') for 'lcd_hw_setup_menu()' function
|
bSettings = false; // flag ('fake parameter') for 'lcd_hw_setup_menu()' function
|
||||||
menu_submenu(lcd_hw_setup_menu);
|
menu_submenu(lcd_hw_setup_menu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void printer_model_check(uint16_t nPrinterModel)
|
void printer_model_check(uint16_t nPrinterModel) {
|
||||||
{
|
|
||||||
if (oCheckModel == ClCheckModel::_None)
|
if (oCheckModel == ClCheckModel::_None)
|
||||||
return;
|
return;
|
||||||
if (nPrinterModel == nPrinterType)
|
if (nPrinterModel == nPrinterType)
|
||||||
|
|
@ -328,8 +317,7 @@ if(nPrinterModel==nPrinterType)
|
||||||
// SERIAL_ECHOLN(nPrinterType);
|
// SERIAL_ECHOLN(nPrinterType);
|
||||||
// SERIAL_ECHOPGM("expected: ");
|
// SERIAL_ECHOPGM("expected: ");
|
||||||
// SERIAL_ECHOLN(nPrinterModel);
|
// SERIAL_ECHOLN(nPrinterModel);
|
||||||
switch(oCheckModel)
|
switch (oCheckModel) {
|
||||||
{
|
|
||||||
case ClCheckModel::_Warn:
|
case ClCheckModel::_Warn:
|
||||||
// lcd_show_fullscreen_message_and_wait_P(_i("Printer model differs from the G-code. Continue?"));
|
// lcd_show_fullscreen_message_and_wait_P(_i("Printer model differs from the G-code. Continue?"));
|
||||||
lcd_display_message_fullscreen_P(_T(MSG_GCODE_DIFF_PRINTER_CONTINUE));
|
lcd_display_message_fullscreen_P(_T(MSG_GCODE_DIFF_PRINTER_CONTINUE));
|
||||||
|
|
@ -347,8 +335,7 @@ lcd_update_enable(true); // display / status-line recovery
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t mCompareValue(uint16_t nX,uint16_t nY)
|
uint8_t mCompareValue(uint16_t nX, uint16_t nY) {
|
||||||
{
|
|
||||||
if (nX > nY)
|
if (nX > nY)
|
||||||
return ((uint8_t)ClCompareValue::_Greater);
|
return ((uint8_t)ClCompareValue::_Greater);
|
||||||
if (nX < nY)
|
if (nX < nY)
|
||||||
|
|
@ -356,8 +343,7 @@ if(nX<nY)
|
||||||
return ((uint8_t)ClCompareValue::_Equal);
|
return ((uint8_t)ClCompareValue::_Equal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fw_version_check(const char *pVersion)
|
void fw_version_check(const char *pVersion) {
|
||||||
{
|
|
||||||
uint16_t aVersion[4];
|
uint16_t aVersion[4];
|
||||||
uint8_t nCompareValueResult;
|
uint8_t nCompareValueResult;
|
||||||
|
|
||||||
|
|
@ -378,8 +364,7 @@ if((nCompareValueResult<COMPARE_VALUE_EQUAL)&&oCheckVersion==ClCheckVersion::_Wa
|
||||||
// SERIAL_ECHOLN(FW_VERSION);
|
// SERIAL_ECHOLN(FW_VERSION);
|
||||||
// SERIAL_ECHOPGM("expected: ");
|
// SERIAL_ECHOPGM("expected: ");
|
||||||
// SERIAL_ECHOLN(pVersion);
|
// SERIAL_ECHOLN(pVersion);
|
||||||
switch(oCheckVersion)
|
switch (oCheckVersion) {
|
||||||
{
|
|
||||||
case ClCheckVersion::_Warn:
|
case ClCheckVersion::_Warn:
|
||||||
// lcd_show_fullscreen_message_and_wait_P(_i("Printer FW version differs from the G-code. Continue?"));
|
// lcd_show_fullscreen_message_and_wait_P(_i("Printer FW version differs from the G-code. Continue?"));
|
||||||
lcd_display_message_fullscreen_P(_i("G-code sliced for a newer firmware. Continue?")); ////MSG_GCODE_NEWER_FIRMWARE_CONTINUE c=20 r=5
|
lcd_display_message_fullscreen_P(_i("G-code sliced for a newer firmware. Continue?")); ////MSG_GCODE_NEWER_FIRMWARE_CONTINUE c=20 r=5
|
||||||
|
|
@ -388,7 +373,8 @@ lcd_wait_for_click_delay(MSG_PRINT_CHECKING_FAILED_TIMEOUT);
|
||||||
lcd_update_enable(true); // display / status-line recovery
|
lcd_update_enable(true); // display / status-line recovery
|
||||||
break;
|
break;
|
||||||
case ClCheckVersion::_Strict:
|
case ClCheckVersion::_Strict:
|
||||||
lcd_show_fullscreen_message_and_wait_P(_i("G-code sliced for a newer firmware. Please update the firmware. Print cancelled."));////MSG_GCODE_NEWER_FIRMWARE_CANCELLED c=20 r=8
|
lcd_show_fullscreen_message_and_wait_P(
|
||||||
|
_i("G-code sliced for a newer firmware. Please update the firmware. Print cancelled.")); ////MSG_GCODE_NEWER_FIRMWARE_CANCELLED c=20 r=8
|
||||||
lcd_print_stop();
|
lcd_print_stop();
|
||||||
break;
|
break;
|
||||||
case ClCheckVersion::_None:
|
case ClCheckVersion::_None:
|
||||||
|
|
@ -397,8 +383,7 @@ lcd_update_enable(true); // display / status-line recovery
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gcode_level_check(uint16_t nGcodeLevel)
|
void gcode_level_check(uint16_t nGcodeLevel) {
|
||||||
{
|
|
||||||
if (oCheckGcode == ClCheckGcode::_None)
|
if (oCheckGcode == ClCheckGcode::_None)
|
||||||
return;
|
return;
|
||||||
if (nGcodeLevel == (uint16_t)GCODE_LEVEL)
|
if (nGcodeLevel == (uint16_t)GCODE_LEVEL)
|
||||||
|
|
@ -411,8 +396,7 @@ if((nGcodeLevel<(uint16_t)GCODE_LEVEL)&&(oCheckGcode==ClCheckGcode::_Warn))
|
||||||
// SERIAL_ECHOLN(GCODE_LEVEL);
|
// SERIAL_ECHOLN(GCODE_LEVEL);
|
||||||
// SERIAL_ECHOPGM("expected: ");
|
// SERIAL_ECHOPGM("expected: ");
|
||||||
// SERIAL_ECHOLN(nGcodeLevel);
|
// SERIAL_ECHOLN(nGcodeLevel);
|
||||||
switch(oCheckGcode)
|
switch (oCheckGcode) {
|
||||||
{
|
|
||||||
case ClCheckGcode::_Warn:
|
case ClCheckGcode::_Warn:
|
||||||
// lcd_show_fullscreen_message_and_wait_P(_i("Printer G-code level differs from the G-code. Continue?"));
|
// lcd_show_fullscreen_message_and_wait_P(_i("Printer G-code level differs from the G-code. Continue?"));
|
||||||
lcd_display_message_fullscreen_P(_i("G-code sliced for a different level. Continue?")); ////MSG_GCODE_DIFF_CONTINUE c=20 r=4
|
lcd_display_message_fullscreen_P(_i("G-code sliced for a different level. Continue?")); ////MSG_GCODE_DIFF_CONTINUE c=20 r=4
|
||||||
|
|
@ -421,7 +405,8 @@ lcd_wait_for_click_delay(MSG_PRINT_CHECKING_FAILED_TIMEOUT);
|
||||||
lcd_update_enable(true); // display / status-line recovery
|
lcd_update_enable(true); // display / status-line recovery
|
||||||
break;
|
break;
|
||||||
case ClCheckGcode::_Strict:
|
case ClCheckGcode::_Strict:
|
||||||
lcd_show_fullscreen_message_and_wait_P(_i("G-code sliced for a different level. Please re-slice the model again. Print cancelled."));////MSG_GCODE_DIFF_CANCELLED c=20 r=7
|
lcd_show_fullscreen_message_and_wait_P(
|
||||||
|
_i("G-code sliced for a different level. Please re-slice the model again. Print cancelled.")); ////MSG_GCODE_DIFF_CANCELLED c=20 r=7
|
||||||
lcd_print_stop();
|
lcd_print_stop();
|
||||||
break;
|
break;
|
||||||
case ClCheckGcode::_None:
|
case ClCheckGcode::_None:
|
||||||
|
|
@ -435,8 +420,7 @@ lcd_update_enable(true); // display / status-line recovery
|
||||||
#define GCODE_DELIMITER '"'
|
#define GCODE_DELIMITER '"'
|
||||||
#define ELLIPSIS "..."
|
#define ELLIPSIS "..."
|
||||||
|
|
||||||
char* code_string(const char* pStr,size_t* nLength)
|
char *code_string(char *pStr, size_t *nLength) {
|
||||||
{
|
|
||||||
char* pStrBegin;
|
char* pStrBegin;
|
||||||
char* pStrEnd;
|
char* pStrEnd;
|
||||||
|
|
||||||
|
|
@ -448,11 +432,11 @@ pStrEnd=strchr(pStrBegin,GCODE_DELIMITER);
|
||||||
if(!pStrEnd)
|
if(!pStrEnd)
|
||||||
return(NULL);
|
return(NULL);
|
||||||
*nLength=pStrEnd-pStrBegin;
|
*nLength=pStrEnd-pStrBegin;
|
||||||
|
pStrBegin[*nLength] = '\0';
|
||||||
return pStrBegin;
|
return pStrBegin;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printer_smodel_check(const char* pStrPos)
|
void printer_smodel_check(char *pStrPos) {
|
||||||
{
|
|
||||||
char* pResult;
|
char* pResult;
|
||||||
size_t nLength,nPrinterNameLength;
|
size_t nLength,nPrinterNameLength;
|
||||||
|
|
||||||
|
|
@ -483,20 +467,16 @@ lcd_update_enable(true); // display / status-line recovery
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void fSetMmuMode(bool bMMu)
|
void fSetMmuMode(bool bMMu) {
|
||||||
{
|
if (bMMu) {
|
||||||
if(bMMu)
|
|
||||||
{
|
|
||||||
nPrinterType = pgm_read_word(&_nPrinterMmuType);
|
nPrinterType = pgm_read_word(&_nPrinterMmuType);
|
||||||
sPrinterName = _sPrinterMmuName;
|
sPrinterName = _sPrinterMmuName;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
nPrinterType = pgm_read_word(&_nPrinterType);
|
nPrinterType = pgm_read_word(&_nPrinterType);
|
||||||
sPrinterName = _sPrinterName;
|
sPrinterName = _sPrinterName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ip4_to_str(char* dest, uint8_t* IP)
|
void ip4_to_str(char* dest, uint8_t* IP)
|
||||||
{
|
{
|
||||||
sprintf_P(dest, PSTR("%u.%u.%u.%u"), IP[0], IP[1], IP[2], IP[3]);
|
sprintf_P(dest, PSTR("%u.%u.%u.%u"), IP[0], IP[1], IP[2], IP[3]);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue