MKS H43 fixup (#21267)

Co-authored-by: makerbase <4164049@qq.com>
Co-authored-by: MKS-Sean <56996910+MKS-Sean@users.noreply.github.com>
Co-authored-by: Scott Lahteine <github@thinkyhead.com>
This commit is contained in:
Sola 2021-03-06 23:04:05 +08:00 committed by Scott Lahteine
parent 05a124930e
commit 5b586ea4d8
17 changed files with 139 additions and 122 deletions

View File

@ -610,6 +610,14 @@ void GCodeQueue::get_available_commands() {
TERN_(SDSUPPORT, get_sdcard_commands());
}
/**
* Run the entire queue in-place. Blocks SD completion/abort until complete.
*/
void GCodeQueue::exhaust() {
while (ring_buffer.occupied()) advance();
planner.synchronize();
}
/**
* Get the next command in the queue, optionally log it to SD, then dispatch it
*/

View File

@ -93,7 +93,9 @@ public:
inline bool full(uint8_t cmdCount=1) const { return length > (BUFSIZE - cmdCount); }
inline bool empty() const { return length == 0; }
inline bool occupied() const { return length != 0; }
inline bool empty() const { return !occupied(); }
inline CommandLine& peek_next_command() { return commands[index_r]; }
@ -162,6 +164,11 @@ public:
*/
static void advance();
/**
* Run the entire queue in-place
*/
static void exhaust();
/**
* Add to the circular command queue the next command from:
* - The command-injection queue (injected_commands_P)

View File

@ -395,20 +395,23 @@ void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *va
default: return;
#if HOTENDS >= 1
case VP_T_E0_Set:
NOMORE(newvalue, HEATER_0_MAXTEMP);
thermalManager.setTargetHotend(newvalue, 0);
acceptedvalue = thermalManager.temp_hotend[0].target;
acceptedvalue = thermalManager.degTargetHotend(0);
break;
#endif
#if HOTENDS >= 2
case VP_T_E1_Set:
NOMORE(newvalue, HEATER_1_MAXTEMP);
thermalManager.setTargetHotend(newvalue, 1);
acceptedvalue = thermalManager.temp_hotend[1].target;
acceptedvalue = thermalManager.degTargetHotend(1);
break;
#endif
#if HAS_HEATED_BED
case VP_T_Bed_Set:
NOMORE(newvalue, BED_MAXTEMP);
thermalManager.setTargetBed(newvalue);
acceptedvalue = thermalManager.temp_bed.target;
acceptedvalue = thermalManager.degTargetBed();
break;
#endif
}

View File

@ -75,7 +75,7 @@ uint16_t z_park_pos = 10;
xyz_pos_t position_before_pause;
void MKS_pause_print_move() {
planner.synchronize();
queue.exhaust();
position_before_pause = current_position;
do_blocking_move_to(X_MIN_POS + x_park_pos, Y_MIN_POS + y_park_pos, current_position.z + z_park_pos);
}

View File

@ -23,10 +23,10 @@
#include "../DGUSDisplayDef.h"
//#define USE_MKS_GREEN_UI
#define USE_MKS_GREEN_UI
//#define DGUS_MKS_RUNOUT_SENSOR
#define LOGO_TIME_DELAY TERN(USE_MKS_GREEN_UI, 5000, 1500)
#define LOGO_TIME_DELAY TERN(USE_MKS_GREEN_UI, 8000, 1500)
#if ENABLED(DGUS_MKS_RUNOUT_SENSOR)
#define MT_DET_1_PIN 1
@ -178,7 +178,7 @@ enum DGUSLCD_Screens : uint8_t {
MKSLCD_SCREEN_PRINT_CONFIG = 72,
MKSLCD_SCREEN_LEVEL_DATA = 106,
MKSLCD_PrintPause_SET = 107,
//MKSLCD_FILAMENT_DATA = 50,
MKSLCD_FILAMENT_DATA = 50,
MKSLCD_ABOUT = 83,
MKSLCD_PID = 108,
MKSLCD_PAUSE_SETTING_MOVE = 98,

View File

@ -39,6 +39,7 @@
#include "../../../../../gcode/gcode.h"
#include "../../../../../pins/pins.h"
#include "../../../../../libs/nozzle.h"
#if ENABLED(HAS_STEALTHCHOP)
#include "../../../../../module/stepper/trinamic.h"
#include "../../../../../module/stepper/indirection.h"
@ -60,7 +61,6 @@ uint8_t DGUSLanguageSwitch = 0; // Switch language for MKS DGUS
uint32_t swap32(const uint32_t value) { return (value & 0x000000FFU) << 24U | (value & 0x0000FF00U) << 8U | (value & 0x00FF0000U) >> 8U | (value & 0xFF000000U) >> 24U; }
#if 0
void DGUSScreenHandler::sendinfoscreen_ch_mks(const uint16_t* line1, const uint16_t* line2, const uint16_t* line3, const uint16_t* line4) {
dgusdisplay.WriteVariable(VP_MSGSTR1, line1, 32, true);
dgusdisplay.WriteVariable(VP_MSGSTR2, line2, 32, true);
@ -264,7 +264,7 @@ void DGUSScreenHandler::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) {
void DGUSScreenHandler::SDPrintingFinished() {
if (DGUSAutoTurnOff) {
while (!queue.ring_buffer.empty()) queue.advance();
queue.exhaust();
gcode.process_subcommands_now_P(PSTR("M81"));
}
GotoScreen(MKSLCD_SCREEN_PrintDone);
@ -465,7 +465,6 @@ void DGUSScreenHandler::Level_Ctrl_MKS(DGUS_VP_Variable &var, void *val_ptr) {
cs = getCurrentScreen();
if (cs != MKSLCD_AUTO_LEVEL) GotoScreen(MKSLCD_AUTO_LEVEL);
#else
GotoScreen(MKSLCD_SCREEN_LEVEL);
@ -499,14 +498,15 @@ void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) {
char cmd_buf[30];
float offset = mesh_adj_distance;
int16_t integer, Deci, Deci2;
// float f3 = current_position.z;
// float f4 = current_position.z;
if (!queue.ring_buffer.empty()) return;
switch (mesh_value) {
case 0:
offset = mesh_adj_distance;
integer = offset; // get int
Deci = (offset * 100);
Deci = Deci % 100;
Deci = (offset * 10);
Deci = Deci % 10;
Deci2 = offset * 100;
Deci2 = Deci2 % 10;
soft_endstop._enabled = false;
@ -520,8 +520,8 @@ void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) {
case 1:
offset = mesh_adj_distance;
integer = offset; // get int
Deci = (offset * 100);
Deci = Deci % 100;
Deci = (offset * 10);
Deci = Deci % 10;
Deci2 = offset * 100;
Deci2 = Deci2 % 10;
soft_endstop._enabled = false;
@ -589,8 +589,8 @@ void DGUSScreenHandler::LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t lcd_value = swap16(*(uint16_t *)val_ptr);
if(lcd_value > 100) lcd_value = 100;
else if(lcd_value < 10) lcd_value = 10;
if (lcd_value > 100) lcd_value = 100;
else if (lcd_value < 10) lcd_value = 10;
lcd_default_light = lcd_value;
@ -794,7 +794,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
DEBUG_ECHOLNPAIR("QUEUE LEN:", queue.length);
if (!print_job_timer.isPaused() && queue.ring_buffer.full(1))
if (!print_job_timer.isPaused() && !queue.ring_buffer.empty())
return;
char axiscode;
@ -1249,8 +1249,8 @@ void DGUSScreenHandler::MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) {
switch (val_t) {
case 0:
#if HOTENDS >= 1
if (thermalManager.temp_hotend[0].celsius < thermalManager.extrude_min_temp) {
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
if (thermalManager.degHotend(0) < thermalManager.extrude_min_temp) {
if (thermalManager.degTargetHotend(0) < thermalManager.extrude_min_temp)
thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 0);
sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true);
SetupConfirmAction(nullptr);
@ -1268,8 +1268,8 @@ void DGUSScreenHandler::MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) {
case 1:
#if HOTENDS >= 2
if (thermalManager.temp_hotend[1].celsius < thermalManager.extrude_min_temp) {
if (thermalManager.temp_hotend[1].target < thermalManager.extrude_min_temp)
if (thermalManager.degHotend(1) < thermalManager.extrude_min_temp) {
if (thermalManager.degTargetHotend(1) < thermalManager.extrude_min_temp)
thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 1);
sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true);
SetupConfirmAction(nullptr);
@ -1284,8 +1284,8 @@ void DGUSScreenHandler::MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) {
}
#endif
#if ENABLED(SINGLENOZZLE)
if (thermalManager.temp_hotend[0].celsius < thermalManager.extrude_min_temp) {
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
if (thermalManager.degHotend(0) < thermalManager.extrude_min_temp) {
if (thermalManager.degTargetHotend(0) < thermalManager.extrude_min_temp)
thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 0);
sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true);
SetupConfirmAction(nullptr);
@ -1313,8 +1313,8 @@ void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr)
switch (val_t) {
case 0:
#if HOTENDS >= 1
if (thermalManager.temp_hotend[0].celsius < thermalManager.extrude_min_temp) {
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
if (thermalManager.degHotend(0) < thermalManager.extrude_min_temp) {
if (thermalManager.degTargetHotend(0) < thermalManager.extrude_min_temp)
thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 0);
sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true);
SetupConfirmAction(nullptr);
@ -1331,8 +1331,8 @@ void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr)
break;
case 1:
#if HOTENDS >= 2
if (thermalManager.temp_hotend[1].celsius < thermalManager.extrude_min_temp) {
if (thermalManager.temp_hotend[1].target < thermalManager.extrude_min_temp)
if (thermalManager.degHotend(1) < thermalManager.extrude_min_temp) {
if (thermalManager.degTargetHotend(1) < thermalManager.extrude_min_temp)
thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 1);
sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true);
SetupConfirmAction(nullptr);
@ -1348,8 +1348,8 @@ void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr)
#endif
#if ENABLED(SINGLENOZZLE)
if (thermalManager.temp_hotend[0].celsius < thermalManager.extrude_min_temp) {
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
if (thermalManager.degHotend(0) < thermalManager.extrude_min_temp) {
if (thermalManager.degTargetHotend(0) < thermalManager.extrude_min_temp)
thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 0);
sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true);
SetupConfirmAction(nullptr);

View File

@ -191,7 +191,7 @@ static void btn_cancel_event_cb(lv_obj_t *btn, lv_event_t event) {
TERN_(ADVANCED_PAUSE_FEATURE, pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT);
}
else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT, TYPE_FILAMENT_UNLOAD_HEAT, TYPE_FILAMENT_HEAT_LOAD_COMPLETED, TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED)) {
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target= uiCfg.desireSprayerTempBak;
thermalManager.setTargetHotend(uiCfg.hotendTargetTempBak, uiCfg.extruderIndex);
clear_cur_ui();
draw_return_ui();
}
@ -204,7 +204,7 @@ static void btn_cancel_event_cb(lv_obj_t *btn, lv_event_t event) {
uiCfg.filament_loading_time_cnt = 0;
uiCfg.filament_unloading_time_flg = false;
uiCfg.filament_unloading_time_cnt = 0;
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = uiCfg.desireSprayerTempBak;
thermalManager.setTargetHotend(uiCfg.hotendTargetTempBak, uiCfg.extruderIndex);
clear_cur_ui();
draw_return_ui();
}
@ -479,9 +479,9 @@ void lv_draw_dialog(uint8_t type) {
void filament_sprayer_temp() {
char buf[20] = {0};
sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target);
sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex));
strcpy(public_buf_l, uiCfg.curSprayerChoose < 1 ? extrude_menu.ext1 : extrude_menu.ext2);
strcpy(public_buf_l, uiCfg.extruderIndex < 1 ? extrude_menu.ext1 : extrude_menu.ext2);
strcat_P(public_buf_l, PSTR(": "));
strcat(public_buf_l, buf);
lv_label_set_text(tempText1, public_buf_l);
@ -500,7 +500,7 @@ void filament_dialog_handle() {
planner.synchronize();
uiCfg.filament_loading_time_flg = true;
uiCfg.filament_loading_time_cnt = 0;
sprintf_P(public_buf_m, PSTR("T%d\nG91\nG1 E%d F%d\nG90"), uiCfg.curSprayerChoose, gCfgItems.filamentchange_load_length, gCfgItems.filamentchange_load_speed);
sprintf_P(public_buf_m, PSTR("T%d\nG91\nG1 E%d F%d\nG90"), uiCfg.extruderIndex, gCfgItems.filamentchange_load_length, gCfgItems.filamentchange_load_speed);
queue.inject(public_buf_m);
}
if (uiCfg.filament_heat_completed_unload) {
@ -510,13 +510,13 @@ void filament_dialog_handle() {
planner.synchronize();
uiCfg.filament_unloading_time_flg = true;
uiCfg.filament_unloading_time_cnt = 0;
sprintf_P(public_buf_m, PSTR("T%d\nG91\nG1 E-%d F%d\nG90"), uiCfg.curSprayerChoose, gCfgItems.filamentchange_unload_length, gCfgItems.filamentchange_unload_speed);
sprintf_P(public_buf_m, PSTR("T%d\nG91\nG1 E-%d F%d\nG90"), uiCfg.extruderIndex, gCfgItems.filamentchange_unload_length, gCfgItems.filamentchange_unload_speed);
queue.inject(public_buf_m);
}
if (((abs((int)((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius - gCfgItems.filament_limit_temper)) <= 1)
|| ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius > gCfgItems.filament_limit_temper))
&& (uiCfg.filament_load_heat_flg)
if ( ((abs((int)((int)thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temper)) <= 1)
|| ((int)thermalManager.degHotend(uiCfg.extruderIndex) > gCfgItems.filament_limit_temper))
&& uiCfg.filament_load_heat_flg
) {
uiCfg.filament_load_heat_flg = false;
lv_clear_dialog();
@ -529,8 +529,8 @@ void filament_dialog_handle() {
lv_clear_dialog();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_COMPLETED);
}
if (((abs((int)((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius - gCfgItems.filament_limit_temper)) <= 1)
|| ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius > gCfgItems.filament_limit_temper))
if (((abs((int)((int)thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temper)) <= 1)
|| ((int)thermalManager.degHotend(uiCfg.extruderIndex) > gCfgItems.filament_limit_temper))
&& uiCfg.filament_unload_heat_flg
) {
uiCfg.filament_unload_heat_flg = false;

View File

@ -54,7 +54,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) {
case ID_E_ADD:
if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= EXTRUDE_MINTEMP) {
if (thermalManager.degHotend(uiCfg.extruderIndex) >= EXTRUDE_MINTEMP) {
sprintf_P((char *)public_buf_l, PSTR("G91\nG1 E%d F%d\nG90"), uiCfg.extruStep, 60 * uiCfg.extruSpeed);
queue.inject(public_buf_l);
extrudeAmount += uiCfg.extruStep;
@ -62,7 +62,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
}
break;
case ID_E_DEC:
if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= EXTRUDE_MINTEMP) {
if (thermalManager.degHotend(uiCfg.extruderIndex) >= EXTRUDE_MINTEMP) {
sprintf_P((char *)public_buf_l, PSTR("G91\nG1 E%d F%d\nG90"), 0 - uiCfg.extruStep, 60 * uiCfg.extruSpeed);
queue.enqueue_one_now(public_buf_l);
extrudeAmount -= uiCfg.extruStep;
@ -71,17 +71,17 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
break;
case ID_E_TYPE:
if (ENABLED(HAS_MULTI_EXTRUDER)) {
if (uiCfg.curSprayerChoose == 0) {
uiCfg.curSprayerChoose = 1;
if (uiCfg.extruderIndex == 0) {
uiCfg.extruderIndex = 1;
queue.inject_P(PSTR("T1"));
}
else {
uiCfg.curSprayerChoose = 0;
uiCfg.extruderIndex = 0;
queue.inject_P(PSTR("T0"));
}
}
else
uiCfg.curSprayerChoose = 0;
uiCfg.extruderIndex = 0;
extrudeAmount = 0;
disp_hotend_temp();
@ -153,7 +153,7 @@ void lv_draw_extrusion() {
}
void disp_ext_type() {
if (uiCfg.curSprayerChoose == 1) {
if (uiCfg.extruderIndex == 1) {
lv_imgbtn_set_src_both(buttonType, "F:/bmp_extru2.bin");
if (gCfgItems.multiple_language) {
lv_label_set_text(labelType, extrude_menu.ext2);
@ -195,7 +195,7 @@ void disp_ext_speed() {
void disp_hotend_temp() {
char buf[20] = {0};
sprintf(buf, extrude_menu.temp_value, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target);
sprintf(buf, extrude_menu.temp_value, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex));
strcpy(public_buf_l, extrude_menu.temper_text);
strcat(public_buf_l, buf);
lv_label_set_text(tempText, public_buf_l);
@ -213,7 +213,7 @@ void disp_extru_amount() {
sprintf(buf1, extrude_menu.count_value_cm, extrudeAmount / 10);
else
sprintf(buf1, extrude_menu.count_value_m, extrudeAmount / 1000);
strcat(public_buf_l, uiCfg.curSprayerChoose < 1 ? extrude_menu.ext1 : extrude_menu.ext2);
strcat(public_buf_l, uiCfg.extruderIndex == 0 ? extrude_menu.ext1 : extrude_menu.ext2);
strcat(public_buf_l, buf1);
lv_label_set_text(ExtruText, public_buf_l);

View File

@ -50,25 +50,25 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
switch (obj->mks_obj_id) {
case ID_FILAMNT_IN:
uiCfg.filament_load_heat_flg = true;
if ((abs(thermalManager.temp_hotend[uiCfg.curSprayerChoose].target - thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius) <= 1)
|| (gCfgItems.filament_limit_temper <= thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius)) {
if ((abs(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex)) <= 1)
|| (gCfgItems.filament_limit_temper <= thermalManager.degHotend(uiCfg.extruderIndex))) {
lv_clear_filament_change();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED);
}
else {
lv_clear_filament_change();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_HEAT);
if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].target < gCfgItems.filament_limit_temper) {
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = gCfgItems.filament_limit_temper;
thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
if (thermalManager.degTargetHotend(uiCfg.extruderIndex) < gCfgItems.filament_limit_temper) {
thermalManager.setTargetHotend(gCfgItems.filament_limit_temper, uiCfg.extruderIndex);
thermalManager.start_watching_hotend(uiCfg.extruderIndex);
}
}
break;
case ID_FILAMNT_OUT:
uiCfg.filament_unload_heat_flg = true;
if ((thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > 0)
&& ((abs((int)((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target - thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius)) <= 1)
|| ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= gCfgItems.filament_limit_temper))
if (thermalManager.degTargetHotend(uiCfg.extruderIndex)
&& ((abs((int)((int)thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex))) <= 1)
|| ((int)thermalManager.degHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temper))
) {
lv_clear_filament_change();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED);
@ -76,28 +76,28 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
else {
lv_clear_filament_change();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_HEAT);
if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].target < gCfgItems.filament_limit_temper) {
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = gCfgItems.filament_limit_temper;
thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
if (thermalManager.degTargetHotend(uiCfg.extruderIndex) < gCfgItems.filament_limit_temper) {
thermalManager.setTargetHotend(gCfgItems.filament_limit_temper, uiCfg.extruderIndex);
thermalManager.start_watching_hotend(uiCfg.extruderIndex);
}
filament_sprayer_temp();
}
break;
case ID_FILAMNT_TYPE:
#if HAS_MULTI_EXTRUDER
uiCfg.curSprayerChoose = !uiCfg.curSprayerChoose;
uiCfg.extruderIndex = !uiCfg.extruderIndex;
#endif
disp_filament_type();
break;
case ID_FILAMNT_RETURN:
#if HAS_MULTI_EXTRUDER
if (uiCfg.print_state != IDLE && uiCfg.print_state != REPRINTED)
gcode.process_subcommands_now_P(uiCfg.curSprayerChoose_bak == 1 ? PSTR("T1") : PSTR("T0"));
gcode.process_subcommands_now_P(uiCfg.extruderIndexBak == 1 ? PSTR("T1") : PSTR("T0"));
#endif
feedrate_mm_s = (float)uiCfg.moveSpeed_bak;
if (uiCfg.print_state == PAUSED)
planner.set_e_position_mm((destination.e = current_position.e = uiCfg.current_e_position_bak));
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = uiCfg.desireSprayerTempBak;
thermalManager.setTargetHotend(uiCfg.hotendTargetTempBak, uiCfg.extruderIndex);
clear_cur_ui();
draw_return_ui();
@ -132,7 +132,7 @@ void lv_draw_filament_change() {
}
void disp_filament_type() {
if (uiCfg.curSprayerChoose == 1) {
if (uiCfg.extruderIndex == 1) {
lv_imgbtn_set_src_both(buttonType, "F:/bmp_extru2.bin");
if (gCfgItems.multiple_language) {
lv_label_set_text(labelType, preheat_menu.ext2);
@ -153,8 +153,8 @@ void disp_filament_temp() {
public_buf_l[0] = '\0';
strcat(public_buf_l, uiCfg.curSprayerChoose < 1 ? preheat_menu.ext1 : preheat_menu.ext2);
sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target);
strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2);
sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex));
strcat_P(public_buf_l, PSTR(": "));
strcat(public_buf_l, buf);

View File

@ -66,7 +66,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
break;
case ID_O_FILAMENT:
#if HAS_MULTI_EXTRUDER
uiCfg.curSprayerChoose_bak = active_extruder;
uiCfg.extruderIndexBak = active_extruder;
#endif
if (uiCfg.print_state == WORKING) {
#if ENABLED(SDSUPPORT)
@ -76,7 +76,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
#endif
}
uiCfg.moveSpeed_bak = (uint16_t)feedrate_mm_s;
uiCfg.desireSprayerTempBak = thermalManager.temp_hotend[active_extruder].target;
uiCfg.hotendTargetTempBak = thermalManager.degTargetHotend(active_extruder);
lv_clear_operation();
lv_draw_filament_change();
break;

View File

@ -48,47 +48,46 @@ enum {
static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) {
case ID_P_ADD:
case ID_P_ADD: {
if (uiCfg.curTempType == 0) {
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target += uiCfg.stepHeat;
if (uiCfg.curSprayerChoose == 0) {
if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > (HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1))) {
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1);
}
}
int16_t max_target;
thermalManager.temp_hotend[uiCfg.extruderIndex].target += uiCfg.stepHeat;
if (uiCfg.extruderIndex == 0)
max_target = HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1);
#if HAS_MULTI_HOTEND
else if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > (HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1))) {
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1);
}
else
max_target = HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1);
#endif
thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
if (thermalManager.degTargetHotend(uiCfg.extruderIndex) > max_target)
thermalManager.setTargetHotend(max_target, uiCfg.extruderIndex);
thermalManager.start_watching_hotend(uiCfg.extruderIndex);
}
#if HAS_HEATED_BED
else {
constexpr int16_t max_target = BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1);
thermalManager.temp_bed.target += uiCfg.stepHeat;
if ((int)thermalManager.temp_bed.target > BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1)) {
thermalManager.temp_bed.target = (float)BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1);
}
if (thermalManager.degTargetBed() > max_target)
thermalManager.setTargetBed(max_target);
thermalManager.start_watching_bed();
}
#endif
disp_desire_temp();
break;
} break;
case ID_P_DEC:
if (uiCfg.curTempType == 0) {
if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > uiCfg.stepHeat)
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target -= uiCfg.stepHeat;
if ((int)thermalManager.degTargetHotend(uiCfg.extruderIndex) > uiCfg.stepHeat)
thermalManager.temp_hotend[uiCfg.extruderIndex].target -= uiCfg.stepHeat;
else
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = 0;
thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
thermalManager.setTargetHotend(0, uiCfg.extruderIndex);
thermalManager.start_watching_hotend(uiCfg.extruderIndex);
}
#if HAS_HEATED_BED
else {
if ((int)thermalManager.temp_bed.target > uiCfg.stepHeat)
thermalManager.temp_bed.target -= uiCfg.stepHeat;
else
thermalManager.temp_bed.target = 0;
thermalManager.setTargetBed(0);
thermalManager.start_watching_bed();
}
@ -98,20 +97,20 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
case ID_P_TYPE:
if (uiCfg.curTempType == 0) {
if (ENABLED(HAS_MULTI_EXTRUDER)) {
if (uiCfg.curSprayerChoose == 0) {
uiCfg.curSprayerChoose = 1;
if (uiCfg.extruderIndex == 0) {
uiCfg.extruderIndex = 1;
}
else if (uiCfg.curSprayerChoose == 1) {
else if (uiCfg.extruderIndex == 1) {
if (TEMP_SENSOR_BED != 0) {
uiCfg.curTempType = 1;
}
else {
uiCfg.curTempType = 0;
uiCfg.curSprayerChoose = 0;
uiCfg.extruderIndex = 0;
}
}
}
else if (uiCfg.curSprayerChoose == 0) {
else if (uiCfg.extruderIndex == 0) {
if (TEMP_SENSOR_BED != 0)
uiCfg.curTempType = 1;
else
@ -119,7 +118,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
}
}
else if (uiCfg.curTempType == 1) {
uiCfg.curSprayerChoose = 0;
uiCfg.extruderIndex = 0;
uiCfg.curTempType = 0;
}
disp_temp_type();
@ -135,8 +134,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
break;
case ID_P_OFF:
if (uiCfg.curTempType == 0) {
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = 0;
thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
thermalManager.setTargetHotend(0, uiCfg.extruderIndex);
thermalManager.start_watching_hotend(uiCfg.extruderIndex);
}
#if HAS_HEATED_BED
else {
@ -186,7 +185,7 @@ void lv_draw_preHeat() {
void disp_temp_type() {
if (uiCfg.curTempType == 0) {
if (uiCfg.curSprayerChoose == 1) {
if (uiCfg.extruderIndex == 1) {
lv_imgbtn_set_src_both(buttonType, "F:/bmp_extru2.bin");
if (gCfgItems.multiple_language) {
lv_label_set_text(labelType, preheat_menu.ext2);
@ -217,13 +216,13 @@ void disp_desire_temp() {
public_buf_l[0] = '\0';
if (uiCfg.curTempType == 0) {
strcat(public_buf_l, uiCfg.curSprayerChoose < 1 ? preheat_menu.ext1 : preheat_menu.ext2);
sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target);
strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2);
sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex));
}
#if HAS_HEATED_BED
else {
strcat(public_buf_l, preheat_menu.hotbed);
sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target);
sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target);
}
#endif
strcat_P(public_buf_l, PSTR(": "));

View File

@ -203,11 +203,11 @@ void lv_draw_printing() {
}
void disp_ext_temp() {
sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[0].celsius, (int)thermalManager.temp_hotend[0].target);
sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0));
lv_label_set_text(labelExt1, public_buf_l);
#if HAS_MULTI_EXTRUDER
sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[1].celsius, (int)thermalManager.temp_hotend[1].target);
sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1));
lv_label_set_text(labelExt2, public_buf_l);
#endif
}

View File

@ -98,10 +98,10 @@ void disp_det_error() {
lv_obj_t *e1, *e2, *e3, *bed;
void mks_disp_test() {
char buf[30] = {0};
sprintf_P(buf, PSTR("e1:%d"), (int)thermalManager.temp_hotend[0].celsius);
sprintf_P(buf, PSTR("e1:%d"), (int)thermalManager.degHotend(0));
lv_label_set_text(e1, buf);
#if HAS_MULTI_HOTEND
sprintf_P(buf, PSTR("e2:%d"), (int)thermalManager.temp_hotend[1].celsius);
sprintf_P(buf, PSTR("e2:%d"), (int)thermalManager.degHotend(1));
lv_label_set_text(e2, buf);
#endif
#if HAS_HEATED_BED
@ -133,12 +133,12 @@ void lv_draw_ready_print() {
#if 1
e1 = lv_label_create_empty(scr);
lv_obj_set_pos(e1, 20, 20);
sprintf_P(buf, PSTR("e1: %d"), (int)thermalManager.temp_hotend[0].celsius);
sprintf_P(buf, PSTR("e1: %d"), (int)thermalManager.degHotend(0));
lv_label_set_text(e1, buf);
#if HAS_MULTI_HOTEND
e2 = lv_label_create_empty(scr);
lv_obj_set_pos(e2, 20, 45);
sprintf_P(buf, PSTR("e1: %d"), (int)thermalManager.temp_hotend[1].celsius);
sprintf_P(buf, PSTR("e1: %d"), (int)thermalManager.degHotend(1));
lv_label_set_text(e2, buf);
#endif

View File

@ -68,7 +68,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
#endif
break;
case ID_T_FILAMENT:
uiCfg.desireSprayerTempBak = thermalManager.temp_hotend[uiCfg.curSprayerChoose].target;
uiCfg.hotendTargetTempBak = thermalManager.degTargetHotend(uiCfg.extruderIndex);
lv_draw_filament_change();
break;
case ID_T_MORE:

View File

@ -179,7 +179,7 @@ void gCfgItems_init() {
void ui_cfg_init() {
uiCfg.curTempType = 0;
uiCfg.curSprayerChoose = 0;
uiCfg.extruderIndex = 0;
uiCfg.stepHeat = 10;
uiCfg.leveling_first_time = false;
uiCfg.para_ui_page = false;

View File

@ -211,9 +211,9 @@ typedef struct {
typedef struct {
uint8_t curTempType:1,
curSprayerChoose:3,
extruderIndex:3,
stepHeat:4,
curSprayerChoose_bak:4;
extruderIndexBak:4;
bool leveling_first_time:1,
para_ui_page:1,
configWifi:1,
@ -246,7 +246,7 @@ typedef struct {
filament_loading_time_cnt,
filament_unloading_time_cnt;
float move_dist;
float desireSprayerTempBak;
float hotendTargetTempBak;
float current_x_position_bak,
current_y_position_bak,
current_z_position_bak,

View File

@ -885,9 +885,9 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
char *outBuf = (char *)tempBuf;
char str_1[16], tbuf[34];
dtostrf(thermalManager.temp_hotend[0].celsius, 1, 1, tbuf);
dtostrf(thermalManager.degHotend(0), 1, 1, tbuf);
strcat_P(tbuf, PSTR(" /"));
strcat(tbuf, dtostrf(thermalManager.temp_hotend[0].target, 1, 1, str_1));
strcat(tbuf, dtostrf(thermalManager.degTargetHotend(0), 1, 1, str_1));
const int tlen = strlen(tbuf);
@ -912,9 +912,9 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
strcat_P(outBuf, PSTR(" T1:"));
outBuf += 4;
#if HAS_MULTI_HOTEND
strcat(outBuf, dtostrf(thermalManager.temp_hotend[1].celsius, 1, 1, str_1));
strcat(outBuf, dtostrf(thermalManager.degHotend(1), 1, 1, str_1));
strcat_P(outBuf, PSTR(" /"));
strcat(outBuf, dtostrf(thermalManager.temp_hotend[1].target, 1, 1, str_1));
strcat(outBuf, dtostrf(thermalManager.degTargetHotend(1), 1, 1, str_1));
#else
strcat_P(outBuf, PSTR("0 /0"));
#endif
@ -924,15 +924,15 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
}
else {
sprintf_P((char *)tempBuf, PSTR("T:%d /%d B:%d /%d T0:%d /%d T1:%d /%d @:0 B@:0\r\n"),
(int)thermalManager.temp_hotend[0].celsius, (int)thermalManager.temp_hotend[0].target,
(int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0),
#if HAS_HEATED_BED
(int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target,
#else
0, 0,
#endif
(int)thermalManager.temp_hotend[0].celsius, (int)thermalManager.temp_hotend[0].target,
(int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0),
#if HAS_MULTI_HOTEND
(int)thermalManager.temp_hotend[1].celsius, (int)thermalManager.temp_hotend[1].target
(int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1)
#else
0, 0
#endif