Skip to content

Commit

Permalink
Do not heat the bed, on load/unload If during a paused print, the pre…
Browse files Browse the repository at this point in the history
…heat is canceled, keep the bed target temperature Display bed temperatures only if bed is also heated Remove not needed variables nTargetOld and nTargetBedOld from the mFilamentItem function. Define new Setting "HeatBedOnLoad" [Yes/No]
  • Loading branch information
Panayiotis-git committed Dec 20, 2021
1 parent 0be90dc commit a7be650
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 26 deletions.
2 changes: 2 additions & 0 deletions Firmware/eeprom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ if (eeprom_read_byte((uint8_t*)EEPROM_PINDA_TEMP_COMPENSATION) == 0xff) eeprom_u

if (eeprom_read_dword((uint32_t*)EEPROM_JOB_ID) == EEPROM_EMPTY_VALUE32)
eeprom_update_dword((uint32_t*)EEPROM_JOB_ID, 0);

if (eeprom_read_byte((uint8_t*)EEPROM_HEAT_BED_ON_LOAD_FILAMENT) == EEPROM_EMPTY_VALUE) eeprom_update_byte((uint8_t *)EEPROM_HEAT_BED_ON_LOAD_FILAMENT, 1);
}

//! @brief Get default sheet name for index
Expand Down
7 changes: 6 additions & 1 deletion Firmware/eeprom.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP
| 0x0D04 3332 | uint8_t | EEPROM_ECOOL_ENABLE | ffh 255 | ^ | Disable extruder motor scaling for non-farm print | LCD menu | D3 Ax0d04 C1
| ^ | ^ | ^ | 2ah 42 | ^ | Enable extruder motor scaling for non-farm print | ^ | D3 Ax0d04 C1
| 0x0D03 3321 | uint8_t | EEPROM_FW_CRASH_FLAG | 01h 1 | ff/00 | Last FW crash reason (dump_crash_reason) | D21/D22 | D3 Ax0d03 C1
| 0x0D02 3330 | uint8 | EEPROM_HEAT_BED_ON_LOAD_FILAMENT | ffh 255 | ffh 255 | Heat bed on load filament unknown state | LCD menu | D3 Ax0d02 C1
| ^ | ^ | ^ | 00h 0 | ^ | Do not heat bed on load filament | ^ | ^
| ^ | ^ | ^ | 01h 1 | ^ | Heat bed on load filament | ^ | ^
| Address begin | Bit/Type | Name | Valid values | Default/FactoryReset | Description | Gcode/Function| Debug code
| :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--:
Expand Down Expand Up @@ -544,8 +547,10 @@ static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_SHEETS_BASE);
#define EEPROM_ECOOL_ENABLE (EEPROM_JOB_ID-1) // uint8_t
#define EEPROM_FW_CRASH_FLAG (EEPROM_ECOOL_ENABLE-1) // uint8_t

#define EEPROM_HEAT_BED_ON_LOAD_FILAMENT (EEPROM_FW_CRASH_FLAG-1) //uint8

//This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items.
#define EEPROM_LAST_ITEM EEPROM_FW_CRASH_FLAG
#define EEPROM_LAST_ITEM EEPROM_HEAT_BED_ON_LOAD_FILAMENT
// !!!!!
// !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!!
// !!!!!
Expand Down
84 changes: 59 additions & 25 deletions Firmware/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2121,12 +2121,42 @@ bool bFilamentPreheatState;
bool bFilamentAction=false;
static bool bFilamentWaitingFlag=false;

bool shouldPreheatOnlyNozzle() {
uint8_t eeprom_setting = eeprom_read_byte((uint8_t*)EEPROM_HEAT_BED_ON_LOAD_FILAMENT);
if (eeprom_setting != 0)
return false;

switch(eFilamentAction) {
case FilamentAction::Load:
case FilamentAction::AutoLoad:
case FilamentAction::UnLoad:
case FilamentAction::MmuLoad:
case FilamentAction::MmuUnLoad:
case FilamentAction::MmuEject:
case FilamentAction::MmuCut:
return true;
default:
return false;
}
}

void lcd_print_target_temps_first_line(){
lcd_set_cursor(0, 0);
lcdui_print_temp(LCD_STR_THERMOMETER[0], (int) degHotend(0), (int) degTargetHotend(0));
lcd_set_cursor(10, 0);
int targetBedTemp = (int) degTargetBed();
if (targetBedTemp) {
lcdui_print_temp(LCD_STR_BEDTEMP[0], (int) degBed(), targetBedTemp);
} else {
lcd_space(10);
}
}

static void mFilamentPrompt()
{
uint8_t nLevel;

lcd_set_cursor(0,0);
lcdui_print_temp(LCD_STR_THERMOMETER[0],(int)degHotend(0),(int)degTargetHotend(0));
lcd_print_target_temps_first_line();
lcd_puts_at_P(0,1, _i("Press the knob")); ////MSG_PRESS_KNOB c=20
lcd_set_cursor(0,2);
switch(eFilamentAction)
Expand Down Expand Up @@ -2182,14 +2212,10 @@ if(lcd_clicked())

void mFilamentItem(uint16_t nTemp, uint16_t nTempBed)
{
static int nTargetOld;
static int nTargetBedOld;
uint8_t nLevel;

nTargetOld = target_temperature[0];
nTargetBedOld = target_temperature_bed;
setTargetHotend0((float )nTemp);
setTargetBed((float) nTempBed);
setTargetHotend0((float)nTemp);
if (!shouldPreheatOnlyNozzle()) setTargetBed((float)nTempBed);

{
const FilamentAction action = eFilamentAction;
Expand Down Expand Up @@ -2317,8 +2343,7 @@ void mFilamentItem(uint16_t nTemp, uint16_t nTempBed)
}

if (bFilamentWaitingFlag) {
lcd_set_cursor(0, 0);
lcdui_print_temp(LCD_STR_THERMOMETER[0], (int) degHotend(0), (int) degTargetHotend(0));
lcd_print_target_temps_first_line();
}

if (lcd_clicked())
Expand All @@ -2327,14 +2352,9 @@ void mFilamentItem(uint16_t nTemp, uint16_t nTempBed)
if (!bFilamentPreheatState)
{
setTargetHotend0(0.0);
setTargetBed(0.0);
if (!isPrintPaused) setTargetBed(0.0);
menu_back();
}
else
{
setTargetHotend0((float )nTargetOld);
setTargetBed((float) nTargetBedOld);
}
menu_back();
if (eFilamentAction == FilamentAction::AutoLoad) eFilamentAction = FilamentAction::None; // i.e. non-autoLoad
}
Expand Down Expand Up @@ -2438,15 +2458,16 @@ void lcd_generic_preheat_menu()
}
else
{
MENU_ITEM_SUBMENU_P(PSTR("PLA - " STRINGIFY(PLA_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PLA_PREHEAT_HPB_TEMP)),mFilamentItem_PLA);
MENU_ITEM_SUBMENU_P(PSTR("PET - " STRINGIFY(PET_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PET_PREHEAT_HPB_TEMP)),mFilamentItem_PET);
MENU_ITEM_SUBMENU_P(PSTR("ASA - " STRINGIFY(ASA_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(ASA_PREHEAT_HPB_TEMP)),mFilamentItem_ASA);
MENU_ITEM_SUBMENU_P(PSTR("PC - " STRINGIFY(PC_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PC_PREHEAT_HPB_TEMP)),mFilamentItem_PC);
MENU_ITEM_SUBMENU_P(PSTR("PVB - " STRINGIFY(PVB_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PVB_PREHEAT_HPB_TEMP)),mFilamentItem_PVB);
MENU_ITEM_SUBMENU_P(PSTR("ABS - " STRINGIFY(ABS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(ABS_PREHEAT_HPB_TEMP)),mFilamentItem_ABS);
MENU_ITEM_SUBMENU_P(PSTR("HIPS - " STRINGIFY(HIPS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(HIPS_PREHEAT_HPB_TEMP)),mFilamentItem_HIPS);
MENU_ITEM_SUBMENU_P(PSTR("PP - " STRINGIFY(PP_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PP_PREHEAT_HPB_TEMP)),mFilamentItem_PP);
MENU_ITEM_SUBMENU_P(PSTR("FLEX - " STRINGIFY(FLEX_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(FLEX_PREHEAT_HPB_TEMP)),mFilamentItem_FLEX);
bool bPreheatOnlyNozzle = shouldPreheatOnlyNozzle();
MENU_ITEM_SUBMENU_P(bPreheatOnlyNozzle ? PSTR("PLA - " STRINGIFY(PLA_PREHEAT_HOTEND_TEMP)) : PSTR("PLA - " STRINGIFY(PLA_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PLA_PREHEAT_HPB_TEMP)) , mFilamentItem_PLA);
MENU_ITEM_SUBMENU_P(bPreheatOnlyNozzle ? PSTR("PET - " STRINGIFY(PET_PREHEAT_HOTEND_TEMP)) : PSTR("PET - " STRINGIFY(PET_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PET_PREHEAT_HPB_TEMP)) , mFilamentItem_PET);
MENU_ITEM_SUBMENU_P(bPreheatOnlyNozzle ? PSTR("ASA - " STRINGIFY(ASA_PREHEAT_HOTEND_TEMP)) : PSTR("ASA - " STRINGIFY(ASA_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(ASA_PREHEAT_HPB_TEMP)) , mFilamentItem_ASA);
MENU_ITEM_SUBMENU_P(bPreheatOnlyNozzle ? PSTR("PC - " STRINGIFY(PC_PREHEAT_HOTEND_TEMP)) : PSTR("PC - " STRINGIFY(PC_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PC_PREHEAT_HPB_TEMP)) , mFilamentItem_PC);
MENU_ITEM_SUBMENU_P(bPreheatOnlyNozzle ? PSTR("PVB - " STRINGIFY(PVB_PREHEAT_HOTEND_TEMP)) : PSTR("PVB - " STRINGIFY(PVB_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PVB_PREHEAT_HPB_TEMP)) , mFilamentItem_PVB);
MENU_ITEM_SUBMENU_P(bPreheatOnlyNozzle ? PSTR("ABS - " STRINGIFY(ABS_PREHEAT_HOTEND_TEMP)) : PSTR("ABS - " STRINGIFY(ABS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(ABS_PREHEAT_HPB_TEMP)) , mFilamentItem_ABS);
MENU_ITEM_SUBMENU_P(bPreheatOnlyNozzle ? PSTR("HIPS - " STRINGIFY(HIPS_PREHEAT_HOTEND_TEMP)): PSTR("HIPS - " STRINGIFY(HIPS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(HIPS_PREHEAT_HPB_TEMP)), mFilamentItem_HIPS);
MENU_ITEM_SUBMENU_P(bPreheatOnlyNozzle ? PSTR("PP - " STRINGIFY(PP_PREHEAT_HOTEND_TEMP)) : PSTR("PP - " STRINGIFY(PP_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PP_PREHEAT_HPB_TEMP)) , mFilamentItem_PP);
MENU_ITEM_SUBMENU_P(bPreheatOnlyNozzle ? PSTR("FLEX - " STRINGIFY(FLEX_PREHEAT_HOTEND_TEMP)): PSTR("FLEX - " STRINGIFY(FLEX_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(FLEX_PREHEAT_HPB_TEMP)), mFilamentItem_FLEX);
}
if (!eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) && eFilamentAction == FilamentAction::Preheat) MENU_ITEM_FUNCTION_P(_T(MSG_COOLDOWN), lcd_cooldown);
MENU_END();
Expand Down Expand Up @@ -5727,6 +5748,9 @@ static void lcd_settings_menu()
}
#endif //LCD_BL_PIN

//! Enables/disables the bed heating while heating the nozzle for loading/unloading filament
MENU_ITEM_TOGGLE_P(_N("HeatBedOnLoad"), eeprom_read_byte((uint8_t *)EEPROM_HEAT_BED_ON_LOAD_FILAMENT) ? _T(MSG_YES) : _T(MSG_NO), lcd_heat_bed_on_load_toggle);

if (farm_mode)
{
MENU_ITEM_FUNCTION_P(PSTR("Disable farm mode"), lcd_disable_farm_mode);
Expand Down Expand Up @@ -9000,3 +9024,13 @@ void lcd_pinda_temp_compensation_toggle()
SERIAL_ECHOLN(pinda_temp_compensation);
}
#endif //PINDA_TEMP_COMP

void lcd_heat_bed_on_load_toggle()
{
uint8_t value = eeprom_read_byte((uint8_t*)EEPROM_HEAT_BED_ON_LOAD_FILAMENT);
if (value > 1)
value = 1;
else
value = !value;
eeprom_update_byte((uint8_t*)EEPROM_HEAT_BED_ON_LOAD_FILAMENT, value);
}
2 changes: 2 additions & 0 deletions Firmware/ultralcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,6 @@ extern void lcd_experimental_menu();
extern void lcd_pinda_temp_compensation_toggle();
#endif //PINDA_TEMP_COMP

extern void lcd_heat_bed_on_load_toggle();

#endif //ULTRALCD_H

0 comments on commit a7be650

Please sign in to comment.