Skip to content

Commit

Permalink
Merge pull request #1 from makerbase-mks/master
Browse files Browse the repository at this point in the history
Add a preheating function to repair the error returned by the bltouch…
  • Loading branch information
solawc authored Aug 5, 2021
2 parents 2878ab7 + 6a16c99 commit 0e896c8
Show file tree
Hide file tree
Showing 16 changed files with 149 additions and 49 deletions.
Binary file modified Firmware/Robin_nano_v3.bin
Binary file not shown.
14 changes: 7 additions & 7 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
*
* :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000]
*/
#define BAUDRATE 250000
#define BAUDRATE 115200

// Enable the Bluetooth serial interface on AT90USB devices
//#define BLUETOOTH
Expand Down Expand Up @@ -627,7 +627,7 @@
* Note: For Bowden Extruders make this large enough to allow load/unload.
*/
#define PREVENT_LENGTHY_EXTRUDE
#define EXTRUDE_MAXLENGTH 200
#define EXTRUDE_MAXLENGTH 1000

//===========================================================================
//======================== Thermal Runaway Protection =======================
Expand Down Expand Up @@ -712,7 +712,7 @@
// Mechanical endstop with COM to ground and NC to Signal uses "false" here (most common setup).
#define X_MIN_ENDSTOP_INVERTING true // Set to true to invert the logic of the endstop.
#define Y_MIN_ENDSTOP_INVERTING true // Set to true to invert the logic of the endstop.
#define Z_MIN_ENDSTOP_INVERTING true // Set to true to invert the logic of the endstop.
#define Z_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
#define X_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
#define Y_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
#define Z_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
Expand Down Expand Up @@ -899,7 +899,7 @@
* The probe replaces the Z-MIN endstop and is used for Z homing.
* (Automatically enables USE_PROBE_FOR_Z_HOMING.)
*/
//#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN

// Force the use of the probe for Z-axis homing
//#define USE_PROBE_FOR_Z_HOMING
Expand Down Expand Up @@ -956,7 +956,7 @@
/**
* The BLTouch probe uses a Hall effect sensor and emulates a servo.
*/
//#define BLTOUCH
// #define BLTOUCH

/**
* Touch-MI Probe by hotends.fr
Expand Down Expand Up @@ -1578,7 +1578,7 @@
// - Move the Z probe (or nozzle) to a defined XY point before Z Homing.
// - Prevent Z homing when the Z probe is outside bed area.
//
//#define Z_SAFE_HOMING
// #define Z_SAFE_HOMING

#if ENABLED(Z_SAFE_HOMING)
#define Z_SAFE_HOMING_X_POINT X_CENTER // X point for Z homing
Expand Down Expand Up @@ -1719,7 +1719,7 @@
* P1 Raise the nozzle always to Z-park height.
* P2 Raise the nozzle by Z-park amount, limited to Z_MAX_POS.
*/
//#define NOZZLE_PARK_FEATURE
#define NOZZLE_PARK_FEATURE

#if ENABLED(NOZZLE_PARK_FEATURE)
// Specify a park position as { X, Y, Z_raise }
Expand Down
4 changes: 2 additions & 2 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@
* Tested with this bootloader:
* https://github.com/FleetProbe/MicroBridge-Arduino-ATMega2560
*/
//#define SD_FIRMWARE_UPDATE
// #define SD_FIRMWARE_UPDATE
#if ENABLED(SD_FIRMWARE_UPDATE)
#define SD_FIRMWARE_UPDATE_EEPROM_ADDR 0x1FF
#define SD_FIRMWARE_UPDATE_ACTIVE_VALUE 0xF0
Expand Down Expand Up @@ -2312,7 +2312,7 @@
* Requires NOZZLE_PARK_FEATURE.
* This feature is required for the default FILAMENT_RUNOUT_SCRIPT.
*/
//#define ADVANCED_PAUSE_FEATURE
// #define ADVANCED_PAUSE_FEATURE
#if ENABLED(ADVANCED_PAUSE_FEATURE)
#define PAUSE_PARK_RETRACT_FEEDRATE 60 // (mm/s) Initial retract feedrate.
#define PAUSE_PARK_RETRACT_LENGTH 2 // (mm) Initial retract.
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
#if EITHER(MIN_SOFTWARE_ENDSTOPS, MAX_SOFTWARE_ENDSTOPS)
#define HAS_SOFTWARE_ENDSTOPS 1
#endif
#if ANY(EXTENSIBLE_UI, IS_NEWPANEL, EMERGENCY_PARSER, HAS_ADC_BUTTONS, DWIN_CREALITY_LCD)
#if ANY(EXTENSIBLE_UI, IS_NEWPANEL, EMERGENCY_PARSER, HAS_ADC_BUTTONS, DWIN_CREALITY_LCD, MKS_TS35_V2_0) // fix-wang
#define HAS_RESUME_CONTINUE 1
#endif

Expand Down
6 changes: 4 additions & 2 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_bltouch_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
lv_clear_bltouch_settings();
if (last_disp_state == DIALOG_UI) lv_draw_ready_print();
else lv_draw_return_ui();
queue.enqueue_now_P(PSTR("G28 X Y"));
// queue.enqueue_now_P(PSTR("G28 X Y")); // fix-wang
queue.inject_P(PSTR("G28 X Y"));
break;
}
}
Expand Down Expand Up @@ -214,7 +215,8 @@ void bltouch_do_init(bool resetZoffset) {
{
sprintf_P(str_1, PSTR("G28\nG1 Z10 F2400\nG1 X%d Y%d\nG0 Z0.3"), X_MAX_POS / 2, Y_MAX_POS / 2);
}
queue.enqueue_now_P(PSTR(str_1));
queue.enqueue_now_P(PSTR(str_1)); // fix-wang
// queue.inject_P(PSTR(str_1));
}

void lv_clear_bltouch_settings() {
Expand Down
13 changes: 7 additions & 6 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,9 @@ static void btn_ok_event_cb(lv_obj_t *btn, lv_event_t event) {
#if ENABLED(ADVANCED_PAUSE_FEATURE)
else if (DIALOG_IS(PAUSE_MESSAGE_WAITING, PAUSE_MESSAGE_INSERT, PAUSE_MESSAGE_HEAT))
wait_for_user = false;
else if (DIALOG_IS(PAUSE_MESSAGE_OPTION))
pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE;
else if (DIALOG_IS(PAUSE_MESSAGE_OPTION)) {
// pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; fix-wang
}
else if (DIALOG_IS(PAUSE_MESSAGE_RESUME)) {
lv_clear_cur_ui();
lv_draw_return_ui();
Expand Down Expand Up @@ -225,7 +226,7 @@ static void btn_ok_event_cb(lv_obj_t *btn, lv_event_t event) {
static void btn_cancel_event_cb(lv_obj_t *btn, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
if (DIALOG_IS(PAUSE_MESSAGE_OPTION)) {
TERN_(ADVANCED_PAUSE_FEATURE, pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT);
// 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)) {
#if HAS_HOTEND
Expand Down Expand Up @@ -265,9 +266,9 @@ void lv_draw_dialog(uint8_t type) {
lv_obj_t *labelDialog = lv_label_create(scr, "");

if (DIALOG_IS(TYPE_FINISH_PRINT, PAUSE_MESSAGE_RESUME)) {
btnOk = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_ok_event_cb);
lv_obj_t *labelOk = lv_label_create_empty(btnOk); // Add a label to the button
lv_label_set_text(labelOk, print_file_dialog_menu.confirm); // Set the labels text
btnOk = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_ok_event_cb);
lv_obj_t *labelOk = lv_label_create_empty(btnOk); // Add a label to the button
lv_label_set_text(labelOk, print_file_dialog_menu.confirm); // Set the labels text
}
else if (DIALOG_IS(PAUSE_MESSAGE_WAITING, PAUSE_MESSAGE_INSERT, PAUSE_MESSAGE_HEAT)) {
btnOk = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_ok_event_cb);
Expand Down
12 changes: 4 additions & 8 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
#else
if (queue.length <= (BUFSIZE - 3)) {
#endif
queue.enqueue_now_P(PSTR("G91"));
sprintf_P((char *)public_buf_l, PSTR("G1 E%d F%d"), uiCfg.extruStep, 60 * uiCfg.extruSpeed);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G90"));
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;
disp_extru_amount();
}
Expand All @@ -82,10 +80,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
#else
if (queue.length <= (BUFSIZE - 3)) {
#endif
queue.enqueue_now_P(PSTR("G91"));
sprintf_P((char *)public_buf_l, PSTR("G1 E%d F%d"), 0 - uiCfg.extruStep, 60 * uiCfg.extruSpeed);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G90"));
sprintf_P((char *)public_buf_l, PSTR("G91\nG1 E%d F%d\nG90"), 0 - uiCfg.extruStep, 60 * uiCfg.extruSpeed);
queue.inject(public_buf_l);
extrudeAmount -= uiCfg.extruStep;
disp_extru_amount();
}
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

void lv_draw_pause_message(const PauseMessage msg) {
switch (msg) {
case PAUSE_MESSAGE_PAUSING: lv_clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_PAUSING); break;
// case PAUSE_MESSAGE_PAUSING: lv_clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_PAUSING); break; fix-wang
case PAUSE_MESSAGE_CHANGING: lv_clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_CHANGING); break;
case PAUSE_MESSAGE_UNLOAD: lv_clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_UNLOAD); break;
case PAUSE_MESSAGE_WAITING: lv_clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_WAITING); break;
Expand All @@ -41,7 +41,7 @@ void lv_draw_pause_message(const PauseMessage msg) {
case PAUSE_MESSAGE_RESUME: lv_clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_RESUME); break;
case PAUSE_MESSAGE_HEAT: lv_clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_HEAT); break;
case PAUSE_MESSAGE_HEATING: lv_clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_HEATING); break;
case PAUSE_MESSAGE_OPTION: pause_menu_response = PAUSE_RESPONSE_WAIT_FOR;
// case PAUSE_MESSAGE_OPTION: pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; fix-wang
lv_clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_OPTION); break;
case PAUSE_MESSAGE_STATUS:
default: break;
Expand Down
40 changes: 39 additions & 1 deletion Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,23 @@ static lv_obj_t *buttonType, *buttonStep;
static lv_obj_t *labelType;
static lv_obj_t *labelStep;
static lv_obj_t *tempText1;
static lv_obj_t *btn_pla;
static lv_obj_t *btn_abs;
static lv_obj_t *label_abs;
static lv_obj_t *label_pla;

static lv_style_t btn_style_pre;
static lv_style_t btn_style_rel;

enum {
ID_P_ADD = 1,
ID_P_DEC,
ID_P_TYPE,
ID_P_STEP,
ID_P_OFF,
ID_P_RETURN
ID_P_RETURN,
ID_P_ABS,
ID_P_PLA,
};

static void event_handler(lv_obj_t *obj, lv_event_t event) {
Expand Down Expand Up @@ -130,10 +139,14 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
else
uiCfg.curTempType = 0;
}
lv_obj_del(btn_pla);
lv_obj_del(btn_abs);
}
else if (uiCfg.curTempType == 1) {
uiCfg.curSprayerChoose = 0;
uiCfg.curTempType = 0;
disp_ext_heart();
lv_refr_now(lv_refr_get_disp_refreshing());
}
disp_temp_type();
break;
Expand Down Expand Up @@ -165,6 +178,12 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
lv_clear_cur_ui();
lv_draw_return_ui();
break;
case ID_P_ABS:
thermalManager.setTargetHotend(PREHEAT_2_TEMP_HOTEND, 0);
break;
case ID_P_PLA:
thermalManager.setTargetHotend(PREHEAT_1_TEMP_HOTEND, 0);
break;
}
}

Expand All @@ -187,6 +206,10 @@ void lv_draw_preHeat(void) {
lv_big_button_create(scr, "F:/bmp_speed0.bin", preheat_menu.off, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_OFF);
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_RETURN);

if(uiCfg.curTempType == 0) {
disp_ext_heart();
}

// Create labels on the image buttons
labelType = lv_label_create_empty(buttonType);
labelStep = lv_label_create_empty(buttonStep);
Expand All @@ -205,8 +228,23 @@ void lv_draw_preHeat(void) {
disp_desire_temp();
}

void disp_ext_heart() {

btn_abs = lv_btn_create(scr, 160, 40, 80, 40, event_handler, ID_P_ABS);
btn_pla = lv_btn_create(scr, 260, 40, 80, 40, event_handler, ID_P_PLA);

lv_btn_set_style(btn_abs, LV_BTN_STYLE_PR, &btn_style_pre);
lv_btn_set_style(btn_abs, LV_BTN_STYLE_REL, &btn_style_rel);
lv_btn_set_style(btn_pla, LV_BTN_STYLE_PR, &btn_style_pre);
lv_btn_set_style(btn_pla, LV_BTN_STYLE_REL, &btn_style_rel);

label_abs = lv_label_create(btn_abs, PREHEAT_2_LABEL);
label_pla = lv_label_create(btn_pla, PREHEAT_1_LABEL);
}

void disp_temp_type() {
if (uiCfg.curTempType == 0) {

#if DISABLED(SINGLENOZZLE)
if (uiCfg.curSprayerChoose == 1) {
lv_imgbtn_set_src_both(buttonType, "F:/bmp_extru2.bin");
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extern void lv_clear_preHeat();
extern void disp_temp_type();
extern void disp_step_heat();
extern void disp_desire_temp();
extern void disp_ext_heart();

#ifdef __cplusplus
} /* C-declarations for C++ */
Expand Down
62 changes: 59 additions & 3 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "../../../../inc/MarlinConfig.h"

static lv_obj_t *scr;
extern lv_group_t* g;
extern lv_group_t* g;

static lv_obj_t *buttonPageUp, *buttonPageDown, *buttonBack,
*buttonGcode[FILE_BTN_CNT], *labelPageUp[FILE_BTN_CNT], *buttonText[FILE_BTN_CNT];
Expand All @@ -53,6 +53,51 @@ extern uint8_t public_buf[513];
extern char public_buf_m[100];

uint8_t sel_id = 0;
uint16_t lv_longFilename[FILENAME_LENGTH * MAX_VFAT_ENTRIES + 1]; // fix wang
/*
Unicode | UTF-8
Hexadecimal | Binary
--------------------------+---------------------------------------------
0000 0000-0000 007F | 0xxxxxxx
0000 0080-0000 07FF | 110xxxxx 10xxxxxx
0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
*/
void unicode_2_utf8(char *des, uint16_t *source, uint8_t Len) {
uint8_t FileName_UTF8[30];
ZERO(FileName_UTF8);
LOOP_L_N(i, Len) {
if(0 <= source[i] && source[i] <= 0x7F) {
// 0xxxxxxx
*des = (source[i] & 0x7F);
des++;
}
else if(0X80 <= source[i] && source[i] <= 0x7FF) {
// 110xxxxx 10xxxxxx
*(des+1) = (source[i] & 0x3F) | 0x80;
*des = ((source[i] >> 6) & 0x1F) | 0xC0;
des += 2;
}
else if(0X800 <= source[i] && source[i] <= 0xFFFF) {
// 1110xxxx 10xxxxxx 10xxxxxx
*(des+2) = (source[i] & 0x3F) | 0x80;
*(des+1) = ((source[i] >> 6) & 0x3F) | 0x80;
*des = ((source[i] >> 12) & 0x0F) | 0xE0;
des += 3;
}
else if(0X10000 <= source[i] && source[i] <= 0x10FFFF) {
// 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
*(des+3) = (source[i] & 0x3F) | 0x80;
*(des+2) = ((source[i] >> 6) & 0x3F) | 0x80;
*(des+1) = ((source[i] >> 12) & 0x3F) | 0x80;
*des = ((source[i] >> 18) & 0x07) | 0xF0;
des += 4;
}
else {
break; //Out of range
}
}
}

#if ENABLED(SDSUPPORT)

Expand All @@ -72,14 +117,24 @@ uint8_t sel_id = 0;
const uint16_t fileCnt = card.get_num_Files();

for (uint16_t i = 0; i < fileCnt; i++) {

if (list_file.Sd_file_cnt == list_file.Sd_file_offset) {
card.getfilename_sorted(SD_ORDER(i, fileCnt));

list_file.IsFolder[valid_name_cnt] = card.flag.filenameIsDir;
strcpy(list_file.file_name[valid_name_cnt], list_file.curDirPath);
strcat_P(list_file.file_name[valid_name_cnt], PSTR("/"));
strcat(list_file.file_name[valid_name_cnt], card.filename);
strcpy(list_file.long_name[valid_name_cnt], card.longest_filename());
// strcpy(list_file.long_name[valid_name_cnt], card.longest_filename());
ZERO(list_file.long_name[valid_name_cnt]);
if (lv_longFilename[0] == 0)
strncpy(list_file.long_name[valid_name_cnt], card.filename, strlen(card.filename));
else {
//chinese is 3 byte, ascii is 1 byte
//max chinese: (sizeof(list_file.long_name[valid_name_cnt]) - strlen(".gcode") - 1) / 3 = (53 - 6 - 1) / 3 = 15
//max ascii: (sizeof(list_file.long_name[valid_name_cnt]) - strlen(".gcode") - 1) = 53 -6 - 1 = 46
unicode_2_utf8(list_file.long_name[valid_name_cnt], lv_longFilename, FILENAME_LENGTH * MAX_VFAT_ENTRIES);
list_file.long_name[valid_name_cnt][SHORT_NAME_LEN * 4] = '\0';
}

valid_name_cnt++;
if (valid_name_cnt == 1)
Expand Down Expand Up @@ -130,6 +185,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
#if ENABLED(SDSUPPORT)
file_count = search_file();
#endif

if (file_count != 0) {
dir_offset[curDirLever].curPage--;
lv_clear_print_file();
Expand Down
3 changes: 2 additions & 1 deletion Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ extern DIR_OFFSET dir_offset[10];
typedef struct {
char file_name[FILE_NUM][(SHORT_NAME_LEN + 1) * MAX_DIR_LEVEL + 1];
char curDirPath[(SHORT_NAME_LEN + 1) * MAX_DIR_LEVEL + 1];
char long_name[FILE_NUM][SHORT_NAME_LEN * 2 + 1];
// char long_name[FILE_NUM][SHORT_NAME_LEN * 2 + 1];
char long_name[FILE_NUM][SHORT_NAME_LEN * 4 + 1];
bool IsFolder[FILE_NUM];
char Sd_file_cnt;
char sd_file_index;
Expand Down
Loading

0 comments on commit 0e896c8

Please sign in to comment.