MKS WiFi for TFT_LVGL_UI (#20191)

This commit is contained in:
MKS-Sean 2021-01-14 12:41:09 +08:00 committed by GitHub
parent a88ae2080c
commit 35c1b330ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 1854 additions and 1110 deletions

View file

@ -2395,6 +2395,10 @@
//#define TFT_COLOR_UI //#define TFT_COLOR_UI
//#define TFT_LVGL_UI //#define TFT_LVGL_UI
#if ENABLED(TFT_LVGL_UI)
//#define MKS_WIFI_MODULE // MKS WiFi module
#endif
/** /**
* TFT Rotation. Set to one of the following values: * TFT Rotation. Set to one of the following values:
* *

View file

@ -0,0 +1,205 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if BOTH(HAS_TFT_LVGL_UI, MKS_WIFI_MODULE)
#include "lv_conf.h"
#include "draw_ui.h"
#include "../../../../MarlinCore.h"
#include "../../../../module/temperature.h"
#include "QR_Encode.h"
extern lv_group_t * g;
static lv_obj_t * scr;
static lv_obj_t *button_bind_or_not = NULL, *label_bind_or_not = NULL;
static lv_obj_t *buttonReleaseBind = NULL, *label_ReleaseBind = NULL;
static lv_obj_t * text_id;
static uint8_t unbinding_flag = 0;
static uint8_t id_mark = 0;
#define ID_CLOUD_BIND_RETURN 1
#define ID_CLOUD_BIND_OR_NOT 2
#define ID_CLOUD_RELEASE_BIND 3
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_CLOUD_BIND_RETURN:
clear_cur_ui();
draw_return_ui();
break;
case ID_CLOUD_RELEASE_BIND:
if (cloud_para.state == 0x12) {
clear_cur_ui();
lv_draw_dialog(DIALOG_TYPE_UNBIND);
}
break;
}
}
void lv_draw_cloud_bind(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL;
scr = lv_screen_create(BIND_UI);
button_bind_or_not = lv_btn_create(scr, NULL);
lv_obj_set_pos(button_bind_or_not, TFT_WIDTH - 130, TFT_HEIGHT - 80 * 3);
lv_obj_set_size(button_bind_or_not, PARA_UI_VALUE_BTN_X_SIZE + 15, PARA_UI_VALUE_BTN_Y_SIZE + 15);
lv_obj_set_event_cb_mks(button_bind_or_not, event_handler, ID_CLOUD_BIND_OR_NOT, NULL, 0);
lv_btn_set_style(button_bind_or_not, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(button_bind_or_not, LV_BTN_STYLE_PR, &style_para_value);
label_bind_or_not = lv_label_create_empty(button_bind_or_not);
buttonReleaseBind = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonReleaseBind, TFT_WIDTH - 130, TFT_HEIGHT - 80 * 2);
lv_obj_set_size(buttonReleaseBind, PARA_UI_VALUE_BTN_X_SIZE + 15, PARA_UI_VALUE_BTN_Y_SIZE + 15);
lv_obj_set_event_cb_mks(buttonReleaseBind, event_handler, ID_CLOUD_RELEASE_BIND, NULL, 0);
label_ReleaseBind = lv_label_create_empty(buttonReleaseBind);
lv_label_set_text(label_ReleaseBind, cloud_menu.unbind);
lv_obj_align(label_ReleaseBind, buttonReleaseBind, LV_ALIGN_CENTER, 0, 0);
buttonBack = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonBack, TFT_WIDTH - 130, TFT_HEIGHT - 80);
lv_obj_set_size(buttonBack, PARA_UI_VALUE_BTN_X_SIZE + 15, PARA_UI_VALUE_BTN_Y_SIZE + 15);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_CLOUD_BIND_RETURN, NULL, 0);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
label_Back = lv_label_create_empty(buttonBack);
lv_label_set_text(label_Back, common_menu.text_back);
lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
#if BUTTONS_EXIST(EN1, EN2, ENC)
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonReleaseBind);
lv_group_add_obj(g, buttonBack);
}
#endif
text_id = lv_label_create_empty(scr);
lv_obj_set_pos(text_id, 50, 60 + 200 + 20);
lv_obj_set_style(text_id, &tft_style_label_rel);
lv_label_set_text(text_id, (char *)cloud_para.id);
id_mark = 0;
disp_bind_state();
}
void disp_bind_state() {
if (cloud_para.state != 0x12)
unbinding_flag = 0;
if (unbinding_flag) {
lv_label_set_text(label_bind_or_not, cloud_menu.unbinding);
lv_obj_align(label_bind_or_not, button_bind_or_not, LV_ALIGN_CENTER, 0, 0);
lv_btn_set_style(buttonReleaseBind, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonReleaseBind, LV_BTN_STYLE_PR, &style_para_value);
}
else {
if (cloud_para.state == 0x10) {
lv_label_set_text(label_bind_or_not, cloud_menu.disconnected);
lv_obj_align(label_bind_or_not, button_bind_or_not, LV_ALIGN_CENTER, 0, 0);
}
else if (cloud_para.state == 0x11) {
lv_label_set_text(label_bind_or_not, cloud_menu.unbinded);
lv_obj_align(label_bind_or_not, button_bind_or_not, LV_ALIGN_CENTER, 0, 0);
}
else if (cloud_para.state == 0x12) {
lv_label_set_text(label_bind_or_not, cloud_menu.binded);
lv_obj_align(label_bind_or_not, button_bind_or_not, LV_ALIGN_CENTER, 0, 0);
}
else {
lv_label_set_text(label_bind_or_not, cloud_menu.disable);
lv_obj_align(label_bind_or_not, button_bind_or_not, LV_ALIGN_CENTER, 0, 0);
}
}
if (cloud_para.state == 0x12 && !unbinding_flag) {
lv_btn_set_style(buttonReleaseBind, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonReleaseBind, LV_BTN_STYLE_PR, &style_para_back);
}
else {
lv_btn_set_style(buttonReleaseBind, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonReleaseBind, LV_BTN_STYLE_PR, &style_para_value);
}
}
static char last_cloud_state = 0;
void refresh_bind_ui() {
if ((last_cloud_state != cloud_para.state) || unbinding_flag) {
disp_bind_state();
last_cloud_state = cloud_para.state;
}
if (cloud_para.id[0]) {
if (!id_mark) {
display_qrcode((uint8_t *)cloud_para.id);
lv_label_set_text(text_id, (char *)cloud_para.id);
}
}
else
id_mark = 0;
}
void display_qrcode(uint8_t *qrcode_data) {
uint8_t i, j;
uint16_t x, y, p;
if (!id_mark) {
EncodeData((char *)qrcode_data);
id_mark = 1;
}
lv_fill_rect(10, QRCODE_Y, 300, QRCODE_Y + 300, LV_COLOR_WHITE);
if (m_nSymbleSize * 2 > QRCODE_WIDTH) return;
for (i = 0; i < 40; i++)
if ((m_nSymbleSize * i * 2) > QRCODE_WIDTH) break;
p = (i - 1) * 2;
x = QRCODE_X + 70;
y = QRCODE_Y + 70;
for (i = 0; i < m_nSymbleSize; i++)
for (j = 0; j < m_nSymbleSize; j++)
if (m_byModuleData[i][j] == 1)
lv_fill_rect(x + p * i, y + p * j, x + p * (i + 1) - 1, y + p * (j + 1) - 1, LV_COLOR_BACKGROUND);
}
void cloud_unbind() {
package_to_wifi(WIFI_CLOUD_UNBIND, (uint8_t *)0, 0);
unbinding_flag = 1;
}
void lv_clear_cloud_bind() {
#if BUTTONS_EXIST(EN1, EN2, ENC)
if (gCfgItems.encoder_enable)
lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

View file

@ -0,0 +1,37 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#ifdef __cplusplus
extern "C" { /* C-declarations for C++ */
#endif
extern void lv_draw_cloud_bind(void);
extern void lv_clear_cloud_bind();
extern void disp_bind_state();
extern void refresh_bind_ui();
extern void display_qrcode(uint8_t *qrcode_data);
extern void cloud_unbind();
#ifdef __cplusplus
} /* C-declarations for C++ */
#endif

View file

@ -172,6 +172,17 @@ static void btn_ok_event_cb(lv_obj_t *btn, lv_event_t event) {
clear_cur_ui(); clear_cur_ui();
draw_return_ui(); draw_return_ui();
} }
#if ENABLED(MKS_WIFI_MODULE)
else if (DIALOG_IS(TYPE_UNBIND)) {
cloud_unbind();
clear_cur_ui();
draw_return_ui();
}
#endif
else {
clear_cur_ui();
draw_return_ui();
}
} }
static void btn_cancel_event_cb(lv_obj_t *btn, lv_event_t event) { static void btn_cancel_event_cb(lv_obj_t *btn, lv_event_t event) {
@ -246,6 +257,9 @@ void lv_draw_dialog(uint8_t type) {
lv_label_set_text(labelOk, print_file_dialog_menu.confirm); lv_label_set_text(labelOk, print_file_dialog_menu.confirm);
} }
} }
else if (DIALOG_IS(TYPE_UPDATE_ESP_FIRMARE)) {
// nothing to do
}
#endif #endif
else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT, TYPE_FILAMENT_UNLOAD_HEAT)) { else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT, TYPE_FILAMENT_UNLOAD_HEAT)) {
btnCancel = lv_button_btn_create(scr, BTN_OK_X+90, BTN_OK_Y, 100, 50, btn_cancel_event_cb); btnCancel = lv_button_btn_create(scr, BTN_OK_X+90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
@ -412,6 +426,10 @@ void lv_draw_dialog(uint8_t type) {
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
} }
else if (DIALOG_IS(TYPE_UPDATE_ESP_FIRMARE)) {
lv_label_set_text(labelDialog, DIALOG_UPDATE_WIFI_FIRMWARE_EN);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
#endif // MKS_WIFI_MODULE #endif // MKS_WIFI_MODULE
else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT)) { else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT)) {
lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_heat); lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_heat);
@ -445,6 +463,12 @@ void lv_draw_dialog(uint8_t type) {
lv_label_set_text(labelDialog, filament_menu.filament_dialog_unloading); lv_label_set_text(labelDialog, filament_menu.filament_dialog_unloading);
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -70); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -70);
} }
#if ENABLED(MKS_WIFI_MODULE)
else if (DIALOG_IS(TYPE_UNBIND)) {
lv_label_set_text(labelDialog, common_menu.unbind_printer_tips);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -70);
}
#endif
#if HAS_ROTARY_ENCODER #if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) { if (gCfgItems.encoder_enable) {
if (btnOk) lv_group_add_obj(g, btnOk); if (btnOk) lv_group_add_obj(g, btnOk);

View file

@ -66,8 +66,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
queue.inject_P(PSTR("M84 X Y")); queue.inject_P(PSTR("M84 X Y"));
break; break;
case ID_H_RETURN: case ID_H_RETURN:
lv_clear_home(); clear_cur_ui();
lv_draw_tool(); draw_return_ui();
break; break;
} }
} }

View file

@ -55,13 +55,13 @@ static const lv_btnm_ctrl_t kb_ctrl_uc_map[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2}; LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2};
static const char * kb_map_spec[] = {"0", "1", "2", "3", "4" ,"5", "6", "7", "8", "9", LV_SYMBOL_BACKSPACE, "\n", static const char * kb_map_spec[] = {"0", "1", "2", "3", "4" ,"5", "6", "7", "8", "9", ".", LV_SYMBOL_BACKSPACE, "\n",
"abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n", "abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n",
"\\", "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n", "\\", "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n",
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""}; LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
static const lv_btnm_ctrl_t kb_ctrl_spec_map[] = { static const lv_btnm_ctrl_t kb_ctrl_spec_map[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2,
LV_KB_CTRL_BTN_FLAGS | 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2}; LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2};

View file

@ -0,0 +1,209 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI
#include "../../../../MarlinCore.h"
#include "draw_ready_print.h"
#include "draw_set.h"
#include "lv_conf.h"
#include "draw_ui.h"
#include "../../../../gcode/queue.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_CUSTOM_1 1
#define ID_CUSTOM_2 2
#define ID_CUSTOM_3 3
#define ID_CUSTOM_4 4
#define ID_CUSTOM_5 5
#define ID_CUSTOM_6 6
#define ID_CUSTOM_7 7
#define ID_M_RETURN 8
static void event_handler(lv_obj_t * obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) {
#if ENABLED(USER_CMD_1_ENABLE)
case ID_CUSTOM_1:
queue.inject_P(PSTR(USER_GCODE_1));
break;
#endif
#if ENABLED(USER_CMD_2_ENABLE)
case ID_CUSTOM_2:
queue.inject_P(PSTR(USER_GCODE_2));
break;
#endif
#if ENABLED(USER_CMD_3_ENABLE)
case ID_CUSTOM_3:
queue.inject_P(PSTR(USER_GCODE_3));
break;
#endif
#if ENABLED(USER_CMD_4_ENABLE)
case ID_CUSTOM_4:
queue.inject_P(PSTR(USER_GCODE_4));
break;
#endif
#if ENABLED(USER_CMD_5_ENABLE)
case ID_CUSTOM_5:
queue.inject_P(PSTR(USER_GCODE_5));
break;
#endif
#if ENABLED(USER_CMD_6_ENABLE)
case ID_CUSTOM_6:
queue.inject_P(PSTR(USER_GCODE_6));
break;
#endif
#if ENABLED(USER_CMD_7_ENABLE)
case ID_CUSTOM_7:
queue.inject_P(PSTR(USER_GCODE_7));
break;
#endif
case ID_M_RETURN:
lv_clear_more();
lv_draw_tool();
break;
}
}
void lv_draw_more(void) {
scr = lv_screen_create(MORE_UI);
const bool enc_ena = TERN0(HAS_ROTARY_ENCODER, gCfgItems.encoder_enable);
#if ENABLED(USER_CMD_1_ENABLE)
lv_obj_t *buttonCustom1 = lv_imgbtn_create(scr, "F:/bmp_custom1.bin", INTERVAL_V, titleHeight, event_handler, ID_CUSTOM_1);
if (enc_ena) lv_group_add_obj(g, buttonCustom1);
lv_obj_t *labelCustom1 = lv_label_create_empty(buttonCustom1);
#endif
#if ENABLED(USER_CMD_2_ENABLE)
lv_obj_t *buttonCustom2 = lv_imgbtn_create(scr, "F:/bmp_custom2.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_CUSTOM_2);
if (enc_ena) lv_group_add_obj(g, buttonCustom2);
lv_obj_t *labelCustom2 = lv_label_create_empty(buttonCustom2);
#endif
#if ENABLED(USER_CMD_3_ENABLE)
lv_obj_t *buttonCustom3 = lv_imgbtn_create(scr, "F:/bmp_custom3.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_CUSTOM_3);
if (enc_ena) lv_group_add_obj(g, buttonCustom3);
lv_obj_t *labelCustom3 = lv_label_create_empty(buttonCustom3);
#endif
#if ENABLED(USER_CMD_4_ENABLE)
lv_obj_t *buttonCustom4 = lv_imgbtn_create(scr, "F:/bmp_custom4.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_CUSTOM_4);
if (enc_ena) lv_group_add_obj(g, buttonCustom4);
lv_obj_t *labelCustom4 = lv_label_create_empty(buttonCustom4);
#endif
#if ENABLED(USER_CMD_5_ENABLE)
lv_obj_t *buttonCustom5 = lv_imgbtn_create(scr, "F:/bmp_custom5.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_5);
if (enc_ena) lv_group_add_obj(g, buttonCustom5);
lv_obj_t *labelCustom5 = lv_label_create_empty(buttonCustom5);
#endif
#if ENABLED(USER_CMD_6_ENABLE)
lv_obj_t *buttonCustom6 = lv_imgbtn_create(scr, "F:/bmp_custom6.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_6);
if (enc_ena) lv_group_add_obj(g, buttonCustom6);
lv_obj_t *labelCustom6 = lv_label_create_empty(buttonCustom6);
#endif
#if ENABLED(USER_CMD_7_ENABLE)
blv_obj_t *uttonCustom7 = lv_imgbtn_create(scr, "F:/bmp_custom7.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_7);
if (enc_ena) lv_group_add_obj(g, buttonCustom7);
lv_obj_t *labelCustom7 = lv_label_create_empty(buttonCustom7);
#endif
lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_RETURN);
if (enc_ena) lv_group_add_obj(g, buttonBack);
lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.multiple_language != 0) {
#if ENABLED(USER_CMD_1_ENABLE)
lv_label_set_text(labelCustom1, more_menu.custom1);
lv_obj_align(labelCustom1, buttonCustom1, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
#endif
#if ENABLED(USER_CMD_2_ENABLE)
lv_label_set_text(labelCustom2, more_menu.custom2);
lv_obj_align(labelCustom2, buttonCustom2, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
#endif
#if ENABLED(USER_CMD_3_ENABLE)
lv_label_set_text(labelCustom3, more_menu.custom3);
lv_obj_align(labelCustom3, buttonCustom3, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
#endif
#if ENABLED(USER_CMD_4_ENABLE)
lv_label_set_text(labelCustom4, more_menu.custom4);
lv_obj_align(labelCustom4, buttonCustom4, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
#endif
#if ENABLED(USER_CMD_5_ENABLE)
lv_label_set_text(labelCustom5, more_menu.custom5);
lv_obj_align(labelCustom5, buttonCustom5, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
#endif
#if ENABLED(USER_CMD_6_ENABLE)
lv_label_set_text(labelCustom6, more_menu.custom6);
lv_obj_align(labelCustom6, buttonCustom6, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
#endif
#if ENABLED(USER_CMD_7_ENABLE)
lv_label_set_text(labelCustom7, more_menu.custom7);
lv_obj_align(labelCustom7, buttonCustom7, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
#endif
lv_label_set_text(label_Back, common_menu.text_back);
lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
}
#if BUTTONS_EXIST(EN1, EN2, ENC)
if (enc_ena) {
#if ENABLED(USER_CMD_1_ENABLE)
lv_group_add_obj(g, buttonCustom1);
#endif
#if ENABLED(USER_CMD_2_ENABLE)
lv_group_add_obj(g, buttonCustom2);
#endif
#if ENABLED(USER_CMD_3_ENABLE)
lv_group_add_obj(g, buttonCustom3);
#endif
#if ENABLED(USER_CMD_4_ENABLE)
lv_group_add_obj(g, buttonCustom4);
#endif
#if ENABLED(USER_CMD_5_ENABLE)
lv_group_add_obj(g, buttonCustom5);
#endif
#if ENABLED(USER_CMD_6_ENABLE)
lv_group_add_obj(g, buttonCustom6);
#endif
#if ENABLED(USER_CMD_7_ENABLE)
lv_group_add_obj(g, buttonCustom7);
#endif
lv_group_add_obj(g, buttonBack);
}
#endif
}
void lv_clear_more() {
#if BUTTONS_EXIST(EN1, EN2, ENC)
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

View file

@ -0,0 +1,33 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#ifdef __cplusplus
extern "C" { /* C-declarations for C++ */
#endif
extern void lv_draw_more(void);
extern void lv_clear_more();
#ifdef __cplusplus
} /* C-declarations for C++ */
#endif

View file

@ -27,12 +27,18 @@
#include <lv_conf.h> #include <lv_conf.h>
#include "../../../../gcode/queue.h" #include "../../../../gcode/queue.h"
#include "../../../../module/motion.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t *g; extern lv_group_t *g;
static lv_obj_t *scr; static lv_obj_t *scr;
static lv_obj_t *labelV, *buttonV; static lv_obj_t *labelV, *buttonV, *labelP;
static lv_task_t *updatePosTask;
static char cur_label = 'Z';
static float cur_pos = 0;
void disp_cur_pos();
enum { enum {
ID_M_X_P = 1, ID_M_X_P = 1,
@ -47,67 +53,41 @@ enum {
static void event_handler(lv_obj_t *obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return; if (event != LV_EVENT_RELEASED) return;
if (queue.length <= (BUFSIZE - 3)) {
float dist = uiCfg.move_dist;
switch (obj->mks_obj_id) {
case ID_M_X_N: dist *= -1; case ID_M_X_P: cur_label = 'X'; break;
case ID_M_Y_N: dist *= -1; case ID_M_Y_P: cur_label = 'Y'; break;
case ID_M_Z_N: dist *= -1; case ID_M_Z_P: cur_label = 'Z'; break;
}
sprintf_P(public_buf_l, PSTR("G91\nG1 %c%3.1f F%d\nG90"), cur_label, dist, uiCfg.moveSpeed);
queue.inject(public_buf_l);
}
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_M_X_P:
if (queue.length <= (BUFSIZE - 3)) {
queue.enqueue_one_P(PSTR("G91"));
sprintf_P(public_buf_l, PSTR("G1 X%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_one_P(PSTR("G90"));
}
break;
case ID_M_X_N:
if (queue.length <= (BUFSIZE - 3)) {
queue.enqueue_now_P(PSTR("G91"));
sprintf_P(public_buf_l, PSTR("G1 X-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G90"));
}
break;
case ID_M_Y_P:
if (queue.length <= (BUFSIZE - 3)) {
queue.enqueue_now_P(PSTR("G91"));
sprintf_P(public_buf_l, PSTR("G1 Y%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G90"));
}
break;
case ID_M_Y_N:
if (queue.length <= (BUFSIZE - 3)) {
queue.enqueue_now_P(PSTR("G91"));
sprintf_P(public_buf_l, PSTR("G1 Y-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G90"));
}
break;
case ID_M_Z_P:
if (queue.length <= (BUFSIZE - 3)) {
queue.enqueue_now_P(PSTR("G91"));
sprintf_P(public_buf_l, PSTR("G1 Z%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G90"));
}
break;
case ID_M_Z_N:
if (queue.length <= (BUFSIZE - 3)) {
queue.enqueue_now_P(PSTR("G91"));
sprintf_P(public_buf_l, PSTR("G1 Z-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G90"));
}
break;
case ID_M_STEP: case ID_M_STEP:
if (abs(10 * (int)uiCfg.move_dist) == 100) if (abs(10 * (int)uiCfg.move_dist) == 100)
uiCfg.move_dist = 0.1; uiCfg.move_dist = 0.1;
else else
uiCfg.move_dist *= (float)10; uiCfg.move_dist *= 10.0f;
disp_move_dist(); disp_move_dist();
break; break;
case ID_M_RETURN: case ID_M_RETURN:
clear_cur_ui(); clear_cur_ui();
draw_return_ui(); draw_return_ui();
break; return;
} }
disp_cur_pos();
}
void refresh_pos(lv_task_t *) {
switch (cur_label) {
case 'X': cur_pos = current_position.x; break;
case 'Y': cur_pos = current_position.y; break;
case 'Z': cur_pos = current_position.z; break;
default: return;
}
disp_cur_pos();
} }
void lv_draw_move_motor(void) { void lv_draw_move_motor(void) {
@ -124,19 +104,28 @@ void lv_draw_move_motor(void) {
buttonV = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_M_STEP); buttonV = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_M_STEP);
labelV = lv_label_create_empty(buttonV); labelV = lv_label_create_empty(buttonV);
#if HAS_ROTARY_ENCODER #if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) { if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonV);
lv_group_add_obj(g, buttonV);
}
#endif #endif
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_M_RETURN); 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_M_RETURN);
// We need to patch the title to leave some space on the right for displaying the status
lv_obj_t * title = lv_obj_get_child_back(scr, NULL);
if (title != NULL) lv_obj_set_width(title, TFT_WIDTH - 101);
labelP = lv_label_create(scr, TFT_WIDTH - 100, TITLE_YPOS, "Z:0.0mm");
if (labelP != NULL)
updatePosTask = lv_task_create(refresh_pos, 300, LV_TASK_PRIO_LOWEST, 0);
disp_move_dist(); disp_move_dist();
disp_cur_pos();
}
void disp_cur_pos() {
sprintf_P(public_buf_l, PSTR("%c:%3.1fmm"), cur_label, cur_pos);
if (labelP) lv_label_set_text(labelP, public_buf_l);
} }
void disp_move_dist() { void disp_move_dist() {
// char buf[30] = {0};
if ((int)(10 * uiCfg.move_dist) == 1) if ((int)(10 * uiCfg.move_dist) == 1)
lv_imgbtn_set_src_both(buttonV, "F:/bmp_step_move0_1.bin"); lv_imgbtn_set_src_both(buttonV, "F:/bmp_step_move0_1.bin");
else if ((int)(10 * uiCfg.move_dist) == 10) else if ((int)(10 * uiCfg.move_dist) == 10)
@ -164,6 +153,7 @@ void lv_clear_move_motor() {
#if HAS_ROTARY_ENCODER #if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif #endif
lv_task_del(updatePosTask);
lv_obj_del(scr); lv_obj_del(scr);
} }

View file

@ -138,12 +138,10 @@ void gCfgItems_init() {
gCfgItems.levelingPos[3][1] = Y_MAX_POS - 30; gCfgItems.levelingPos[3][1] = Y_MAX_POS - 30;
gCfgItems.levelingPos[4][0] = X_BED_SIZE / 2; gCfgItems.levelingPos[4][0] = X_BED_SIZE / 2;
gCfgItems.levelingPos[4][1] = Y_BED_SIZE / 2; gCfgItems.levelingPos[4][1] = Y_BED_SIZE / 2;
gCfgItems.cloud_enable = true; gCfgItems.cloud_enable = false;
#if ENABLED(MKS_WIFI_MODULE) gCfgItems.wifi_mode_sel = STA_MODEL;
gCfgItems.wifi_mode_sel = STA_MODEL; gCfgItems.fileSysType = FILE_SYS_SD;
gCfgItems.fileSysType = FILE_SYS_SD; gCfgItems.wifi_type = ESP_WIFI;
gCfgItems.wifi_type = ESP_WIFI;
#endif
gCfgItems.filamentchange_load_length = 200; gCfgItems.filamentchange_load_length = 200;
gCfgItems.filamentchange_load_speed = 1000; gCfgItems.filamentchange_load_speed = 1000;
gCfgItems.filamentchange_unload_length = 200; gCfgItems.filamentchange_unload_length = 200;
@ -449,6 +447,7 @@ void titleText_cat(char *str, int strSize, char *addPart) {
char *getDispText(int index) { char *getDispText(int index) {
ZERO(public_buf_l);
switch (disp_state_stack._disp_state[index]) { switch (disp_state_stack._disp_state[index]) {
case PRINT_READY_UI: case PRINT_READY_UI:
@ -593,7 +592,9 @@ char *creat_title_text() {
if (strlen(public_buf_m) > MAX_TITLE_LEN) { if (strlen(public_buf_m) > MAX_TITLE_LEN) {
ZERO(public_buf_m); ZERO(public_buf_m);
tmpText = getDispText(0); tmpText = 0;
for (index = 0; index <= disp_state_stack._disp_index && (!tmpText || *tmpText == 0); index++)
tmpText = getDispText(index);
if (*tmpText != 0) { if (*tmpText != 0) {
titleText_cat(public_buf_m, sizeof(public_buf_m), tmpText); titleText_cat(public_buf_m, sizeof(public_buf_m), tmpText);
titleText_cat(public_buf_m, sizeof(public_buf_m), (char *)">...>"); titleText_cat(public_buf_m, sizeof(public_buf_m), (char *)">...>");
@ -639,253 +640,97 @@ char *creat_title_text() {
#endif #endif
} }
#if 1 void gcode_preview(char *path, int xpos_pixel, int ypos_pixel) {
#if ENABLED(SDSUPPORT)
volatile uint32_t i, j;
volatile uint16_t *p_index;
char *cur_name;
void gcode_preview(char *path, int xpos_pixel, int ypos_pixel) { cur_name = strrchr(path, '/');
#if ENABLED(SDSUPPORT) card.openFileRead(cur_name);
//uint8_t ress;
//uint32_t write;
volatile uint32_t i, j;
volatile uint16_t *p_index;
//int res;
char *cur_name;
cur_name = strrchr(path, '/');
card.openFileRead(cur_name);
if (gPicturePreviewStart <= 0) {
while (1) {
uint32_t br = card.read(public_buf, 400);
uint32_t* p1 = (uint32_t *)strstr((char *)public_buf, ";gimage:");
if (p1) {
gPicturePreviewStart += (uint32_t)p1 - (uint32_t)((uint32_t *)(&public_buf[0]));
break;
}
else {
gPicturePreviewStart += br;
}
if (br < 400) break;
}
}
card.setIndex((gPicturePreviewStart + To_pre_view) + size * row + 8);
SPI_TFT.setWindow(xpos_pixel, ypos_pixel + row, 200, 1);
j = i = 0;
if (gPicturePreviewStart <= 0) {
while (1) { while (1) {
card.read(public_buf, 400); uint32_t br = card.read(public_buf, 400);
for (i = 0; i < 400;) { uint32_t* p1 = (uint32_t *)strstr((char *)public_buf, ";gimage:");
bmp_public_buf[j] = ascii2dec_test((char*)&public_buf[i]) << 4 | ascii2dec_test((char*)&public_buf[i + 1]); if (p1) {
i += 2; gPicturePreviewStart += (uint32_t)p1 - (uint32_t)((uint32_t *)(&public_buf[0]));
j++;
}
if (j >= 400) break;
}
for (i = 0; i < 400; i += 2) {
p_index = (uint16_t *)(&bmp_public_buf[i]);
if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full;
}
SPI_TFT.tftio.WriteSequence((uint16_t*)bmp_public_buf, 200);
#if HAS_BAK_VIEW_IN_FLASH
W25QXX.init(SPI_QUARTER_SPEED);
if (row < 20) W25QXX.SPI_FLASH_SectorErase(BAK_VIEW_ADDR_TFT35 + row * 4096);
W25QXX.SPI_FLASH_BufferWrite(bmp_public_buf, BAK_VIEW_ADDR_TFT35 + row * 400, 400);
#endif
row++;
if (row >= 200) {
size = 809;
row = 0;
gcode_preview_over = false;
//flash_preview_begin = true;
card.closefile();
/*
if (gCurFileState.file_open_flag != 0xAA) {
reset_file_info();
res = f_open(file, curFileName, FA_OPEN_EXISTING | FA_READ);
if (res == FR_OK) {
f_lseek(file,PREVIEW_SIZE+To_pre_view);
gCurFileState.file_open_flag = 0xAA;
//bakup_file_path((uint8_t *)curFileName, strlen(curFileName));
srcfp = file;
mksReprint.mks_printer_state = MKS_WORKING;
once_flag = false;
}
}
*/
char *cur_name;
cur_name = strrchr(list_file.file_name[sel_id], '/');
SdFile file;
SdFile *curDir;
card.endFilePrint();
const char * const fname = card.diveToFile(true, curDir, cur_name);
if (!fname) return;
if (file.open(curDir, fname, O_READ)) {
gCfgItems.curFilesize = file.fileSize();
file.close();
update_spi_flash();
}
card.openFileRead(cur_name);
if (card.isFileOpen()) {
feedrate_percentage = 100;
//saved_feedrate_percentage = feedrate_percentage;
planner.flow_percentage[0] = 100;
planner.e_factor[0] = planner.flow_percentage[0] * 0.01;
#if HAS_MULTI_EXTRUDER
planner.flow_percentage[1] = 100;
planner.e_factor[1] = planner.flow_percentage[1] * 0.01;
#endif
card.startFileprint();
TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
once_flag = false;
}
return;
}
card.closefile();
#endif // SDSUPPORT
}
#else // if 1
void gcode_preview(char *path, int xpos_pixel, int ypos_pixel) {
#if ENABLED(SDSUPPORT)
//uint8_t ress;
//uint32_t write;
volatile uint32_t i, j;
volatile uint16_t *p_index;
//int res;
char *cur_name;
uint16_t Color;
cur_name = strrchr(path, '/');
card.openFileRead(cur_name);
card.setIndex((PREVIEW_LITTLE_PIC_SIZE + To_pre_view) + size * row + 8);
#if HAS_TFT_LVGL_UI_SPI
SPI_TFT.setWindow(xpos_pixel, ypos_pixel + row, 200, 1);
#else
LCD_setWindowArea(xpos_pixel, ypos_pixel + row, 200, 1);
LCD_WriteRAM_Prepare();
#endif
j = 0;
i = 0;
while (1) {
card.read(public_buf, 400);
for (i = 0; i < 400;) {
bmp_public_buf[j] = ascii2dec_test((char*)&public_buf[i]) << 4 | ascii2dec_test((char*)&public_buf[i + 1]);
i += 2;
j++;
}
//if (i > 800) break;
//#ifdef TFT70
// if (j > 400) {
// f_read(file, buff_pic, 1, &read);
// break;
// }
//#elif defined(TFT35)
if (j >= 400)
//f_read(file, buff_pic, 1, &read);
break; break;
//#endif }
else {
gPicturePreviewStart += br;
}
if (br < 400) break;
} }
#if HAS_TFT_LVGL_UI_SPI }
for (i = 0; i < 400;) {
p_index = (uint16_t *)(&bmp_public_buf[i]);
Color = (*p_index >> 8); card.setIndex(gPicturePreviewStart + size * row + 8);
*p_index = Color | ((*p_index & 0xFF) << 8); SPI_TFT.setWindow(xpos_pixel, ypos_pixel + row, 200, 1);
i += 2;
if (*p_index == 0x0000) *p_index = 0xC318;
}
TFT_CS_L;
TFT_DC_H;
SPI.dmaSend(bmp_public_buf, 400, true);
TFT_CS_H;
#else j = i = 0;
for (i = 0; i < 400;) {
p_index = (uint16_t *)(&bmp_public_buf[i]); while (1) {
if (*p_index == 0x0000) *p_index = 0x18C3; card.read(public_buf, 400);
LCD_IO_WriteData(*p_index); for (i = 0; i < 400;) {
i = i + 2; bmp_public_buf[j] = ascii2dec_test((char*)&public_buf[i]) << 4 | ascii2dec_test((char*)&public_buf[i + 1]);
} i += 2;
#endif j++;
}
if (j >= 400) break;
}
for (i = 0; i < 400; i += 2) {
p_index = (uint16_t *)(&bmp_public_buf[i]);
if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full;
}
SPI_TFT.tftio.WriteSequence((uint16_t*)bmp_public_buf, 200);
#if HAS_BAK_VIEW_IN_FLASH
W25QXX.init(SPI_QUARTER_SPEED); W25QXX.init(SPI_QUARTER_SPEED);
if (row < 20) if (row < 20) W25QXX.SPI_FLASH_SectorErase(BAK_VIEW_ADDR_TFT35 + row * 4096);
W25QXX.SPI_FLASH_SectorErase(BAK_VIEW_ADDR_TFT35 + row * 4096);
W25QXX.SPI_FLASH_BufferWrite(bmp_public_buf, BAK_VIEW_ADDR_TFT35 + row * 400, 400); W25QXX.SPI_FLASH_BufferWrite(bmp_public_buf, BAK_VIEW_ADDR_TFT35 + row * 400, 400);
row++; #endif
if (row >= 200) { row++;
size = 809; if (row >= 200) {
row = 0; size = 809;
row = 0;
gcode_preview_over = false; gcode_preview_over = false;
//flash_preview_begin = true;
card.closefile();
/*
if (gCurFileState.file_open_flag != 0xAA) {
reset_file_info();
res = f_open(file, curFileName, FA_OPEN_EXISTING | FA_READ);
if (res == FR_OK) {
f_lseek(file,PREVIEW_SIZE+To_pre_view);
gCurFileState.file_open_flag = 0xAA;
//bakup_file_path((uint8_t *)curFileName, strlen(curFileName));
srcfp = file;
mksReprint.mks_printer_state = MKS_WORKING;
once_flag = false;
}
}
*/
char *cur_name;
cur_name = strrchr(list_file.file_name[sel_id], '/');
SdFile file;
SdFile *curDir;
card.endFilePrint();
const char * const fname = card.diveToFile(true, curDir, cur_name);
if (!fname) return;
if (file.open(curDir, fname, O_READ)) {
gCfgItems.curFilesize = file.fileSize();
file.close();
update_spi_flash();
}
card.openFileRead(cur_name);
if (card.isFileOpen()) {
feedrate_percentage = 100;
//saved_feedrate_percentage = feedrate_percentage;
planner.flow_percentage[0] = 100;
planner.e_factor[0] = planner.flow_percentage[0] * 0.01;
#if HAS_MULTI_EXTRUDER
planner.flow_percentage[1] = 100;
planner.e_factor[1] = planner.flow_percentage[1] * 0.01;
#endif
card.startFileprint();
TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
once_flag = false;
}
return;
}
card.closefile(); card.closefile();
#endif // SDSUPPORT char *cur_name;
}
#endif // if 1 cur_name = strrchr(list_file.file_name[sel_id], '/');
void Draw_default_preview(int xpos_pixel, int ypos_pixel, uint8_t sel) { SdFile file;
SdFile *curDir;
card.endFilePrint();
const char * const fname = card.diveToFile(true, curDir, cur_name);
if (!fname) return;
if (file.open(curDir, fname, O_READ)) {
gCfgItems.curFilesize = file.fileSize();
file.close();
update_spi_flash();
}
card.openFileRead(cur_name);
if (card.isFileOpen()) {
feedrate_percentage = 100;
planner.flow_percentage[0] = 100;
planner.e_factor[0] = planner.flow_percentage[0] * 0.01;
#if HAS_MULTI_EXTRUDER
planner.flow_percentage[1] = 100;
planner.e_factor[1] = planner.flow_percentage[1] * 0.01;
#endif
card.startFileprint();
TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
once_flag = false;
}
return;
}
card.closefile();
#endif // SDSUPPORT
}
void draw_default_preview(int xpos_pixel, int ypos_pixel, uint8_t sel) {
int index; int index;
int y_off = 0; int y_off = 0;
W25QXX.init(SPI_QUARTER_SPEED); W25QXX.init(SPI_QUARTER_SPEED);
@ -914,12 +759,12 @@ char *creat_title_text() {
#if HAS_BAK_VIEW_IN_FLASH #if HAS_BAK_VIEW_IN_FLASH
if (flash_preview_begin) { if (flash_preview_begin) {
flash_preview_begin = false; flash_preview_begin = false;
Draw_default_preview(xpos_pixel, ypos_pixel, 1); draw_default_preview(xpos_pixel, ypos_pixel, 1);
} }
#endif #endif
#if HAS_GCODE_DEFAULT_VIEW_IN_FLASH #if HAS_GCODE_DEFAULT_VIEW_IN_FLASH
if (default_preview_flg) { if (default_preview_flg) {
Draw_default_preview(xpos_pixel, ypos_pixel, 0); draw_default_preview(xpos_pixel, ypos_pixel, 0);
default_preview_flg = false; default_preview_flg = false;
} }
#endif #endif
@ -1005,12 +850,11 @@ void GUI_RefreshPage() {
temps_update_flag = false; temps_update_flag = false;
} }
break; break;
case BIND_UI:
refresh_bind_ui();
break;
#endif #endif
case BIND_UI:
/*refresh_bind_ui();*/
break;
case FILAMENTCHANGE_UI: case FILAMENTCHANGE_UI:
if (temps_update_flag) { if (temps_update_flag) {
temps_update_flag = false; temps_update_flag = false;
@ -1097,8 +941,7 @@ void clear_cur_ui() {
last_disp_state = disp_state_stack._disp_state[disp_state_stack._disp_index]; last_disp_state = disp_state_stack._disp_state[disp_state_stack._disp_index];
switch (disp_state_stack._disp_state[disp_state_stack._disp_index]) { switch (disp_state_stack._disp_state[disp_state_stack._disp_index]) {
case PRINT_READY_UI: case PRINT_READY_UI: lv_clear_ready_print(); break;
lv_clear_ready_print(); break;
case PRINT_FILE_UI: lv_clear_print_file(); break; case PRINT_FILE_UI: lv_clear_print_file(); break;
case PRINTING_UI: lv_clear_printing(); break; case PRINTING_UI: lv_clear_printing(); break;
case MOVE_MOTOR_UI: lv_clear_move_motor(); break; case MOVE_MOTOR_UI: lv_clear_move_motor(); break;
@ -1119,14 +962,16 @@ void clear_cur_ui() {
#if ENABLED(MKS_WIFI_MODULE) #if ENABLED(MKS_WIFI_MODULE)
case WIFI_UI: lv_clear_wifi(); break; case WIFI_UI: lv_clear_wifi(); break;
#endif #endif
case MORE_UI: /* Clear_more(); */ break; case MORE_UI: lv_clear_more(); break;
case FILETRANSFER_UI: break; case FILETRANSFER_UI: break;
case DIALOG_UI: lv_clear_dialog(); break; case DIALOG_UI: lv_clear_dialog(); break;
case FILETRANSFERSTATE_UI: break; case FILETRANSFERSTATE_UI: break;
case PRINT_MORE_UI: break; case PRINT_MORE_UI: break;
case FILAMENTCHANGE_UI: lv_clear_filament_change(); break; case FILAMENTCHANGE_UI: lv_clear_filament_change(); break;
case LEVELING_UI: lv_clear_manualLevel(); break; case LEVELING_UI: lv_clear_manualLevel(); break;
case BIND_UI: /* Clear_Bind(); */ break; #if ENABLED(MKS_WIFI_MODULE)
case BIND_UI: lv_clear_cloud_bind(); break;
#endif
#if HAS_BED_PROBE #if HAS_BED_PROBE
case NOZZLE_PROBE_OFFSET_UI: lv_clear_auto_level_offset_settings(); break; case NOZZLE_PROBE_OFFSET_UI: lv_clear_auto_level_offset_settings(); break;
#endif #endif
@ -1224,11 +1069,13 @@ void draw_return_ui() {
#if ENABLED(MKS_WIFI_MODULE) #if ENABLED(MKS_WIFI_MODULE)
case WIFI_UI: lv_draw_wifi(); break; case WIFI_UI: lv_draw_wifi(); break;
#endif #endif
case PRINT_MORE_UI: /* draw_printmore(); */ break;
case MORE_UI: break; case MORE_UI: break;
case PRINT_MORE_UI: lv_draw_more(); break;
case FILAMENTCHANGE_UI: lv_draw_filament_change(); break; case FILAMENTCHANGE_UI: lv_draw_filament_change(); break;
case LEVELING_UI: lv_draw_manualLevel(); break; case LEVELING_UI: lv_draw_manualLevel(); break;
case BIND_UI: /* draw_bind(); */ break; #if ENABLED(MKS_WIFI_MODULE)
case BIND_UI: lv_draw_cloud_bind(); break;
#endif
#if HAS_BED_PROBE #if HAS_BED_PROBE
case NOZZLE_PROBE_OFFSET_UI: lv_draw_auto_level_offset_settings(); break; case NOZZLE_PROBE_OFFSET_UI: lv_draw_auto_level_offset_settings(); break;
#endif #endif

View file

@ -46,6 +46,7 @@
#include "draw_preHeat.h" #include "draw_preHeat.h"
#include "draw_extrusion.h" #include "draw_extrusion.h"
#include "draw_home.h" #include "draw_home.h"
#include "draw_more.h"
#include "draw_move_motor.h" #include "draw_move_motor.h"
#include "draw_fan.h" #include "draw_fan.h"
#include "draw_about.h" #include "draw_about.h"
@ -76,6 +77,8 @@
#include "draw_keyboard.h" #include "draw_keyboard.h"
#include "draw_encoder_settings.h" #include "draw_encoder_settings.h"
#include "../../inc/MarlinConfigPre.h"
#if ENABLED(MKS_WIFI_MODULE) #if ENABLED(MKS_WIFI_MODULE)
#include "wifiSerial.h" #include "wifiSerial.h"
#include "wifi_module.h" #include "wifi_module.h"
@ -84,11 +87,15 @@
#include "draw_wifi.h" #include "draw_wifi.h"
#include "draw_wifi_list.h" #include "draw_wifi_list.h"
#include "draw_wifi_tips.h" #include "draw_wifi_tips.h"
#include "draw_cloud_bind.h"
#endif #endif
#include "../../../../inc/MarlinConfigPre.h" #define ESP_WIFI 0x02
#define FILE_SYS_USB 0 #define AP_MODEL 0x01
#define FILE_SYS_SD 1 #define STA_MODEL 0x02
#define FILE_SYS_USB 0
#define FILE_SYS_SD 1
#define TICK_CYCLE 1 #define TICK_CYCLE 1
@ -157,6 +164,10 @@
#define PARA_UI_BACK_BTN_X_SIZE 70 #define PARA_UI_BACK_BTN_X_SIZE 70
#define PARA_UI_BACK_BTN_Y_SIZE 40 #define PARA_UI_BACK_BTN_Y_SIZE 40
#define QRCODE_X 20
#define QRCODE_Y 40
#define QRCODE_WIDTH 160
#else // ifdef TFT35 #else // ifdef TFT35
#define TFT_WIDTH 320 #define TFT_WIDTH 320
@ -237,6 +248,7 @@ typedef struct {
float desireSprayerTempBak; float desireSprayerTempBak;
float current_x_position_bak; float current_x_position_bak;
float current_y_position_bak; float current_y_position_bak;
float current_z_position_bak;
float current_e_position_bak; float current_e_position_bak;
} UI_CFG; } UI_CFG;

View file

@ -41,60 +41,64 @@ enum {
static void event_handler(lv_obj_t *obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return; if (event != LV_EVENT_RELEASED) return;
clear_cur_ui();
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_W_RETURN: case ID_W_RETURN:
clear_cur_ui();
lv_draw_set(); lv_draw_set();
break; break;
case ID_W_CLOUD: case ID_W_CLOUD:
//clear_cur_ui(); lv_draw_cloud_bind();
//draw_return_ui();
break;
case ID_W_RECONNECT:
clear_cur_ui();
lv_draw_wifi_list();
break; break;
#if ENABLED(MKS_WIFI_MODULE)
case ID_W_RECONNECT: {
uint8_t cmd_wifi_list[] = { 0xA5, 0x07, 0x00, 0x00, 0xFC };
raw_send_to_wifi(cmd_wifi_list, COUNT(cmd_wifi_list));
lv_draw_wifi_list();
} break;
#endif
} }
} }
void lv_draw_wifi(void) { void lv_draw_wifi(void) {
scr = lv_screen_create(WIFI_UI); scr = lv_screen_create(WIFI_UI);
// Create an Image button
lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_W_RETURN);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif
lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
lv_obj_t *buttonReconnect = nullptr, *label_Reconnect = nullptr; lv_obj_t *buttonReconnect = nullptr, *label_Reconnect = nullptr;
lv_obj_t *buttonCloud = nullptr, *label_Cloud = nullptr;
const bool enc_ena = TERN0(HAS_ROTARY_ENCODER, gCfgItems.encoder_enable);
if (gCfgItems.wifi_mode_sel == STA_MODEL) { if (gCfgItems.wifi_mode_sel == STA_MODEL) {
buttonReconnect = lv_imgbtn_create(scr, nullptr); if (gCfgItems.cloud_enable)
buttonCloud = lv_imgbtn_create(scr, "F:/bmp_cloud.bin", BTN_X_PIXEL+INTERVAL_V*2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_W_CLOUD);
lv_obj_set_event_cb_mks(buttonReconnect, event_handler, ID_W_RECONNECT, "", 0); buttonReconnect = lv_imgbtn_create(scr, "F:/bmp_wifi.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_W_RECONNECT);
lv_imgbtn_set_src_both(buttonReconnect, "F:/bmp_wifi.bin");
lv_imgbtn_use_label_style(buttonReconnect);
#if HAS_ROTARY_ENCODER #if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonReconnect); if (gCfgItems.cloud_enable) lv_group_add_obj(g, buttonCloud);
if (enc_ena) lv_group_add_obj(g, buttonReconnect);
#endif #endif
lv_obj_set_pos(buttonReconnect, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
lv_btn_set_layout(buttonReconnect, LV_LAYOUT_OFF);
label_Reconnect = lv_label_create_empty(buttonReconnect); label_Reconnect = lv_label_create_empty(buttonReconnect);
if (gCfgItems.cloud_enable) label_Cloud = lv_label_create_empty(buttonCloud);
} }
if (gCfgItems.multiple_language) { // Create an Image button
lv_label_set_text(label_Back, common_menu.text_back); lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_W_RETURN);
lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); if (enc_ena) lv_group_add_obj(g, buttonBack);
lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.multiple_language) {
if (gCfgItems.wifi_mode_sel == STA_MODEL) { if (gCfgItems.wifi_mode_sel == STA_MODEL) {
if (gCfgItems.cloud_enable) {
lv_label_set_text(label_Cloud, wifi_menu.cloud);
lv_obj_align(label_Cloud, buttonCloud, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
}
lv_label_set_text(label_Reconnect, wifi_menu.reconnect); lv_label_set_text(label_Reconnect, wifi_menu.reconnect);
lv_obj_align(label_Reconnect, buttonReconnect, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); lv_obj_align(label_Reconnect, buttonReconnect, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
} }
lv_label_set_text(label_Back, common_menu.text_back);
lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
} }
wifi_ip_text = lv_label_create_empty(scr); wifi_ip_text = lv_label_create_empty(scr);

View file

@ -46,20 +46,10 @@
#define WIFI_IO1_RESET() WRITE(WIFI_IO1_PIN, LOW); #define WIFI_IO1_RESET() WRITE(WIFI_IO1_PIN, LOW);
void __irq_usart1(void) { void __irq_usart1(void) {
WIFISERIAL.wifi_usart_irq(USART1_BASE); if ((USART1_BASE->CR1 & USART_CR1_RXNEIE) && (USART1_BASE->SR & USART_SR_RXNE))
if (wifi_link_state == WIFI_TRANS_FILE) { WRITE(WIFI_IO1_PIN, HIGH);
if (WIFISERIAL.available() == (400)) WIFI_IO1_SET();
if (WIFISERIAL.wifi_rb_is_full()) { WIFISERIAL.wifi_usart_irq(USART1_BASE);
if (esp_state == TRANSFER_IDLE) esp_state = TRANSFERING;
if (storeRcvData(UART_RX_BUFFER_SIZE)) {
if (wifiTransError.flag != 0x1) WIFI_IO1_RESET();
}
else {
WIFI_IO1_SET();
esp_state = TRANSFER_STORE;
}
}
}
} }
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -42,7 +42,7 @@ extern uint16_t DeviceCode;
#endif #endif
static const char assets[][LONG_FILENAME_LENGTH] = { static const char assets[][LONG_FILENAME_LENGTH] = {
//homing screen // Homing screen
"bmp_zeroAll.bin", "bmp_zeroAll.bin",
"bmp_zero.bin", "bmp_zero.bin",
"bmp_zeroX.bin", "bmp_zeroX.bin",
@ -50,14 +50,15 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
"bmp_zeroZ.bin", "bmp_zeroZ.bin",
"bmp_manual_off.bin", "bmp_manual_off.bin",
//tool screen // Tool screen
"bmp_preHeat.bin", "bmp_preHeat.bin",
"bmp_extruct.bin", "bmp_extruct.bin",
"bmp_mov.bin", "bmp_mov.bin",
"bmp_leveling.bin", "bmp_leveling.bin",
"bmp_filamentchange.bin", "bmp_filamentchange.bin",
"bmp_more.bin",
//fan screen // Fan screen
"bmp_Add.bin", "bmp_Add.bin",
"bmp_Dec.bin", "bmp_Dec.bin",
"bmp_speed255.bin", "bmp_speed255.bin",
@ -70,7 +71,7 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
"bmp_step5_degree.bin", "bmp_step5_degree.bin",
"bmp_step10_degree.bin", "bmp_step10_degree.bin",
//extrusion screen // Extrusion screen
"bmp_in.bin", "bmp_in.bin",
"bmp_out.bin", "bmp_out.bin",
"bmp_extru1.bin", "bmp_extru1.bin",
@ -84,15 +85,15 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
"bmp_step5_mm.bin", "bmp_step5_mm.bin",
"bmp_step10_mm.bin", "bmp_step10_mm.bin",
//select file screen // Select file screen
"bmp_pageUp.bin", "bmp_pageUp.bin",
"bmp_pageDown.bin", "bmp_pageDown.bin",
"bmp_back.bin", //TODO: why two back buttons? Why not just one? (return / back) "bmp_back.bin", //TODO: why two back buttons? Why not just one? (return / back)
"bmp_dir.bin", "bmp_dir.bin",
"bmp_file.bin", "bmp_file.bin",
//move motor screen // Move motor screen
//TODO: 6 equal icons, just in diffenct rotation... it may be optimized too // TODO: 6 equal icons, just in diffenct rotation... it may be optimized too
"bmp_xAdd.bin", "bmp_xAdd.bin",
"bmp_xDec.bin", "bmp_xDec.bin",
"bmp_yAdd.bin", "bmp_yAdd.bin",
@ -103,7 +104,7 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
"bmp_step_move1.bin", "bmp_step_move1.bin",
"bmp_step_move10.bin", "bmp_step_move10.bin",
//operation screen // Operation screen
"bmp_auto_off.bin", "bmp_auto_off.bin",
"bmp_speed.bin", "bmp_speed.bin",
"bmp_fan.bin", "bmp_fan.bin",
@ -111,7 +112,7 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
"bmp_extrude_opr.bin", "bmp_extrude_opr.bin",
"bmp_move_opr.bin", "bmp_move_opr.bin",
//change speed screen // Change speed screen
"bmp_step1_percent.bin", "bmp_step1_percent.bin",
"bmp_step5_percent.bin", "bmp_step5_percent.bin",
"bmp_step10_percent.bin", "bmp_step10_percent.bin",
@ -120,7 +121,7 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
"bmp_mov_sel.bin", "bmp_mov_sel.bin",
"bmp_speed_extruct.bin", "bmp_speed_extruct.bin",
//printing screen // Printing screen
"bmp_pause.bin", "bmp_pause.bin",
"bmp_resume.bin", "bmp_resume.bin",
"bmp_stop.bin", "bmp_stop.bin",
@ -134,7 +135,7 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
"bmp_zpos_state.bin", "bmp_zpos_state.bin",
"bmp_operate.bin", "bmp_operate.bin",
//manual leval screen (only if disabled auto level) // Manual Level screen (only if auto level is disabled)
#if DISABLED(AUTO_BED_LEVELING_BILINEAR) #if DISABLED(AUTO_BED_LEVELING_BILINEAR)
"bmp_leveling1.bin", "bmp_leveling1.bin",
"bmp_leveling2.bin", "bmp_leveling2.bin",
@ -143,7 +144,7 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
"bmp_leveling5.bin", "bmp_leveling5.bin",
#endif #endif
//lang select screen // Language Select screen
#if HAS_LANG_SELECT_SCREEN #if HAS_LANG_SELECT_SCREEN
"bmp_language.bin", "bmp_language.bin",
"bmp_simplified_cn.bin", "bmp_simplified_cn.bin",
@ -162,7 +163,7 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
"bmp_italy_sel.bin", "bmp_italy_sel.bin",
#endif // HAS_LANG_SELECT_SCREEN #endif // HAS_LANG_SELECT_SCREEN
// gcode preview // G-code preview
#if HAS_GCODE_DEFAULT_VIEW_IN_FLASH #if HAS_GCODE_DEFAULT_VIEW_IN_FLASH
"bmp_preview.bin", "bmp_preview.bin",
#endif #endif
@ -171,20 +172,18 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
"bmp_logo.bin", "bmp_logo.bin",
#endif #endif
// settings screen // Settings screen
"bmp_about.bin", "bmp_about.bin",
//start screen
"bmp_printing.bin",
"bmp_set.bin",
"bmp_tool.bin",
// settings screen
"bmp_eeprom_settings.bin", "bmp_eeprom_settings.bin",
"bmp_machine_para.bin", "bmp_machine_para.bin",
"bmp_function1.bin", "bmp_function1.bin",
// base icons // Start screen
"bmp_printing.bin",
"bmp_set.bin",
"bmp_tool.bin",
// Base icons
"bmp_arrow.bin", "bmp_arrow.bin",
"bmp_back70x40.bin", "bmp_back70x40.bin",
"bmp_value_blank.bin", "bmp_value_blank.bin",
@ -194,14 +193,24 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
"bmp_return.bin", "bmp_return.bin",
#if ENABLED(MKS_WIFI_MODULE) #if ENABLED(MKS_WIFI_MODULE)
// wifi screen // Wifi screen
"bmp_wifi.bin", "bmp_wifi.bin",
"bmp_cloud.bin",
#endif #endif
// babystep screen // Babystep screen
"bmp_baby_move0_01.bin", "bmp_baby_move0_01.bin",
"bmp_baby_move0_05.bin", "bmp_baby_move0_05.bin",
"bmp_baby_move0_1.bin" "bmp_baby_move0_1.bin",
// More screen
"bmp_custom1.bin",
"bmp_custom2.bin",
"bmp_custom3.bin",
"bmp_custom4.bin",
"bmp_custom5.bin",
"bmp_custom6.bin",
"bmp_custom7.bin"
}; };
#if HAS_SPI_FLASH_FONT #if HAS_SPI_FLASH_FONT
@ -235,14 +244,13 @@ uint32_t lv_get_pic_addr(uint8_t *Pname) {
} while (PIC.name[j++] != '\0'); } while (PIC.name[j++] != '\0');
if ((strcasecmp((char*)Pname, (char*)PIC.name)) == 0) { if ((strcasecmp((char*)Pname, (char*)PIC.name)) == 0) {
if ((DeviceCode == 0x9488) || (DeviceCode == 0x5761)) if (DeviceCode == 0x9488 || DeviceCode == 0x5761)
addr = PIC_DATA_ADDR_TFT35 + i * PER_PIC_MAX_SPACE_TFT35; addr = PIC_DATA_ADDR_TFT35 + i * PER_PIC_MAX_SPACE_TFT35;
else else
addr = PIC_DATA_ADDR_TFT32 + i * PER_PIC_MAX_SPACE_TFT32; addr = PIC_DATA_ADDR_TFT32 + i * PER_PIC_MAX_SPACE_TFT32;
return addr; return addr;
} }
} }
return addr; return addr;
} }

View file

@ -120,7 +120,7 @@
// SD card information first addr // SD card information first addr
#define VAR_INF_ADDR 0x000000 #define VAR_INF_ADDR 0x000000
#define FLASH_INF_VALID_FLAG 0x20200831 #define FLASH_INF_VALID_FLAG 0x20201118
//Store some gcode commands, such as auto leveling commands //Store some gcode commands, such as auto leveling commands
#define GCODE_COMMAND_ADDR VAR_INF_ADDR + 3*1024 #define GCODE_COMMAND_ADDR VAR_INF_ADDR + 3*1024

View file

@ -32,6 +32,7 @@
#include "../../../../sd/cardreader.h" #include "../../../../sd/cardreader.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
#include "../../../../MarlinCore.h" #include "../../../../MarlinCore.h"
#include "../../../../gcode/queue.h"
#if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(POWER_LOSS_RECOVERY)
#include "../../../../feature/powerloss.h" #include "../../../../feature/powerloss.h"
@ -55,6 +56,7 @@ void printer_state_polling() {
//save the positon //save the positon
uiCfg.current_x_position_bak = current_position.x; uiCfg.current_x_position_bak = current_position.x;
uiCfg.current_y_position_bak = current_position.y; uiCfg.current_y_position_bak = current_position.y;
uiCfg.current_z_position_bak = current_position.z;
if (gCfgItems.pausePosZ != (float)-1) { if (gCfgItems.pausePosZ != (float)-1) {
gcode.process_subcommands_now_P(PSTR("G91")); gcode.process_subcommands_now_P(PSTR("G91"));
@ -87,10 +89,9 @@ void printer_state_polling() {
gcode.process_subcommands_now(public_buf_m); gcode.process_subcommands_now(public_buf_m);
} }
if (gCfgItems.pausePosZ != (float)-1) { if (gCfgItems.pausePosZ != (float)-1) {
gcode.process_subcommands_now_P(PSTR("G91")); ZERO(public_buf_m);
sprintf_P(public_buf_l, PSTR("G1 Z-%.1f"), gCfgItems.pausePosZ); sprintf_P(public_buf_m, PSTR("G1 Z%.1f"), uiCfg.current_z_position_bak);
gcode.process_subcommands_now(public_buf_l); gcode.process_subcommands_now(public_buf_m);
gcode.process_subcommands_now_P(PSTR("G90"));
} }
gcode.process_subcommands_now_P(M24_STR); gcode.process_subcommands_now_P(M24_STR);
uiCfg.print_state = WORKING; uiCfg.print_state = WORKING;

View file

@ -114,6 +114,7 @@
#define PROBE_Z_SPEED_EN "Probe Z-axis speed" #define PROBE_Z_SPEED_EN "Probe Z-axis speed"
#define ENABLE_EN "YES" #define ENABLE_EN "YES"
#define DISABLE_EN "NO" #define DISABLE_EN "NO"
#define LOCKED_EN "N/A"
#define Z_MIN_EN "ZMin" #define Z_MIN_EN "ZMin"
#define Z_MAX_EN "ZMax" #define Z_MAX_EN "ZMax"
@ -725,3 +726,11 @@
#define EEPROM_STORE_TIPS_EN "Store settings to EEPROM?" #define EEPROM_STORE_TIPS_EN "Store settings to EEPROM?"
#define EEPROM_READ_TIPS_EN "Read settings from EEPROM?" #define EEPROM_READ_TIPS_EN "Read settings from EEPROM?"
#define EEPROM_REVERT_TIPS_EN "Revert settings to factory defaults?" #define EEPROM_REVERT_TIPS_EN "Revert settings to factory defaults?"
#define MORE_CUSTOM1_TEXT_EN USER_DESC_1
#define MORE_CUSTOM2_TEXT_EN USER_DESC_2
#define MORE_CUSTOM3_TEXT_EN USER_DESC_3
#define MORE_CUSTOM4_TEXT_EN USER_DESC_4
#define MORE_CUSTOM5_TEXT_EN USER_DESC_5
#define MORE_CUSTOM6_TEXT_EN USER_DESC_6
#define MORE_CUSTOM7_TEXT_EN USER_DESC_7

View file

@ -257,3 +257,11 @@
#define EEPROM_STORE_TIPS_FR "Stocker les paramètres dans l'EEPROM?" #define EEPROM_STORE_TIPS_FR "Stocker les paramètres dans l'EEPROM?"
#define EEPROM_READ_TIPS_FR "Lire les paramètres de l'EEPROM?" #define EEPROM_READ_TIPS_FR "Lire les paramètres de l'EEPROM?"
#define EEPROM_REVERT_TIPS_FR "Rétablir les paramètres par défaut d'usine?" #define EEPROM_REVERT_TIPS_FR "Rétablir les paramètres par défaut d'usine?"
#define MORE_CUSTOM1_TEXT_FR USER_DESC_1
#define MORE_CUSTOM2_TEXT_FR USER_DESC_2
#define MORE_CUSTOM3_TEXT_FR USER_DESC_3
#define MORE_CUSTOM4_TEXT_FR USER_DESC_4
#define MORE_CUSTOM5_TEXT_FR USER_DESC_5
#define MORE_CUSTOM6_TEXT_FR USER_DESC_6
#define MORE_CUSTOM7_TEXT_FR USER_DESC_7

View file

@ -254,3 +254,11 @@
#define EEPROM_STORE_TIPS_IT "Memorizzare le impostazioni su EEPROM?" #define EEPROM_STORE_TIPS_IT "Memorizzare le impostazioni su EEPROM?"
#define EEPROM_READ_TIPS_IT "Leggi le impostazioni dalla EEPROM?" #define EEPROM_READ_TIPS_IT "Leggi le impostazioni dalla EEPROM?"
#define EEPROM_REVERT_TIPS_IT "Ripristinare le impostazioni predefinite?" #define EEPROM_REVERT_TIPS_IT "Ripristinare le impostazioni predefinite?"
#define MORE_CUSTOM1_TEXT_IT USER_DESC_1
#define MORE_CUSTOM2_TEXT_IT USER_DESC_2
#define MORE_CUSTOM3_TEXT_IT USER_DESC_3
#define MORE_CUSTOM4_TEXT_IT USER_DESC_4
#define MORE_CUSTOM5_TEXT_IT USER_DESC_5
#define MORE_CUSTOM6_TEXT_IT USER_DESC_6
#define MORE_CUSTOM7_TEXT_IT USER_DESC_7

View file

@ -29,7 +29,7 @@
#define PRINT_TEXT_RU " печать" #define PRINT_TEXT_RU " печать"
#define EXTRUDE_TEXT_RU "экструзия" #define EXTRUDE_TEXT_RU "экструзия"
#define LEVELING_TEXT_RU "уровень" #define LEVELING_TEXT_RU "уровень"
#define AUTO_LEVELING_TEXT_RU "aвто" #define AUTO_LEVELING_TEXT_RU "aвтоуровень"
#define SET_TEXT_RU "настройки" #define SET_TEXT_RU "настройки"
#define MORE_TEXT_RU "больше" #define MORE_TEXT_RU "больше"
@ -46,23 +46,23 @@
#define BACK_TEXT_RU "назад" #define BACK_TEXT_RU "назад"
#define TOOL_PREHEAT_RU "нагрев" #define TOOL_PREHEAT_RU "нагрев"
#define TOOL_EXTRUDE_RU "экструзия" #define TOOL_EXTRUDE_RU "экструдер"
#define TOOL_MOVE_RU "движение" #define TOOL_MOVE_RU "движение"
#define TOOL_HOME_RU "домой" #define TOOL_HOME_RU "домой"
#define TOOL_LEVELING_RU "уровень" #define TOOL_LEVELING_RU "уровень"
#define TOOL_AUTO_LEVELING_RU "aвто" #define TOOL_AUTO_LEVELING_RU "aвтоуровень"
#define TOOL_FILAMENT_RU "замена" #define TOOL_FILAMENT_RU "замена"
#define TOOL_MORE_RU "больше" #define TOOL_MORE_RU "больше"
#define AXIS_X_ADD_TEXT_RU "X+" #define AXIS_X_ADD_TEXT_RU "X +"
#define AXIS_X_DEC_TEXT_RU "X-" #define AXIS_X_DEC_TEXT_RU "X -"
#define AXIS_Y_ADD_TEXT_RU "Y+" #define AXIS_Y_ADD_TEXT_RU "Y +"
#define AXIS_Y_DEC_TEXT_RU "Y-" #define AXIS_Y_DEC_TEXT_RU "Y -"
#define AXIS_Z_ADD_TEXT_RU "Z+" #define AXIS_Z_ADD_TEXT_RU "Z +"
#define AXIS_Z_DEC_TEXT_RU "Z-" #define AXIS_Z_DEC_TEXT_RU "Z -"
#define TEXT_01MM_RU "0.1mm" #define TEXT_01MM_RU "0.1 mm"
#define TEXT_1MM_RU "1mm" #define TEXT_1MM_RU "1 mm"
#define TEXT_10MM_RU "10mm" #define TEXT_10MM_RU "10 mm"
#define HOME_X_TEXT_RU "X" #define HOME_X_TEXT_RU "X"
#define HOME_Y_TEXT_RU "Y" #define HOME_Y_TEXT_RU "Y"
@ -75,18 +75,18 @@
#define EXTRUDER_IN_TEXT_RU "втянуть" #define EXTRUDER_IN_TEXT_RU "втянуть"
#define EXTRUDER_OUT_TEXT_RU "выдавить" #define EXTRUDER_OUT_TEXT_RU "выдавить"
#define EXTRUDE_1MM_TEXT_RU "1mm" #define EXTRUDE_1MM_TEXT_RU "1 mm"
#define EXTRUDE_5MM_TEXT_RU "5mm" #define EXTRUDE_5MM_TEXT_RU "5 mm"
#define EXTRUDE_10MM_TEXT_RU "10mm" #define EXTRUDE_10MM_TEXT_RU "10 mm"
#define EXTRUDE_LOW_SPEED_TEXT_RU "мин" #define EXTRUDE_LOW_SPEED_TEXT_RU "мин"
#define EXTRUDE_MEDIUM_SPEED_TEXT_RU "сред" #define EXTRUDE_MEDIUM_SPEED_TEXT_RU "сред"
#define EXTRUDE_HIGH_SPEED_TEXT_RU "выс" #define EXTRUDE_HIGH_SPEED_TEXT_RU "выс"
#define LEVELING_POINT1_TEXT_RU "1точка" #define LEVELING_POINT1_TEXT_RU "1 точка"
#define LEVELING_POINT2_TEXT_RU "2точка" #define LEVELING_POINT2_TEXT_RU "2 точка"
#define LEVELING_POINT3_TEXT_RU "3точка" #define LEVELING_POINT3_TEXT_RU "3 точка"
#define LEVELING_POINT4_TEXT_RU "4точка" #define LEVELING_POINT4_TEXT_RU "4 точка"
#define LEVELING_POINT5_TEXT_RU "5точка" #define LEVELING_POINT5_TEXT_RU "5 точка"
#define FILESYS_TEXT_RU "система" #define FILESYS_TEXT_RU "система"
#define WIFI_TEXT_RU "WiFi" #define WIFI_TEXT_RU "WiFi"
@ -95,11 +95,10 @@
#define BREAK_POINT_TEXT_RU "продолжить" #define BREAK_POINT_TEXT_RU "продолжить"
#define FILAMENT_TEXT_RU "замена" #define FILAMENT_TEXT_RU "замена"
#define LANGUAGE_TEXT_RU "язык" #define LANGUAGE_TEXT_RU "язык"
#define MOTOR_OFF_TEXT_RU "отклмотор" #define MOTOR_OFF_TEXT_RU "откл. мотор"
#define MOTOR_OFF_XY_TEXT_RU "Off-XY" #define MOTOR_OFF_XY_TEXT_RU "Off-XY"
#define SHUTDOWN_TEXT_RU "выключение" #define SHUTDOWN_TEXT_RU "выключение"
#define MACHINE_PARA_RU "конфиг" #define MACHINE_PARA_RU "конфиг"
#define EEPROM_SETTINGS_RU "Eeprom Set"
#define U_DISK_TEXT_RU "U диск" #define U_DISK_TEXT_RU "U диск"
#define SD_CARD_TEXT_RU "SD диск" #define SD_CARD_TEXT_RU "SD диск"
@ -111,14 +110,14 @@
#define WIFI_CONNECTED_TEXT_RU "подключен" #define WIFI_CONNECTED_TEXT_RU "подключен"
#define WIFI_DISCONNECTED_TEXT_RU "не подключен" #define WIFI_DISCONNECTED_TEXT_RU "не подключен"
#define WIFI_EXCEPTION_TEXT_RU "исключение" #define WIFI_EXCEPTION_TEXT_RU "исключение"
#define WIFI_RECONNECT_TEXT_RU "Reconnect" #define WIFI_RECONNECT_TEXT_RU "выбор сети"
#define CLOUD_TEXT_RU "облако" #define CLOUD_TEXT_RU "облако"
#define CLOUD_BIND_RU "соединён" #define CLOUD_BIND_RU "соединён"
#define CLOUD_UNBIND_RU "не соединён" #define CLOUD_UNBIND_RU "отсоед."
#define CLOUD_UNBINDING_RU "Unbinding" #define CLOUD_UNBINDING_RU "отвязано"
#define CLOUD_DISCONNECTED_RU "Disconnected" #define CLOUD_DISCONNECTED_RU "отключено"
#define CLOUD_UNBINDED_RU "Unbinded" #define CLOUD_UNBINDED_RU "несвяз."
#define CLOUD_BINDED_RU "Binded" #define CLOUD_BINDED_RU "связано"
#define CLOUD_DISABLE_RU "Disable" #define CLOUD_DISABLE_RU "Disable"
#define FAN_ADD_TEXT_RU "добавить" #define FAN_ADD_TEXT_RU "добавить"
@ -169,11 +168,11 @@
#define ABOUT_VERSION_TEXT_RU "Firmware: " #define ABOUT_VERSION_TEXT_RU "Firmware: "
#define ABOUT_WIFI_TEXT_RU "WiFi: " #define ABOUT_WIFI_TEXT_RU "WiFi: "
#define PRINTING_OPERATION_RU "управление" #define PRINTING_OPERATION_RU "опции"
#define PRINTING_PAUSE_RU "пауза" #define PRINTING_PAUSE_RU "пауза"
#define PRINTING_TEMP_RU "темп" #define PRINTING_TEMP_RU "темп"
#define PRINTING_CHANGESPEED_RU "скорости" #define PRINTING_CHANGESPEED_RU "скорости"
#define PRINTING_RESUME_RU "возобновить" #define PRINTING_RESUME_RU "возобн. "
#define PRINTING_STOP_RU "стоп" #define PRINTING_STOP_RU "стоп"
#define PRINTING_MORE_RU "больше" #define PRINTING_MORE_RU "больше"
#define PRINTING_EXTRUDER_RU "экстр" #define PRINTING_EXTRUDER_RU "экстр"
@ -193,6 +192,7 @@
#define TITLE_HOME_RU "Home" #define TITLE_HOME_RU "Home"
#define TITLE_EXTRUDE_RU "экструзия" #define TITLE_EXTRUDE_RU "экструзия"
#define TITLE_LEVELING_RU "уровень" #define TITLE_LEVELING_RU "уровень"
#define TITLE_MLEVELING_RU "углы"
#define TITLE_SET_RU "настройки" #define TITLE_SET_RU "настройки"
#define TITLE_MORE_RU "больше" #define TITLE_MORE_RU "больше"
#define TITLE_CHOOSEFILE_RU "файла" #define TITLE_CHOOSEFILE_RU "файла"
@ -230,7 +230,7 @@
#define DIALOG_CLOSE_MACHINE_RU "Closing machine......" #define DIALOG_CLOSE_MACHINE_RU "Closing machine......"
#define DIALOG_UNBIND_PRINTER_RU "Unbind the printer?" #define DIALOG_UNBIND_PRINTER_RU "Unbind the printer?"
#define DIALOG_FILAMENT_NO_PRESS_RU "Filament detection switch is not pressed" #define DIALOG_FILAMENT_NO_PRESS_RU "Filament detection switch is not pressed"
#define DIALOG_PRINT_FINISH_RU "Печать завершена!" #define DIALOG_PRINT_FINISH_RU "печать завершена!"
#define DIALOG_PRINT_TIME_RU "Время печати: " #define DIALOG_PRINT_TIME_RU "Время печати: "
#define DIALOG_REPRINT_RU "Print again" #define DIALOG_REPRINT_RU "Print again"
#define DIALOG_WIFI_ENABLE_TIPS_RU "The wifi module is being configured,\nplease wait a moment....." #define DIALOG_WIFI_ENABLE_TIPS_RU "The wifi module is being configured,\nplease wait a moment....."
@ -253,6 +253,115 @@
#define EEPROM_SETTINGS_READ_RU "Чтение настроек из EEPROM" #define EEPROM_SETTINGS_READ_RU "Чтение настроек из EEPROM"
#define EEPROM_SETTINGS_REVERT_RU "Bосстановить заводские настройки по умолчанию" #define EEPROM_SETTINGS_REVERT_RU "Bосстановить заводские настройки по умолчанию"
#define EEPROM_STORE_TIPS_RU "Сохранить настройки в EEPROM?" #define MORE_CUSTOM1_TEXT_RU USER_DESC_1
#define EEPROM_READ_TIPS_RU "Читать настройки из EEPROM?" #define MORE_CUSTOM2_TEXT_RU USER_DESC_2
#define EEPROM_REVERT_TIPS_RU "Revert settings to factory defaults?" #define MORE_CUSTOM3_TEXT_RU USER_DESC_3
#define MORE_CUSTOM4_TEXT_RU USER_DESC_4
#define MORE_CUSTOM5_TEXT_RU USER_DESC_5
#define MORE_CUSTOM6_TEXT_RU USER_DESC_6
#define MORE_CUSTOM7_TEXT_RU USER_DESC_7
//Malderin translate
//
//
#define EEPROM_STORE_TIPS_RU "Cохранить настройки в EEPROM?"
#define EEPROM_READ_TIPS_RU "читать настройки из EEPROM?"
#define EEPROM_REVERT_TIPS_RU "Cбросить настройки к значениям по умолчанию?"
#define EEPROM_SETTINGS_RU "EEPROM"
#define NEXT_RU "след."
#define PREVIOUS_RU "пред."
#define ENABLE_RU "да "
#define DISABLE_RU "нет"
#define KEY_CONFIRM_RU "OK"
#define MACHINE_PARA_TITLE_RU "настройки"
#define MACHINE_TYPE_CNOFIG_RU "Hастройки принтера"
#define MOTOR_CONFIG_RU "Hастройки моторов"
#define MACHINE_LEVELING_CONFIG_RU "Hастройки уровня"
#define ADVANCE_CONFIG_RU "Pасширенные настройки"
#define MACHINE_FILAMENT_CONFIG_RU "Hастройки филамента"
#define ENCODER_SETTINGS_RU "Hастройки энкодера"
#define LEVELING_CONF_TITLE_RU "Hастройки принтера>Hастройки уровня"
#define LEVELING_PARA_CONF_RU "настройки уровня"
#define LEVELING_MANUAL_POS_RU "настройки координат для уровня"
#define LEVELING_AUTO_COMMAND_RU "настройки комманд увтоуровня"
#define LEVELING_AUTO_ZOFFSET_RU "координаты смещения сопла"
#define MACHINE_CONFIG_TITLE_RU "Hастройки принтера>настройки притера"
#define MAXFEEDRATE_CONF_RU "настройки максимальной скорости"
#define ACCELERATION_CONF_RU "настройки ускорений"
#define JERKCONF_RU "настройки рывков"
#define MOTOR_CONF_TITLE_RU "Hастройки принтера>Hастройки моторов"
#define STEPSCONF_RU "настройки шагов"
#define TMC_CURRENT_RU "TMC настройки токов"
#define TMC_STEP_MODE_RU "TMC настрйоки режима шагов"
#define ACCELERATION_CONF_TITLE_RU "Hастройки принтера>ускорения"
#define PRINT_ACCELERATION_RU "ускорение печати"
#define RETRACT_ACCELERATION_RU "ускорение ретракта"
#define TRAVEL_ACCELERATION_RU "ускорение перемещений"
#define X_ACCELERATION_RU "ускорение оси X"
#define Y_ACCELERATION_RU "ускорение оси Y"
#define Z_ACCELERATION_RU "ускорение оси Z"
#define E0_ACCELERATION_RU "ускорение E0"
#define E1_ACCELERATION_RU "ускорение E1"
#define MAXFEEDRATE_CONF_TITLE_RU "Hастройки принтера>максимальная скорость"
#define X_MAXFEEDRATE_RU "максимальная скорость оси X"
#define Y_MAXFEEDRATE_RU "максимальная скорость оси Y"
#define Z_MAXFEEDRATE_RU "максимальная скорость оси Z"
#define E0_MAXFEEDRATE_RU "максимальная скорость E0"
#define E1_MAXFEEDRATE_RU "максимальная скорость E1"
#define JERK_CONF_TITLE_RU "Hастройки принтера>скорость рывка"
#define X_JERK_RU "скорость рывка оси X"
#define Y_JERK_RU "скорость рывка оси Y"
#define Z_JERK_RU "скорость рывка оси Z"
#define E_JERK_RU "скорость рывка оси E"
#define STEPS_CONF_TITLE_RU "Hастройки принтера>настройки шагов"
#define X_STEPS_RU "шаги оси X"
#define Y_STEPS_RU "шаги оси Y"
#define Z_STEPS_RU "шаги оси Z"
#define E0_STEPS_RU "шаги E0"
#define E1_STEPS_RU "шаги E1"
#define TMC_CURRENT_CONF_TITLE_RU "Hастройки принтера>TMC настройка токов"
#define X_TMC_CURRENT_RU "ток оси X (mA)"
#define Y_TMC_CURRENT_RU "ток оси Y (mA)"
#define Z_TMC_CURRENT_RU "ток оси Z (mA)"
#define E0_TMC_CURRENT_RU "ток E0 (mA)"
#define E1_TMC_CURRENT_RU "ток E1 (mA)"
#define TMC_MODE_CONF_TITLE_RU "Hастройки принтера>TMC настройки режима шагов"
#define X_TMC_MODE_RU "включает ли двигатель X режим StealthChop"
#define Y_TMC_MODE_RU "включает ли ось Y режим StealthChop"
#define Z_TMC_MODE_RU "включает ли ось Z режим StealthChop"
#define E0_TMC_MODE_RU "включает ли E0 режим StealthChop"
#define E1_TMC_MODE_RU "включает ли E1 режим StealthChop"
#define ADVANCED_CONF_TITLE_RU "Hастройки принтера>Pасширенные"
#define PAUSE_POSITION_RU "Hастройки позиции паузы печати"
#define PAUSE_POSITION_X_RU "положение по X (абс. полож., -1 недействит.)"
#define PAUSE_POSITION_Y_RU "положение по Y (абс. полож., -1 недействит.)"
#define PAUSE_POSITION_Z_RU "положение по Z (абс. полож., -1 недействит.)"
#define OFFSET_TITLE_RU "Hастройки принтера>отступ"
#define OFFSET_X_RU "X отступ"
#define OFFSET_Y_RU "Y отступ"
#define OFFSET_Z_RU "Z отступ"
#define FILAMENT_CONF_TITLE_RU "Hастройки принтера>Hастройки филамента"
#define FILAMENT_IN_LENGTH_RU "длинна загрузки"
#define FILAMENT_IN_SPEED_RU "скорость загрузки"
#define FILAMENT_TEMPERATURE_RU "температура филамента"
#define FILAMENT_OUT_LENGTH_RU "длинна извлечения"
#define FILAMENT_OUT_SPEED_RU "скорость извлечения"
#define ENCODER_CONF_TITLE_RU "Hастройки принтера>Hастройки энкодера"
#define ENCODER_CONF_TEXT_RU "энкодер используется?"
//end of Malderin translate

View file

@ -99,6 +99,7 @@
#define PROBE_Z_SPEED_CN "探针Z方向移动速度" #define PROBE_Z_SPEED_CN "探针Z方向移动速度"
#define ENABLE_CN "是" #define ENABLE_CN "是"
#define DISABLE_CN "否" #define DISABLE_CN "否"
#define LOCKED_CN "否"
#define Z_MIN_CN "ZMin" #define Z_MIN_CN "ZMin"
#define Z_MAX_CN "ZMax" #define Z_MAX_CN "ZMax"
@ -491,3 +492,11 @@
#define EEPROM_STORE_TIPS_CN "是否保存参数到EEPROM?" #define EEPROM_STORE_TIPS_CN "是否保存参数到EEPROM?"
#define EEPROM_READ_TIPS_CN "是否使用EEPROM参数?" #define EEPROM_READ_TIPS_CN "是否使用EEPROM参数?"
#define EEPROM_REVERT_TIPS_CN "是否恢复默认参数?" #define EEPROM_REVERT_TIPS_CN "是否恢复默认参数?"
#define MORE_CUSTOM1_TEXT_CN USER_DESC_1
#define MORE_CUSTOM2_TEXT_CN USER_DESC_2
#define MORE_CUSTOM3_TEXT_CN USER_DESC_3
#define MORE_CUSTOM4_TEXT_CN USER_DESC_4
#define MORE_CUSTOM5_TEXT_CN USER_DESC_5
#define MORE_CUSTOM6_TEXT_CN USER_DESC_6
#define MORE_CUSTOM7_TEXT_CN USER_DESC_7

View file

@ -29,6 +29,7 @@
#define PRINT_TEXT_SP "Imprimir" #define PRINT_TEXT_SP "Imprimir"
#define EXTRUDE_TEXT_SP "Extrusor" #define EXTRUDE_TEXT_SP "Extrusor"
#define LEVELING_TEXT_SP "Leveling" #define LEVELING_TEXT_SP "Leveling"
#define MLEVELING_TEXT_SP "Leveling"
#define AUTO_LEVELING_TEXT_SP "Autolevel" #define AUTO_LEVELING_TEXT_SP "Autolevel"
#define SET_TEXT_SP "Config" #define SET_TEXT_SP "Config"
#define MORE_TEXT_SP "Más" #define MORE_TEXT_SP "Más"
@ -50,6 +51,7 @@
#define TOOL_MOVE_SP "Mover" #define TOOL_MOVE_SP "Mover"
#define TOOL_HOME_SP "Origen" #define TOOL_HOME_SP "Origen"
#define TOOL_LEVELING_SP "Leveling" #define TOOL_LEVELING_SP "Leveling"
#define TOOL_MLEVELING_SP "Leveling"
#define TOOL_AUTO_LEVELING_SP "Autolevel" #define TOOL_AUTO_LEVELING_SP "Autolevel"
#define TOOL_FILAMENT_SP "Filamento" #define TOOL_FILAMENT_SP "Filamento"
#define TOOL_MORE_SP "Más" #define TOOL_MORE_SP "Más"
@ -261,3 +263,11 @@
#define EEPROM_STORE_TIPS_SP "¿Guardar ajustes en EEPROM?" #define EEPROM_STORE_TIPS_SP "¿Guardar ajustes en EEPROM?"
#define EEPROM_READ_TIPS_SP "Leer la configuración de EEPROM?" #define EEPROM_READ_TIPS_SP "Leer la configuración de EEPROM?"
#define EEPROM_REVERT_TIPS_SP "Revert settings to factory defaults?" #define EEPROM_REVERT_TIPS_SP "Revert settings to factory defaults?"
#define MORE_CUSTOM1_TEXT_SP USER_DESC_1
#define MORE_CUSTOM2_TEXT_SP USER_DESC_2
#define MORE_CUSTOM3_TEXT_SP USER_DESC_3
#define MORE_CUSTOM4_TEXT_SP USER_DESC_4
#define MORE_CUSTOM5_TEXT_SP USER_DESC_5
#define MORE_CUSTOM6_TEXT_SP USER_DESC_6
#define MORE_CUSTOM7_TEXT_SP USER_DESC_7

View file

@ -99,6 +99,7 @@
#define PROBE_Z_SPEED_T_CN "探针Z方向移動速度" #define PROBE_Z_SPEED_T_CN "探针Z方向移動速度"
#define ENABLE_T_CN "是" #define ENABLE_T_CN "是"
#define DISABLE_T_CN "否" #define DISABLE_T_CN "否"
#define LOCKED_T_CN "否"
#define Z_MIN_T_CN "ZMin" #define Z_MIN_T_CN "ZMin"
#define Z_MAX_T_CN "ZMax" #define Z_MAX_T_CN "ZMax"
@ -489,3 +490,11 @@
#define EEPROM_STORE_TIPS_T_CN "是否保存參數到EEPROM?" #define EEPROM_STORE_TIPS_T_CN "是否保存參數到EEPROM?"
#define EEPROM_READ_TIPS_T_CN "是否使用EEPROM參數?" #define EEPROM_READ_TIPS_T_CN "是否使用EEPROM參數?"
#define EEPROM_REVERT_TIPS_T_CN "是否恢復默認參數?" #define EEPROM_REVERT_TIPS_T_CN "是否恢復默認參數?"
#define MORE_CUSTOM1_TEXT_T_CN USER_DESC_1
#define MORE_CUSTOM2_TEXT_T_CN USER_DESC_2
#define MORE_CUSTOM3_TEXT_T_CN USER_DESC_3
#define MORE_CUSTOM4_TEXT_T_CN USER_DESC_4
#define MORE_CUSTOM5_TEXT_T_CN USER_DESC_5
#define MORE_CUSTOM6_TEXT_T_CN USER_DESC_6
#define MORE_CUSTOM7_TEXT_T_CN USER_DESC_7

View file

@ -19,12 +19,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
* *
*/ */
/**
* @file tft_lvgl_configuration.cpp
* @date 2020-02-21
*/
#include "../../../../inc/MarlinConfigPre.h" #include "../../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI #if HAS_TFT_LVGL_UI
@ -56,6 +50,10 @@ XPT2046 touch;
#include "draw_touch_calibration.h" #include "draw_touch_calibration.h"
#endif #endif
#if ENABLED(MKS_WIFI_MODULE)
#include "wifi_module.h"
#endif
#include <SPI.h> #include <SPI.h>
#ifndef TFT_WIDTH #ifndef TFT_WIDTH
@ -120,6 +118,10 @@ void tft_lvgl_init() {
watchdog_refresh(); // LVGL init takes time watchdog_refresh(); // LVGL init takes time
#if MB(MKS_ROBIN_NANO)
OUT_WRITE(PB0, LOW); // HE1
#endif
// Init TFT first! // Init TFT first!
SPI_TFT.spi_init(SPI_FULL_SPEED); SPI_TFT.spi_init(SPI_FULL_SPEED);
SPI_TFT.LCD_init(); SPI_TFT.LCD_init();
@ -137,19 +139,19 @@ void tft_lvgl_init() {
lv_init(); lv_init();
lv_disp_buf_init(&disp_buf, bmp_public_buf, nullptr, LV_HOR_RES_MAX * 14); /*Initialize the display buffer*/ lv_disp_buf_init(&disp_buf, bmp_public_buf, nullptr, LV_HOR_RES_MAX * 14); // Initialize the display buffer
lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/ lv_disp_drv_t disp_drv; // Descriptor of a display driver
lv_disp_drv_init(&disp_drv); /*Basic initialization*/ lv_disp_drv_init(&disp_drv); // Basic initialization
disp_drv.flush_cb = my_disp_flush; /*Set your driver function*/ disp_drv.flush_cb = my_disp_flush; // Set your driver function
disp_drv.buffer = &disp_buf; /*Assign the buffer to the display*/ disp_drv.buffer = &disp_buf; // Assign the buffer to the display
lv_disp_drv_register(&disp_drv); /*Finally register the driver*/ lv_disp_drv_register(&disp_drv); // Finally register the driver
lv_indev_drv_t indev_drv; lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv); /*Descriptor of a input device driver*/ lv_indev_drv_init(&indev_drv); // Descriptor of a input device driver
indev_drv.type = LV_INDEV_TYPE_POINTER; /*Touch pad is a pointer-like device*/ indev_drv.type = LV_INDEV_TYPE_POINTER; // Touch pad is a pointer-like device
indev_drv.read_cb = my_touchpad_read; /*Set your driver function*/ indev_drv.read_cb = my_touchpad_read; // Set your driver function
lv_indev_drv_register(&indev_drv); /*Finally register the driver*/ lv_indev_drv_register(&indev_drv); // Finally register the driver
#if HAS_ROTARY_ENCODER #if HAS_ROTARY_ENCODER
g = lv_group_create(); g = lv_group_create();
@ -193,6 +195,8 @@ void tft_lvgl_init() {
lv_encoder_pin_init(); lv_encoder_pin_init();
TERN_(MKS_WIFI_MODULE, mks_wifi_firmware_update());
bool ready = true; bool ready = true;
#if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(POWER_LOSS_RECOVERY)
recovery.load(); recovery.load();
@ -212,12 +216,9 @@ void tft_lvgl_init() {
} }
#endif #endif
if (ready) { if (ready) lv_draw_ready_print();
lv_draw_ready_print();
}
if (mks_test_flag == 0x1E) if (mks_test_flag == 0x1E) mks_gpio_test();
mks_gpio_test();
} }
void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p) { void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p) {
@ -229,11 +230,20 @@ void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * co
for (uint16_t i = 0; i < height; i++) for (uint16_t i = 0; i < height; i++)
SPI_TFT.tftio.WriteSequence((uint16_t*)(color_p + width * i), width); SPI_TFT.tftio.WriteSequence((uint16_t*)(color_p + width * i), width);
lv_disp_flush_ready(disp); /* Indicate you are ready with the flushing*/ lv_disp_flush_ready(disp); // Indicate you are ready with the flushing
W25QXX.init(SPI_QUARTER_SPEED); W25QXX.init(SPI_QUARTER_SPEED);
} }
void lv_fill_rect(lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2, lv_color_t bk_color) {
uint16_t width, height;
width = x2 - x1 + 1;
height = y2 - y1 + 1;
SPI_TFT.setWindow((uint16_t)x1, (uint16_t)y1, width, height);
SPI_TFT.tftio.WriteMultiple(bk_color.full, width * height);
W25QXX.init(SPI_QUARTER_SPEED);
}
#define TICK_CYCLE 1 #define TICK_CYCLE 1
unsigned int getTickDiff(unsigned int curTick, unsigned int lastTick) { unsigned int getTickDiff(unsigned int curTick, unsigned int lastTick) {
@ -298,13 +308,13 @@ int16_t enc_diff = 0;
lv_indev_state_t state = LV_INDEV_STATE_REL; lv_indev_state_t state = LV_INDEV_STATE_REL;
bool my_mousewheel_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) { bool my_mousewheel_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) {
(void) indev_drv; /*Unused*/ (void) indev_drv; // Unused
data->state = state; data->state = state;
data->enc_diff = enc_diff; data->enc_diff = enc_diff;
enc_diff = 0; enc_diff = 0;
return false; /*No more data to read so return false*/ return false; // No more data to read so return false
} }
extern uint8_t currentFlashPage; extern uint8_t currentFlashPage;
@ -327,7 +337,7 @@ lv_fs_res_t spi_flash_open_cb (lv_fs_drv_t * drv, void * file_p, const char * pa
lv_fs_res_t spi_flash_close_cb (lv_fs_drv_t * drv, void * file_p) { lv_fs_res_t spi_flash_close_cb (lv_fs_drv_t * drv, void * file_p) {
lv_fs_res_t res = LV_FS_RES_OK; lv_fs_res_t res = LV_FS_RES_OK;
/* Add your code here*/ /* Add your code here */
pic_read_addr_offset = pic_read_base_addr; pic_read_addr_offset = pic_read_base_addr;
return res; return res;
} }
@ -379,7 +389,7 @@ lv_fs_res_t sd_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_
} }
lv_fs_res_t sd_close_cb (lv_fs_drv_t * drv, void * file_p) { lv_fs_res_t sd_close_cb (lv_fs_drv_t * drv, void * file_p) {
/* Add your code here*/ /* Add your code here */
lv_close_gcode_file(); lv_close_gcode_file();
return LV_FS_RES_OK; return LV_FS_RES_OK;
} }

View file

@ -33,7 +33,9 @@
#include <lvgl.h> #include <lvgl.h>
//#define TFT_ROTATION TFT_ROTATE_180 //#define TFT_ROTATION TFT_ROTATE_180
#define MKS_WIFI_MODULE 0
extern uint8_t bmp_public_buf[14 * 1024];
extern uint8_t public_buf[513];
extern uint8_t bmp_public_buf[14 * 1024]; extern uint8_t bmp_public_buf[14 * 1024];
extern uint8_t public_buf[513]; extern uint8_t public_buf[513];
@ -63,6 +65,8 @@ extern lv_fs_res_t sd_read_cb (lv_fs_drv_t * drv, void * file_p, void * buf, uin
extern lv_fs_res_t sd_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos); extern lv_fs_res_t sd_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos);
extern lv_fs_res_t sd_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p); extern lv_fs_res_t sd_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p);
extern void lv_fill_rect(lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2, lv_color_t bk_color);
#ifdef __cplusplus #ifdef __cplusplus
} /* C-declarations for C++ */ } /* C-declarations for C++ */
#endif #endif

View file

@ -136,6 +136,7 @@ void machine_setting_disp() {
machine_menu.ProbeZspeed = PROBE_Z_SPEED_CN; machine_menu.ProbeZspeed = PROBE_Z_SPEED_CN;
machine_menu.enable = ENABLE_CN; machine_menu.enable = ENABLE_CN;
machine_menu.disable = DISABLE_CN; machine_menu.disable = DISABLE_CN;
machine_menu.locked = LOCKED_CN;
machine_menu.z_min = Z_MIN_CN; machine_menu.z_min = Z_MIN_CN;
machine_menu.z_max = Z_MAX_CN; machine_menu.z_max = Z_MAX_CN;
@ -363,6 +364,7 @@ void machine_setting_disp() {
machine_menu.ProbeZspeed = PROBE_Z_SPEED_T_CN; machine_menu.ProbeZspeed = PROBE_Z_SPEED_T_CN;
machine_menu.enable = ENABLE_T_CN; machine_menu.enable = ENABLE_T_CN;
machine_menu.disable = DISABLE_T_CN; machine_menu.disable = DISABLE_T_CN;
machine_menu.locked = LOCKED_T_CN;
machine_menu.z_min = Z_MIN_T_CN; machine_menu.z_min = Z_MIN_T_CN;
machine_menu.z_max = Z_MAX_T_CN; machine_menu.z_max = Z_MAX_T_CN;
@ -591,6 +593,7 @@ void machine_setting_disp() {
machine_menu.ProbeZspeed = PROBE_Z_SPEED_EN; machine_menu.ProbeZspeed = PROBE_Z_SPEED_EN;
machine_menu.enable = ENABLE_EN; machine_menu.enable = ENABLE_EN;
machine_menu.disable = DISABLE_EN; machine_menu.disable = DISABLE_EN;
machine_menu.locked = LOCKED_EN;
machine_menu.z_min = Z_MIN_EN; machine_menu.z_min = Z_MIN_EN;
machine_menu.z_max = Z_MAX_EN; machine_menu.z_max = Z_MAX_EN;
@ -941,7 +944,28 @@ void disp_language_init() {
filesys_menu.sd_sys = SD_CARD_TEXT_CN; filesys_menu.sd_sys = SD_CARD_TEXT_CN;
filesys_menu.usb_sys = U_DISK_TEXT_CN; filesys_menu.usb_sys = U_DISK_TEXT_CN;
// //
more_menu.title = TITLE_MORE_CN; more_menu.title = TITLE_MORE_CN;
#if ENABLED(USER_CMD_1_ENABLE)
more_menu.custom1 = MORE_CUSTOM1_TEXT_CN;
#endif
#if ENABLED(USER_CMD_2_ENABLE)
more_menu.custom2 = MORE_CUSTOM2_TEXT_CN;
#endif
#if ENABLED(USER_CMD_3_ENABLE)
more_menu.custom3 = MORE_CUSTOM3_TEXT_CN;
#endif
#if ENABLED(USER_CMD_4_ENABLE)
more_menu.custom4 = MORE_CUSTOM4_TEXT_CN;
#endif
#if ENABLED(USER_CMD_5_ENABLE)
more_menu.custom5 = MORE_CUSTOM5_TEXT_CN;
#endif
#if ENABLED(USER_CMD_6_ENABLE)
more_menu.custom6 = MORE_CUSTOM6_TEXT_CN;
#endif
#if ENABLED(USER_CMD_7_ENABLE)
more_menu.custom7 = MORE_CUSTOM7_TEXT_CN;
#endif
// WIFI // WIFI
wifi_menu.title = WIFI_TEXT; wifi_menu.title = WIFI_TEXT;
wifi_menu.cloud = CLOUD_TEXT_CN; wifi_menu.cloud = CLOUD_TEXT_CN;
@ -953,6 +977,7 @@ void disp_language_init() {
cloud_menu.unbind = CLOUD_UNBIND_CN; cloud_menu.unbind = CLOUD_UNBIND_CN;
cloud_menu.unbinding = CLOUD_UNBINDED_CN; cloud_menu.unbinding = CLOUD_UNBINDED_CN;
cloud_menu.disconnected = CLOUD_DISCONNECTED_CN; cloud_menu.disconnected = CLOUD_DISCONNECTED_CN;
cloud_menu.unbinded = CLOUD_UNBINDED_CN;
cloud_menu.disable = CLOUD_DISABLE_CN; cloud_menu.disable = CLOUD_DISABLE_CN;
// //
about_menu.title = ABOUT_TEXT_CN; about_menu.title = ABOUT_TEXT_CN;
@ -1166,9 +1191,30 @@ void disp_language_init() {
filesys_menu.sd_sys = SD_CARD_TEXT_T_CN; filesys_menu.sd_sys = SD_CARD_TEXT_T_CN;
filesys_menu.usb_sys = U_DISK_TEXT_T_CN; filesys_menu.usb_sys = U_DISK_TEXT_T_CN;
// //
more_menu.title = TITLE_MORE_T_CN; more_menu.title = TITLE_MORE_T_CN;
#if ENABLED(USER_CMD_1_ENABLE)
more_menu.custom1 = MORE_CUSTOM1_TEXT_T_CN;
#endif
#if ENABLED(USER_CMD_2_ENABLE)
more_menu.custom2 = MORE_CUSTOM2_TEXT_T_CN;
#endif
#if ENABLED(USER_CMD_3_ENABLE)
more_menu.custom3 = MORE_CUSTOM3_TEXT_T_CN;
#endif
#if ENABLED(USER_CMD_4_ENABLE)
more_menu.custom4 = MORE_CUSTOM4_TEXT_T_CN;
#endif
#if ENABLED(USER_CMD_5_ENABLE)
more_menu.custom5 = MORE_CUSTOM5_TEXT_T_CN;
#endif
#if ENABLED(USER_CMD_6_ENABLE)
more_menu.custom6 = MORE_CUSTOM6_TEXT_T_CN;
#endif
#if ENABLED(USER_CMD_7_ENABLE)
more_menu.custom7 = MORE_CUSTOM7_TEXT_T_CN;
#endif
// WIFI // WIFI
wifi_menu.title = WIFI_TEXT; wifi_menu.title = WIFI_TEXT;
wifi_menu.cloud = CLOUD_TEXT_T_CN; wifi_menu.cloud = CLOUD_TEXT_T_CN;
wifi_menu.reconnect = WIFI_RECONNECT_TEXT_T_CN; wifi_menu.reconnect = WIFI_RECONNECT_TEXT_T_CN;
// CLOUD // CLOUD
@ -1178,6 +1224,7 @@ void disp_language_init() {
cloud_menu.unbind = CLOUD_UNBIND_T_CN; cloud_menu.unbind = CLOUD_UNBIND_T_CN;
cloud_menu.unbinding = CLOUD_UNBINDED_T_CN; cloud_menu.unbinding = CLOUD_UNBINDED_T_CN;
cloud_menu.disconnected = CLOUD_DISCONNECTED_T_CN; cloud_menu.disconnected = CLOUD_DISCONNECTED_T_CN;
cloud_menu.unbinded = CLOUD_UNBINDED_T_CN;
cloud_menu.disable = CLOUD_DISABLE_T_CN; cloud_menu.disable = CLOUD_DISABLE_T_CN;
// //
about_menu.title = ABOUT_TEXT_T_CN; about_menu.title = ABOUT_TEXT_T_CN;
@ -1334,7 +1381,7 @@ void disp_language_init() {
preheat_menu.hotbed = HEATBED_TEXT_EN; preheat_menu.hotbed = HEATBED_TEXT_EN;
preheat_menu.off = CLOSE_TEXT_EN; preheat_menu.off = CLOSE_TEXT_EN;
// //
move_menu.title = TITLE_MOVE_EN; move_menu.title = TITLE_MOVE_EN;
// //
home_menu.title = TITLE_HOME_EN; home_menu.title = TITLE_HOME_EN;
home_menu.stopmove = HOME_STOPMOVE_EN; home_menu.stopmove = HOME_STOPMOVE_EN;
@ -1377,12 +1424,34 @@ void disp_language_init() {
set_menu.machine_para = MACHINE_PARA_EN; set_menu.machine_para = MACHINE_PARA_EN;
set_menu.eepromSet = EEPROM_SETTINGS_EN; set_menu.eepromSet = EEPROM_SETTINGS_EN;
more_menu.title = TITLE_MORE_EN; more_menu.title = TITLE_MORE_EN;
#if ENABLED(USER_CMD_1_ENABLE)
more_menu.custom1 = MORE_CUSTOM1_TEXT_EN;
#endif
#if ENABLED(USER_CMD_2_ENABLE)
more_menu.custom2 = MORE_CUSTOM2_TEXT_EN;
#endif
#if ENABLED(USER_CMD_3_ENABLE)
more_menu.custom3 = MORE_CUSTOM3_TEXT_EN;
#endif
#if ENABLED(USER_CMD_4_ENABLE)
more_menu.custom4 = MORE_CUSTOM4_TEXT_EN;
#endif
#if ENABLED(USER_CMD_5_ENABLE)
more_menu.custom5 = MORE_CUSTOM5_TEXT_EN;
#endif
#if ENABLED(USER_CMD_6_ENABLE)
more_menu.custom6 = MORE_CUSTOM6_TEXT_EN;
#endif
#if ENABLED(USER_CMD_7_ENABLE)
more_menu.custom7 = MORE_CUSTOM7_TEXT_EN;
#endif
// //
filesys_menu.title = TITLE_FILESYS_EN; filesys_menu.title = TITLE_FILESYS_EN;
filesys_menu.sd_sys = SD_CARD_TEXT_EN; filesys_menu.sd_sys = SD_CARD_TEXT_EN;
filesys_menu.usb_sys = U_DISK_TEXT_EN; filesys_menu.usb_sys = U_DISK_TEXT_EN;
// WIFI // WIFI
wifi_menu.title = WIFI_TEXT; wifi_menu.title = WIFI_TEXT;
wifi_menu.cloud = CLOUD_TEXT_EN; wifi_menu.cloud = CLOUD_TEXT_EN;
wifi_menu.reconnect = WIFI_RECONNECT_TEXT_EN; wifi_menu.reconnect = WIFI_RECONNECT_TEXT_EN;
@ -1392,6 +1461,7 @@ void disp_language_init() {
cloud_menu.unbind = CLOUD_UNBIND_EN; cloud_menu.unbind = CLOUD_UNBIND_EN;
cloud_menu.unbinding = CLOUD_UNBINDED_EN; cloud_menu.unbinding = CLOUD_UNBINDED_EN;
cloud_menu.disconnected = CLOUD_DISCONNECTED_EN; cloud_menu.disconnected = CLOUD_DISCONNECTED_EN;
cloud_menu.unbinded = CLOUD_UNBINDED_EN;
cloud_menu.disable = CLOUD_DISABLE_EN; cloud_menu.disable = CLOUD_DISABLE_EN;
// //
about_menu.title = TITLE_ABOUT_EN; about_menu.title = TITLE_ABOUT_EN;
@ -1545,7 +1615,7 @@ void disp_language_init() {
preheat_menu.hotbed = HEATBED_TEXT_RU; preheat_menu.hotbed = HEATBED_TEXT_RU;
preheat_menu.off = CLOSE_TEXT_RU; preheat_menu.off = CLOSE_TEXT_RU;
// //
move_menu.title = MOVE_TEXT_RU; move_menu.title = MOVE_TEXT_RU;
// //
home_menu.title = TITLE_HOME_RU; home_menu.title = TITLE_HOME_RU;
home_menu.stopmove = HOME_STOPMOVE_RU; home_menu.stopmove = HOME_STOPMOVE_RU;
@ -1588,21 +1658,137 @@ void disp_language_init() {
set_menu.machine_para = MACHINE_PARA_RU; set_menu.machine_para = MACHINE_PARA_RU;
set_menu.eepromSet = EEPROM_SETTINGS_RU; set_menu.eepromSet = EEPROM_SETTINGS_RU;
more_menu.title = TITLE_MORE_RU; more_menu.title = TITLE_MORE_RU;
#if ENABLED(USER_CMD_1_ENABLE)
more_menu.custom1 = MORE_CUSTOM1_TEXT_RU;
#endif
#if ENABLED(USER_CMD_2_ENABLE)
more_menu.custom2 = MORE_CUSTOM2_TEXT_RU;
#endif
#if ENABLED(USER_CMD_3_ENABLE)
more_menu.custom3 = MORE_CUSTOM3_TEXT_RU;
#endif
#if ENABLED(USER_CMD_4_ENABLE)
more_menu.custom4 = MORE_CUSTOM4_TEXT_RU;
#endif
#if ENABLED(USER_CMD_5_ENABLE)
more_menu.custom5 = MORE_CUSTOM5_TEXT_RU;
#endif
#if ENABLED(USER_CMD_6_ENABLE)
more_menu.custom6 = MORE_CUSTOM6_TEXT_RU;
#endif
#if ENABLED(USER_CMD_7_ENABLE)
more_menu.custom7 = MORE_CUSTOM7_TEXT_RU;
#endif
// //
filesys_menu.title = TITLE_FILESYS_RU; filesys_menu.title = TITLE_FILESYS_RU;
filesys_menu.sd_sys = SD_CARD_TEXT_RU; filesys_menu.sd_sys = SD_CARD_TEXT_RU;
filesys_menu.usb_sys = U_DISK_TEXT_RU; filesys_menu.usb_sys = U_DISK_TEXT_RU;
// WIFI // WIFI
wifi_menu.title = WIFI_TEXT; wifi_menu.title = WIFI_TEXT;
wifi_menu.cloud = CLOUD_TEXT_RU; wifi_menu.cloud = CLOUD_TEXT_RU;
wifi_menu.reconnect = WIFI_RECONNECT_TEXT_RU; wifi_menu.reconnect = WIFI_RECONNECT_TEXT_RU;
machine_menu.next = NEXT_RU;
machine_menu.previous = PREVIOUS_RU;
machine_menu.enable = ENABLE_RU;
machine_menu.disable = DISABLE_RU;
machine_menu.key_confirm = KEY_CONFIRM_RU;
MachinePara_menu.MachineSetting = MACHINE_TYPE_CNOFIG_RU;
MachinePara_menu.title = MACHINE_PARA_TITLE_RU;
machine_menu.MachineConfigTitle = MACHINE_CONFIG_TITLE_RU;
MachinePara_menu.MotorSetting = MOTOR_CONFIG_RU;
MachinePara_menu.leveling = MACHINE_LEVELING_CONFIG_RU;
MachinePara_menu.AdvanceSetting = ADVANCE_CONFIG_RU;
machine_menu.MotorConfTitle = MOTOR_CONF_TITLE_RU;
machine_menu.MaxFeedRateConf = MAXFEEDRATE_CONF_RU;
machine_menu.AccelerationConf = ACCELERATION_CONF_RU;
machine_menu.JerkConf = JERKCONF_RU;
machine_menu.StepsConf = STEPSCONF_RU;
machine_menu.TMCcurrentConf = TMC_CURRENT_RU;
machine_menu.TMCStepModeConf = TMC_STEP_MODE_RU;
machine_menu.PausePosition = PAUSE_POSITION_RU;
machine_menu.FilamentConf = MACHINE_FILAMENT_CONFIG_RU;
machine_menu.EncoderSettings = ENCODER_SETTINGS_RU;
machine_menu.AdvancedConfTitle = ADVANCED_CONF_TITLE_RU;
machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_RU;
machine_menu.LevelingParaConf = LEVELING_PARA_CONF_RU;
machine_menu.LevelingManuPosConf = LEVELING_MANUAL_POS_RU;
machine_menu.LevelingAutoCommandConf = LEVELING_AUTO_COMMAND_RU;
machine_menu.LevelingAutoZoffsetConf = LEVELING_AUTO_ZOFFSET_RU;
machine_menu.AccelerationConfTitle = ACCELERATION_CONF_TITLE_RU;
machine_menu.PrintAcceleration = PRINT_ACCELERATION_RU;
machine_menu.RetractAcceleration = RETRACT_ACCELERATION_RU;
machine_menu.TravelAcceleration = TRAVEL_ACCELERATION_RU;
machine_menu.X_Acceleration = X_ACCELERATION_RU;
machine_menu.Y_Acceleration = Y_ACCELERATION_RU;
machine_menu.Z_Acceleration = Z_ACCELERATION_RU;
machine_menu.E0_Acceleration = E0_ACCELERATION_RU;
machine_menu.E1_Acceleration = E1_ACCELERATION_RU;
machine_menu.MaxFeedRateConfTitle = MAXFEEDRATE_CONF_TITLE_RU;
machine_menu.XMaxFeedRate = X_MAXFEEDRATE_RU;
machine_menu.YMaxFeedRate = Y_MAXFEEDRATE_RU;
machine_menu.ZMaxFeedRate = Z_MAXFEEDRATE_RU;
machine_menu.E0MaxFeedRate = E0_MAXFEEDRATE_RU;
machine_menu.E1MaxFeedRate = E1_MAXFEEDRATE_RU;
machine_menu.JerkConfTitle = JERK_CONF_TITLE_RU;
machine_menu.X_Jerk = X_JERK_RU;
machine_menu.Y_Jerk = Y_JERK_RU;
machine_menu.Z_Jerk = Z_JERK_RU;
machine_menu.E_Jerk = E_JERK_RU;
machine_menu.StepsConfTitle = STEPS_CONF_TITLE_RU;
machine_menu.X_Steps = X_STEPS_RU;
machine_menu.Y_Steps = Y_STEPS_RU;
machine_menu.Z_Steps = Z_STEPS_RU;
machine_menu.E0_Steps = E0_STEPS_RU;
machine_menu.E1_Steps = E1_STEPS_RU;
machine_menu.TmcCurrentConfTitle = TMC_CURRENT_CONF_TITLE_RU;
machine_menu.X_Current = X_TMC_CURRENT_RU;
machine_menu.Y_Current = Y_TMC_CURRENT_RU;
machine_menu.Z_Current = Z_TMC_CURRENT_RU;
machine_menu.E0_Current = E0_TMC_CURRENT_RU;
machine_menu.E1_Current = E1_TMC_CURRENT_RU;
machine_menu.TmcStepModeConfTitle = TMC_MODE_CONF_TITLE_RU;
machine_menu.X_StepMode = X_TMC_MODE_RU;
machine_menu.Y_StepMode = Y_TMC_MODE_RU;
machine_menu.Z_StepMode = Z_TMC_MODE_RU;
machine_menu.E0_StepMode = E0_TMC_MODE_RU;
machine_menu.E1_StepMode = E1_TMC_MODE_RU;
machine_menu.PausePosText = PAUSE_POSITION_RU;
machine_menu.xPos = PAUSE_POSITION_X_RU;
machine_menu.yPos = PAUSE_POSITION_Y_RU;
machine_menu.zPos = PAUSE_POSITION_Z_RU;
machine_menu.OffsetConfTitle = OFFSET_TITLE_RU;
machine_menu.Xoffset = OFFSET_X_RU;
machine_menu.Yoffset = OFFSET_Y_RU;
machine_menu.Zoffset = OFFSET_Z_RU;
machine_menu.FilamentConfTitle = FILAMENT_CONF_TITLE_RU;
machine_menu.InLength = FILAMENT_IN_LENGTH_RU;
machine_menu.InSpeed = FILAMENT_IN_SPEED_RU;
machine_menu.FilamentTemperature = FILAMENT_TEMPERATURE_RU;
machine_menu.OutLength = FILAMENT_OUT_LENGTH_RU;
machine_menu.OutSpeed = FILAMENT_OUT_SPEED_RU;
machine_menu.EncoderConfTitle = ENCODER_CONF_TITLE_RU;
machine_menu.EncoderConfText = ENCODER_CONF_TEXT_RU;
cloud_menu.title = TITLE_CLOUD_TEXT_RU; cloud_menu.title = TITLE_CLOUD_TEXT_RU;
cloud_menu.bind = CLOUD_BINDED_RU; cloud_menu.bind = CLOUD_BINDED_RU;
cloud_menu.binded = CLOUD_BINDED_RU; cloud_menu.binded = CLOUD_BINDED_RU;
cloud_menu.unbind = CLOUD_UNBIND_RU; cloud_menu.unbind = CLOUD_UNBIND_RU;
cloud_menu.unbinding = CLOUD_UNBINDED_RU; cloud_menu.unbinding = CLOUD_UNBINDED_RU;
cloud_menu.disconnected = CLOUD_DISCONNECTED_RU; cloud_menu.disconnected = CLOUD_DISCONNECTED_RU;
cloud_menu.unbinded = CLOUD_UNBINDED_RU;
cloud_menu.disable = CLOUD_DISABLE_RU; cloud_menu.disable = CLOUD_DISABLE_RU;
// //
about_menu.title = ABOUT_TEXT_RU; about_menu.title = ABOUT_TEXT_RU;
@ -1802,13 +1988,34 @@ void disp_language_init() {
set_menu.machine_para = MACHINE_PARA_SP; set_menu.machine_para = MACHINE_PARA_SP;
set_menu.eepromSet = EEPROM_SETTINGS_SP; set_menu.eepromSet = EEPROM_SETTINGS_SP;
more_menu.title = TITLE_MORE_SP; more_menu.title = TITLE_MORE_SP;
#if ENABLED(USER_CMD_1_ENABLE)
more_menu.custom1 = MORE_CUSTOM1_TEXT_SP;
#endif
#if ENABLED(USER_CMD_2_ENABLE)
more_menu.custom2 = MORE_CUSTOM2_TEXT_SP;
#endif
#if ENABLED(USER_CMD_3_ENABLE)
more_menu.custom3 = MORE_CUSTOM3_TEXT_SP;
#endif
#if ENABLED(USER_CMD_4_ENABLE)
more_menu.custom4 = MORE_CUSTOM4_TEXT_SP;
#endif
#if ENABLED(USER_CMD_5_ENABLE)
more_menu.custom5 = MORE_CUSTOM5_TEXT_SP;
#endif
#if ENABLED(USER_CMD_6_ENABLE)
more_menu.custom6 = MORE_CUSTOM6_TEXT_SP;
#endif
#if ENABLED(USER_CMD_7_ENABLE)
more_menu.custom7 = MORE_CUSTOM7_TEXT_SP;
#endif
// //
filesys_menu.title = TITLE_FILESYS_SP; filesys_menu.title = TITLE_FILESYS_SP;
filesys_menu.sd_sys = SD_CARD_TEXT_SP; filesys_menu.sd_sys = SD_CARD_TEXT_SP;
filesys_menu.usb_sys = U_DISK_TEXT_SP; filesys_menu.usb_sys = U_DISK_TEXT_SP;
// WIFI // WIFI
wifi_menu.title = WIFI_TEXT; wifi_menu.title = WIFI_TEXT;
wifi_menu.cloud = CLOUD_TEXT_SP; wifi_menu.cloud = CLOUD_TEXT_SP;
wifi_menu.reconnect = WIFI_RECONNECT_TEXT_SP; wifi_menu.reconnect = WIFI_RECONNECT_TEXT_SP;
@ -1818,6 +2025,7 @@ void disp_language_init() {
cloud_menu.unbind = CLOUD_UNBIND_SP; cloud_menu.unbind = CLOUD_UNBIND_SP;
cloud_menu.unbinding = CLOUD_UNBINDED_SP; cloud_menu.unbinding = CLOUD_UNBINDED_SP;
cloud_menu.disconnected = CLOUD_DISCONNECTED_SP; cloud_menu.disconnected = CLOUD_DISCONNECTED_SP;
cloud_menu.unbinded = CLOUD_UNBINDED_SP;
cloud_menu.disable = CLOUD_DISABLE_SP; cloud_menu.disable = CLOUD_DISABLE_SP;
// //
about_menu.title = ABOUT_TEXT_SP; about_menu.title = ABOUT_TEXT_SP;
@ -2015,6 +2223,27 @@ void disp_language_init() {
set_menu.machine_para = MACHINE_PARA_FR; set_menu.machine_para = MACHINE_PARA_FR;
set_menu.eepromSet = EEPROM_SETTINGS_FR; set_menu.eepromSet = EEPROM_SETTINGS_FR;
more_menu.title = TITLE_MORE_FR; more_menu.title = TITLE_MORE_FR;
#if ENABLED(USER_CMD_1_ENABLE)
more_menu.custom1 = MORE_CUSTOM1_TEXT_FR;
#endif
#if ENABLED(USER_CMD_2_ENABLE)
more_menu.custom2 = MORE_CUSTOM2_TEXT_FR;
#endif
#if ENABLED(USER_CMD_3_ENABLE)
more_menu.custom3 = MORE_CUSTOM3_TEXT_FR;
#endif
#if ENABLED(USER_CMD_4_ENABLE)
more_menu.custom4 = MORE_CUSTOM4_TEXT_FR;
#endif
#if ENABLED(USER_CMD_5_ENABLE)
more_menu.custom5 = MORE_CUSTOM5_TEXT_FR;
#endif
#if ENABLED(USER_CMD_6_ENABLE)
more_menu.custom6 = MORE_CUSTOM6_TEXT_FR;
#endif
#if ENABLED(USER_CMD_7_ENABLE)
more_menu.custom7 = MORE_CUSTOM7_TEXT_FR;
#endif
// //
filesys_menu.title = TITLE_FILESYS_FR; filesys_menu.title = TITLE_FILESYS_FR;
filesys_menu.sd_sys = SD_CARD_TEXT_FR; filesys_menu.sd_sys = SD_CARD_TEXT_FR;
@ -2023,7 +2252,7 @@ void disp_language_init() {
file_menu.no_file = NO_FILE_FR; file_menu.no_file = NO_FILE_FR;
file_menu.no_file_and_check = NO_FILE_FR; file_menu.no_file_and_check = NO_FILE_FR;
// WIFI // WIFI
wifi_menu.title = WIFI_NAME_TEXT_FR; wifi_menu.title = WIFI_NAME_TEXT_FR;
wifi_menu.cloud = CLOUD_TEXT_FR; wifi_menu.cloud = CLOUD_TEXT_FR;
wifi_menu.reconnect = WIFI_RECONNECT_TEXT_FR; wifi_menu.reconnect = WIFI_RECONNECT_TEXT_FR;
@ -2033,6 +2262,7 @@ void disp_language_init() {
cloud_menu.unbind = CLOUD_UNBIND_FR; cloud_menu.unbind = CLOUD_UNBIND_FR;
cloud_menu.unbinding = CLOUD_UNBINDED_FR; cloud_menu.unbinding = CLOUD_UNBINDED_FR;
cloud_menu.disconnected = CLOUD_DISCONNECTED_FR; cloud_menu.disconnected = CLOUD_DISCONNECTED_FR;
cloud_menu.unbinded = CLOUD_UNBINDED_FR;
cloud_menu.disable = CLOUD_DISABLE_FR; cloud_menu.disable = CLOUD_DISABLE_FR;
// //
about_menu.title = ABOUT_TEXT_FR; about_menu.title = ABOUT_TEXT_FR;
@ -2229,13 +2459,34 @@ void disp_language_init() {
set_menu.machine_para = MACHINE_PARA_IT; set_menu.machine_para = MACHINE_PARA_IT;
set_menu.eepromSet = EEPROM_SETTINGS_IT; set_menu.eepromSet = EEPROM_SETTINGS_IT;
more_menu.title = TITLE_MORE_IT; more_menu.title = TITLE_MORE_IT;
#if ENABLED(USER_CMD_1_ENABLE)
more_menu.custom1 = MORE_CUSTOM1_TEXT_IT;
#endif
#if ENABLED(USER_CMD_2_ENABLE)
more_menu.custom2 = MORE_CUSTOM2_TEXT_IT;
#endif
#if ENABLED(USER_CMD_3_ENABLE)
more_menu.custom3 = MORE_CUSTOM3_TEXT_IT;
#endif
#if ENABLED(USER_CMD_4_ENABLE)
more_menu.custom4 = MORE_CUSTOM4_TEXT_IT;
#endif
#if ENABLED(USER_CMD_5_ENABLE)
more_menu.custom5 = MORE_CUSTOM5_TEXT_IT;
#endif
#if ENABLED(USER_CMD_6_ENABLE)
more_menu.custom6 = MORE_CUSTOM6_TEXT_IT;
#endif
#if ENABLED(USER_CMD_7_ENABLE)
more_menu.custom7 = MORE_CUSTOM7_TEXT_IT;
#endif
// //
filesys_menu.title = TITLE_FILESYS_IT; filesys_menu.title = TITLE_FILESYS_IT;
filesys_menu.sd_sys = SD_CARD_TEXT_IT; filesys_menu.sd_sys = SD_CARD_TEXT_IT;
filesys_menu.usb_sys = U_DISK_TEXT_IT; filesys_menu.usb_sys = U_DISK_TEXT_IT;
// WIFI // WIFI
wifi_menu.title = WIFI_NAME_TEXT_IT; wifi_menu.title = WIFI_NAME_TEXT_IT;
wifi_menu.cloud = CLOSE_TEXT_IT; wifi_menu.cloud = CLOSE_TEXT_IT;
wifi_menu.reconnect = WIFI_RECONNECT_TEXT_IT; wifi_menu.reconnect = WIFI_RECONNECT_TEXT_IT;
@ -2245,6 +2496,7 @@ void disp_language_init() {
cloud_menu.unbind = CLOUD_UNBIND_IT; cloud_menu.unbind = CLOUD_UNBIND_IT;
cloud_menu.unbinding = CLOUD_UNBINDED_IT; cloud_menu.unbinding = CLOUD_UNBINDED_IT;
cloud_menu.disconnected = CLOUD_DISCONNECTED_IT; cloud_menu.disconnected = CLOUD_DISCONNECTED_IT;
cloud_menu.unbinded = CLOUD_UNBINDED_IT;
cloud_menu.disable = CLOUD_DISABLE_IT; cloud_menu.disable = CLOUD_DISABLE_IT;
// //
about_menu.title = ABOUT_TEXT_IT; about_menu.title = ABOUT_TEXT_IT;
@ -2442,13 +2694,34 @@ void disp_language_init() {
set_menu.machine_para = MACHINE_PARA_EN; set_menu.machine_para = MACHINE_PARA_EN;
set_menu.eepromSet = EEPROM_SETTINGS_EN; set_menu.eepromSet = EEPROM_SETTINGS_EN;
// //
more_menu.title = TITLE_MORE_EN; more_menu.title = TITLE_MORE_EN;
#if ENABLED(USER_CMD_1_ENABLE)
more_menu.custom1 = MORE_CUSTOM1_TEXT_EN;
#endif
#if ENABLED(USER_CMD_2_ENABLE)
more_menu.custom2 = MORE_CUSTOM2_TEXT_EN;
#endif
#if ENABLED(USER_CMD_3_ENABLE)
more_menu.custom3 = MORE_CUSTOM3_TEXT_EN;
#endif
#if ENABLED(USER_CMD_4_ENABLE)
more_menu.custom4 = MORE_CUSTOM4_TEXT_EN;
#endif
#if ENABLED(USER_CMD_5_ENABLE)
more_menu.custom5 = MORE_CUSTOM5_TEXT_EN;
#endif
#if ENABLED(USER_CMD_6_ENABLE)
more_menu.custom6 = MORE_CUSTOM6_TEXT_EN;
#endif
#if ENABLED(USER_CMD_7_ENABLE)
more_menu.custom7 = MORE_CUSTOM7_TEXT_EN;
#endif
// //
filesys_menu.title = TITLE_FILESYS_EN; filesys_menu.title = TITLE_FILESYS_EN;
filesys_menu.sd_sys = SD_CARD_TEXT_EN; filesys_menu.sd_sys = SD_CARD_TEXT_EN;
filesys_menu.usb_sys = U_DISK_TEXT_EN; filesys_menu.usb_sys = U_DISK_TEXT_EN;
// WIFI // WIFI
wifi_menu.title = WIFI_TEXT; wifi_menu.title = WIFI_TEXT;
wifi_menu.cloud = CLOUD_TEXT_EN; wifi_menu.cloud = CLOUD_TEXT_EN;
wifi_menu.reconnect = WIFI_RECONNECT_TEXT_EN; wifi_menu.reconnect = WIFI_RECONNECT_TEXT_EN;
@ -2458,6 +2731,7 @@ void disp_language_init() {
cloud_menu.unbind = CLOUD_UNBIND_EN; cloud_menu.unbind = CLOUD_UNBIND_EN;
cloud_menu.unbinding = CLOUD_UNBINDED_EN; cloud_menu.unbinding = CLOUD_UNBINDED_EN;
cloud_menu.disconnected = CLOUD_DISCONNECTED_EN; cloud_menu.disconnected = CLOUD_DISCONNECTED_EN;
cloud_menu.unbinded = CLOUD_UNBINDED_EN;
cloud_menu.disable = CLOUD_DISABLE_EN; cloud_menu.disable = CLOUD_DISABLE_EN;
// //
about_menu.title = TITLE_ABOUT_EN; about_menu.title = TITLE_ABOUT_EN;

View file

@ -118,6 +118,7 @@ typedef struct machine_common_disp{
const char *ProbeZspeed; const char *ProbeZspeed;
const char *enable; const char *enable;
const char *disable; const char *disable;
const char *locked;
const char *z_min; const char *z_min;
const char *z_max; const char *z_max;
@ -456,6 +457,13 @@ extern filesys_menu_def filesys_menu;
typedef struct more_menu_disp { typedef struct more_menu_disp {
const char *title; const char *title;
const char *custom1;
const char *custom2;
const char *custom3;
const char *custom4;
const char *custom5;
const char *custom6;
const char *custom7;
const char *back; const char *back;
} more_menu_def; } more_menu_def;
@ -757,15 +765,15 @@ extern eeprom_def eeprom_menu;
#define AXIS_Y_DEC_TEXT "Y-" #define AXIS_Y_DEC_TEXT "Y-"
#define AXIS_Z_ADD_TEXT "Z+" #define AXIS_Z_ADD_TEXT "Z+"
#define AXIS_Z_DEC_TEXT "Z-" #define AXIS_Z_DEC_TEXT "Z-"
#define TEXT_001MM "0.01mm" #define TEXT_001MM "0.01 mm"
#define TEXT_005MM "0.05mm" #define TEXT_005MM "0.05 mm"
#define TEXT_01MM "0.1mm" #define TEXT_01MM "0.1 mm"
#define TEXT_1MM "1mm" #define TEXT_1MM "1 mm"
#define TEXT_10MM "10mm" #define TEXT_10MM "10 mm"
#define EXTRUDE_1MM_TEXT "1mm" #define EXTRUDE_1MM_TEXT "1 mm"
#define EXTRUDE_5MM_TEXT "5mm" #define EXTRUDE_5MM_TEXT "5 mm"
#define EXTRUDE_10MM_TEXT "10mm" #define EXTRUDE_10MM_TEXT "10 mm"
#define STEP_1PERCENT "1%" #define STEP_1PERCENT "1%"
#define STEP_5PERCENT "5%" #define STEP_5PERCENT "5%"
@ -819,6 +827,6 @@ extern eeprom_def eeprom_menu;
#define DIALOG_UPDATE_WIFI_WEB_EN "Updating wifi model web data" #define DIALOG_UPDATE_WIFI_WEB_EN "Updating wifi model web data"
#define DIALOG_UPDATE_NO_DEVICE_EN "Please check whether\nmemory device inserted!" #define DIALOG_UPDATE_NO_DEVICE_EN "Please check whether\nmemory device inserted!"
#define ZOFFSET_STEP001 "0.01mm" #define ZOFFSET_STEP001 "0.01 mm"
#define ZOFFSET_STEP01 "0.1mm" #define ZOFFSET_STEP01 "0.1 mm"
#define ZOFFSET_STEP1 "1mm" #define ZOFFSET_STEP1 "1 mm"

View file

@ -55,10 +55,29 @@ WifiSerial::WifiSerial(usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin) {
static void disable_timer_if_necessary(timer_dev *dev, uint8 ch) { static void disable_timer_if_necessary(timer_dev *dev, uint8 ch) {
if (dev) timer_set_mode(dev, ch, TIMER_DISABLED); if (dev) timer_set_mode(dev, ch, TIMER_DISABLED);
} }
static void usart_enable_no_irq(usart_dev *usart_device, bool with_irq) {
if (with_irq) usart_enable(usart_device);
else {
usart_reg_map *regs = usart_device->regs;
regs->CR1 |= (USART_CR1_TE | USART_CR1_RE);// don't change the word length etc, and 'or' in the patten not overwrite |USART_CR1_M_8N1);
regs->CR1 |= USART_CR1_UE;
}
}
#elif STM32_MCU_SERIES == STM32_SERIES_F2 || STM32_MCU_SERIES == STM32_SERIES_F4 #elif STM32_MCU_SERIES == STM32_SERIES_F2 || STM32_MCU_SERIES == STM32_SERIES_F4
#define disable_timer_if_necessary(dev, ch) ((void)0) #define disable_timer_if_necessary(dev, ch) ((void)0)
static void usart_enable_no_irq(usart_dev *usart_device, bool with_irq) {
if (with_irq) usart_enable(usart_device);
else {
usart_reg_map *regs = usart_device->regs;
regs->CR1 |= (USART_CR1_TE | USART_CR1_RE);// don't change the word length etc, and 'or' in the patten not overwrite |USART_CR1_M_8N1);
regs->CR1 |= USART_CR1_UE;
}
}
#else #else
#warning "Unsupported STM32 series; timer conflicts are possible" #warning "Unsupported STM32 series; timer conflicts are possible"
#define usart_enable_no_irq(X, Y) usart_enable(X)
#endif #endif
void WifiSerial::begin(uint32 baud) { begin(baud, SERIAL_8N1); } void WifiSerial::begin(uint32 baud) { begin(baud, SERIAL_8N1); }
@ -89,7 +108,7 @@ void WifiSerial::begin(uint32 baud, uint8_t config) {
txi->gpio_device, txi->gpio_bit, txi->gpio_device, txi->gpio_bit,
config); config);
usart_set_baud_rate(this->usart_device, USART_USE_PCLK, baud); usart_set_baud_rate(this->usart_device, USART_USE_PCLK, baud);
usart_enable(this->usart_device); usart_enable_no_irq(this->usart_device, baud == WIFI_BAUDRATE);
} }
void WifiSerial::end(void) { void WifiSerial::end(void) {

View file

@ -89,8 +89,9 @@ class WifiSerial {
int wifi_rb_is_full(void); int wifi_rb_is_full(void);
private:
struct usart_dev *usart_device; struct usart_dev *usart_device;
private:
uint8 tx_pin; uint8 tx_pin;
uint8 rx_pin; uint8 rx_pin;
}; };

View file

@ -26,6 +26,7 @@
#include "draw_ui.h" #include "draw_ui.h"
#include "wifi_module.h" #include "wifi_module.h"
#include "wifi_upload.h" #include "wifi_upload.h"
#include "SPI_TFT.h"
#if ENABLED(MKS_WIFI_MODULE) #if ENABLED(MKS_WIFI_MODULE)
@ -36,6 +37,8 @@
#include "../../../../lcd/marlinui.h" #include "../../../../lcd/marlinui.h"
#include "../../../../sd/cardreader.h" #include "../../../../sd/cardreader.h"
#include "../../../../module/planner.h" #include "../../../../module/planner.h"
#include "../../../../module/servo.h"
#include "../../../../module/probe.h"
#if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(POWER_LOSS_RECOVERY)
#include "../../../../feature/powerloss.h" #include "../../../../feature/powerloss.h"
#endif #endif
@ -109,10 +112,9 @@ extern IP_PARA ipPara;
extern CLOUD_PARA cloud_para; extern CLOUD_PARA cloud_para;
extern bool once_flag, flash_preview_begin, default_preview_flg, gcode_preview_over; extern bool once_flag, flash_preview_begin, default_preview_flg, gcode_preview_over;
extern bool flash_dma_mode;
uint32_t getWifiTick() { uint32_t getWifiTick() { return millis(); }
return millis();
}
uint32_t getWifiTickDiff(int32_t lastTick, int32_t curTick) { uint32_t getWifiTickDiff(int32_t lastTick, int32_t curTick) {
if (lastTick <= curTick) if (lastTick <= curTick)
@ -149,40 +151,123 @@ void mount_file_sys(uint8_t disk_type) {
} }
} }
static void dma_init() { #include <libmaple/timer.h>
#if 0 #include <libmaple/util.h>
__HAL_RCC_DMA1_CLK_ENABLE(); #include <libmaple/rcc.h>
//HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0); #include <boards.h>
HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 4, 0); #include <wirish.h>
HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn);
hdma_usart1_rx.Instance = DMA1_Channel5; #include <libmaple/dma.h>
//hdma_usart1_rx.Init.Channel = DMA_CHANNEL_4; #include <libmaple/bitband.h>
hdma_usart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_usart1_rx.Init.PeriphInc = DMA_PINC_DISABLE; #include <libmaple/libmaple.h>
hdma_usart1_rx.Init.MemInc = DMA_MINC_ENABLE; #include <libmaple/gpio.h>
hdma_usart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; #include <libmaple/usart.h>
hdma_usart1_rx.Init.MemDataAlignment = DMA_PDATAALIGN_BYTE; #include <libmaple/ring_buffer.h>
hdma_usart1_rx.Init.Mode = DMA_NORMAL;
hdma_usart1_rx.Init.Priority = DMA_PRIORITY_VERY_HIGH; void changeFlashMode(const bool dmaMode) {
if (HAL_DMA_Init((DMA_HandleTypeDef *)&hdma_usart1_rx) != HAL_OK) { if (flash_dma_mode != dmaMode) {
Error_Handler(); flash_dma_mode = dmaMode;
if (!flash_dma_mode) {
dma_disable(DMA1, DMA_CH5);
dma_clear_isr_bits(DMA1, DMA_CH4);
}
}
}
static bool longName2DosName(const char *longName, uint8_t *dosName) {
uint8_t i;
for (i = FILENAME_LENGTH; i--;) dosName[i] = '\0';
while (*longName) {
uint8_t c = *longName++;
if (c == '.') { // For a dot...
if (i == 0) return false;
strcat((char *)dosName, ".GCO");
break;
}
else {
if (c < 0x21 || c == 0x7F) return false; // Check size, non-printable characters
// Fail for illegal characters
PGM_P p = PSTR("|<>^+=?/[];,*\"\\");
while (const uint8_t b = pgm_read_byte(p++)) if (b == c) return false;
dosName[i++] = c + (WITHIN(c, 'a', 'z') ? 'A' - 'a' : 0); // Uppercase required for 8.3 name
}
if (i >= 5) {
strcat((char *)dosName, "~1.GCO");
break;
}
}
return dosName[0] != '\0'; // Return true if any name was set
}
static int storeRcvData(volatile uint8_t *bufToCpy, int32_t len) {
unsigned char tmpW = wifiDmaRcvFifo.write_cur;
if (len > UDISKBUFLEN) return 0;
if (wifiDmaRcvFifo.state[tmpW] == udisk_buf_empty) {
memcpy((unsigned char *) wifiDmaRcvFifo.bufferAddr[tmpW], (uint8_t *)bufToCpy, len);
wifiDmaRcvFifo.state[tmpW] = udisk_buf_full;
wifiDmaRcvFifo.write_cur = (tmpW + 1) % TRANS_RCV_FIFO_BLOCK_NUM;
return 1;
} }
return 0;
}
HAL_DMA_Start_IT((DMA_HandleTypeDef *)&hdma_usart1_rx, static void esp_dma_pre() {
(uint32_t)&huart1.Instance->DR, dma_channel_reg_map *channel_regs = dma_tube_regs(DMA1, DMA_CH5);
(uint32_t)(&WifiRxFifo.uartTxBuffer[0]),
UART_RX_BUFFER_SIZE);
//HAL_UART_Receive_DMA(&huart1,(uint8_t*)&WifiRxFifo.uartTxBuffer[0], UART_RX_BUFFER_SIZE); CBI32(channel_regs->CCR, 0);
channel_regs->CMAR = (uint32_t)WIFISERIAL.usart_device->rb->buf;
channel_regs->CNDTR = 0x0000;
channel_regs->CNDTR = UART_RX_BUFFER_SIZE;
DMA1->regs->IFCR = 0xF0000;
SBI32(channel_regs->CCR, 0);
}
/* Enable the DMA transfer for the receiver request by setting the DMAR bit static void dma_ch5_irq_handle() {
in the UART CR3 register */ uint8 status_bits = dma_get_isr_bits(DMA1, DMA_CH5);
SET_BIT(huart1.Instance->CR3, USART_CR3_DMAR); dma_clear_isr_bits(DMA1, DMA_CH5);
if (status_bits & 0x8) {
// DMA transmit Error
}
else if (status_bits & 0x2) {
// DMA transmit complete
if (esp_state == TRANSFER_IDLE)
esp_state = TRANSFERING;
if (storeRcvData(WIFISERIAL.usart_device->rb->buf, UART_RX_BUFFER_SIZE)) {
esp_dma_pre();
if (wifiTransError.flag != 0x1)
WIFI_IO1_RESET();
}
else {
WIFI_IO1_SET();
esp_state = TRANSFER_STORE;
}
}
else if (status_bits & 0x4) {
// DMA transmit half
WIFI_IO1_SET();
}
}
static void wifi_usart_dma_init() {
dma_init(DMA1);
uint32_t flags = ( DMA_MINC_MODE | DMA_TRNS_CMPLT | DMA_HALF_TRNS | DMA_TRNS_ERR);
dma_xfer_size dma_bit_size = DMA_SIZE_8BITS;
dma_setup_transfer(DMA1, DMA_CH5, &USART1_BASE->DR, dma_bit_size,
(volatile void*)WIFISERIAL.usart_device->rb->buf, dma_bit_size, flags);// Transmit buffer DMA
dma_set_priority(DMA1, DMA_CH5, DMA_PRIORITY_LOW);
dma_attach_interrupt(DMA1, DMA_CH5, &dma_ch5_irq_handle);
dma_clear_isr_bits(DMA1, DMA_CH5);
dma_set_num_transfers(DMA1, DMA_CH5, UART_RX_BUFFER_SIZE);
bb_peri_set_bit(&USART1_BASE->CR3, USART_CR3_DMAR_BIT, 1);
dma_enable(DMA1, DMA_CH5); // enable transmit
#endif
for (uint8_t i = 0; i < TRANS_RCV_FIFO_BLOCK_NUM; i++) { for (uint8_t i = 0; i < TRANS_RCV_FIFO_BLOCK_NUM; i++) {
wifiDmaRcvFifo.bufferAddr[i] = &bmp_public_buf[1024 * i]; wifiDmaRcvFifo.bufferAddr[i] = &bmp_public_buf[1024 * i];
wifiDmaRcvFifo.state[i] = udisk_buf_empty; wifiDmaRcvFifo.state[i] = udisk_buf_empty;
@ -193,113 +278,39 @@ static void dma_init() {
wifiDmaRcvFifo.write_cur = 0; wifiDmaRcvFifo.write_cur = 0;
} }
static void wifi_deInit() {
#if 0
HAL_DMA_Abort((DMA_HandleTypeDef *)&hdma_usart1_rx);
HAL_DMA_DeInit((DMA_HandleTypeDef *)&hdma_usart1_rx);
__HAL_DMA_DISABLE((DMA_HandleTypeDef *)&hdma_usart1_rx);
#endif
}
extern uint8_t mksUsart1Rx;
void esp_port_begin(uint8_t interrupt) { void esp_port_begin(uint8_t interrupt) {
WifiRxFifo.uart_read_point = 0; WifiRxFifo.uart_read_point = 0;
WifiRxFifo.uart_write_point = 0; WifiRxFifo.uart_write_point = 0;
#if 0
NVIC_InitTypeDef NVIC_InitStructure;
USART_InitTypeDef USART_InitStructure; #if 1
GPIO_InitTypeDef GPIO_InitStruct;
WifiRxFifo.uart_read_point = 0; #if ENABLED(MKS_WIFI_MODULE)
WifiRxFifo.uart_write_point = 0; WIFISERIAL.end();
memset((uint8_t*)WifiRxFifo.uartTxBuffer, 0, sizeof(WifiRxFifo.uartTxBuffer)); if (interrupt) {
for (uint16_t i = 0; i < 65535; i++) { /*nada*/ }
if (interrupt) { WIFISERIAL.begin(WIFI_BAUDRATE);
#if TAN uint32_t serial_connect_timeout = millis() + 1000UL;
wifi_deInit (); while (PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
}
//SZ_STM32_COMInit(COM1, 115200); else {
__HAL_UART_ENABLE_IT(USART1, USART_IT_RXNE); WIFISERIAL.usart_device->regs->CR1 &= ~USART_CR1_RXNEIE;
WIFISERIAL.begin(WIFI_UPLOAD_BAUDRATE);
USART_InitStructure.USART_BaudRate = 115200; //<2F><><EFBFBD>ڵIJ<DAB5><C4B2><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3><EFBFBD><EFBFBD><EFBFBD>115200 <20><>ߴ<EFBFBD>4.5Mbits/s wifi_usart_dma_init();
USART_InitStructure.USART_WordLength = USART_WordLength_8b; //<2F><><EFBFBD><EFBFBD><EFBFBD>ֳ<EFBFBD><D6B3><EFBFBD>(8λ<38><CEBB>9λ) }
USART_InitStructure.USART_StopBits = USART_StopBits_1; //<2F><><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ֹͣλ-֧<><D6A7>1<EFBFBD><31>2<EFBFBD><32>ֹͣλ
USART_InitStructure.USART_Parity = USART_Parity_No; //<2F><><EFBFBD><EFBFBD>żУ<C5BC><D0A3>
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; //<2F><>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //˫<><CBAB>ģʽ<C4A3><CABD>ʹ<EFBFBD>ܷ<EFBFBD><DCB7>ͺͽ<CDBA><CDBD><EFBFBD>
__HAL_RCC_USART1_CLK_ENABLE();
GPIO_InitStruct.Pin = TFT_WIFI_TX_Pin|TFT_WIFI_RX_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pin = TFT_WIFI_RX_Pin;
HAL_GPIO_Init(GPIOA,&GPIO_InitStruct);
USART_Init(USART1, &USART_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
// NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
// NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
#else
HAL_UART_DeInit(&huart1);
MX_USART1_UART_Init(3);
//__HAL_UART_ENABLE_IT(&huart1, UART_IT_RXNE);
HAL_UART_Receive_IT(&huart1,&mksUsart1Rx,1);
#endif #endif
}
else{
#if 0
NVIC_DisableIRQ(SZ_STM32_COM1_IRQn);
USART_Cmd(SZ_STM32_COM1, DISABLE); #else
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, DISABLE); #if MKS_WIFI_MODULE
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); WIFISERIAL.end();
for (uint16_t i = 0; i < 65535; i++) { /*nada*/ }
SZ_STM32_COMInit(COM1, 1958400); WIFISERIAL.begin(interrupt ? WIFI_BAUDRATE : WIFI_UPLOAD_BAUDRATE);
uint32_t serial_connect_timeout = millis() + 1000UL;
USART_Cmd(SZ_STM32_COM1, ENABLE); while (PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
wifi_delay(10);
dma_init();
#endif #endif
HAL_UART_DeInit(&huart1); if (!interrupt) wifi_usart_dma_init();
MX_USART1_UART_Init(5);
//dma1_5_IRQ_sel = 1;
dma_init();
}
#endif #endif
#if ENABLED(MKS_WIFI_MODULE)
WIFISERIAL.end();
for (uint16_t i = 0; i < 65535; i++) { /*nada*/ }
WIFISERIAL.begin(interrupt ? WIFI_BAUDRATE : WIFI_UPLOAD_BAUDRATE);
const millis_t serial_connect_timeout = millis() + 1000UL;
while (/*!WIFISERIAL && */PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
if (interrupt) {
//for (uint8_t i=0;i<100;i++) WIFISERIAL.write(0x33);
}
else {
//for (uint16_t i=0;i<65535;i++); //WIFISERIAL.write(0x33);
}
#endif
if (!interrupt) dma_init();
} }
#if ENABLED(MKS_WIFI_MODULE) #if ENABLED(MKS_WIFI_MODULE)
@ -441,10 +452,12 @@ int package_to_wifi(WIFI_RET_TYPE type, uint8_t *buf, int len) {
ZERO(buf_to_wifi); ZERO(buf_to_wifi);
index_to_wifi = 0; index_to_wifi = 0;
} }
return 1;
} }
int send_to_wifi(char *buf, int len) { return package_to_wifi(WIFI_TRANS_INF, buf, len); } #define SEND_OK_TO_WIFI send_to_wifi((uint8_t *)"ok\r\n", strlen("ok\r\n"))
int send_to_wifi(uint8_t *buf, int len) { return package_to_wifi(WIFI_TRANS_INF, buf, len); }
void set_cur_file_sys(int fileType) { gCfgItems.fileSysType = fileType; } void set_cur_file_sys(int fileType) { gCfgItems.fileSysType = fileType; }
@ -463,9 +476,9 @@ void get_file_list(char *path) {
char wait_ip_back_flag = 0; char wait_ip_back_flag = 0;
typedef struct { typedef struct {
char write_buf[513];
int write_index; int write_index;
uint8_t saveFileName[30]; uint8_t saveFileName[30];
uint8_t fileTransfer;
uint32_t fileLen; uint32_t fileLen;
uint32_t tick_begin; uint32_t tick_begin;
uint32_t tick_end; uint32_t tick_end;
@ -475,22 +488,43 @@ FILE_WRITER file_writer;
int32_t lastFragment = 0; int32_t lastFragment = 0;
char lastBinaryCmd[50] = { 0 }; char saveFilePath[50];
int total_write = 0; static SdFile upload_file, *upload_curDir;
char binary_head[2] = { 0, 0 }; static filepos_t pos;
unsigned char binary_data_len = 0;
int write_to_file(char *buf, int len) { int write_to_file(char *buf, int len) {
for (int i = 0; i < len; i++) { int i;
file_writer.write_buf[file_writer.write_index++] = buf[i]; int res = 0;
for (i = 0; i < len; i++) {
public_buf[file_writer.write_index++] = buf[i];
if (file_writer.write_index >= 512) { if (file_writer.write_index >= 512) {
int res = card.write(file_writer.write_buf, file_writer.write_index); res = upload_file.write(public_buf, file_writer.write_index);
if (res == -1) return -1;
ZERO(file_writer.write_buf); if (res == -1) {
upload_file.close();
const char * const fname = card.diveToFile(true, upload_curDir, saveFilePath);
if (upload_file.open(upload_curDir, fname, O_WRITE)) {
upload_file.setpos(&pos);
res = upload_file.write(public_buf, file_writer.write_index);
}
}
if (res == -1) {
return -1;
}
upload_file.getpos(&pos);
file_writer.write_index = 0; file_writer.write_index = 0;
} }
} }
if (res == -1) {
memset(public_buf, 0, sizeof(public_buf));
file_writer.write_index = 0;
return -1;
}
return 0; return 0;
} }
@ -543,10 +577,8 @@ uint8_t Explore_Disk(char* path , uint8_t recu_level) {
for (uint8_t i = 0; i < fileCnt; i++) { for (uint8_t i = 0; i < fileCnt; i++) {
card.getfilename_sorted(SD_ORDER(i, fileCnt)); card.getfilename_sorted(SD_ORDER(i, fileCnt));
//if (card.longFilename[0] == 0) memset(tmp, 0, sizeof(tmp));
strcpy(tmp, card.filename); strcpy(tmp, card.filename);
//else
// strcpy(tmp, card.longFilename);
ZERO(Fstream); ZERO(Fstream);
strcpy(Fstream, tmp); strcpy(Fstream, tmp);
@ -584,6 +616,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
switch (cmd_value) { switch (cmd_value) {
case 20: // M20: Print SD / µdisk file case 20: // M20: Print SD / µdisk file
file_writer.fileTransfer = 0;
if (uiCfg.print_state == IDLE) { if (uiCfg.print_state == IDLE) {
int index = 0; int index = 0;
@ -591,8 +624,8 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
gCfgItems.fileSysType = FILE_SYS_SD; gCfgItems.fileSysType = FILE_SYS_SD;
send_to_wifi((uint8_t *)"Begin file list\r\n", strlen("Begin file list\r\n")); send_to_wifi((uint8_t *)"Begin file list\r\n", strlen("Begin file list\r\n"));
get_file_list((char *)"0:/"); get_file_list((char *)"0:/");
send_to_wifi((char *)"End file list\r\n", strlen("End file list\r\n")); send_to_wifi((uint8_t *)"End file list\r\n", strlen("End file list\r\n"));
send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); SEND_OK_TO_WIFI;
break; break;
} }
@ -613,14 +646,14 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
get_file_list(path); get_file_list(path);
send_to_wifi((uint8_t *)"End file list\r\n", strlen("End file list\r\n")); send_to_wifi((uint8_t *)"End file list\r\n", strlen("End file list\r\n"));
} }
send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); SEND_OK_TO_WIFI;
} }
} }
break; break;
case 21: case 21:
/*init sd card*/ /*init sd card*/
send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); SEND_OK_TO_WIFI;
break; break;
case 23: case 23:
@ -632,15 +665,40 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
if (strstr((char *)&tmpStr[index], ".g") || strstr((char *)&tmpStr[index], ".G")) { if (strstr((char *)&tmpStr[index], ".g") || strstr((char *)&tmpStr[index], ".G")) {
if (strlen((char *)&tmpStr[index]) < 80) { if (strlen((char *)&tmpStr[index]) < 80) {
ZERO(list_file.file_name[sel_id]); ZERO(list_file.file_name[sel_id]);
ZERO(list_file.long_name[sel_id]);
uint8_t has_path_selected = 0;
if (gCfgItems.wifi_type == ESP_WIFI) { if (gCfgItems.wifi_type == ESP_WIFI) {
if (strncmp((char *)&tmpStr[index], "1:", 2) == 0) if (strncmp((char *)&tmpStr[index], "1:", 2) == 0) {
gCfgItems.fileSysType = FILE_SYS_SD; gCfgItems.fileSysType = FILE_SYS_SD;
else if (strncmp((char *)&tmpStr[index], "0:", 2) == 0) has_path_selected = 1;
}
else if (strncmp((char *)&tmpStr[index], "0:", 2) == 0) {
gCfgItems.fileSysType = FILE_SYS_USB; gCfgItems.fileSysType = FILE_SYS_USB;
has_path_selected = 1;
}
else if (tmpStr[index] != '/') else if (tmpStr[index] != '/')
strcat((char *)list_file.file_name[0], "/"); strcat((char *)list_file.file_name[sel_id], "/");
strcat((char *)list_file.file_name[sel_id], (char *)&tmpStr[index]);
if (file_writer.fileTransfer == 1) {
uint8_t dosName[FILENAME_LENGTH];
uint8_t fileName[sizeof(list_file.file_name[sel_id])];
fileName[0] = '\0';
if (has_path_selected == 1) {
strcat((char *)fileName, (char *)&tmpStr[index + 3]);
strcat((char *)list_file.file_name[sel_id], "/");
}
else strcat((char *)fileName, (char *)&tmpStr[index]);
if (!longName2DosName((const char *)fileName, dosName)) {
strcpy(list_file.file_name[sel_id], "notValid");
}
strcat((char *)list_file.file_name[sel_id], (char *)dosName);
strcat((char *)list_file.long_name[sel_id], (char *)dosName);
}
else {
strcat((char *)list_file.file_name[sel_id], (char *)&tmpStr[index]);
strcat((char *)list_file.long_name[sel_id], (char *)&tmpStr[index]);
}
} }
else else
@ -656,7 +714,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
send_to_wifi((uint8_t *)"file.open failed\r\n", strlen("file.open failed\r\n")); send_to_wifi((uint8_t *)"file.open failed\r\n", strlen("file.open failed\r\n"));
strcpy(list_file.file_name[sel_id], "notValid"); strcpy(list_file.file_name[sel_id], "notValid");
} }
send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); SEND_OK_TO_WIFI;
} }
} }
} }
@ -680,6 +738,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
SdFile file; SdFile file;
SdFile *curDir; SdFile *curDir;
card.endFilePrint();
const char * const fname = card.diveToFile(true, curDir, cur_name); const char * const fname = card.diveToFile(true, curDir, cur_name);
if (!fname) return; if (!fname) return;
if (file.open(curDir, fname, O_READ)) { if (file.open(curDir, fname, O_READ)) {
@ -726,7 +785,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
lv_draw_printing(); lv_draw_printing();
} }
} }
send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); SEND_OK_TO_WIFI;
break; break;
case 25: case 25:
@ -745,7 +804,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
else else
default_preview_flg = true; default_preview_flg = true;
lv_draw_printing(); lv_draw_printing();
send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); SEND_OK_TO_WIFI;
} }
break; break;
@ -762,7 +821,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
lv_draw_ready_print(); lv_draw_ready_print();
send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); SEND_OK_TO_WIFI;
} }
break; break;
@ -805,8 +864,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
ZERO(tempBuf); ZERO(tempBuf);
sprintf((char *)tempBuf, "Writing to file: %s\r\n", (char *)file_writer.saveFileName); sprintf((char *)tempBuf, "Writing to file: %s\r\n", (char *)file_writer.saveFileName);
wifi_ret_ack(); wifi_ret_ack();
send_to_wifi((char *)tempBuf, strlen((char *)tempBuf)); send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf));
total_write = 0;
wifi_link_state = WIFI_WAIT_TRANS_START; wifi_link_state = WIFI_WAIT_TRANS_START;
} }
else { else {
@ -822,7 +880,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
case 991: case 991:
ZERO(tempBuf); ZERO(tempBuf);
if (cmd_value == 105) { if (cmd_value == 105) {
send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); SEND_OK_TO_WIFI;
sprintf((char *)tempBuf,"T:%.1f /%.1f B:%.1f /%.1f T0:%.1f /%.1f T1:%.1f /%.1f @:0 B@:0\r\n", sprintf((char *)tempBuf,"T:%.1f /%.1f B:%.1f /%.1f T0:%.1f /%.1f T1:%.1f /%.1f @:0 B@:0\r\n",
(float)thermalManager.temp_hotend[0].celsius, (float)thermalManager.temp_hotend[0].target, (float)thermalManager.temp_hotend[0].celsius, (float)thermalManager.temp_hotend[0].target,
@ -891,7 +949,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
} }
else if (uiCfg.print_state == PAUSED) { else if (uiCfg.print_state == PAUSED) {
wifi_ret_ack(); wifi_ret_ack();
send_to_wifi((char *)"M997 PAUSE\r\n", strlen("M997 PAUSE\r\n")); send_to_wifi((uint8_t *)"M997 PAUSE\r\n", strlen("M997 PAUSE\r\n"));
} }
else if (uiCfg.print_state == REPRINTING) { else if (uiCfg.print_state == REPRINTING) {
wifi_ret_ack(); wifi_ret_ack();
@ -913,8 +971,8 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
case 115: case 115:
ZERO(tempBuf); ZERO(tempBuf);
send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); SEND_OK_TO_WIFI;
send_to_wifi((char *)"FIRMWARE_NAME:Robin_nano\r\n", strlen("FIRMWARE_NAME:Robin_nano\r\n")); send_to_wifi((uint8_t *)"FIRMWARE_NAME:Robin_nano\r\n", strlen("FIRMWARE_NAME:Robin_nano\r\n"));
break; break;
default: default:
@ -935,7 +993,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
index++; index++;
} }
if (left - WIFI_GCODE_BUFFER_LEAST_SIZE >= strlen((const char *)cmd_line)) if (left - WIFI_GCODE_BUFFER_LEAST_SIZE >= strlen((const char *)cmd_line))
send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); SEND_OK_TO_WIFI;
else else
need_ok_later = true; need_ok_later = true;
} }
@ -961,7 +1019,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
index++; index++;
} }
if (left_g - WIFI_GCODE_BUFFER_LEAST_SIZE >= strlen((const char *)cmd_line)) if (left_g - WIFI_GCODE_BUFFER_LEAST_SIZE >= strlen((const char *)cmd_line))
send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); SEND_OK_TO_WIFI;
else else
need_ok_later = true; need_ok_later = true;
} }
@ -1191,29 +1249,6 @@ void utf8_2_unicode(uint8_t *source,uint8_t Len) {
COPY(source, FileName_unicode); COPY(source, FileName_unicode);
} }
char saveFilePath[50];
static bool longName2DosName(const char* longName, uint8_t* dosName) {
uint8_t i = 11;
while (i--) dosName[i] = '\0';
while (*longName) {
uint8_t c = *longName++;
if (c == '.') { // For a dot...
if (i == 0) return false;
else { strcat((char *)dosName,".GCO"); return dosName[0] != '\0'; }
}
else {
// Fail for illegal characters
PGM_P p = PSTR("|<>^+=?/[];,*\"\\");
while (uint8_t b = pgm_read_byte(p++)) if (b == c) return false;
if (c < 0x21 || c == 0x7F) return false; // Check size, non-printable characters
dosName[i++] = (c < 'a' || c > 'z') ? (c) : (c + ('A' - 'a')); // Uppercase required for 8.3 name
}
if (i >= 5) strcat((char *)dosName,"~1.GCO");
}
return dosName[0] != '\0'; // Return true if any name was set
}
static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) { static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) {
uint8_t fileNameLen = *msg; uint8_t fileNameLen = *msg;
@ -1226,7 +1261,7 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) {
utf8_2_unicode(file_writer.saveFileName,fileNameLen); utf8_2_unicode(file_writer.saveFileName,fileNameLen);
ZERO(file_writer.write_buf); ZERO(public_buf);
if (strlen((const char *)file_writer.saveFileName) > sizeof(saveFilePath)) if (strlen((const char *)file_writer.saveFileName) > sizeof(saveFilePath))
return; return;
@ -1234,11 +1269,7 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) {
ZERO(saveFilePath); ZERO(saveFilePath);
if (gCfgItems.fileSysType == FILE_SYS_SD) { if (gCfgItems.fileSysType == FILE_SYS_SD) {
//sprintf((char *)saveFilePath, "/%s", file_writer.saveFileName); TERN_(SDSUPPORT, card.mount());
card.mount();
//ZERO(list_file.long_name[sel_id]);
//memcpy(list_file.long_name[sel_id],file_writer.saveFileName,sizeof(list_file.long_name[sel_id]));
} }
else if (gCfgItems.fileSysType == FILE_SYS_USB) { else if (gCfgItems.fileSysType == FILE_SYS_USB) {
@ -1266,26 +1297,19 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) {
lv_draw_dialog(DIALOG_TYPE_UPLOAD_FILE); lv_draw_dialog(DIALOG_TYPE_UPLOAD_FILE);
return; return;
} }
sprintf((char *)saveFilePath, "/%s", dosName); sprintf((char *)saveFilePath, "%s", dosName);
ZERO(list_file.long_name[sel_id]); card.cdroot();
memcpy(list_file.long_name[sel_id], dosName, sizeof(dosName)); upload_file.close();
const char * const fname = card.diveToFile(true, upload_curDir, saveFilePath);
char *cur_name=strrchr((const char *)saveFilePath,'/'); if (!upload_file.open(upload_curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) {
SdFile file;
SdFile *curDir;
card.endFilePrint();
const char * const fname = card.diveToFile(true, curDir, cur_name);
if (!fname) return;
if (file.open(curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) {
gCfgItems.curFilesize = file.fileSize();
}
else {
clear_cur_ui(); clear_cur_ui();
upload_result = 2; upload_result = 2;
wifiTransError.flag = 1; wifiTransError.flag = 1;
wifiTransError.start_tick = getWifiTick(); wifiTransError.start_tick = getWifiTick();
lv_draw_dialog(DIALOG_TYPE_UPLOAD_FILE); lv_draw_dialog(DIALOG_TYPE_UPLOAD_FILE);
return; return;
} }
@ -1302,22 +1326,23 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) {
lv_task_handler(); lv_task_handler();
file_writer.tick_begin = getWifiTick(); file_writer.tick_begin = getWifiTick();
file_writer.fileTransfer = 1;
} }
#define FRAG_MASK _BV32(31) #define FRAG_MASK ~_BV32(31)
static void file_fragment_msg_handle(uint8_t * msg, uint16_t msgLen) { static void file_fragment_msg_handle(uint8_t * msg, uint16_t msgLen) {
uint32_t frag = *((uint32_t *)msg); uint32_t frag = *((uint32_t *)msg);
if ((frag & FRAG_MASK) != (uint32_t)(lastFragment + 1)) { if ((frag & FRAG_MASK) != (uint32_t)(lastFragment + 1)) {
ZERO(file_writer.write_buf); ZERO(public_buf);
file_writer.write_index = 0; file_writer.write_index = 0;
wifi_link_state = WIFI_CONNECTED; wifi_link_state = WIFI_CONNECTED;
upload_result = 2; upload_result = 2;
} }
else { else {
if (write_to_file((char *)msg + 4, msgLen - 4) < 0) { if (write_to_file((char *)msg + 4, msgLen - 4) < 0) {
ZERO(file_writer.write_buf); ZERO(public_buf);
file_writer.write_index = 0; file_writer.write_index = 0;
wifi_link_state = WIFI_CONNECTED; wifi_link_state = WIFI_CONNECTED;
upload_result = 2; upload_result = 2;
@ -1325,16 +1350,31 @@ static void file_fragment_msg_handle(uint8_t * msg, uint16_t msgLen) {
} }
lastFragment = frag; lastFragment = frag;
if ((frag & (~FRAG_MASK))) { if ((frag & (~FRAG_MASK)) != 0) {
int res = card.write(file_writer.write_buf, file_writer.write_index); int res = upload_file.write(public_buf, file_writer.write_index);
if (res == -1) { if (res == -1) {
ZERO(file_writer.write_buf); upload_file.close();
const char * const fname = card.diveToFile(true, upload_curDir, saveFilePath);
if (upload_file.open(upload_curDir, fname, O_WRITE)) {
upload_file.setpos(&pos);
res = upload_file.write(public_buf, file_writer.write_index);
}
}
upload_file.close();
SdFile file, *curDir;
const char * const fname = card.diveToFile(true, curDir, saveFilePath);
if (file.open(curDir, fname, O_RDWR)) {
gCfgItems.curFilesize = file.fileSize();
file.close();
}
else {
ZERO(public_buf);
file_writer.write_index = 0; file_writer.write_index = 0;
wifi_link_state = WIFI_CONNECTED; wifi_link_state = WIFI_CONNECTED;
upload_result = 2; upload_result = 2;
return; return;
} }
ZERO(file_writer.write_buf); ZERO(public_buf);
file_writer.write_index = 0; file_writer.write_index = 0;
file_writer.tick_end = getWifiTick(); file_writer.tick_end = getWifiTick();
upload_time = getWifiTickDiff(file_writer.tick_begin, file_writer.tick_end) / 1000; upload_time = getWifiTickDiff(file_writer.tick_begin, file_writer.tick_end) / 1000;
@ -1342,7 +1382,6 @@ static void file_fragment_msg_handle(uint8_t * msg, uint16_t msgLen) {
wifi_link_state = WIFI_CONNECTED; wifi_link_state = WIFI_CONNECTED;
upload_result = 3; upload_result = 3;
} }
} }
} }
@ -1453,7 +1492,6 @@ void esp_data_parser(char *cmdRxBuf, int len) {
esp_msg_index = 0; esp_msg_index = 0;
return; return;
} }
if ((charAtArray(esp_msg_buf, esp_msg_index, ESP_PROTOC_HEAD) != -1) && (charAtArray(esp_msg_buf, esp_msg_index, ESP_PROTOC_TAIL) != -1)) if ((charAtArray(esp_msg_buf, esp_msg_index, ESP_PROTOC_HEAD) != -1) && (charAtArray(esp_msg_buf, esp_msg_index, ESP_PROTOC_TAIL) != -1))
loop_again = true; loop_again = true;
} }
@ -1461,19 +1499,6 @@ void esp_data_parser(char *cmdRxBuf, int len) {
} }
int32_t tick_net_time1, tick_net_time2; int32_t tick_net_time1, tick_net_time2;
int storeRcvData(int32_t len) {
unsigned char tmpW = wifiDmaRcvFifo.write_cur;
if (len <= UDISKBUFLEN && wifiDmaRcvFifo.state[tmpW] == udisk_buf_empty) {
for (uint16_t i = 0; i < len; i++)
wifiDmaRcvFifo.bufferAddr[tmpW][i] = WIFISERIAL.read();
wifiDmaRcvFifo.state[tmpW] = udisk_buf_full;
wifiDmaRcvFifo.write_cur = (tmpW + 1) % TRANS_RCV_FIFO_BLOCK_NUM;
return 1;
}
return 0;
}
int32_t readWifiFifo(uint8_t *retBuf, uint32_t bufLen) { int32_t readWifiFifo(uint8_t *retBuf, uint32_t bufLen) {
unsigned char tmpR = wifiDmaRcvFifo.read_cur; unsigned char tmpR = wifiDmaRcvFifo.read_cur;
if (bufLen >= UDISKBUFLEN && wifiDmaRcvFifo.state[tmpR] == udisk_buf_full) { if (bufLen >= UDISKBUFLEN && wifiDmaRcvFifo.state[tmpR] == udisk_buf_full) {
@ -1496,20 +1521,33 @@ void stopEspTransfer() {
wifiTransError.start_tick = getWifiTick(); wifiTransError.start_tick = getWifiTick();
card.removeFile((const char *)saveFilePath); card.removeFile((const char *)saveFilePath);
} }
else {
}
wifi_delay(200); wifi_delay(200);
WIFI_IO1_SET(); WIFI_IO1_SET();
//exchangeFlashMode(1); //change spi flash to use dma mode
// disable dma
dma_clear_isr_bits(DMA1, DMA_CH5);
bb_peri_set_bit(&USART1_BASE->CR3, USART_CR3_DMAR_BIT, 0);
dma_disable(DMA1, DMA_CH5);
wifi_delay(200);
changeFlashMode(true); // Set SPI flash to use DMA mode
esp_port_begin(1); esp_port_begin(1);
wifi_delay(200);
W25QXX.init(SPI_QUARTER_SPEED);
TERN_(HAS_TFT_LVGL_UI_SPI, SPI_TFT.spi_init(SPI_FULL_SPEED));
TERN_(HAS_SERVOS, servo_init());
TERN_(HAS_Z_SERVO_PROBE, probe.servo_probe_init());
if (wifiTransError.flag != 0x1) WIFI_IO1_RESET(); if (wifiTransError.flag != 0x1) WIFI_IO1_RESET();
} }
void wifi_rcv_handle() { void wifi_rcv_handle() {
int32_t len = 0; int32_t len = 0;
uint8_t ucStr[(UART_RX_BUFFER_SIZE) + 1] = { 0 }; uint8_t ucStr[(UART_RX_BUFFER_SIZE) + 1] = {0};
int8_t getDataF = 0; int8_t getDataF = 0;
if (wifi_link_state == WIFI_TRANS_FILE) { if (wifi_link_state == WIFI_TRANS_FILE) {
#if 0 #if 0
if (WIFISERIAL.available() == UART_RX_BUFFER_SIZE) { if (WIFISERIAL.available() == UART_RX_BUFFER_SIZE) {
@ -1531,9 +1569,9 @@ void wifi_rcv_handle() {
getDataF = 1; getDataF = 1;
} }
if (esp_state == TRANSFER_STORE) { if (esp_state == TRANSFER_STORE) {
if (storeRcvData(UART_RX_BUFFER_SIZE)) { if (storeRcvData(WIFISERIAL.usart_device->rb->buf, UART_RX_BUFFER_SIZE)) {
esp_state = TRANSFERING; esp_state = TRANSFERING;
//esp_dma_pre(); esp_dma_pre();
if (wifiTransError.flag != 0x1) WIFI_IO1_RESET(); if (wifiTransError.flag != 0x1) WIFI_IO1_RESET();
} }
else else
@ -1541,13 +1579,11 @@ void wifi_rcv_handle() {
} }
} }
else { else {
//len = readUsartFifo((SZ_USART_FIFO *)&WifiRxFifo, (int8_t *)ucStr, UART_RX_BUFFER_SIZE);
len = readWifiBuf((int8_t *)ucStr, UART_RX_BUFFER_SIZE); len = readWifiBuf((int8_t *)ucStr, UART_RX_BUFFER_SIZE);
if (len > 0) { if (len > 0) {
esp_data_parser((char *)ucStr, len); esp_data_parser((char *)ucStr, len);
if (wifi_link_state == WIFI_TRANS_FILE) { if (wifi_link_state == WIFI_TRANS_FILE) {
//exchangeFlashMode(0); //change spi flash not use dma mode changeFlashMode(false); // Set SPI flash to use non-DMA mode
wifi_delay(10); wifi_delay(10);
esp_port_begin(0); esp_port_begin(0);
wifi_delay(10); wifi_delay(10);
@ -1558,7 +1594,7 @@ void wifi_rcv_handle() {
} }
if (need_ok_later && (queue.length < BUFSIZE)) { if (need_ok_later && (queue.length < BUFSIZE)) {
need_ok_later = false; need_ok_later = false;
send_to_wifi((char *)"ok\r\n", strlen("ok\r\n")); send_to_wifi((uint8_t *)"ok\r\n", strlen("ok\r\n"));
} }
} }
@ -1569,7 +1605,7 @@ void wifi_rcv_handle() {
tick_net_time2 = getWifiTick(); tick_net_time2 = getWifiTick();
if (wifi_link_state == WIFI_TRANS_FILE) { if (wifi_link_state == WIFI_TRANS_FILE) {
if ((tick_net_time1 != 0) && (getWifiTickDiff(tick_net_time1, tick_net_time2) > 4500)) { if (tick_net_time1 && getWifiTickDiff(tick_net_time1, tick_net_time2) > 8000) {
wifi_link_state = WIFI_CONNECTED; wifi_link_state = WIFI_CONNECTED;
upload_result = 2; upload_result = 2;
clear_cur_ui(); clear_cur_ui();
@ -1577,11 +1613,10 @@ void wifi_rcv_handle() {
lv_draw_dialog(DIALOG_TYPE_UPLOAD_FILE); lv_draw_dialog(DIALOG_TYPE_UPLOAD_FILE);
} }
} }
if (tick_net_time1 && getWifiTickDiff(tick_net_time1, tick_net_time2) > 10000)
if ((tick_net_time1 != 0) && (getWifiTickDiff(tick_net_time1, tick_net_time2) > 10000))
wifi_link_state = WIFI_NOT_CONFIG; wifi_link_state = WIFI_NOT_CONFIG;
if ((tick_net_time1 != 0) && (getWifiTickDiff(tick_net_time1, tick_net_time2) > 120000)) { if (tick_net_time1 && getWifiTickDiff(tick_net_time1, tick_net_time2) > 120000) {
wifi_link_state = WIFI_NOT_CONFIG; wifi_link_state = WIFI_NOT_CONFIG;
wifi_reset(); wifi_reset();
tick_net_time1 = getWifiTick(); tick_net_time1 = getWifiTick();
@ -1598,7 +1633,10 @@ void wifi_rcv_handle() {
} }
void wifi_looping() { void wifi_looping() {
do { wifi_rcv_handle(); } while (wifi_link_state == WIFI_TRANS_FILE); do {
wifi_rcv_handle();
watchdog_refresh();
} while (wifi_link_state == WIFI_TRANS_FILE);
} }
void mks_esp_wifi_init() { void mks_esp_wifi_init() {
@ -1616,32 +1654,8 @@ void mks_esp_wifi_init() {
wifi_reset(); wifi_reset();
#if 0 #if 0
res = f_open(&esp_upload.uploadFile, ESP_FIRMWARE_FILE, FA_OPEN_EXISTING | FA_READ); if (update_flag == 0) {
res = f_open(&esp_upload.uploadFile, ESP_WEB_FIRMWARE_FILE, FA_OPEN_EXISTING | FA_READ);
if (res == FR_OK) {
f_close(&esp_upload.uploadFile);
wifi_delay(2000);
if (usartFifoAvailable((SZ_USART_FIFO *)&WifiRxFifo) < 20) {
return;
}
clear_cur_ui();
draw_dialog(DIALOG_TYPE_UPDATE_ESP_FIRMARE);
if (wifi_upload(0) >= 0) {
f_unlink("1:/MKS_WIFI_CUR");
f_rename(ESP_FIRMWARE_FILE,"/MKS_WIFI_CUR");
}
draw_return_ui();
update_flag = 1;
}
if (update_flag == 0) {
res = f_open(&esp_upload.uploadFile, ESP_WEB_FIRMWARE_FILE, FA_OPEN_EXISTING | FA_READ);
if (res == FR_OK) { if (res == FR_OK) {
f_close(&esp_upload.uploadFile); f_close(&esp_upload.uploadFile);
@ -1694,32 +1708,42 @@ void mks_esp_wifi_init() {
wifi_link_state = WIFI_NOT_CONFIG; wifi_link_state = WIFI_NOT_CONFIG;
} }
#define BUF_INC_POINTER(p) ((p + 1 == UART_FIFO_BUFFER_SIZE) ? 0 : (p + 1))
void mks_wifi_firmware_update() {
card.openFileRead((char *)ESP_FIRMWARE_FILE);
if (card.isFileOpen()) {
card.closefile();
wifi_delay(2000);
if (usartFifoAvailable((SZ_USART_FIFO *)&WifiRxFifo) < 20)
return;
clear_cur_ui();
lv_draw_dialog(DIALOG_TYPE_UPDATE_ESP_FIRMARE);
lv_task_handler();
watchdog_refresh();
if (wifi_upload(0) >= 0) {
card.removeFile((char *)ESP_FIRMWARE_FILE_RENAME);
SdFile file, *curDir;
const char * const fname = card.diveToFile(true, curDir, ESP_FIRMWARE_FILE);
if (file.open(curDir, fname, O_READ)) {
file.rename(curDir, (char *)ESP_FIRMWARE_FILE_RENAME);
file.close();
}
}
clear_cur_ui();
}
}
#define BUF_INC_POINTER(p) ((p + 1 == UART_FIFO_BUFFER_SIZE) ? 0:(p + 1))
int usartFifoAvailable(SZ_USART_FIFO *fifo) { int usartFifoAvailable(SZ_USART_FIFO *fifo) {
int diff = fifo->uart_write_point - fifo->uart_read_point; return WIFISERIAL.available();
if (diff < 0) diff += UART_FIFO_BUFFER_SIZE;
return diff;
}
int readUsartFifo(SZ_USART_FIFO *fifo, int8_t *buf, int32_t len) {
int i = 0 ;
while (i < len && fifo->uart_read_point != fifo->uart_write_point) {
buf[i++] = fifo->uartTxBuffer[fifo->uart_read_point];
fifo->uart_read_point = BUF_INC_POINTER(fifo->uart_read_point);
}
return i;
}
int writeUsartFifo(SZ_USART_FIFO *fifo, int8_t *buf, int32_t len) {
if (buf == 0 || len <= 0) return -1;
int i = 0 ;
while (i < len && fifo->uart_read_point != BUF_INC_POINTER(fifo->uart_write_point)) {
fifo->uartTxBuffer[fifo->uart_write_point] = buf[i++];
fifo->uart_write_point = BUF_INC_POINTER(fifo->uart_write_point);
}
return i;
} }
void get_wifi_commands() { void get_wifi_commands() {
@ -1791,10 +1815,9 @@ void get_wifi_commands() {
if (!wifi_comment_mode) wifi_line_buffer[wifi_read_count++] = wifi_char; if (!wifi_comment_mode) wifi_line_buffer[wifi_read_count++] = wifi_char;
} }
} }
}// queue has space, serial has data } // queue has space, serial has data
else { else
espGcodeFifo.wait_tick++; espGcodeFifo.wait_tick++;
}
} }
int readWifiBuf(int8_t *buf, int32_t len) { int readWifiBuf(int8_t *buf, int32_t len) {

View file

@ -34,11 +34,6 @@
#define UART_RX_BUFFER_SIZE 1024 #define UART_RX_BUFFER_SIZE 1024
#define UART_FIFO_BUFFER_SIZE 1024 #define UART_FIFO_BUFFER_SIZE 1024
#define ESP_WIFI 0x02
#define AP_MODEL 0x01
#define STA_MODEL 0x02
#define WIFI_DECODE_TYPE 1 #define WIFI_DECODE_TYPE 1
#define IP_DHCP_FLAG 1 #define IP_DHCP_FLAG 1
@ -66,7 +61,7 @@ typedef enum{
udisk_buf_full, udisk_buf_full,
} UDISK_DATA_BUFFER_STATE; } UDISK_DATA_BUFFER_STATE;
#define TRANS_RCV_FIFO_BLOCK_NUM 8 #define TRANS_RCV_FIFO_BLOCK_NUM 14
typedef struct { typedef struct {
unsigned char *bufferAddr[TRANS_RCV_FIFO_BLOCK_NUM]; unsigned char *bufferAddr[TRANS_RCV_FIFO_BLOCK_NUM];
@ -164,7 +159,7 @@ typedef enum {
typedef struct { typedef struct {
uint32_t uart_read_point; uint32_t uart_read_point;
uint32_t uart_write_point; uint32_t uart_write_point;
uint8_t uartTxBuffer[UART_FIFO_BUFFER_SIZE]; //uint8_t uartTxBuffer[UART_FIFO_BUFFER_SIZE];
} SZ_USART_FIFO; } SZ_USART_FIFO;
#define WIFI_GCODE_BUFFER_LEAST_SIZE 96 #define WIFI_GCODE_BUFFER_LEAST_SIZE 96
@ -195,7 +190,7 @@ extern int package_to_wifi(WIFI_RET_TYPE type, uint8_t *buf, int len);
extern void get_wifi_list_command_send(); extern void get_wifi_list_command_send();
extern void get_wifi_commands(); extern void get_wifi_commands();
extern int readWifiBuf(int8_t *buf, int32_t len); extern int readWifiBuf(int8_t *buf, int32_t len);
extern int storeRcvData(int32_t len); extern void mks_wifi_firmware_update();
#ifdef __cplusplus #ifdef __cplusplus
} /* C-declarations for C++ */ } /* C-declarations for C++ */

View file

@ -28,6 +28,7 @@
#include "wifi_upload.h" #include "wifi_upload.h"
#include "../../../../MarlinCore.h" #include "../../../../MarlinCore.h"
#include "../../../../sd/cardreader.h"
#define WIFI_SET() WRITE(WIFI_RESET_PIN, HIGH); #define WIFI_SET() WRITE(WIFI_RESET_PIN, HIGH);
#define WIFI_RESET() WRITE(WIFI_RESET_PIN, LOW); #define WIFI_RESET() WRITE(WIFI_RESET_PIN, LOW);
@ -85,6 +86,7 @@ static const uint32_t defaultTimeout = 500;
static const uint32_t eraseTimeout = 15000; static const uint32_t eraseTimeout = 15000;
static const uint32_t blockWriteTimeout = 200; static const uint32_t blockWriteTimeout = 200;
static const uint32_t blockWriteInterval = 15; // 15ms is long enough, 10ms is mostly too short static const uint32_t blockWriteInterval = 15; // 15ms is long enough, 10ms is mostly too short
static SdFile update_file, *update_curDir;
// Messages corresponding to result codes, should make sense when followed by " error" // Messages corresponding to result codes, should make sense when followed by " error"
const char *resultMessages[] = { const char *resultMessages[] = {
@ -113,23 +115,15 @@ signed char IsReady() {
return esp_upload.state == upload_idle; return esp_upload.state == upload_idle;
} }
void uploadPort_write(const uint8_t *buf, size_t len) { void uploadPort_write(const uint8_t *buf, const size_t len) {
#if 0 for (size_t i = 0; i < len; i++)
int i; WIFISERIAL.write(*(buf + i));
for (i = 0; i < len; i++) {
while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET) { /* nada */ }
USART_SendData(USART1, *(buf + i));
}
#endif
} }
char uploadPort_read() { char uploadPort_read() {
uint8_t retChar; uint8_t retChar;
if (readUsartFifo(&WifiRxFifo, (int8_t *)&retChar, 1) == 1) retChar = WIFISERIAL.read();
return retChar; return _MAX(retChar, 0);
else
return 0;
} }
int uploadPort_available() { int uploadPort_available() {
@ -156,25 +150,21 @@ void flushInput() {
// Extract 1-4 bytes of a value in little-endian order from a buffer beginning at a specified offset // Extract 1-4 bytes of a value in little-endian order from a buffer beginning at a specified offset
uint32_t getData(unsigned byteCnt, const uint8_t *buf, int ofst) { uint32_t getData(unsigned byteCnt, const uint8_t *buf, int ofst) {
uint32_t val = 0; uint32_t val = 0;
if (buf && byteCnt) { if (buf && byteCnt) {
unsigned int shiftCnt = 0; unsigned int shiftCnt = 0;
if (byteCnt > 4) NOMORE(byteCnt, 4);
byteCnt = 4; do {
do{
val |= (uint32_t)buf[ofst++] << shiftCnt; val |= (uint32_t)buf[ofst++] << shiftCnt;
shiftCnt += 8; shiftCnt += 8;
} while (--byteCnt); } while (--byteCnt);
} }
return(val); return val;
} }
// Put 1-4 bytes of a value in little-endian order into a buffer beginning at a specified offset. // Put 1-4 bytes of a value in little-endian order into a buffer beginning at a specified offset.
void putData(uint32_t val, unsigned byteCnt, uint8_t *buf, int ofst) { void putData(uint32_t val, unsigned byteCnt, uint8_t *buf, int ofst) {
if (buf && byteCnt) { if (buf && byteCnt) {
if (byteCnt > 4) { NOMORE(byteCnt, 4);
byteCnt = 4;
}
do { do {
buf[ofst++] = (uint8_t)(val & 0xFF); buf[ofst++] = (uint8_t)(val & 0xFF);
val >>= 8; val >>= 8;
@ -191,44 +181,25 @@ void putData(uint32_t val, unsigned byteCnt, uint8_t *buf, int ofst) {
// -2 - a SLIP escape byte was found but the following byte wasn't available // -2 - a SLIP escape byte was found but the following byte wasn't available
// -3 - a SLIP escape byte was followed by an invalid byte // -3 - a SLIP escape byte was followed by an invalid byte
int ReadByte(uint8_t *data, signed char slipDecode) { int ReadByte(uint8_t *data, signed char slipDecode) {
if (uploadPort_available() == 0) { if (uploadPort_available() == 0) return 0;
return(0);
}
// at least one byte is available // At least one byte is available
*data = uploadPort_read(); *data = uploadPort_read();
if (!slipDecode) {
return(1);
}
if (*data == 0xC0) { if (!slipDecode) return 1;
// this shouldn't happen
return(-1);
}
// if not the SLIP escape, we're done if (*data == 0xC0) return -1; // This shouldn't happen
if (*data != 0xDB) { if (*data != 0xDB) return 1; // If not the SLIP escape, we're done
return(1);
}
// SLIP escape, check availability of subsequent byte // SLIP escape, check availability of subsequent byte
if (uploadPort_available() == 0) { if (uploadPort_available() == 0) return -2;
return(-2);
}
// process the escaped byte // process the escaped byte
*data = uploadPort_read(); *data = uploadPort_read();
if (*data == 0xDC) { if (*data == 0xDC) { *data = 0xC0; return 2; }
*data = 0xC0; if (*data == 0xDD) { *data = 0xDB; return 2; }
return(2);
}
if (*data == 0xDD) { return -3; // invalid
*data = 0xDB;
return(2);
}
// invalid
return(-3);
} }
// When we write a sync packet, there must be no gaps between most of the characters. // When we write a sync packet, there must be no gaps between most of the characters.
// So use this function, which does a block write to the UART buffer in the latest CoreNG. // So use this function, which does a block write to the UART buffer in the latest CoreNG.
@ -242,7 +213,7 @@ void WriteByteRaw(uint8_t b) {
} }
// Write a byte to the serial port optionally SLIP encoding. Return the number of bytes actually written. // Write a byte to the serial port optionally SLIP encoding. Return the number of bytes actually written.
void WriteByteSlip(uint8_t b) { void WriteByteSlip(const uint8_t b) {
if (b == 0xC0) { if (b == 0xC0) {
WriteByteRaw(0xDB); WriteByteRaw(0xDB);
WriteByteRaw(0xDC); WriteByteRaw(0xDC);
@ -251,9 +222,8 @@ void WriteByteSlip(uint8_t b) {
WriteByteRaw(0xDB); WriteByteRaw(0xDB);
WriteByteRaw(0xDD); WriteByteRaw(0xDD);
} }
else { else
uploadPort_write((const uint8_t *)&b, 1); uploadPort_write((const uint8_t *)&b, 1);
}
} }
// Wait for a data packet to be returned. If the body of the packet is // Wait for a data packet to be returned. If the body of the packet is
@ -295,10 +265,10 @@ EspUploadResult readPacket(uint8_t op, uint32_t *valp, size_t *bodyLen, uint32_t
EspUploadResult stat; EspUploadResult stat;
//IWDG_ReloadCounter(); //IWDG_ReloadCounter();
watchdog_refresh();
if (getWifiTickDiff(startTime, getWifiTick()) > msTimeout) { if (getWifiTickDiff(startTime, getWifiTick()) > msTimeout)
return(timeout); return timeout;
}
if (uploadPort_available() < needBytes) { if (uploadPort_available() < needBytes) {
// insufficient data available // insufficient data available
@ -310,9 +280,7 @@ EspUploadResult readPacket(uint8_t op, uint32_t *valp, size_t *bodyLen, uint32_t
switch (state) { switch (state) {
case begin: // expecting frame start case begin: // expecting frame start
c = uploadPort_read(); c = uploadPort_read();
if (c != (uint8_t)0xC0) { if (c == (uint8_t)0xC0) break;
break;
}
state = header; state = header;
needBytes = 2; needBytes = 2;
break; break;
@ -323,50 +291,45 @@ EspUploadResult readPacket(uint8_t op, uint32_t *valp, size_t *bodyLen, uint32_t
break; break;
case header: // reading an 8-byte header case header: // reading an 8-byte header
case body: // reading the response body case body: { // reading the response body
{ int rslt;
int rslt; // retrieve a byte with SLIP decoding
// retrieve a byte with SLIP decoding rslt = ReadByte(&c, 1);
rslt = ReadByte(&c, 1); if (rslt != 1 && rslt != 2) {
if (rslt != 1 && rslt != 2) { // some error occurred
// some error occurred stat = (rslt == 0 || rslt == -2) ? slipData : slipFrame;
stat = (rslt == 0 || rslt == -2) ? slipData : slipFrame; return stat;
return stat; }
} else if (state == header) {
else if (state == header) { //store the header byte
//store the header byte hdr[hdrIdx++] = c;
hdr[hdrIdx++] = c; if (hdrIdx >= headerLength) {
if (hdrIdx >= headerLength) { // get the body length, prepare a buffer for it
// get the body length, prepare a buffer for it *bodyLen = (uint16_t)getData(2, hdr, 2);
*bodyLen = (uint16_t)getData(2, hdr, 2);
// extract the value, if requested // extract the value, if requested
if (valp != 0) { if (valp)
*valp = getData(4, hdr, 4); *valp = getData(4, hdr, 4);
}
if (*bodyLen != 0) { if (*bodyLen != 0)
state = body; state = body;
} else {
else {
needBytes = 1;
state = end;
}
}
}
else {
// Store the response body byte, check for completion
if (bodyIdx < ARRAY_SIZE(respBuf)) {
respBuf[bodyIdx] = c;
}
++bodyIdx;
if (bodyIdx >= *bodyLen) {
needBytes = 1; needBytes = 1;
state = end; state = end;
} }
} }
} }
break; else {
// Store the response body byte, check for completion
if (bodyIdx < ARRAY_SIZE(respBuf))
respBuf[bodyIdx] = c;
if (++bodyIdx >= *bodyLen) {
needBytes = 1;
state = end;
}
}
} break;
default: return slipState; // this shouldn't happen default: return slipState; // this shouldn't happen
} }
@ -376,9 +339,7 @@ EspUploadResult readPacket(uint8_t op, uint32_t *valp, size_t *bodyLen, uint32_t
resp = (uint8_t)getData(1, hdr, 0); resp = (uint8_t)getData(1, hdr, 0);
opRet = (uint8_t)getData(1, hdr, 1); opRet = (uint8_t)getData(1, hdr, 1);
// Sync packets often provoke a response with a zero opcode instead of ESP_SYNC // Sync packets often provoke a response with a zero opcode instead of ESP_SYNC
if (resp != 0x01 || opRet != op) { if (resp != 0x01 || opRet != op) return respHeader;
return respHeader;
}
return success; return success;
} }
@ -483,6 +444,7 @@ EspUploadResult Sync(uint16_t timeout) {
for (;;) { for (;;) {
size_t bodyLen; size_t bodyLen;
EspUploadResult rc = readPacket(ESP_SYNC, 0, &bodyLen, defaultTimeout); EspUploadResult rc = readPacket(ESP_SYNC, 0, &bodyLen, defaultTimeout);
watchdog_refresh();
if (rc != success || bodyLen != 2) break; if (rc != success || bodyLen != 2) break;
} }
} }
@ -527,7 +489,6 @@ uint16_t checksum(const uint8_t *data, uint16_t dataLen, uint16_t cksum) {
} }
EspUploadResult flashWriteBlock(uint16_t flashParmVal, uint16_t flashParmMask) { EspUploadResult flashWriteBlock(uint16_t flashParmVal, uint16_t flashParmMask) {
#if 0
const uint32_t blkSize = EspFlashBlockSize; const uint32_t blkSize = EspFlashBlockSize;
int i; int i;
@ -548,15 +509,14 @@ EspUploadResult flashWriteBlock(uint16_t flashParmVal, uint16_t flashParmMask) {
putData(0, 4, blkBuf, hdrOfst + 12); putData(0, 4, blkBuf, hdrOfst + 12);
// Get the data for the block // Get the data for the block
f_read(&esp_upload.uploadFile, blkBuf + dataOfst, blkSize, &cnt );//->Read(reinterpret_cast<char *>(blkBuf + dataOfst), blkSize); cnt = update_file.read(blkBuf + dataOfst, blkSize); //->Read(reinterpret_cast<char *>(blkBuf + dataOfst), blkSize);
if (cnt != blkSize) { if (cnt != blkSize) {
if (f_tell(&esp_upload.uploadFile) == esp_upload.fileSize) { if (update_file.curPosition() == esp_upload.fileSize) {
// partial last block, fill the remainder // partial last block, fill the remainder
memset(blkBuf + dataOfst + cnt, 0xFF, blkSize - cnt); memset(blkBuf + dataOfst + cnt, 0xFF, blkSize - cnt);
} }
else { else
return fileRead; return fileRead;
}
} }
// Patch the flash parameters into the first block if it is loaded at address 0 // Patch the flash parameters into the first block if it is loaded at address 0
@ -573,212 +533,132 @@ EspUploadResult flashWriteBlock(uint16_t flashParmVal, uint16_t flashParmMask) {
if ((stat = doCommand(ESP_FLASH_DATA, blkBuf, blkBufSize, cksum, 0, blockWriteTimeout)) == success) if ((stat = doCommand(ESP_FLASH_DATA, blkBuf, blkBufSize, cksum, 0, blockWriteTimeout)) == success)
break; break;
return stat; return stat;
#else
return success;
#endif
} }
void upload_spin() { void upload_spin() {
#if 0
switch (esp_upload.state) { switch (esp_upload.state) {
case resetting: case resetting:
if (esp_upload.connectAttemptNumber == 9) {
if (esp_upload.connectAttemptNumber == 9) { esp_upload.uploadResult = connected;
// Time to give up
//Network::ResetWiFi();
esp_upload.uploadResult = connected;
esp_upload.state = done;
}
else {
// Reset the serial port at the new baud rate. Also reset the ESP8266.
// const uint32_t baud = uploadBaudRates[esp_upload.connectAttemptNumber/esp_upload.retriesPerBaudRate];
if (esp_upload.connectAttemptNumber % esp_upload.retriesPerBaudRate == 0) {
}
//uploadPort.begin(baud);
//uploadPort_close();
uploadPort_begin();
wifi_delay(2000);
flushInput();
esp_upload.lastAttemptTime = esp_upload.lastResetTime = getWifiTick();
esp_upload.state = connecting;
}
break;
case connecting:
if ((getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= connectAttemptInterval) && (getWifiTickDiff(esp_upload.lastResetTime, getWifiTick()) >= 500)) {
// Attempt to establish a connection to the ESP8266.
EspUploadResult res = Sync(5000);
esp_upload.lastAttemptTime = getWifiTick();
if (res == success) {
// Successful connection
//MessageF(" success on attempt %d\n", (connectAttemptNumber % retriesPerBaudRate) + 1);
//printf("connect success\n");
esp_upload.state = erasing;
}
else {
// This attempt failed
esp_upload.connectAttemptNumber++;
if (esp_upload.connectAttemptNumber % retriesPerReset == 0) {
esp_upload.state = resetting; // try a reset and a lower baud rate
}
}
}
break;
case erasing:
if (getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= blockWriteInterval) {
uint32_t eraseSize;
const uint32_t sectorsPerBlock = 16;
const uint32_t sectorSize = 4096;
const uint32_t numSectors = (esp_upload.fileSize + sectorSize - 1)/sectorSize;
const uint32_t startSector = esp_upload.uploadAddress/sectorSize;
uint32_t headSectors = sectorsPerBlock - (startSector % sectorsPerBlock);
NOMORE(headSectors, numSectors);
eraseSize = (numSectors < 2 * headSectors)
? (numSectors + 1) / 2 * sectorSize
: (numSectors - headSectors) * sectorSize;
//MessageF("Erasing %u bytes...\n", fileSize);
esp_upload.uploadResult = flashBegin(esp_upload.uploadAddress, eraseSize);
if (esp_upload.uploadResult == success) {
//MessageF("Uploading file...\n");
esp_upload.uploadBlockNumber = 0;
esp_upload.uploadNextPercentToReport = percentToReportIncrement;
esp_upload.lastAttemptTime = getWifiTick();
esp_upload.state = uploading;
}
else {
//MessageF("Erase failed\n");
esp_upload.state = done; esp_upload.state = done;
} }
} else {
break; uploadPort_begin();
wifi_delay(2000);
flushInput();
esp_upload.lastAttemptTime = esp_upload.lastResetTime = getWifiTick();
esp_upload.state = connecting;
}
break;
case uploading: case connecting:
// The ESP needs several milliseconds to recover from one packet before it will accept another if ((getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= connectAttemptInterval) && (getWifiTickDiff(esp_upload.lastResetTime, getWifiTick()) >= 500)) {
if (getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= 15) { EspUploadResult res = Sync(5000);
unsigned int percentComplete;
const uint32_t blkCnt = (esp_upload.fileSize + EspFlashBlockSize - 1) / EspFlashBlockSize;
if (esp_upload.uploadBlockNumber < blkCnt) {
esp_upload.uploadResult = flashWriteBlock(0, 0);
esp_upload.lastAttemptTime = getWifiTick(); esp_upload.lastAttemptTime = getWifiTick();
if (esp_upload.uploadResult != success) { if (res == success)
//MessageF("Flash block upload failed\n"); esp_upload.state = erasing;
else {
esp_upload.connectAttemptNumber++;
if (esp_upload.connectAttemptNumber % retriesPerReset == 0)
esp_upload.state = resetting;
}
}
break;
case erasing:
if (getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= blockWriteInterval) {
uint32_t eraseSize;
const uint32_t sectorsPerBlock = 16;
const uint32_t sectorSize = 4096;
const uint32_t numSectors = (esp_upload.fileSize + sectorSize - 1)/sectorSize;
const uint32_t startSector = esp_upload.uploadAddress/sectorSize;
uint32_t headSectors = sectorsPerBlock - (startSector % sectorsPerBlock);
NOMORE(headSectors, numSectors);
eraseSize = (numSectors < 2 * headSectors)
? (numSectors + 1) / 2 * sectorSize
: (numSectors - headSectors) * sectorSize;
esp_upload.uploadResult = flashBegin(esp_upload.uploadAddress, eraseSize);
if (esp_upload.uploadResult == success) {
esp_upload.uploadBlockNumber = 0;
esp_upload.uploadNextPercentToReport = percentToReportIncrement;
esp_upload.lastAttemptTime = getWifiTick();
esp_upload.state = uploading;
}
else
esp_upload.state = done; esp_upload.state = done;
}
percentComplete = (100 * esp_upload.uploadBlockNumber)/blkCnt;
++esp_upload.uploadBlockNumber;
if (percentComplete >= esp_upload.uploadNextPercentToReport) {
//MessageF("%u%% complete\n", percentComplete);
esp_upload.uploadNextPercentToReport += percentToReportIncrement;
}
} }
else { break;
esp_upload.state = done;
case uploading:
// The ESP needs several milliseconds to recover from one packet before it will accept another
if (getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= 15) {
unsigned int percentComplete;
const uint32_t blkCnt = (esp_upload.fileSize + EspFlashBlockSize - 1) / EspFlashBlockSize;
if (esp_upload.uploadBlockNumber < blkCnt) {
esp_upload.uploadResult = flashWriteBlock(0, 0);
esp_upload.lastAttemptTime = getWifiTick();
if (esp_upload.uploadResult != success)
esp_upload.state = done;
percentComplete = (100 * esp_upload.uploadBlockNumber)/blkCnt;
++esp_upload.uploadBlockNumber;
if (percentComplete >= esp_upload.uploadNextPercentToReport)
esp_upload.uploadNextPercentToReport += percentToReportIncrement;
}
else
esp_upload.state = done;
} }
} break;
break;
case done: case done:
f_close(&esp_upload.uploadFile); update_file.close();
//uploadPort.end(); esp_upload.state = upload_idle;
//uploadPort_close(); break;
//WIFI_COM.begin(115200, true);
//wifi_init();
if (esp_upload.uploadResult == success) {
//printf("upload successfully\n");
}
else {
//printf("upload failed\n");
}
esp_upload.state = upload_idle;//idle;
break;
default: break; default: break;
} }
#endif
} }
// Try to upload the given file at the given address // Try to upload the given file at the given address
void SendUpdateFile(const char *file, uint32_t address) { void SendUpdateFile(const char *file, uint32_t address) {
#if 0 const char * const fname = card.diveToFile(true, update_curDir, ESP_FIRMWARE_FILE);
FRESULT res = f_open(&esp_upload.uploadFile, file, FA_OPEN_EXISTING | FA_READ); if (!update_file.open(update_curDir, fname, O_READ)) return;
if (res != FR_OK) return; esp_upload.fileSize = update_file.fileSize();
esp_upload.fileSize = f_size(&esp_upload.uploadFile);
if (esp_upload.fileSize == 0) { if (esp_upload.fileSize == 0) {
f_close(&esp_upload.uploadFile); update_file.close();
return; return;
} }
f_lseek(&esp_upload.uploadFile, 0);
esp_upload.uploadAddress = address; esp_upload.uploadAddress = address;
esp_upload.connectAttemptNumber = 0; esp_upload.connectAttemptNumber = 0;
esp_upload.state = resetting; esp_upload.state = resetting;
#endif
} }
static const uint32_t FirmwareAddress = 0x00000000, WebFilesAddress = 0x00100000; static const uint32_t FirmwareAddress = 0x00000000, WebFilesAddress = 0x00100000;
void ResetWiFiForUpload(int begin_or_end) { void ResetWiFiForUpload(int begin_or_end) {
#if 0 //#if 0
uint32_t start, now; uint32_t start, now;
GPIO_InitTypeDef GPIO_InitStructure; start = getWifiTick();
now = start;
#if V1_0_V1_1 if (begin_or_end == 0) {
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH; SET_OUTPUT(WIFI_IO0_PIN);
GPIO_InitStructure.Pin = GPIO_Pin_8; WRITE(WIFI_IO0_PIN, LOW);
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; }
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); else
#else SET_INPUT_PULLUP(WIFI_IO0_PIN);
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStructure.Pin = GPIO_Pin_13;
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
#endif
start = getWifiTick();
now = start;
if (begin_or_end == 0) { WIFI_RESET();
#if V1_0_V1_1 while (getWifiTickDiff(start, now) < 500) now = getWifiTick();
HAL_GPIO_WritePin(GPIOA,GPIO_Pin_8,GPIO_PIN_RESET); //update mode WIFI_SET();
#else //#endif
HAL_GPIO_WritePin(GPIOC,GPIO_Pin_13,GPIO_PIN_RESET); //update mode
#endif
}
else {
#if V1_0_V1_1
#if V1_0_V1_1
HAL_GPIO_WritePin(GPIOA,GPIO_Pin_8,GPIO_PIN_SET); //boot mode
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStructure.Pin = GPIO_Pin_8;
GPIO_InitStructure.Mode = GPIO_MODE_INPUT;
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
#endif
#else
HAL_GPIO_WritePin(GPIOC,GPIO_Pin_13,GPIO_PIN_SET); //boot mode
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStructure.Pin = GPIO_Pin_13;
GPIO_InitStructure.Mode = GPIO_MODE_INPUT;
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
#endif
}
WIFI_RESET();
while (getWifiTickDiff(start, now) < 500) now = getWifiTick();
WIFI_SET();
#endif
} }
int32_t wifi_upload(int type) { int32_t wifi_upload(int type) {
@ -797,7 +677,7 @@ int32_t wifi_upload(int type) {
while (esp_upload.state != upload_idle) { while (esp_upload.state != upload_idle) {
upload_spin(); upload_spin();
//IWDG_ReloadCounter(); watchdog_refresh();
} }
ResetWiFiForUpload(1); ResetWiFiForUpload(1);

View file

@ -25,9 +25,10 @@
extern "C" { /* C-declarations for C++ */ extern "C" { /* C-declarations for C++ */
#endif #endif
#define ESP_FIRMWARE_FILE "1:/MksWifi.bin" #define ESP_FIRMWARE_FILE "MksWifi.bin"
#define ESP_WEB_FIRMWARE_FILE "1:/MksWifi_Web.bin" #define ESP_FIRMWARE_FILE_RENAME "MKSWIFI.CUR"
#define ESP_WEB_FILE "1:/MksWifi_WebView.bin" #define ESP_WEB_FIRMWARE_FILE "1:/MksWifi_Web.bin"
#define ESP_WEB_FILE "1:/MksWifi_WebView.bin"
typedef enum { typedef enum {
upload_idle, upload_idle,

View file

@ -49,6 +49,8 @@ MarlinSPI W25QXXFlash::mySPI(SPI_FLASH_MOSI_PIN, SPI_FLASH_MISO_PIN, SPI_FLASH_S
#define W25QXX_CS_H OUT_WRITE(SPI_FLASH_CS_PIN, HIGH) #define W25QXX_CS_H OUT_WRITE(SPI_FLASH_CS_PIN, HIGH)
#define W25QXX_CS_L OUT_WRITE(SPI_FLASH_CS_PIN, LOW) #define W25QXX_CS_L OUT_WRITE(SPI_FLASH_CS_PIN, LOW)
bool flash_dma_mode = true;
void W25QXXFlash::init(uint8_t spiRate) { void W25QXXFlash::init(uint8_t spiRate) {
OUT_WRITE(SPI_FLASH_CS_PIN, HIGH); OUT_WRITE(SPI_FLASH_CS_PIN, HIGH);
@ -144,11 +146,11 @@ uint16_t W25QXXFlash::W25QXX_ReadID(void) {
} }
void W25QXXFlash::SPI_FLASH_WriteEnable(void) { void W25QXXFlash::SPI_FLASH_WriteEnable(void) {
/* Select the FLASH: Chip Select low */ // Select the FLASH: Chip Select low
W25QXX_CS_L; W25QXX_CS_L;
/* Send "Write Enable" instruction */ // Send "Write Enable" instruction
spi_flash_Send(W25X_WriteEnable); spi_flash_Send(W25X_WriteEnable);
/* Deselect the FLASH: Chip Select high */ // Deselect the FLASH: Chip Select high
W25QXX_CS_H; W25QXX_CS_H;
} }
@ -164,54 +166,54 @@ void W25QXXFlash::SPI_FLASH_WriteEnable(void) {
void W25QXXFlash::SPI_FLASH_WaitForWriteEnd(void) { void W25QXXFlash::SPI_FLASH_WaitForWriteEnd(void) {
uint8_t FLASH_Status = 0; uint8_t FLASH_Status = 0;
/* Select the FLASH: Chip Select low */ // Select the FLASH: Chip Select low
W25QXX_CS_L; W25QXX_CS_L;
/* Send "Read Status Register" instruction */ // Send "Read Status Register" instruction
spi_flash_Send(W25X_ReadStatusReg); spi_flash_Send(W25X_ReadStatusReg);
/* Loop as long as the memory is busy with a write cycle */ // Loop as long as the memory is busy with a write cycle
do do
/* Send a dummy byte to generate the clock needed by the FLASH /* Send a dummy byte to generate the clock needed by the FLASH
and put the value of the status register in FLASH_Status variable */ and put the value of the status register in FLASH_Status variable */
FLASH_Status = spi_flash_Rec(); FLASH_Status = spi_flash_Rec();
while ((FLASH_Status & WIP_Flag) == 0x01); /* Write in progress */ while ((FLASH_Status & WIP_Flag) == 0x01); // Write in progress
/* Deselect the FLASH: Chip Select high */ // Deselect the FLASH: Chip Select high
W25QXX_CS_H; W25QXX_CS_H;
} }
void W25QXXFlash::SPI_FLASH_SectorErase(uint32_t SectorAddr) { void W25QXXFlash::SPI_FLASH_SectorErase(uint32_t SectorAddr) {
/* Send write enable instruction */ // Send write enable instruction
SPI_FLASH_WriteEnable(); SPI_FLASH_WriteEnable();
/* Sector Erase */ // Sector Erase
/* Select the FLASH: Chip Select low */ // Select the FLASH: Chip Select low
W25QXX_CS_L; W25QXX_CS_L;
/* Send Sector Erase instruction */ // Send Sector Erase instruction
spi_flash_Send(W25X_SectorErase); spi_flash_Send(W25X_SectorErase);
/* Send SectorAddr high nibble address byte */ // Send SectorAddr high nibble address byte
spi_flash_Send((SectorAddr & 0xFF0000) >> 16); spi_flash_Send((SectorAddr & 0xFF0000) >> 16);
/* Send SectorAddr medium nibble address byte */ // Send SectorAddr medium nibble address byte
spi_flash_Send((SectorAddr & 0xFF00) >> 8); spi_flash_Send((SectorAddr & 0xFF00) >> 8);
/* Send SectorAddr low nibble address byte */ // Send SectorAddr low nibble address byte
spi_flash_Send(SectorAddr & 0xFF); spi_flash_Send(SectorAddr & 0xFF);
/* Deselect the FLASH: Chip Select high */ // Deselect the FLASH: Chip Select high
W25QXX_CS_H; W25QXX_CS_H;
/* Wait the end of Flash writing */ // Wait the end of Flash writing
SPI_FLASH_WaitForWriteEnd(); SPI_FLASH_WaitForWriteEnd();
} }
void W25QXXFlash::SPI_FLASH_BlockErase(uint32_t BlockAddr) { void W25QXXFlash::SPI_FLASH_BlockErase(uint32_t BlockAddr) {
SPI_FLASH_WriteEnable(); SPI_FLASH_WriteEnable();
W25QXX_CS_L; W25QXX_CS_L;
/* Send Sector Erase instruction */ // Send Sector Erase instruction
spi_flash_Send(W25X_BlockErase); spi_flash_Send(W25X_BlockErase);
/* Send SectorAddr high nibble address byte */ // Send SectorAddr high nibble address byte
spi_flash_Send((BlockAddr & 0xFF0000) >> 16); spi_flash_Send((BlockAddr & 0xFF0000) >> 16);
/* Send SectorAddr medium nibble address byte */ // Send SectorAddr medium nibble address byte
spi_flash_Send((BlockAddr & 0xFF00) >> 8); spi_flash_Send((BlockAddr & 0xFF00) >> 8);
/* Send SectorAddr low nibble address byte */ // Send SectorAddr low nibble address byte
spi_flash_Send(BlockAddr & 0xFF); spi_flash_Send(BlockAddr & 0xFF);
W25QXX_CS_H; W25QXX_CS_H;
@ -227,18 +229,18 @@ void W25QXXFlash::SPI_FLASH_BlockErase(uint32_t BlockAddr) {
* Return : None * Return : None
*******************************************************************************/ *******************************************************************************/
void W25QXXFlash::SPI_FLASH_BulkErase(void) { void W25QXXFlash::SPI_FLASH_BulkErase(void) {
/* Send write enable instruction */ // Send write enable instruction
SPI_FLASH_WriteEnable(); SPI_FLASH_WriteEnable();
/* Bulk Erase */ // Bulk Erase
/* Select the FLASH: Chip Select low */ // Select the FLASH: Chip Select low
W25QXX_CS_L; W25QXX_CS_L;
/* Send Bulk Erase instruction */ // Send Bulk Erase instruction
spi_flash_Send(W25X_ChipErase); spi_flash_Send(W25X_ChipErase);
/* Deselect the FLASH: Chip Select high */ // Deselect the FLASH: Chip Select high
W25QXX_CS_H; W25QXX_CS_H;
/* Wait the end of Flash writing */ // Wait the end of Flash writing
SPI_FLASH_WaitForWriteEnd(); SPI_FLASH_WaitForWriteEnd();
} }
@ -256,34 +258,34 @@ void W25QXXFlash::SPI_FLASH_BulkErase(void) {
* Return : None * Return : None
*******************************************************************************/ *******************************************************************************/
void W25QXXFlash::SPI_FLASH_PageWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite) { void W25QXXFlash::SPI_FLASH_PageWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite) {
/* Enable the write access to the FLASH */ // Enable the write access to the FLASH
SPI_FLASH_WriteEnable(); SPI_FLASH_WriteEnable();
/* Select the FLASH: Chip Select low */ // Select the FLASH: Chip Select low
W25QXX_CS_L; W25QXX_CS_L;
/* Send "Write to Memory " instruction */ // Send "Write to Memory " instruction
spi_flash_Send(W25X_PageProgram); spi_flash_Send(W25X_PageProgram);
/* Send WriteAddr high nibble address byte to write to */ // Send WriteAddr high nibble address byte to write to
spi_flash_Send((WriteAddr & 0xFF0000) >> 16); spi_flash_Send((WriteAddr & 0xFF0000) >> 16);
/* Send WriteAddr medium nibble address byte to write to */ // Send WriteAddr medium nibble address byte to write to
spi_flash_Send((WriteAddr & 0xFF00) >> 8); spi_flash_Send((WriteAddr & 0xFF00) >> 8);
/* Send WriteAddr low nibble address byte to write to */ // Send WriteAddr low nibble address byte to write to
spi_flash_Send(WriteAddr & 0xFF); spi_flash_Send(WriteAddr & 0xFF);
NOMORE(NumByteToWrite, SPI_FLASH_PerWritePageSize); NOMORE(NumByteToWrite, SPI_FLASH_PerWritePageSize);
/* while there is data to be written on the FLASH */ // While there is data to be written on the FLASH
while (NumByteToWrite--) { while (NumByteToWrite--) {
/* Send the current byte */ // Send the current byte
spi_flash_Send(*pBuffer); spi_flash_Send(*pBuffer);
/* Point on the next byte to be written */ // Point on the next byte to be written
pBuffer++; pBuffer++;
} }
/* Deselect the FLASH: Chip Select high */ // Deselect the FLASH: Chip Select high
W25QXX_CS_H; W25QXX_CS_H;
/* Wait the end of Flash writing */ // Wait the end of Flash writing
SPI_FLASH_WaitForWriteEnd(); SPI_FLASH_WaitForWriteEnd();
} }
@ -306,11 +308,11 @@ void W25QXXFlash::SPI_FLASH_BufferWrite(uint8_t* pBuffer, uint32_t WriteAddr, ui
NumOfPage = NumByteToWrite / SPI_FLASH_PageSize; NumOfPage = NumByteToWrite / SPI_FLASH_PageSize;
NumOfSingle = NumByteToWrite % SPI_FLASH_PageSize; NumOfSingle = NumByteToWrite % SPI_FLASH_PageSize;
if (Addr == 0) { /* WriteAddr is SPI_FLASH_PageSize aligned */ if (Addr == 0) { // WriteAddr is SPI_FLASH_PageSize aligned
if (NumOfPage == 0) { /* NumByteToWrite < SPI_FLASH_PageSize */ if (NumOfPage == 0) { // NumByteToWrite < SPI_FLASH_PageSize
SPI_FLASH_PageWrite(pBuffer, WriteAddr, NumByteToWrite); SPI_FLASH_PageWrite(pBuffer, WriteAddr, NumByteToWrite);
} }
else { /* NumByteToWrite > SPI_FLASH_PageSize */ else { // NumByteToWrite > SPI_FLASH_PageSize
while (NumOfPage--) { while (NumOfPage--) {
SPI_FLASH_PageWrite(pBuffer, WriteAddr, SPI_FLASH_PageSize); SPI_FLASH_PageWrite(pBuffer, WriteAddr, SPI_FLASH_PageSize);
WriteAddr += SPI_FLASH_PageSize; WriteAddr += SPI_FLASH_PageSize;
@ -319,9 +321,9 @@ void W25QXXFlash::SPI_FLASH_BufferWrite(uint8_t* pBuffer, uint32_t WriteAddr, ui
SPI_FLASH_PageWrite(pBuffer, WriteAddr, NumOfSingle); SPI_FLASH_PageWrite(pBuffer, WriteAddr, NumOfSingle);
} }
} }
else { /* WriteAddr is not SPI_FLASH_PageSize aligned */ else { // WriteAddr is not SPI_FLASH_PageSize aligned
if (NumOfPage == 0) { /* NumByteToWrite < SPI_FLASH_PageSize */ if (NumOfPage == 0) { // NumByteToWrite < SPI_FLASH_PageSize
if (NumOfSingle > count) { /* (NumByteToWrite + WriteAddr) > SPI_FLASH_PageSize */ if (NumOfSingle > count) { // (NumByteToWrite + WriteAddr) > SPI_FLASH_PageSize
temp = NumOfSingle - count; temp = NumOfSingle - count;
SPI_FLASH_PageWrite(pBuffer, WriteAddr, count); SPI_FLASH_PageWrite(pBuffer, WriteAddr, count);
WriteAddr += count; WriteAddr += count;
@ -332,7 +334,7 @@ void W25QXXFlash::SPI_FLASH_BufferWrite(uint8_t* pBuffer, uint32_t WriteAddr, ui
SPI_FLASH_PageWrite(pBuffer, WriteAddr, NumByteToWrite); SPI_FLASH_PageWrite(pBuffer, WriteAddr, NumByteToWrite);
} }
} }
else { /* NumByteToWrite > SPI_FLASH_PageSize */ else { // NumByteToWrite > SPI_FLASH_PageSize
NumByteToWrite -= count; NumByteToWrite -= count;
NumOfPage = NumByteToWrite / SPI_FLASH_PageSize; NumOfPage = NumByteToWrite / SPI_FLASH_PageSize;
NumOfSingle = NumByteToWrite % SPI_FLASH_PageSize; NumOfSingle = NumByteToWrite % SPI_FLASH_PageSize;
@ -364,24 +366,24 @@ void W25QXXFlash::SPI_FLASH_BufferWrite(uint8_t* pBuffer, uint32_t WriteAddr, ui
* Return : None * Return : None
*******************************************************************************/ *******************************************************************************/
void W25QXXFlash::SPI_FLASH_BufferRead(uint8_t* pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead) { void W25QXXFlash::SPI_FLASH_BufferRead(uint8_t* pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead) {
/* Select the FLASH: Chip Select low */ // Select the FLASH: Chip Select low
W25QXX_CS_L; W25QXX_CS_L;
/* Send "Read from Memory " instruction */ // Send "Read from Memory " instruction
spi_flash_Send(W25X_ReadData); spi_flash_Send(W25X_ReadData);
/* Send ReadAddr high nibble address byte to read from */ // Send ReadAddr high nibble address byte to read from
spi_flash_Send((ReadAddr & 0xFF0000) >> 16); spi_flash_Send((ReadAddr & 0xFF0000) >> 16);
/* Send ReadAddr medium nibble address byte to read from */ // Send ReadAddr medium nibble address byte to read from
spi_flash_Send((ReadAddr & 0xFF00) >> 8); spi_flash_Send((ReadAddr & 0xFF00) >> 8);
/* Send ReadAddr low nibble address byte to read from */ // Send ReadAddr low nibble address byte to read from
spi_flash_Send(ReadAddr & 0xFF); spi_flash_Send(ReadAddr & 0xFF);
if (NumByteToRead < 33) { if (NumByteToRead <= 32 || !flash_dma_mode) {
while (NumByteToRead--) { /* while there is data to be read */ while (NumByteToRead--) { // While there is data to be read
/* Read a byte from the FLASH */ // Read a byte from the FLASH
*pBuffer = spi_flash_Rec(); *pBuffer = spi_flash_Rec();
/* Point to the next location where the byte read will be saved */ // Point to the next location where the byte read will be saved
pBuffer++; pBuffer++;
} }
} }

View file

@ -401,8 +401,8 @@ bool SdBaseFile::make83Name(const char* str, uint8_t* name, const char** ptr) {
// Fail for illegal characters // Fail for illegal characters
PGM_P p = PSTR("|<>^+=?/[];,*\"\\"); PGM_P p = PSTR("|<>^+=?/[];,*\"\\");
while (uint8_t b = pgm_read_byte(p++)) if (b == c) return false; while (uint8_t b = pgm_read_byte(p++)) if (b == c) return false;
if (i > n || c < 0x21 || c == 0x7F) return false; // Check size, non-printable characters if (i > n || c < 0x21 || c == 0x7F) return false; // Check size, non-printable characters
name[i++] = (c < 'a' || c > 'z') ? (c) : (c + ('A' - 'a')); // Uppercase required for 8.3 name name[i++] = c + (WITHIN(c, 'a', 'z') ? 'A' - 'a' : 0); // Uppercase required for 8.3 name
} }
} }
*ptr = str; // Set passed pointer to the end *ptr = str; // Set passed pointer to the end

View file

@ -214,6 +214,7 @@ lib_deps =
HAS_TFT_LVGL_UI = lvgl=https://github.com/makerbase-mks/LVGL-6.1.1-MKS/archive/master.zip HAS_TFT_LVGL_UI = lvgl=https://github.com/makerbase-mks/LVGL-6.1.1-MKS/archive/master.zip
src_filter=+<src/lcd/extui/lib/mks_ui> src_filter=+<src/lcd/extui/lib/mks_ui>
extra_scripts=download_mks_assets.py extra_scripts=download_mks_assets.py
MKS_WIFI_MODULE = QRCode=https://github.com/makerbase-mks/QRCode/archive/master.zip
HAS_TRINAMIC_CONFIG = TMCStepper@~0.7.1 HAS_TRINAMIC_CONFIG = TMCStepper@~0.7.1
src_filter=+<src/feature/tmc_util.cpp> +<src/module/stepper/trinamic.cpp> +<src/gcode/feature/trinamic/M122.cpp> +<src/gcode/feature/trinamic/M906.cpp> +<src/gcode/feature/trinamic/M911-M914.cpp> src_filter=+<src/feature/tmc_util.cpp> +<src/module/stepper/trinamic.cpp> +<src/gcode/feature/trinamic/M122.cpp> +<src/gcode/feature/trinamic/M906.cpp> +<src/gcode/feature/trinamic/M911-M914.cpp>
HAS_STEALTHCHOP = src_filter=+<src/gcode/feature/trinamic/M569.cpp> HAS_STEALTHCHOP = src_filter=+<src/gcode/feature/trinamic/M569.cpp>