makerbase
4 years ago
committed by
Scott Lahteine
94 changed files with 12673 additions and 2970 deletions
@ -0,0 +1,203 @@ |
|||
/**
|
|||
* 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, HAS_BED_PROBE) |
|||
|
|||
#include "lv_conf.h" |
|||
#include "draw_ui.h" |
|||
|
|||
#include "../../../../MarlinCore.h" |
|||
#include "../../../../module/planner.h" |
|||
#include "../../../../module/probe.h" |
|||
|
|||
extern lv_group_t * g; |
|||
static lv_obj_t * scr; |
|||
|
|||
#define ID_OFFSET_RETURN 1 |
|||
#define ID_OFFSET_X 2 |
|||
#define ID_OFFSET_Y 3 |
|||
#define ID_OFFSET_Z 4 |
|||
|
|||
static void event_handler(lv_obj_t * obj, lv_event_t event) { |
|||
switch (obj->mks_obj_id) { |
|||
case ID_OFFSET_RETURN: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
lv_clear_auto_level_offset_settings(); |
|||
draw_return_ui(); |
|||
} |
|||
break; |
|||
case ID_OFFSET_X: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = x_offset; |
|||
lv_clear_auto_level_offset_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
case ID_OFFSET_Y: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = y_offset; |
|||
lv_clear_auto_level_offset_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
case ID_OFFSET_Z: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = z_offset; |
|||
lv_clear_auto_level_offset_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
} |
|||
} |
|||
|
|||
void lv_draw_auto_level_offset_settings(void) { |
|||
lv_obj_t *buttonBack = NULL, *label_Back = NULL; |
|||
lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL; |
|||
lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL; |
|||
lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL; |
|||
lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL; |
|||
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != NOZZLE_PROBE_OFFSET_UI) { |
|||
disp_state_stack._disp_index++; |
|||
disp_state_stack._disp_state[disp_state_stack._disp_index] = NOZZLE_PROBE_OFFSET_UI; |
|||
} |
|||
disp_state = NOZZLE_PROBE_OFFSET_UI; |
|||
|
|||
scr = lv_obj_create(NULL, NULL); |
|||
|
|||
lv_obj_set_style(scr, &tft_style_scr); |
|||
lv_scr_load(scr); |
|||
lv_obj_clean(scr); |
|||
|
|||
lv_obj_t * title = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(title, &tft_style_label_rel); |
|||
lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); |
|||
lv_label_set_text(title, machine_menu.OffsetConfTitle); |
|||
|
|||
lv_refr_now(lv_refr_get_disp_refreshing()); |
|||
|
|||
labelXText = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelXText, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10); |
|||
lv_label_set_text(labelXText, machine_menu.Xoffset); |
|||
|
|||
buttonXValue = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_OFFSET_X, NULL, 0); |
|||
lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelXValue = lv_label_create(buttonXValue, NULL); |
|||
|
|||
line1 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line1, line_points[0]); |
|||
|
|||
labelYText = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelYText, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10); |
|||
lv_label_set_text(labelYText, machine_menu.Yoffset); |
|||
|
|||
buttonYValue = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_OFFSET_Y, NULL, 0); |
|||
lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelYValue = lv_label_create(buttonYValue, NULL); |
|||
|
|||
line2 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line2, line_points[1]); |
|||
|
|||
labelZText = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelZText, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10); |
|||
lv_label_set_text(labelZText, machine_menu.Zoffset); |
|||
|
|||
buttonZValue = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_OFFSET_Z, NULL, 0); |
|||
lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelZValue = lv_label_create(buttonZValue, NULL); |
|||
|
|||
line3 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line3, line_points[2]); |
|||
|
|||
buttonBack = lv_btn_create(scr, NULL); |
|||
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_OFFSET_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); |
|||
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); |
|||
lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); |
|||
label_Back = lv_label_create(buttonBack, NULL); |
|||
|
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) { |
|||
lv_group_add_obj(g, buttonXValue); |
|||
lv_group_add_obj(g, buttonYValue); |
|||
lv_group_add_obj(g, buttonZValue); |
|||
lv_group_add_obj(g, buttonBack); |
|||
} |
|||
#endif |
|||
|
|||
if (gCfgItems.multiple_language != 0) { |
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%.1f"), TERN(HAS_PROBE_XY_OFFSET, probe.offset.x, 0)); |
|||
lv_label_set_text(labelXValue, public_buf_l); |
|||
lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%.1f"), TERN(HAS_PROBE_XY_OFFSET, probe.offset.y, 0)); |
|||
lv_label_set_text(labelYValue, public_buf_l); |
|||
lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%.1f"), probe.offset.z); |
|||
lv_label_set_text(labelZValue, public_buf_l); |
|||
lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
lv_label_set_text(label_Back, common_menu.text_back); |
|||
lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); |
|||
} |
|||
} |
|||
|
|||
void lv_clear_auto_level_offset_settings() { |
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); |
|||
#endif |
|||
lv_obj_del(scr); |
|||
} |
|||
|
|||
#endif // HAS_TFT_LVGL_UI && HAS_BED_PROBE
|
@ -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_auto_level_offset_settings(void); |
|||
extern void lv_clear_auto_level_offset_settings(); |
|||
|
|||
#ifdef __cplusplus |
|||
} /* C-declarations for C++ */ |
|||
#endif |
@ -0,0 +1,352 @@ |
|||
/**
|
|||
* 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 "lv_conf.h" |
|||
#include "draw_ui.h" |
|||
|
|||
#include "../../../../MarlinCore.h" |
|||
#include "../../../../gcode/queue.h" |
|||
#include "../../../../gcode/gcode.h" |
|||
|
|||
#if HAS_BED_PROBE |
|||
#include "../../../../module/probe.h" |
|||
#endif |
|||
|
|||
extern lv_group_t * g; |
|||
static lv_obj_t * scr; |
|||
|
|||
static lv_obj_t *labelV, *buttonV, * zOffsetText; |
|||
|
|||
#define ID_BABY_STEP_X_P 1 |
|||
#define ID_BABY_STEP_X_N 2 |
|||
#define ID_BABY_STEP_Y_P 3 |
|||
#define ID_BABY_STEP_Y_N 4 |
|||
#define ID_BABY_STEP_Z_P 5 |
|||
#define ID_BABY_STEP_Z_N 6 |
|||
#define ID_BABY_STEP_DIST 7 |
|||
#define ID_BABY_STEP_RETURN 8 |
|||
|
|||
static float babystep_dist=0.01; |
|||
static uint8_t has_adjust_z = 0; |
|||
|
|||
static void event_handler(lv_obj_t * obj, lv_event_t event) { |
|||
char baby_buf[30]={0}; |
|||
switch (obj->mks_obj_id) { |
|||
case ID_BABY_STEP_X_P: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
// nothing to do
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
ZERO(baby_buf); |
|||
sprintf_P(baby_buf, PSTR("M290 X%.3f"),babystep_dist); |
|||
gcode.process_subcommands_now_P(PSTR(baby_buf)); |
|||
has_adjust_z = 1; |
|||
} |
|||
break; |
|||
case ID_BABY_STEP_X_N: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
// nothing to do
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
ZERO(baby_buf); |
|||
sprintf_P(baby_buf, PSTR("M290 X%.3f"),((float)0 - babystep_dist)); |
|||
gcode.process_subcommands_now_P(PSTR(baby_buf)); |
|||
has_adjust_z = 1; |
|||
} |
|||
break; |
|||
case ID_BABY_STEP_Y_P: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
// nothing to do
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
ZERO(baby_buf); |
|||
sprintf_P(baby_buf, PSTR("M290 Y%.3f"), babystep_dist); |
|||
gcode.process_subcommands_now_P(PSTR(baby_buf)); |
|||
has_adjust_z = 1; |
|||
} |
|||
break; |
|||
case ID_BABY_STEP_Y_N: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
// nothing to do
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
ZERO(baby_buf); |
|||
sprintf_P(baby_buf, PSTR("M290 Y%.3f"),((float)0 - babystep_dist)); |
|||
gcode.process_subcommands_now_P(PSTR(baby_buf)); |
|||
has_adjust_z = 1; |
|||
} |
|||
break; |
|||
case ID_BABY_STEP_Z_P: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
// nothing to do
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
ZERO(baby_buf); |
|||
sprintf_P(baby_buf, PSTR("M290 Z%.3f"), babystep_dist); |
|||
gcode.process_subcommands_now_P(PSTR(baby_buf)); |
|||
has_adjust_z = 1; |
|||
} |
|||
break; |
|||
case ID_BABY_STEP_Z_N: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
// nothing to do
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
ZERO(baby_buf); |
|||
sprintf_P(baby_buf, PSTR("M290 Z%.3f"),((float)0 - babystep_dist)); |
|||
gcode.process_subcommands_now_P(PSTR(baby_buf)); |
|||
has_adjust_z = 1; |
|||
} |
|||
break; |
|||
case ID_BABY_STEP_DIST: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
// nothing to do
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
if (abs((int)(100 * babystep_dist)) == 1) |
|||
babystep_dist = 0.05; |
|||
else if (abs((int)(100 * babystep_dist)) == 5) |
|||
babystep_dist = 0.1; |
|||
else |
|||
babystep_dist = 0.01; |
|||
disp_baby_step_dist(); |
|||
} |
|||
|
|||
break; |
|||
case ID_BABY_STEP_RETURN: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
// nothing to do
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
if (has_adjust_z == 1) { |
|||
gcode.process_subcommands_now_P(PSTR("M500")); |
|||
has_adjust_z = 0; |
|||
} |
|||
clear_cur_ui(); |
|||
draw_return_ui(); |
|||
} |
|||
break; |
|||
} |
|||
} |
|||
|
|||
void lv_draw_baby_stepping(void) { |
|||
lv_obj_t *buttonXI, *buttonXD, *buttonYI, *buttonYD, *buttonZI, *buttonZD, *buttonBack; |
|||
|
|||
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != BABY_STEP_UI) { |
|||
disp_state_stack._disp_index++; |
|||
disp_state_stack._disp_state[disp_state_stack._disp_index] = BABY_STEP_UI; |
|||
} |
|||
disp_state = BABY_STEP_UI; |
|||
|
|||
scr = lv_obj_create(NULL, NULL); |
|||
|
|||
lv_obj_set_style(scr, &tft_style_scr); |
|||
lv_scr_load(scr); |
|||
lv_obj_clean(scr); |
|||
|
|||
lv_obj_t * title = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(title, &tft_style_label_rel); |
|||
lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); |
|||
lv_label_set_text(title, creat_title_text()); |
|||
|
|||
lv_refr_now(lv_refr_get_disp_refreshing()); |
|||
|
|||
// Create an Image button
|
|||
buttonXI = lv_imgbtn_create(scr, NULL); |
|||
buttonXD = lv_imgbtn_create(scr, NULL); |
|||
buttonYI = lv_imgbtn_create(scr, NULL); |
|||
buttonYD = lv_imgbtn_create(scr, NULL); |
|||
buttonZI = lv_imgbtn_create(scr, NULL); |
|||
buttonZD = lv_imgbtn_create(scr, NULL); |
|||
buttonV = lv_imgbtn_create(scr, NULL); |
|||
buttonBack = lv_imgbtn_create(scr, NULL); |
|||
|
|||
lv_obj_set_event_cb_mks(buttonXI, event_handler, ID_BABY_STEP_X_P, NULL, 0); |
|||
lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_REL, "F:/bmp_xAdd.bin"); |
|||
lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_PR, "F:/bmp_xAdd.bin"); |
|||
lv_imgbtn_set_style(buttonXI, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonXI, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
|
|||
#if 1 |
|||
lv_obj_set_event_cb_mks(buttonXD, event_handler, ID_BABY_STEP_X_N, NULL, 0); |
|||
lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_REL, "F:/bmp_xDec.bin"); |
|||
lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_PR, "F:/bmp_xDec.bin"); |
|||
lv_imgbtn_set_style(buttonXD, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonXD, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
|
|||
lv_obj_set_event_cb_mks(buttonYI, event_handler, ID_BABY_STEP_Y_P, NULL, 0); |
|||
lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_REL, "F:/bmp_yAdd.bin"); |
|||
lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_PR, "F:/bmp_yAdd.bin"); |
|||
lv_imgbtn_set_style(buttonYI, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonYI, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
|
|||
lv_obj_set_event_cb_mks(buttonYD, event_handler, ID_BABY_STEP_Y_N, NULL, 0); |
|||
lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_REL, "F:/bmp_yDec.bin"); |
|||
lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_PR, "F:/bmp_yDec.bin"); |
|||
lv_imgbtn_set_style(buttonYD, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonYD, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
|
|||
lv_obj_set_event_cb_mks(buttonZI, event_handler, ID_BABY_STEP_Z_P, NULL, 0); |
|||
lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_REL, "F:/bmp_zAdd.bin"); |
|||
lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_PR, "F:/bmp_zAdd.bin"); |
|||
lv_imgbtn_set_style(buttonZI, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonZI, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
|
|||
lv_obj_set_event_cb_mks(buttonZD, event_handler, ID_BABY_STEP_Z_N, NULL, 0); |
|||
lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_REL, "F:/bmp_zDec.bin"); |
|||
lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_PR, "F:/bmp_zDec.bin"); |
|||
lv_imgbtn_set_style(buttonZD, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonZD, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
|
|||
lv_obj_set_event_cb_mks(buttonV, event_handler, ID_BABY_STEP_DIST, NULL, 0); |
|||
lv_imgbtn_set_style(buttonV, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonV, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
|
|||
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_BABY_STEP_RETURN, NULL, 0); |
|||
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin"); |
|||
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin"); |
|||
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
|
|||
#endif // if 1
|
|||
lv_obj_set_pos(buttonXI, INTERVAL_V, titleHeight); |
|||
lv_obj_set_pos(buttonYI, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight); |
|||
lv_obj_set_pos(buttonZI, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight); |
|||
lv_obj_set_pos(buttonV, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight); |
|||
lv_obj_set_pos(buttonXD, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); |
|||
lv_obj_set_pos(buttonYD, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight); |
|||
lv_obj_set_pos(buttonZD, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight); |
|||
lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); |
|||
|
|||
// Create labels on the image buttons
|
|||
lv_btn_set_layout(buttonXI, LV_LAYOUT_OFF); |
|||
lv_btn_set_layout(buttonXD, LV_LAYOUT_OFF); |
|||
lv_btn_set_layout(buttonYI, LV_LAYOUT_OFF); |
|||
lv_btn_set_layout(buttonYD, LV_LAYOUT_OFF); |
|||
lv_btn_set_layout(buttonZI, LV_LAYOUT_OFF); |
|||
lv_btn_set_layout(buttonZD, LV_LAYOUT_OFF); |
|||
lv_btn_set_layout(buttonV, LV_LAYOUT_OFF); |
|||
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); |
|||
|
|||
lv_obj_t *labelXI = lv_label_create(buttonXI, NULL); |
|||
lv_obj_t *labelXD = lv_label_create(buttonXD, NULL); |
|||
lv_obj_t *labelYI = lv_label_create(buttonYI, NULL); |
|||
lv_obj_t *labelYD = lv_label_create(buttonYD, NULL); |
|||
lv_obj_t *labelZI = lv_label_create(buttonZI, NULL); |
|||
lv_obj_t *labelZD = lv_label_create(buttonZD, NULL); |
|||
labelV = lv_label_create(buttonV, NULL); |
|||
lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); |
|||
|
|||
if (gCfgItems.multiple_language != 0) { |
|||
lv_label_set_text(labelXI, move_menu.x_add); |
|||
lv_obj_align(labelXI, buttonXI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); |
|||
|
|||
lv_label_set_text(labelXD, move_menu.x_dec); |
|||
lv_obj_align(labelXD, buttonXD, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); |
|||
|
|||
lv_label_set_text(labelYI, move_menu.y_add); |
|||
lv_obj_align(labelYI, buttonYI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); |
|||
|
|||
lv_label_set_text(labelYD, move_menu.y_dec); |
|||
lv_obj_align(labelYD, buttonYD, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); |
|||
|
|||
lv_label_set_text(labelZI, move_menu.z_add); |
|||
lv_obj_align(labelZI, buttonZI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); |
|||
|
|||
lv_label_set_text(labelZD, move_menu.z_dec); |
|||
lv_obj_align(labelZD, buttonZD, 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); |
|||
} |
|||
|
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) { |
|||
lv_group_add_obj(g, buttonXI); |
|||
lv_group_add_obj(g, buttonXD); |
|||
lv_group_add_obj(g, buttonYI); |
|||
lv_group_add_obj(g, buttonYD); |
|||
lv_group_add_obj(g, buttonZI); |
|||
lv_group_add_obj(g, buttonZD); |
|||
lv_group_add_obj(g, buttonV); |
|||
lv_group_add_obj(g, buttonBack); |
|||
} |
|||
#endif |
|||
|
|||
disp_baby_step_dist(); |
|||
|
|||
zOffsetText = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(zOffsetText, &tft_style_label_rel); |
|||
lv_obj_set_pos(zOffsetText, 290, TITLE_YPOS); |
|||
disp_z_offset_value(); |
|||
} |
|||
|
|||
void disp_baby_step_dist() { |
|||
// char buf[30] = {0};
|
|||
|
|||
if ((int)(100 * babystep_dist) == 1) { |
|||
lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_baby_move0_01.bin"); |
|||
lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_baby_move0_01.bin"); |
|||
} |
|||
else if ((int)(100 * babystep_dist) == 5) { |
|||
lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_baby_move0_05.bin"); |
|||
lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_baby_move0_05.bin"); |
|||
} |
|||
else if ((int)(100 * babystep_dist) == 10) { |
|||
lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_baby_move0_1.bin"); |
|||
lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_baby_move0_1.bin"); |
|||
} |
|||
if (gCfgItems.multiple_language != 0) { |
|||
if ((int)(100 * babystep_dist) == 1) { |
|||
lv_label_set_text(labelV, move_menu.step_001mm); |
|||
lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); |
|||
} |
|||
else if ((int)(100 * babystep_dist) == 5) { |
|||
lv_label_set_text(labelV, move_menu.step_005mm); |
|||
lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); |
|||
} |
|||
else if ((int)(100 * babystep_dist) == 10) { |
|||
lv_label_set_text(labelV, move_menu.step_01mm); |
|||
lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void disp_z_offset_value() { |
|||
char buf[20]; |
|||
|
|||
ZERO(buf); |
|||
sprintf_P(buf, PSTR("offset Z: %.3f"), (double)TERN(HAS_BED_PROBE, probe.offset.z, 0)); |
|||
lv_label_set_text(zOffsetText, buf); |
|||
} |
|||
|
|||
void lv_clear_baby_stepping() { |
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); |
|||
#endif |
|||
lv_obj_del(scr); |
|||
} |
|||
|
|||
#endif // HAS_TFT_LVGL_UI
|
@ -0,0 +1,36 @@ |
|||
/**
|
|||
* 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_baby_stepping(void); |
|||
extern void lv_clear_baby_stepping(); |
|||
extern void disp_baby_step_dist(); |
|||
extern void disp_z_offset_value(); |
|||
|
|||
//extern void disp_temp_ready_print();
|
|||
#ifdef __cplusplus |
|||
} /* C-declarations for C++ */ |
|||
#endif |
@ -0,0 +1,172 @@ |
|||
/**
|
|||
* 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 "lv_conf.h" |
|||
#include "draw_ui.h" |
|||
|
|||
#include "../../../../MarlinCore.h" |
|||
#include "../../../../module/planner.h" |
|||
#include "../../../../module/stepper/indirection.h" |
|||
#include "../../../../feature/tmc_util.h" |
|||
#include "../../../../gcode/gcode.h" |
|||
#include "../../../../module/planner.h" |
|||
|
|||
#if BUTTONS_EXIST(EN1, EN2) |
|||
|
|||
extern lv_group_t * g; |
|||
static lv_obj_t * scr; |
|||
static lv_obj_t * buttonEncoderState = NULL; |
|||
static lv_obj_t *labelEncoderState = NULL; |
|||
|
|||
#define ID_ENCODER_RETURN 1 |
|||
#define ID_ENCODER_STATE 2 |
|||
|
|||
static void event_handler(lv_obj_t * obj, lv_event_t event) { |
|||
switch (obj->mks_obj_id) { |
|||
case ID_ENCODER_RETURN: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
lv_clear_encoder_settings(); |
|||
draw_return_ui(); |
|||
} |
|||
break; |
|||
case ID_ENCODER_STATE: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
if (gCfgItems.encoder_enable) { |
|||
gCfgItems.encoder_enable = false; |
|||
lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); |
|||
lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); |
|||
lv_label_set_text(labelEncoderState, machine_menu.disable); |
|||
update_spi_flash(); |
|||
} |
|||
else { |
|||
gCfgItems.encoder_enable = true; |
|||
lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, "F:/bmp_enable.bin"); |
|||
lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, "F:/bmp_enable.bin"); |
|||
lv_label_set_text(labelEncoderState, machine_menu.enable); |
|||
update_spi_flash(); |
|||
} |
|||
} |
|||
break; |
|||
} |
|||
} |
|||
|
|||
void lv_draw_encoder_settings(void) { |
|||
lv_obj_t *buttonBack = NULL, *label_Back = NULL; |
|||
lv_obj_t *labelEncoderTips = NULL; |
|||
|
|||
lv_obj_t * line1 = NULL; |
|||
|
|||
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ENCODER_SETTINGS_UI) { |
|||
disp_state_stack._disp_index++; |
|||
disp_state_stack._disp_state[disp_state_stack._disp_index] = ENCODER_SETTINGS_UI; |
|||
} |
|||
disp_state = ENCODER_SETTINGS_UI; |
|||
|
|||
scr = lv_obj_create(NULL, NULL); |
|||
|
|||
lv_obj_set_style(scr, &tft_style_scr); |
|||
lv_scr_load(scr); |
|||
lv_obj_clean(scr); |
|||
|
|||
lv_obj_t * title = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(title, &tft_style_label_rel); |
|||
lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); |
|||
lv_label_set_text(title, machine_menu.EncoderConfTitle); |
|||
|
|||
lv_refr_now(lv_refr_get_disp_refreshing()); |
|||
|
|||
labelEncoderTips = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelEncoderTips, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelEncoderTips, PARA_UI_POS_X, PARA_UI_POS_Y + 10); |
|||
lv_label_set_text(labelEncoderTips, machine_menu.EncoderConfText); |
|||
|
|||
buttonEncoderState = lv_imgbtn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonEncoderState, PARA_UI_STATE_POS_X, PARA_UI_POS_Y + PARA_UI_STATE_V); |
|||
if (gCfgItems.encoder_enable) { |
|||
lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, "F:/bmp_enable.bin"); |
|||
lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, "F:/bmp_enable.bin"); |
|||
} |
|||
else { |
|||
lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); |
|||
lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); |
|||
} |
|||
|
|||
lv_obj_set_event_cb_mks(buttonEncoderState, event_handler, ID_ENCODER_STATE, NULL, 0); |
|||
|
|||
lv_imgbtn_set_style(buttonEncoderState, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonEncoderState, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
lv_btn_set_layout(buttonEncoderState, LV_LAYOUT_OFF); |
|||
labelEncoderState = lv_label_create(buttonEncoderState, NULL); |
|||
|
|||
line1 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line1, line_points[0]); |
|||
|
|||
buttonBack = lv_imgbtn_create(scr, NULL); |
|||
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_ENCODER_RETURN, NULL, 0); |
|||
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin"); |
|||
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin"); |
|||
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
|
|||
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); |
|||
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); |
|||
label_Back = lv_label_create(buttonBack, NULL); |
|||
|
|||
if (gCfgItems.encoder_enable) { |
|||
lv_label_set_text(labelEncoderState, machine_menu.enable); |
|||
lv_obj_align(labelEncoderState, buttonEncoderState, LV_ALIGN_CENTER, 0, 0); |
|||
} |
|||
else { |
|||
lv_label_set_text(labelEncoderState, machine_menu.disable); |
|||
lv_obj_align(labelEncoderState, buttonEncoderState, LV_ALIGN_CENTER, 0, 0); |
|||
} |
|||
|
|||
lv_label_set_text(label_Back, common_menu.text_back); |
|||
lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) { |
|||
lv_group_add_obj(g, buttonEncoderState); |
|||
lv_group_add_obj(g, buttonBack); |
|||
} |
|||
#endif |
|||
} |
|||
|
|||
void lv_clear_encoder_settings() { |
|||
#if HAS_ROTARY_ENCODER |
|||
lv_group_remove_all_objs(g); |
|||
#endif |
|||
lv_obj_del(scr); |
|||
} |
|||
|
|||
#endif // BUTTONS_EXIST(EN1, EN2)
|
|||
|
|||
#endif // HAS_TFT_LVGL_UI
|
@ -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_encoder_settings(void); |
|||
extern void lv_clear_encoder_settings(); |
|||
|
|||
#ifdef __cplusplus |
|||
} /* C-declarations for C++ */ |
|||
#endif |
@ -0,0 +1,270 @@ |
|||
/**
|
|||
* 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 "lv_conf.h" |
|||
#include "draw_ui.h" |
|||
|
|||
#include "../../../../MarlinCore.h" |
|||
#include "../../../../module/temperature.h" |
|||
#include "../../../../gcode/queue.h" |
|||
#include "../../../../gcode/gcode.h" |
|||
#include "../../../../module/motion.h" |
|||
#include "../../../../module/planner.h" |
|||
|
|||
extern lv_group_t * g; |
|||
static lv_obj_t * scr; |
|||
static lv_obj_t *buttoType; |
|||
static lv_obj_t *labelType; |
|||
static lv_obj_t * tempText1; |
|||
|
|||
#define ID_FILAMNT_IN 1 |
|||
#define ID_FILAMNT_OUT 2 |
|||
#define ID_FILAMNT_TYPE 3 |
|||
#define ID_FILAMNT_RETURN 4 |
|||
|
|||
extern feedRate_t feedrate_mm_s; |
|||
|
|||
static void event_handler(lv_obj_t * obj, lv_event_t event) { |
|||
switch (obj->mks_obj_id) { |
|||
case ID_FILAMNT_IN: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
// nothing to do
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
uiCfg.filament_load_heat_flg = 1; |
|||
if ((abs(thermalManager.temp_hotend[uiCfg.curSprayerChoose].target - thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius) <= 1) |
|||
|| (gCfgItems.filament_limit_temper <= thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius)) { |
|||
lv_clear_filament_change(); |
|||
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED); |
|||
} |
|||
else { |
|||
lv_clear_filament_change(); |
|||
lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_HEAT); |
|||
if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].target < gCfgItems.filament_limit_temper) { |
|||
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = gCfgItems.filament_limit_temper; |
|||
thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); |
|||
} |
|||
} |
|||
} |
|||
break; |
|||
case ID_FILAMNT_OUT: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
// nothing to do
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
uiCfg.filament_unload_heat_flg=1; |
|||
if ((thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > 0) |
|||
&& ((abs((int)((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target - thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius)) <= 1) |
|||
|| ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= gCfgItems.filament_limit_temper)) |
|||
) { |
|||
lv_clear_filament_change(); |
|||
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED); |
|||
} |
|||
else { |
|||
lv_clear_filament_change(); |
|||
lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_HEAT); |
|||
if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].target < gCfgItems.filament_limit_temper) { |
|||
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = gCfgItems.filament_limit_temper; |
|||
thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); |
|||
} |
|||
filament_sprayer_temp(); |
|||
} |
|||
} |
|||
break; |
|||
case ID_FILAMNT_TYPE: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
// nothing to do
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
#if HAS_MULTI_EXTRUDER |
|||
if (uiCfg.curSprayerChoose == 0) |
|||
uiCfg.curSprayerChoose = 1; |
|||
else if (uiCfg.curSprayerChoose == 1) |
|||
uiCfg.curSprayerChoose = 0; |
|||
#endif |
|||
disp_filament_type(); |
|||
} |
|||
break; |
|||
case ID_FILAMNT_RETURN: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
// nothing to do
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
#if HAS_MULTI_EXTRUDER |
|||
if (uiCfg.print_state != IDLE && uiCfg.print_state != REPRINTED) |
|||
gcode.process_subcommands_now_P(uiCfg.curSprayerChoose_bak == 1 ? PSTR("T1") : PSTR("T0")); |
|||
#endif |
|||
feedrate_mm_s = (float)uiCfg.moveSpeed_bak; |
|||
if (uiCfg.print_state == PAUSED) |
|||
planner.set_e_position_mm((destination.e = current_position.e = uiCfg.current_e_position_bak)); |
|||
//current_position.e = destination.e = uiCfg.current_e_position_bak;
|
|||
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = uiCfg.desireSprayerTempBak; |
|||
|
|||
clear_cur_ui(); |
|||
draw_return_ui(); |
|||
} |
|||
break; |
|||
} |
|||
} |
|||
|
|||
void lv_draw_filament_change(void) { |
|||
lv_obj_t *buttonIn, *buttonOut; |
|||
lv_obj_t *buttonBack; |
|||
|
|||
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != FILAMENTCHANGE_UI) { |
|||
disp_state_stack._disp_index++; |
|||
disp_state_stack._disp_state[disp_state_stack._disp_index] = FILAMENTCHANGE_UI; |
|||
} |
|||
disp_state = FILAMENTCHANGE_UI; |
|||
|
|||
scr = lv_obj_create(NULL, NULL); |
|||
|
|||
lv_obj_set_style(scr, &tft_style_scr); |
|||
lv_scr_load(scr); |
|||
lv_obj_clean(scr); |
|||
|
|||
lv_obj_t * title = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(title, &tft_style_label_rel); |
|||
lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); |
|||
lv_label_set_text(title, creat_title_text()); |
|||
|
|||
lv_refr_now(lv_refr_get_disp_refreshing()); |
|||
|
|||
// Create an Image button
|
|||
buttonIn = lv_imgbtn_create(scr, NULL); |
|||
buttonOut = lv_imgbtn_create(scr, NULL); |
|||
buttoType = lv_imgbtn_create(scr, NULL); |
|||
buttonBack = lv_imgbtn_create(scr, NULL); |
|||
|
|||
lv_obj_set_event_cb_mks(buttonIn, event_handler, ID_FILAMNT_IN, NULL, 0); |
|||
lv_imgbtn_set_src(buttonIn, LV_BTN_STATE_REL, "F:/bmp_in.bin"); |
|||
lv_imgbtn_set_src(buttonIn, LV_BTN_STATE_PR, "F:/bmp_in.bin"); |
|||
lv_imgbtn_set_style(buttonIn, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonIn, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
lv_obj_clear_protect(buttonIn, LV_PROTECT_FOLLOW); |
|||
|
|||
lv_obj_set_event_cb_mks(buttonOut, event_handler, ID_FILAMNT_OUT, NULL, 0); |
|||
lv_imgbtn_set_src(buttonOut, LV_BTN_STATE_REL, "F:/bmp_out.bin"); |
|||
lv_imgbtn_set_src(buttonOut, LV_BTN_STATE_PR, "F:/bmp_out.bin"); |
|||
lv_imgbtn_set_style(buttonOut, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonOut, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
|
|||
lv_obj_set_event_cb_mks(buttoType, event_handler, ID_FILAMNT_TYPE, NULL, 0); |
|||
lv_imgbtn_set_style(buttoType, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttoType, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
|
|||
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_FILAMNT_RETURN, NULL, 0); |
|||
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin"); |
|||
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin"); |
|||
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
|
|||
lv_obj_set_pos(buttonIn, INTERVAL_V, titleHeight); |
|||
lv_obj_set_pos(buttonOut, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight); |
|||
lv_obj_set_pos(buttoType, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight); |
|||
lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight); |
|||
|
|||
// Create labels on the image buttons
|
|||
lv_btn_set_layout(buttonIn, LV_LAYOUT_OFF); |
|||
lv_btn_set_layout(buttonOut, LV_LAYOUT_OFF); |
|||
lv_btn_set_layout(buttoType, LV_LAYOUT_OFF); |
|||
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); |
|||
|
|||
lv_obj_t *labelIn = lv_label_create(buttonIn, NULL); |
|||
lv_obj_t *labelOut = lv_label_create(buttonOut, NULL); |
|||
labelType = lv_label_create(buttoType, NULL); |
|||
lv_obj_t *label_Back = lv_label_create(buttonBack, NULL); |
|||
|
|||
if (gCfgItems.multiple_language != 0) { |
|||
lv_label_set_text(labelIn, filament_menu.in); |
|||
lv_obj_align(labelIn, buttonIn, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); |
|||
|
|||
lv_label_set_text(labelOut, filament_menu.out); |
|||
lv_obj_align(labelOut, buttonOut, 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); |
|||
} |
|||
|
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) { |
|||
lv_group_add_obj(g, buttonIn); |
|||
lv_group_add_obj(g, buttonOut); |
|||
lv_group_add_obj(g, buttoType); |
|||
lv_group_add_obj(g, buttonBack); |
|||
} |
|||
#endif |
|||
|
|||
disp_filament_type(); |
|||
|
|||
tempText1 = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(tempText1, &tft_style_label_rel); |
|||
disp_filament_temp(); |
|||
} |
|||
|
|||
void disp_filament_type() { |
|||
if (uiCfg.curSprayerChoose == 1) { |
|||
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru2.bin"); |
|||
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru2.bin"); |
|||
if (gCfgItems.multiple_language != 0) { |
|||
lv_label_set_text(labelType, preheat_menu.ext2); |
|||
lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); |
|||
} |
|||
} |
|||
else { |
|||
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru1.bin"); |
|||
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru1.bin"); |
|||
if (gCfgItems.multiple_language != 0) { |
|||
lv_label_set_text(labelType, preheat_menu.ext1); |
|||
lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void disp_filament_temp() { |
|||
char buf[20] = {0}; |
|||
|
|||
public_buf_l[0] = '\0'; |
|||
|
|||
if (uiCfg.curSprayerChoose < 1) |
|||
strcat(public_buf_l, preheat_menu.ext1); |
|||
else |
|||
strcat(public_buf_l, preheat_menu.ext2); |
|||
sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target); |
|||
|
|||
strcat_P(public_buf_l, PSTR(": ")); |
|||
strcat(public_buf_l, buf); |
|||
lv_label_set_text(tempText1, public_buf_l); |
|||
lv_obj_align(tempText1, NULL, LV_ALIGN_CENTER, 0, -50); |
|||
} |
|||
|
|||
void lv_clear_filament_change() { |
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); |
|||
#endif |
|||
lv_obj_del(scr); |
|||
} |
|||
|
|||
#endif // HAS_TFT_LVGL_UI
|
@ -0,0 +1,36 @@ |
|||
/**
|
|||
* 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_filament_change(void); |
|||
extern void lv_clear_filament_change(); |
|||
extern void disp_filament_type(); |
|||
extern void disp_filament_temp(); |
|||
|
|||
//extern void disp_temp_ready_print();
|
|||
#ifdef __cplusplus |
|||
} /* C-declarations for C++ */ |
|||
#endif |
@ -0,0 +1,329 @@ |
|||
/**
|
|||
* 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 "lv_conf.h" |
|||
#include "draw_ui.h" |
|||
|
|||
#include "../../../../MarlinCore.h" |
|||
#include "../../../../module/planner.h" |
|||
|
|||
extern lv_group_t * g; |
|||
static lv_obj_t * scr; |
|||
|
|||
#define ID_FILAMENT_SET_RETURN 1 |
|||
#define ID_FILAMENT_SET_IN_LENGTH 2 |
|||
#define ID_FILAMENT_SET_IN_SPEED 3 |
|||
#define ID_FILAMENT_SET_OUT_LENGTH 4 |
|||
#define ID_FILAMENT_SET_OUT_SPEED 5 |
|||
#define ID_FILAMENT_SET_TEMP 6 |
|||
#define ID_FILAMENT_SET_DOWN 12 |
|||
#define ID_FILAMENT_SET_UP 13 |
|||
|
|||
static void event_handler(lv_obj_t * obj, lv_event_t event) { |
|||
switch (obj->mks_obj_id) { |
|||
case ID_FILAMENT_SET_RETURN: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
uiCfg.para_ui_page = 0; |
|||
lv_clear_filament_settings(); |
|||
draw_return_ui(); |
|||
} |
|||
break; |
|||
case ID_FILAMENT_SET_IN_LENGTH: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = load_length; |
|||
lv_clear_filament_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
case ID_FILAMENT_SET_IN_SPEED: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = load_speed; |
|||
lv_clear_filament_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
case ID_FILAMENT_SET_OUT_LENGTH: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = unload_length; |
|||
lv_clear_filament_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
case ID_FILAMENT_SET_OUT_SPEED: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = unload_speed; |
|||
lv_clear_filament_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
case ID_FILAMENT_SET_TEMP: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = filament_temp; |
|||
lv_clear_filament_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
case ID_FILAMENT_SET_UP: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
uiCfg.para_ui_page = 0; |
|||
lv_clear_filament_settings(); |
|||
lv_draw_filament_settings(); |
|||
} |
|||
break; |
|||
case ID_FILAMENT_SET_DOWN: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
uiCfg.para_ui_page = 1; |
|||
lv_clear_filament_settings(); |
|||
lv_draw_filament_settings(); |
|||
} |
|||
break; |
|||
} |
|||
} |
|||
|
|||
void lv_draw_filament_settings(void) { |
|||
lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL; |
|||
lv_obj_t *labelInLengthText = NULL, *buttonInLengthValue = NULL, *labelInLengthValue = NULL; |
|||
lv_obj_t *labelInSpeedText = NULL, *buttonInSpeedValue = NULL, *labelInSpeedValue = NULL; |
|||
lv_obj_t *labelOutLengthText = NULL, *buttonOutLengthValue = NULL, *labelOutLengthValue = NULL; |
|||
lv_obj_t *labelOutSpeedText = NULL, *buttonOutSpeedValue = NULL, *labelOutSpeedValue = NULL; |
|||
lv_obj_t *labelTemperText = NULL, *buttonTemperValue = NULL, *labelTemperValue = NULL; |
|||
lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL; |
|||
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != FILAMENT_SETTINGS_UI) { |
|||
disp_state_stack._disp_index++; |
|||
disp_state_stack._disp_state[disp_state_stack._disp_index] = FILAMENT_SETTINGS_UI; |
|||
} |
|||
disp_state = FILAMENT_SETTINGS_UI; |
|||
|
|||
scr = lv_obj_create(NULL, NULL); |
|||
|
|||
lv_obj_set_style(scr, &tft_style_scr); |
|||
lv_scr_load(scr); |
|||
lv_obj_clean(scr); |
|||
|
|||
lv_obj_t * title = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(title, &tft_style_label_rel); |
|||
lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); |
|||
lv_label_set_text(title, machine_menu.FilamentConfTitle); |
|||
|
|||
lv_refr_now(lv_refr_get_disp_refreshing()); |
|||
|
|||
if (uiCfg.para_ui_page != 1) { |
|||
labelInLengthText = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelInLengthText, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelInLengthText, PARA_UI_POS_X, PARA_UI_POS_Y + 10); |
|||
lv_label_set_text(labelInLengthText, machine_menu.InLength); |
|||
|
|||
buttonInLengthValue = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonInLengthValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonInLengthValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonInLengthValue, event_handler, ID_FILAMENT_SET_IN_LENGTH, NULL, 0); |
|||
lv_btn_set_style(buttonInLengthValue, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonInLengthValue, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelInLengthValue = lv_label_create(buttonInLengthValue, NULL); |
|||
|
|||
line1 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line1, line_points[0]); |
|||
|
|||
labelInSpeedText = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelInSpeedText, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelInSpeedText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10); |
|||
lv_label_set_text(labelInSpeedText, machine_menu.InSpeed); |
|||
|
|||
buttonInSpeedValue = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonInSpeedValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonInSpeedValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonInSpeedValue, event_handler, ID_FILAMENT_SET_IN_SPEED, NULL, 0); |
|||
lv_btn_set_style(buttonInSpeedValue, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonInSpeedValue, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelInSpeedValue = lv_label_create(buttonInSpeedValue, NULL); |
|||
|
|||
line2 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line2, line_points[1]); |
|||
|
|||
labelOutLengthText = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelOutLengthText, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelOutLengthText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 6); |
|||
lv_label_set_text(labelOutLengthText, machine_menu.OutLength); |
|||
|
|||
buttonOutLengthValue = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonOutLengthValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonOutLengthValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonOutLengthValue, event_handler, ID_FILAMENT_SET_OUT_LENGTH, NULL, 0); |
|||
lv_btn_set_style(buttonOutLengthValue, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonOutLengthValue, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelOutLengthValue = lv_label_create(buttonOutLengthValue, NULL); |
|||
|
|||
line3 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line3, line_points[2]); |
|||
|
|||
labelOutSpeedText = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelOutSpeedText, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelOutSpeedText, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10); |
|||
lv_label_set_text(labelOutSpeedText, machine_menu.OutSpeed); |
|||
|
|||
buttonOutSpeedValue = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonOutSpeedValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonOutSpeedValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonOutSpeedValue, event_handler, ID_FILAMENT_SET_OUT_SPEED, NULL, 0); |
|||
lv_btn_set_style(buttonOutSpeedValue, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonOutSpeedValue, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelOutSpeedValue = lv_label_create(buttonOutSpeedValue, NULL); |
|||
|
|||
line4 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line4, line_points[3]); |
|||
|
|||
buttonTurnPage = lv_btn_create(scr, NULL); |
|||
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FILAMENT_SET_DOWN, NULL, 0); |
|||
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back); |
|||
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back); |
|||
|
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) { |
|||
lv_group_add_obj(g, buttonInLengthValue); |
|||
lv_group_add_obj(g, buttonInSpeedValue); |
|||
lv_group_add_obj(g, buttonOutLengthValue); |
|||
lv_group_add_obj(g, buttonOutSpeedValue); |
|||
lv_group_add_obj(g, buttonTurnPage); |
|||
} |
|||
#endif |
|||
} |
|||
else { |
|||
labelTemperText = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelTemperText, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelTemperText, PARA_UI_POS_X, PARA_UI_POS_Y + 10); |
|||
lv_label_set_text(labelTemperText, machine_menu.FilamentTemperature); |
|||
|
|||
buttonTemperValue = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonTemperValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonTemperValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonTemperValue, event_handler, ID_FILAMENT_SET_TEMP, NULL, 0); |
|||
lv_btn_set_style(buttonTemperValue, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonTemperValue, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelTemperValue = lv_label_create(buttonTemperValue, NULL); |
|||
|
|||
line1 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line1, line_points[0]); |
|||
|
|||
buttonTurnPage = lv_btn_create(scr, NULL); |
|||
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FILAMENT_SET_UP, NULL, 0); |
|||
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back); |
|||
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back); |
|||
|
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) { |
|||
lv_group_add_obj(g, buttonTemperValue); |
|||
lv_group_add_obj(g, buttonTurnPage); |
|||
} |
|||
#endif |
|||
} |
|||
|
|||
lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y); |
|||
lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); |
|||
labelTurnPage = lv_label_create(buttonTurnPage, NULL); |
|||
|
|||
buttonBack = lv_btn_create(scr, NULL); |
|||
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_FILAMENT_SET_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); |
|||
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); |
|||
lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); |
|||
label_Back = lv_label_create(buttonBack, NULL); |
|||
|
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); |
|||
#endif |
|||
|
|||
if (gCfgItems.multiple_language != 0) { |
|||
if (uiCfg.para_ui_page != 1) { |
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_load_length); |
|||
lv_label_set_text(labelInLengthValue, public_buf_l); |
|||
lv_obj_align(labelInLengthValue, buttonInLengthValue, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_load_speed); |
|||
lv_label_set_text(labelInSpeedValue, public_buf_l); |
|||
lv_obj_align(labelInSpeedValue, buttonInSpeedValue, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_unload_length); |
|||
lv_label_set_text(labelOutLengthValue, public_buf_l); |
|||
lv_obj_align(labelOutLengthValue, buttonOutLengthValue, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_unload_speed); |
|||
lv_label_set_text(labelOutSpeedValue, public_buf_l); |
|||
lv_obj_align(labelOutSpeedValue, buttonOutSpeedValue, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
lv_label_set_text(labelTurnPage, machine_menu.next); |
|||
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0); |
|||
} |
|||
else { |
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filament_limit_temper); |
|||
lv_label_set_text(labelTemperValue, public_buf_l); |
|||
lv_obj_align(labelTemperValue, buttonTemperValue, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
lv_label_set_text(labelTurnPage, machine_menu.previous); |
|||
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0); |
|||
} |
|||
|
|||
lv_label_set_text(label_Back, common_menu.text_back); |
|||
lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); |
|||
} |
|||
} |
|||
|
|||
void lv_clear_filament_settings() { |
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); |
|||
#endif |
|||
lv_obj_del(scr); |
|||
} |
|||
|
|||
#endif // HAS_TFT_LVGL_UI
|
@ -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_filament_settings(void); |
|||
extern void lv_clear_filament_settings(); |
|||
|
|||
#ifdef __cplusplus |
|||
} /* C-declarations for C++ */ |
|||
#endif |
@ -0,0 +1,262 @@ |
|||
/**
|
|||
* 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 "lv_conf.h" |
|||
#include "draw_ui.h" |
|||
|
|||
#include "../../../../MarlinCore.h" |
|||
#include "../../../../module/planner.h" |
|||
#include "../../../../module/probe.h" |
|||
|
|||
#if USE_SENSORLESS |
|||
#include "../../../../module/stepper/indirection.h" |
|||
#include "../../../../feature/tmc_util.h" |
|||
|
|||
extern lv_group_t * g; |
|||
static lv_obj_t * scr; |
|||
|
|||
#define ID_SENSITIVITY_RETURN 1 |
|||
#define ID_SENSITIVITY_X 2 |
|||
#define ID_SENSITIVITY_Y 3 |
|||
#define ID_SENSITIVITY_Z 4 |
|||
#define ID_SENSITIVITY_Z2 5 |
|||
|
|||
static void event_handler(lv_obj_t * obj, lv_event_t event) { |
|||
switch (obj->mks_obj_id) { |
|||
case ID_SENSITIVITY_RETURN: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
lv_clear_homing_sensitivity_settings(); |
|||
draw_return_ui(); |
|||
} |
|||
break; |
|||
case ID_SENSITIVITY_X: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = x_sensitivity; |
|||
lv_clear_homing_sensitivity_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
case ID_SENSITIVITY_Y: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = y_sensitivity; |
|||
lv_clear_homing_sensitivity_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
case ID_SENSITIVITY_Z: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = z_sensitivity; |
|||
lv_clear_homing_sensitivity_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
#if Z2_SENSORLESS |
|||
case ID_SENSITIVITY_Z2: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = z2_sensitivity; |
|||
lv_clear_homing_sensitivity_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
#endif |
|||
} |
|||
} |
|||
|
|||
void lv_draw_homing_sensitivity_settings(void) { |
|||
lv_obj_t *buttonBack = NULL, *label_Back = NULL; |
|||
lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL; |
|||
lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL; |
|||
lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL; |
|||
lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL; |
|||
#if Z2_SENSORLESS |
|||
lv_obj_t *labelZ2Text = NULL, *buttonZ2Value = NULL, *labelZ2Value = NULL; |
|||
lv_obj_t * line4 = NULL; |
|||
#endif |
|||
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != HOMING_SENSITIVITY_UI) { |
|||
disp_state_stack._disp_index++; |
|||
disp_state_stack._disp_state[disp_state_stack._disp_index] = HOMING_SENSITIVITY_UI; |
|||
} |
|||
disp_state = HOMING_SENSITIVITY_UI; |
|||
|
|||
scr = lv_obj_create(NULL, NULL); |
|||
|
|||
lv_obj_set_style(scr, &tft_style_scr); |
|||
lv_scr_load(scr); |
|||
lv_obj_clean(scr); |
|||
|
|||
lv_obj_t * title = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(title, &tft_style_label_rel); |
|||
lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); |
|||
lv_label_set_text(title, machine_menu.HomingSensitivityConfTitle); |
|||
|
|||
lv_refr_now(lv_refr_get_disp_refreshing()); |
|||
|
|||
labelXText = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelXText, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10); |
|||
lv_label_set_text(labelXText, machine_menu.X_Sensitivity); |
|||
|
|||
buttonXValue = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_SENSITIVITY_X, NULL, 0); |
|||
lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelXValue = lv_label_create(buttonXValue, NULL); |
|||
|
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonXValue); |
|||
#endif |
|||
|
|||
line1 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line1, line_points[0]); |
|||
|
|||
labelYText = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelYText, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10); |
|||
lv_label_set_text(labelYText, machine_menu.Y_Sensitivity); |
|||
|
|||
buttonYValue = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_SENSITIVITY_Y, NULL, 0); |
|||
lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelYValue = lv_label_create(buttonYValue, NULL); |
|||
|
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonYValue); |
|||
#endif |
|||
|
|||
line2 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line2, line_points[1]); |
|||
|
|||
labelZText = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelZText, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10); |
|||
lv_label_set_text(labelZText, machine_menu.Z_Sensitivity); |
|||
|
|||
buttonZValue = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_SENSITIVITY_Z, NULL, 0); |
|||
lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelZValue = lv_label_create(buttonZValue, NULL); |
|||
|
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable == true) lv_group_add_obj(g, buttonZValue); |
|||
#endif |
|||
|
|||
line3 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line3, line_points[2]); |
|||
|
|||
#if Z2_SENSORLESS |
|||
labelZ2Text = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelZ2Text, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelZ2Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10); |
|||
lv_label_set_text(labelZ2Text, machine_menu.Z2_Sensitivity); |
|||
|
|||
buttonZ2Value = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonZ2Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonZ2Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonZ2Value, event_handler, ID_SENSITIVITY_Z2, NULL, 0); |
|||
lv_btn_set_style(buttonZ2Value, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonZ2Value, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelZ2Value = lv_label_create(buttonZ2Value, NULL); |
|||
|
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonZ2Value); |
|||
#endif |
|||
|
|||
line4 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line4, line_points[3]); |
|||
#endif |
|||
|
|||
buttonBack = lv_btn_create(scr, NULL); |
|||
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_SENSITIVITY_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); |
|||
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); |
|||
lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); |
|||
label_Back = lv_label_create(buttonBack, NULL); |
|||
|
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); |
|||
#endif |
|||
|
|||
if (gCfgItems.multiple_language != 0) { |
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%d"), TERN(X_SENSORLESS, stepperX.homing_threshold(), 0)); |
|||
lv_label_set_text(labelXValue, public_buf_l); |
|||
lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%d"), TERN(Y_SENSORLESS, stepperY.homing_threshold(), 0)); |
|||
lv_label_set_text(labelYValue, public_buf_l); |
|||
lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%d"), TERN(Z_SENSORLESS, stepperZ.homing_threshold(), 0)); |
|||
lv_label_set_text(labelZValue, public_buf_l); |
|||
lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
#if Z2_SENSORLESS |
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%d"), TERN(Z2_SENSORLESS, stepperZ2.homing_threshold(), 0)); |
|||
lv_label_set_text(labelZ2Value, public_buf_l); |
|||
lv_obj_align(labelZ2Value, buttonZ2Value, LV_ALIGN_CENTER, 0, 0); |
|||
#endif |
|||
|
|||
lv_label_set_text(label_Back, common_menu.text_back); |
|||
lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); |
|||
} |
|||
} |
|||
|
|||
void lv_clear_homing_sensitivity_settings() { |
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); |
|||
#endif |
|||
lv_obj_del(scr); |
|||
} |
|||
|
|||
#endif // USE_SENSORLESS
|
|||
|
|||
#endif // HAS_TFT_LVGL_UI && USE_SENSORLESS
|
@ -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_homing_sensitivity_settings(void); |
|||
extern void lv_clear_homing_sensitivity_settings(); |
|||
|
|||
#ifdef __cplusplus |
|||
} /* C-declarations for C++ */ |
|||
#endif |
@ -0,0 +1,286 @@ |
|||
/**
|
|||
* 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 "lv_conf.h" |
|||
#include "draw_ui.h" |
|||
|
|||
#include "../../../../../Configuration.h" |
|||
#include "../../../../MarlinCore.h" |
|||
|
|||
extern lv_group_t * g; |
|||
static lv_obj_t * scr; |
|||
|
|||
#define LV_KB_CTRL_BTN_FLAGS (LV_BTNM_CTRL_NO_REPEAT | LV_BTNM_CTRL_CLICK_TRIG) |
|||
|
|||
static const char * kb_map_lc[] = {"1#", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", LV_SYMBOL_BACKSPACE, "\n", |
|||
"ABC", "a", "s", "d", "f", "g", "h", "j", "k", "l", LV_SYMBOL_NEW_LINE, "\n", |
|||
"_", "-", "z", "x", "c", "v", "b", "n", "m", ".", ",", ":", "\n", |
|||
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""}; |
|||
|
|||
static const lv_btnm_ctrl_t kb_ctrl_lc_map[] = { |
|||
LV_KB_CTRL_BTN_FLAGS | 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, |
|||
LV_KB_CTRL_BTN_FLAGS | 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, |
|||
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}; |
|||
|
|||
static const char * kb_map_uc[] = {"1#", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", LV_SYMBOL_BACKSPACE, "\n", |
|||
"abc", "A", "S", "D", "F", "G", "H", "J", "K", "L", LV_SYMBOL_NEW_LINE, "\n", |
|||
"_", "-", "Z", "X", "C", "V", "B", "N", "M", ".", ",", ":", "\n", |
|||
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""}; |
|||
|
|||
static const lv_btnm_ctrl_t kb_ctrl_uc_map[] = { |
|||
LV_KB_CTRL_BTN_FLAGS | 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, |
|||
LV_KB_CTRL_BTN_FLAGS | 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, |
|||
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}; |
|||
|
|||
static const char * kb_map_spec[] = {"0", "1", "2", "3", "4" ,"5", "6", "7", "8", "9", LV_SYMBOL_BACKSPACE, "\n", |
|||
"abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n", |
|||
"\\", "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n", |
|||
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""}; |
|||
|
|||
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, |
|||
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, |
|||
LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2}; |
|||
|
|||
static const lv_btnm_ctrl_t kb_ctrl_num_map[] = { |
|||
1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2, |
|||
1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2, |
|||
1, 1, 1, 2, |
|||
1, 1, 1, 1, 1}; |
|||
|
|||
static void lv_kb_event_cb(lv_obj_t * kb, lv_event_t event) { |
|||
//LV_ASSERT_OBJ(kb, LV_OBJX_NAME);
|
|||
|
|||
if (event != LV_EVENT_VALUE_CHANGED) return; |
|||
|
|||
lv_kb_ext_t * ext = (lv_kb_ext_t * )lv_obj_get_ext_attr(kb); |
|||
const uint16_t btn_id = lv_btnm_get_active_btn(kb); |
|||
if (btn_id == LV_BTNM_BTN_NONE) return; |
|||
if (lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_HIDDEN | LV_BTNM_CTRL_INACTIVE)) return; |
|||
if (lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_NO_REPEAT) && event == LV_EVENT_LONG_PRESSED_REPEAT) return; |
|||
|
|||
const char * txt = lv_btnm_get_active_btn_text(kb); |
|||
if (txt == NULL) return; |
|||
|
|||
// Do the corresponding action according to the text of the button
|
|||
if (strcmp(txt, "abc") == 0) { |
|||
lv_btnm_set_map(kb, kb_map_lc); |
|||
lv_btnm_set_ctrl_map(kb, kb_ctrl_lc_map); |
|||
return; |
|||
} |
|||
else if (strcmp(txt, "ABC") == 0) { |
|||
lv_btnm_set_map(kb, kb_map_uc); |
|||
lv_btnm_set_ctrl_map(kb, kb_ctrl_uc_map); |
|||
return; |
|||
} |
|||
else if (strcmp(txt, "1#") == 0) { |
|||
lv_btnm_set_map(kb, kb_map_spec); |
|||
lv_btnm_set_ctrl_map(kb, kb_ctrl_spec_map); |
|||
return; |
|||
} |
|||
else if (strcmp(txt, LV_SYMBOL_CLOSE) == 0) { |
|||
if (kb->event_cb != lv_kb_def_event_cb) { |
|||
//lv_res_t res = lv_event_send(kb, LV_EVENT_CANCEL, NULL);
|
|||
//if (res != LV_RES_OK) return;
|
|||
lv_clear_keyboard(); |
|||
draw_return_ui(); |
|||
} |
|||
else { |
|||
lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/ |
|||
lv_obj_del(kb); |
|||
return; |
|||
} |
|||
return; |
|||
} |
|||
else if (strcmp(txt, LV_SYMBOL_OK) == 0) { |
|||
if (kb->event_cb != lv_kb_def_event_cb) { |
|||
//lv_res_t res = lv_event_send(kb, LV_EVENT_APPLY, NULL);
|
|||
//if (res != LV_RES_OK) return;
|
|||
const char * ret_ta_txt = lv_ta_get_text(ext->ta); |
|||
switch (keyboard_value) { |
|||
#if ENABLED(USE_WIFI_FUNCTION) |
|||
case wifiName: |
|||
memcpy(uiCfg.wifi_name,ret_ta_txt,sizeof(uiCfg.wifi_name)); |
|||
lv_clear_keyboard(); |
|||
draw_return_ui(); |
|||
break; |
|||
case wifiPassWord: |
|||
memcpy(uiCfg.wifi_key,ret_ta_txt,sizeof(uiCfg.wifi_name)); |
|||
lv_clear_keyboard(); |
|||
draw_return_ui(); |
|||
break; |
|||
case wifiConfig: |
|||
memset((void *)uiCfg.wifi_name, 0, sizeof(uiCfg.wifi_name)); |
|||
memcpy((void *)uiCfg.wifi_name, wifi_list.wifiName[wifi_list.nameIndex], 32); |
|||
|
|||
memset((void *)uiCfg.wifi_key, 0, sizeof(uiCfg.wifi_key)); |
|||
memcpy((void *)uiCfg.wifi_key, ret_ta_txt, sizeof(uiCfg.wifi_key)); |
|||
|
|||
gCfgItems.wifi_mode_sel = STA_MODEL; |
|||
|
|||
package_to_wifi(WIFI_PARA_SET, (char *)0, 0); |
|||
|
|||
memset(public_buf_l,0,sizeof(public_buf_l)); |
|||
|
|||
public_buf_l[0] = 0xA5; |
|||
public_buf_l[1] = 0x09; |
|||
public_buf_l[2] = 0x01; |
|||
public_buf_l[3] = 0x00; |
|||
public_buf_l[4] = 0x01; |
|||
public_buf_l[5] = 0xFC; |
|||
public_buf_l[6] = 0x00; |
|||
raw_send_to_wifi(public_buf_l, 6); |
|||
|
|||
last_disp_state = KEY_BOARD_UI; |
|||
lv_clear_keyboard(); |
|||
wifi_tips_type = TIPS_TYPE_JOINING; |
|||
lv_draw_wifi_tips(); |
|||
break; |
|||
#endif // USE_WIFI_FUNCTION
|
|||
case gcodeCommand: |
|||
uint8_t buf[100]; |
|||
strncpy((char *)buf,ret_ta_txt,sizeof(buf)); |
|||
update_gcode_command(AUTO_LEVELING_COMMAND_ADDR,buf); |
|||
lv_clear_keyboard(); |
|||
draw_return_ui(); |
|||
break; |
|||
default: break; |
|||
} |
|||
} |
|||
else { |
|||
lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/ |
|||
} |
|||
return; |
|||
} |
|||
|
|||
/*Add the characters to the text area if set*/ |
|||
if (ext->ta == NULL) return; |
|||
|
|||
if (strcmp(txt, "Enter") == 0 || strcmp(txt, LV_SYMBOL_NEW_LINE) == 0) |
|||
lv_ta_add_char(ext->ta, '\n'); |
|||
else if (strcmp(txt, LV_SYMBOL_LEFT) == 0) |
|||
lv_ta_cursor_left(ext->ta); |
|||
else if (strcmp(txt, LV_SYMBOL_RIGHT) == 0) |
|||
lv_ta_cursor_right(ext->ta); |
|||
else if (strcmp(txt, LV_SYMBOL_BACKSPACE) == 0) |
|||
lv_ta_del_char(ext->ta); |
|||
else if (strcmp(txt, "+/-") == 0) { |
|||
uint16_t cur = lv_ta_get_cursor_pos(ext->ta); |
|||
const char * ta_txt = lv_ta_get_text(ext->ta); |
|||
if (ta_txt[0] == '-') { |
|||
lv_ta_set_cursor_pos(ext->ta, 1); |
|||
lv_ta_del_char(ext->ta); |
|||
lv_ta_add_char(ext->ta, '+'); |
|||
lv_ta_set_cursor_pos(ext->ta, cur); |
|||
} |
|||
else if (ta_txt[0] == '+') { |
|||
lv_ta_set_cursor_pos(ext->ta, 1); |
|||
lv_ta_del_char(ext->ta); |
|||
lv_ta_add_char(ext->ta, '-'); |
|||
lv_ta_set_cursor_pos(ext->ta, cur); |
|||
} |
|||
else { |
|||
lv_ta_set_cursor_pos(ext->ta, 0); |
|||
lv_ta_add_char(ext->ta, '-'); |
|||
lv_ta_set_cursor_pos(ext->ta, cur + 1); |
|||
} |
|||
} |
|||
else { |
|||
lv_ta_add_text(ext->ta, txt); |
|||
} |
|||
} |
|||
|
|||
void lv_draw_keyboard() { |
|||
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != KEY_BOARD_UI) { |
|||
disp_state_stack._disp_index++; |
|||
disp_state_stack._disp_state[disp_state_stack._disp_index] = KEY_BOARD_UI; |
|||
} |
|||
disp_state = KEY_BOARD_UI; |
|||
|
|||
scr = lv_obj_create(NULL, NULL); |
|||
|
|||
lv_obj_set_style(scr, &tft_style_scr); |
|||
lv_scr_load(scr); |
|||
lv_obj_clean(scr); |
|||
|
|||
lv_refr_now(lv_refr_get_disp_refreshing()); |
|||
|
|||
/*Create styles for the keyboard*/ |
|||
static lv_style_t rel_style, pr_style; |
|||
|
|||
lv_style_copy(&rel_style, &lv_style_btn_rel); |
|||
rel_style.body.radius = 0; |
|||
rel_style.body.border.width = 1; |
|||
rel_style.body.main_color = lv_color_make(0xa9, 0x62, 0x1d); |
|||
rel_style.body.grad_color = lv_color_make(0xa7, 0x59, 0x0e); |
|||
|
|||
lv_style_copy(&pr_style, &lv_style_btn_pr); |
|||
pr_style.body.radius = 0; |
|||
pr_style.body.border.width = 1; |
|||
pr_style.body.main_color = lv_color_make(0x72, 0x42, 0x15); |
|||
pr_style.body.grad_color = lv_color_make(0x6a, 0x3a, 0x0c); |
|||
|
|||
/*Create a keyboard and apply the styles*/ |
|||
lv_obj_t *kb = lv_kb_create(scr, NULL); |
|||
lv_obj_set_event_cb(kb, lv_kb_event_cb); |
|||
lv_kb_set_cursor_manage(kb, true); |
|||
lv_kb_set_style(kb, LV_KB_STYLE_BG, &lv_style_transp_tight); |
|||
lv_kb_set_style(kb, LV_KB_STYLE_BTN_REL, &rel_style); |
|||
lv_kb_set_style(kb, LV_KB_STYLE_BTN_PR, &pr_style); |
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) { |
|||
//lv_group_add_obj(g, kb);
|
|||
//lv_group_set_editing(g, true);
|
|||
} |
|||
#endif |
|||
|
|||
/*Create a text area. The keyboard will write here*/ |
|||
lv_obj_t *ta = lv_ta_create(scr, NULL); |
|||
lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_MID, 0, 10); |
|||
if (keyboard_value == gcodeCommand) { |
|||
get_gcode_command(AUTO_LEVELING_COMMAND_ADDR,(uint8_t *)public_buf_m); |
|||
public_buf_m[sizeof(public_buf_m)-1] = 0; |
|||
lv_ta_set_text(ta, public_buf_m); |
|||
} |
|||
else { |
|||
lv_ta_set_text(ta, ""); |
|||
} |
|||
|
|||
/*Assign the text area to the keyboard*/ |
|||
lv_kb_set_ta(kb, ta); |
|||
} |
|||
|
|||
void lv_clear_keyboard() { |
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) { /* lv_group_remove_all_objs(g); */ } |
|||
#endif |
|||
lv_obj_del(scr); |
|||
} |
|||
|
|||
|
|||
#endif // HAS_TFT_LVGL_UI
|
@ -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_keyboard(); |
|||
extern void lv_clear_keyboard(); |
|||
|
|||
#ifdef __cplusplus |
|||
} /* C-declarations for C++ */ |
|||
#endif |
@ -0,0 +1,261 @@ |
|||
/**
|
|||
* 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 "lv_conf.h" |
|||
#include "draw_ui.h" |
|||
|
|||
#include "../../../../MarlinCore.h" |
|||
|
|||
extern lv_group_t * g; |
|||
static lv_obj_t * scr; |
|||
|
|||
#define ID_LEVEL_RETURN 1 |
|||
#define ID_LEVEL_POSITION 2 |
|||
#define ID_LEVEL_POSITION_ARROW 3 |
|||
#define ID_LEVEL_COMMAND 4 |
|||
#define ID_LEVEL_COMMAND_ARROW 5 |
|||
#define ID_LEVEL_ZOFFSET 6 |
|||
#define ID_LEVEL_ZOFFSET_ARROW 7 |
|||
|
|||
|
|||
static void event_handler(lv_obj_t * obj, lv_event_t event) { |
|||
switch (obj->mks_obj_id) { |
|||
case ID_LEVEL_RETURN: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
lv_clear_level_settings(); |
|||
draw_return_ui(); |
|||
} |
|||
break; |
|||
case ID_LEVEL_POSITION: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
lv_clear_level_settings(); |
|||
lv_draw_manual_level_pos_settings(); |
|||
} |
|||
break; |
|||
case ID_LEVEL_POSITION_ARROW: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
lv_clear_level_settings(); |
|||
lv_draw_manual_level_pos_settings(); |
|||
} |
|||
break; |
|||
case ID_LEVEL_COMMAND: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
keyboard_value = gcodeCommand; |
|||
lv_clear_level_settings(); |
|||
lv_draw_keyboard(); |
|||
} |
|||
break; |
|||
case ID_LEVEL_COMMAND_ARROW: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
keyboard_value = gcodeCommand; |
|||
lv_clear_level_settings(); |
|||
lv_draw_keyboard(); |
|||
} |
|||
break; |
|||
#if HAS_BED_PROBE |
|||
case ID_LEVEL_ZOFFSET: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
lv_clear_level_settings(); |
|||
lv_draw_auto_level_offset_settings(); |
|||
} |
|||
break; |
|||
case ID_LEVEL_ZOFFSET_ARROW: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
lv_clear_level_settings(); |
|||
lv_draw_auto_level_offset_settings(); |
|||
} |
|||
break; |
|||
#endif |
|||
} |
|||
} |
|||
|
|||
void lv_draw_level_settings(void) { |
|||
lv_obj_t *buttonBack, *label_Back; |
|||
lv_obj_t *buttonPosition, *labelPosition, *buttonPositionNarrow; |
|||
lv_obj_t *buttonCommand, *labelCommand, *buttonCommandNarrow; |
|||
#if HAS_BED_PROBE |
|||
lv_obj_t *buttonZoffset, *labelZoffset, *buttonZoffsetNarrow; |
|||
lv_obj_t * line3; |
|||
#endif |
|||
lv_obj_t * line1, * line2; |
|||
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != LEVELING_PARA_UI) { |
|||
disp_state_stack._disp_index++; |
|||
disp_state_stack._disp_state[disp_state_stack._disp_index] = LEVELING_PARA_UI; |
|||
} |
|||
disp_state = LEVELING_PARA_UI; |
|||
|
|||
scr = lv_obj_create(NULL, NULL); |
|||
|
|||
lv_obj_set_style(scr, &tft_style_scr); |
|||
lv_scr_load(scr); |
|||
lv_obj_clean(scr); |
|||
|
|||
lv_obj_t * title = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(title, &tft_style_label_rel); |
|||
lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); |
|||
lv_label_set_text(title, machine_menu.LevelingParaConfTitle); |
|||
|
|||
lv_refr_now(lv_refr_get_disp_refreshing()); |
|||
|
|||
|
|||
buttonPosition = lv_btn_create(scr, NULL); /*Add a button the current screen*/ |
|||
lv_obj_set_pos(buttonPosition, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ |
|||
lv_obj_set_size(buttonPosition, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ |
|||
lv_obj_set_event_cb_mks(buttonPosition, event_handler, ID_LEVEL_POSITION, NULL, 0); |
|||
lv_btn_set_style(buttonPosition, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ |
|||
lv_btn_set_style(buttonPosition, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ |
|||
lv_btn_set_layout(buttonPosition, LV_LAYOUT_OFF); |
|||
labelPosition = lv_label_create(buttonPosition, NULL); /*Add a label to the button*/ |
|||
|
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonPosition); |
|||
#endif |
|||
|
|||
buttonPositionNarrow = lv_imgbtn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonPositionNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V); |
|||
lv_obj_set_event_cb_mks(buttonPositionNarrow, event_handler, ID_LEVEL_POSITION_ARROW, NULL, 0); |
|||
lv_imgbtn_set_src(buttonPositionNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); |
|||
lv_imgbtn_set_src(buttonPositionNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); |
|||
lv_imgbtn_set_style(buttonPositionNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonPositionNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
lv_btn_set_layout(buttonPositionNarrow, LV_LAYOUT_OFF); |
|||
|
|||
line1 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line1, line_points[0]); |
|||
|
|||
buttonCommand = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonCommand, PARA_UI_POS_X, PARA_UI_POS_Y * 2); |
|||
lv_obj_set_size(buttonCommand, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); |
|||
lv_obj_set_event_cb_mks(buttonCommand, event_handler, ID_LEVEL_COMMAND, NULL, 0); |
|||
lv_btn_set_style(buttonCommand, LV_BTN_STYLE_REL, &tft_style_label_rel); |
|||
lv_btn_set_style(buttonCommand, LV_BTN_STYLE_PR, &tft_style_label_pre); |
|||
lv_btn_set_layout(buttonCommand, LV_LAYOUT_OFF); |
|||
labelCommand = lv_label_create(buttonCommand, NULL); |
|||
|
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonCommand); |
|||
#endif |
|||
|
|||
buttonCommandNarrow = lv_imgbtn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonCommandNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V); |
|||
lv_obj_set_event_cb_mks(buttonCommandNarrow, event_handler, ID_LEVEL_COMMAND_ARROW, NULL, 0); |
|||
lv_imgbtn_set_src(buttonCommandNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); |
|||
lv_imgbtn_set_src(buttonCommandNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); |
|||
lv_imgbtn_set_style(buttonCommandNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonCommandNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
lv_btn_set_layout(buttonCommandNarrow, LV_LAYOUT_OFF); |
|||
|
|||
line2 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line2, line_points[1]); |
|||
|
|||
#if HAS_BED_PROBE |
|||
|
|||
buttonZoffset = lv_btn_create(scr, NULL); /*Add a button the current screen*/ |
|||
lv_obj_set_pos(buttonZoffset, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/ |
|||
lv_obj_set_size(buttonZoffset, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ |
|||
lv_obj_set_event_cb_mks(buttonZoffset, event_handler, ID_LEVEL_ZOFFSET, NULL, 0); |
|||
lv_btn_set_style(buttonZoffset, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ |
|||
lv_btn_set_style(buttonZoffset, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ |
|||
lv_btn_set_layout(buttonZoffset, LV_LAYOUT_OFF); |
|||
labelZoffset = lv_label_create(buttonZoffset, NULL); /*Add a label to the button*/ |
|||
|
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonZoffset); |
|||
#endif |
|||
|
|||
buttonZoffsetNarrow = lv_imgbtn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonZoffsetNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V); |
|||
lv_obj_set_event_cb_mks(buttonZoffsetNarrow, event_handler, ID_LEVEL_ZOFFSET_ARROW, NULL, 0); |
|||
lv_imgbtn_set_src(buttonZoffsetNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin"); |
|||
lv_imgbtn_set_src(buttonZoffsetNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin"); |
|||
lv_imgbtn_set_style(buttonZoffsetNarrow, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonZoffsetNarrow, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
lv_btn_set_layout(buttonZoffsetNarrow, LV_LAYOUT_OFF); |
|||
|
|||
line3 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line3, line_points[2]); |
|||
|
|||
#endif // HAS_BED_PROBE
|
|||
|
|||
buttonBack = lv_imgbtn_create(scr, NULL); |
|||
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_LEVEL_RETURN, NULL, 0); |
|||
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin"); |
|||
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin"); |
|||
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); |
|||
#endif |
|||
|
|||
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); |
|||
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); |
|||
label_Back = lv_label_create(buttonBack, NULL); |
|||
|
|||
if (gCfgItems.multiple_language != 0) { |
|||
lv_label_set_text(label_Back, common_menu.text_back); |
|||
lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
lv_label_set_text(labelPosition, machine_menu.LevelingManuPosConf); |
|||
lv_obj_align(labelPosition, buttonPosition, LV_ALIGN_IN_LEFT_MID, 0, 0); |
|||
|
|||
lv_label_set_text(labelCommand, machine_menu.LevelingAutoCommandConf); |
|||
lv_obj_align(labelCommand, buttonCommand, LV_ALIGN_IN_LEFT_MID, 0, 0); |
|||
#if HAS_BED_PROBE |
|||
lv_label_set_text(labelZoffset, machine_menu.LevelingAutoZoffsetConf); |
|||
lv_obj_align(labelZoffset, buttonZoffset, LV_ALIGN_IN_LEFT_MID, 0, 0); |
|||
#endif |
|||
} |
|||
|
|||
} |
|||
|
|||
void lv_clear_level_settings() { |
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); |
|||
#endif |
|||
lv_obj_del(scr); |
|||
} |
|||
|
|||
#endif // HAS_TFT_LVGL_UI
|
@ -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_level_settings(void); |
|||
extern void lv_clear_level_settings(); |
|||
|
|||
#ifdef __cplusplus |
|||
} /* C-declarations for C++ */ |
|||
#endif |
@ -0,0 +1,459 @@ |
|||
/**
|
|||
* 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 "lv_conf.h" |
|||
#include "draw_ui.h" |
|||
|
|||
#include "../../../../MarlinCore.h" |
|||
#include "../../../../module/planner.h" |
|||
|
|||
extern lv_group_t * g; |
|||
static lv_obj_t * scr; |
|||
|
|||
#define ID_MANUAL_POS_RETURN 1 |
|||
#define ID_MANUAL_POS_X1 2 |
|||
#define ID_MANUAL_POS_Y1 3 |
|||
#define ID_MANUAL_POS_X2 4 |
|||
#define ID_MANUAL_POS_Y2 5 |
|||
#define ID_MANUAL_POS_X3 6 |
|||
#define ID_MANUAL_POS_Y3 7 |
|||
#define ID_MANUAL_POS_X4 8 |
|||
#define ID_MANUAL_POS_Y4 9 |
|||
#define ID_MANUAL_POS_X5 10 |
|||
#define ID_MANUAL_POS_Y5 11 |
|||
#define ID_MANUAL_POS_DOWN 12 |
|||
#define ID_MANUAL_POS_UP 13 |
|||
|
|||
static void event_handler(lv_obj_t * obj, lv_event_t event) { |
|||
switch (obj->mks_obj_id) { |
|||
case ID_MANUAL_POS_RETURN: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
uiCfg.para_ui_page = 0; |
|||
lv_clear_manual_level_pos_settings(); |
|||
draw_return_ui(); |
|||
} |
|||
break; |
|||
case ID_MANUAL_POS_X1: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = level_pos_x1; |
|||
lv_clear_manual_level_pos_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
case ID_MANUAL_POS_Y1: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = level_pos_y1; |
|||
lv_clear_manual_level_pos_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
case ID_MANUAL_POS_X2: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = level_pos_x2; |
|||
lv_clear_manual_level_pos_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
case ID_MANUAL_POS_Y2: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = level_pos_y2; |
|||
lv_clear_manual_level_pos_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
case ID_MANUAL_POS_X3: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = level_pos_x3; |
|||
lv_clear_manual_level_pos_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
case ID_MANUAL_POS_Y3: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = level_pos_y3; |
|||
lv_clear_manual_level_pos_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
case ID_MANUAL_POS_X4: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = level_pos_x4; |
|||
lv_clear_manual_level_pos_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
case ID_MANUAL_POS_Y4: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = level_pos_y4; |
|||
lv_clear_manual_level_pos_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
case ID_MANUAL_POS_X5: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = level_pos_y5; |
|||
lv_clear_manual_level_pos_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
case ID_MANUAL_POS_Y5: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
value = level_pos_y5; |
|||
lv_clear_manual_level_pos_settings(); |
|||
lv_draw_number_key(); |
|||
} |
|||
break; |
|||
case ID_MANUAL_POS_UP: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
uiCfg.para_ui_page = 0; |
|||
lv_clear_manual_level_pos_settings(); |
|||
lv_draw_manual_level_pos_settings(); |
|||
} |
|||
break; |
|||
case ID_MANUAL_POS_DOWN: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
uiCfg.para_ui_page = 1; |
|||
lv_clear_manual_level_pos_settings(); |
|||
lv_draw_manual_level_pos_settings(); |
|||
} |
|||
break; |
|||
} |
|||
} |
|||
|
|||
void lv_draw_manual_level_pos_settings(void) { |
|||
lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL; |
|||
lv_obj_t *labelPoint1Text = NULL, *buttonX1Value = NULL, *labelX1Value = NULL; |
|||
lv_obj_t *buttonY1Value = NULL, *labelY1Value = NULL; |
|||
lv_obj_t *labelPoint2Text = NULL, *buttonX2Value = NULL, *labelX2Value = NULL; |
|||
lv_obj_t *buttonY2Value = NULL, *labelY2Value = NULL; |
|||
lv_obj_t *labelPoint3Text = NULL, *buttonX3Value = NULL, *labelX3Value = NULL; |
|||
lv_obj_t *buttonY3Value = NULL, *labelY3Value = NULL; |
|||
lv_obj_t *labelPoint4Text = NULL, *buttonX4Value = NULL, *labelX4Value = NULL; |
|||
lv_obj_t *buttonY4Value = NULL, *labelY4Value = NULL; |
|||
lv_obj_t *labelPoint5Text = NULL, *buttonX5Value = NULL, *labelX5Value = NULL; |
|||
lv_obj_t *buttonY5Value = NULL, *labelY5Value = NULL; |
|||
lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL; |
|||
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MANUAL_LEVELING_POSIGION_UI) { |
|||
disp_state_stack._disp_index++; |
|||
disp_state_stack._disp_state[disp_state_stack._disp_index] = MANUAL_LEVELING_POSIGION_UI; |
|||
} |
|||
disp_state = MANUAL_LEVELING_POSIGION_UI; |
|||
|
|||
scr = lv_obj_create(NULL, NULL); |
|||
|
|||
lv_obj_set_style(scr, &tft_style_scr); |
|||
lv_scr_load(scr); |
|||
lv_obj_clean(scr); |
|||
|
|||
lv_obj_t * title = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(title, &tft_style_label_rel); |
|||
lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS); |
|||
lv_label_set_text(title, machine_menu.LevelingParaConfTitle); |
|||
|
|||
lv_refr_now(lv_refr_get_disp_refreshing()); |
|||
|
|||
if (uiCfg.para_ui_page != 1) { |
|||
labelPoint1Text = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelPoint1Text, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelPoint1Text, PARA_UI_POS_X, PARA_UI_POS_Y + 10); |
|||
lv_label_set_text(labelPoint1Text, leveling_menu.position1); |
|||
|
|||
buttonX1Value = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonX1Value, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonX1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonX1Value, event_handler, ID_MANUAL_POS_X1, NULL, 0); |
|||
lv_btn_set_style(buttonX1Value, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonX1Value, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelX1Value = lv_label_create(buttonX1Value, NULL); |
|||
|
|||
buttonY1Value = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonY1Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonY1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonY1Value, event_handler, ID_MANUAL_POS_Y1, NULL, 0); |
|||
lv_btn_set_style(buttonY1Value, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonY1Value, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelY1Value = lv_label_create(buttonY1Value, NULL); |
|||
|
|||
line1 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line1, line_points[0]); |
|||
|
|||
labelPoint2Text = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelPoint2Text, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelPoint2Text, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10); |
|||
lv_label_set_text(labelPoint2Text, leveling_menu.position2); |
|||
|
|||
buttonX2Value = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonX2Value, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonX2Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonX2Value, event_handler, ID_MANUAL_POS_X2, NULL, 0); |
|||
lv_btn_set_style(buttonX2Value, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonX2Value, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelX2Value = lv_label_create(buttonX2Value, NULL); |
|||
|
|||
buttonY2Value = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonY2Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonY2Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonY2Value, event_handler, ID_MANUAL_POS_Y2, NULL, 0); |
|||
lv_btn_set_style(buttonY2Value, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonY2Value, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelY2Value = lv_label_create(buttonY2Value, NULL); |
|||
|
|||
line2 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line2, line_points[1]); |
|||
|
|||
labelPoint3Text = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelPoint3Text, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelPoint3Text, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10); |
|||
lv_label_set_text(labelPoint3Text, leveling_menu.position3); |
|||
|
|||
buttonX3Value = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonX3Value, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonX3Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonX3Value, event_handler, ID_MANUAL_POS_X3, NULL, 0); |
|||
lv_btn_set_style(buttonX3Value, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonX3Value, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelX3Value = lv_label_create(buttonX3Value, NULL); |
|||
|
|||
buttonY3Value = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonY3Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonY3Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonY3Value, event_handler, ID_MANUAL_POS_Y3, NULL, 0); |
|||
lv_btn_set_style(buttonY3Value, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonY3Value, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelY3Value = lv_label_create(buttonY3Value, NULL); |
|||
|
|||
line3 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line3, line_points[2]); |
|||
|
|||
labelPoint4Text = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelPoint4Text, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelPoint4Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10); |
|||
lv_label_set_text(labelPoint4Text, leveling_menu.position4); |
|||
|
|||
buttonX4Value = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonX4Value, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonX4Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonX4Value, event_handler, ID_MANUAL_POS_X4, NULL, 0); |
|||
lv_btn_set_style(buttonX4Value, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonX4Value, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelX4Value = lv_label_create(buttonX4Value, NULL); |
|||
|
|||
buttonY4Value = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonY4Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonY4Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonY4Value, event_handler, ID_MANUAL_POS_Y4, NULL, 0); |
|||
lv_btn_set_style(buttonY4Value, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonY4Value, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelY4Value = lv_label_create(buttonY4Value, NULL); |
|||
|
|||
line4 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line4, line_points[3]); |
|||
|
|||
buttonTurnPage = lv_btn_create(scr, NULL); |
|||
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_MANUAL_POS_DOWN, NULL, 0); |
|||
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back); |
|||
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back); |
|||
|
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) { |
|||
lv_group_add_obj(g, buttonX1Value); |
|||
lv_group_add_obj(g, buttonY1Value); |
|||
lv_group_add_obj(g, buttonX2Value); |
|||
lv_group_add_obj(g, buttonY2Value); |
|||
lv_group_add_obj(g, buttonX3Value); |
|||
lv_group_add_obj(g, buttonY3Value); |
|||
lv_group_add_obj(g, buttonX4Value); |
|||
lv_group_add_obj(g, buttonY4Value); |
|||
lv_group_add_obj(g, buttonTurnPage); |
|||
} |
|||
#endif |
|||
} |
|||
else { |
|||
labelPoint5Text = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelPoint5Text, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelPoint5Text, PARA_UI_POS_X, PARA_UI_POS_Y + 10); |
|||
lv_label_set_text(labelPoint5Text, leveling_menu.position5); |
|||
|
|||
buttonX5Value = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonX5Value, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonX5Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonX5Value, event_handler, ID_MANUAL_POS_X5, NULL, 0); |
|||
lv_btn_set_style(buttonX5Value, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonX5Value, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelX5Value = lv_label_create(buttonX5Value, NULL); |
|||
|
|||
buttonY5Value = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonY5Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2); |
|||
lv_obj_set_size(buttonY5Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonY5Value, event_handler, ID_MANUAL_POS_Y5, NULL, 0); |
|||
lv_btn_set_style(buttonY5Value, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonY5Value, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelY5Value = lv_label_create(buttonY5Value, NULL); |
|||
|
|||
line1 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line1, line_points[0]); |
|||
|
|||
buttonTurnPage = lv_btn_create(scr, NULL); |
|||
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_MANUAL_POS_UP, NULL, 0); |
|||
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back); |
|||
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back); |
|||
|
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) { |
|||
lv_group_add_obj(g, buttonX5Value); |
|||
lv_group_add_obj(g, buttonY5Value); |
|||
lv_group_add_obj(g, buttonTurnPage); |
|||
} |
|||
#endif |
|||
} |
|||
|
|||
lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y); |
|||
lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); |
|||
labelTurnPage = lv_label_create(buttonTurnPage, NULL); |
|||
|
|||
buttonBack = lv_btn_create(scr, NULL); |
|||
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MANUAL_POS_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); |
|||
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); |
|||
lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE); |
|||
label_Back = lv_label_create(buttonBack, NULL); |
|||
|
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); |
|||
#endif |
|||
|
|||
if (gCfgItems.multiple_language != 0) { |
|||
if (uiCfg.para_ui_page != 1) { |
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[0][0]); |
|||
lv_label_set_text(labelX1Value, public_buf_l); |
|||
lv_obj_align(labelX1Value, buttonX1Value, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[0][1]); |
|||
lv_label_set_text(labelY1Value, public_buf_l); |
|||
lv_obj_align(labelY1Value, buttonY1Value, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[1][0]); |
|||
lv_label_set_text(labelX2Value, public_buf_l); |
|||
lv_obj_align(labelX2Value, buttonX2Value, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[1][1]); |
|||
lv_label_set_text(labelY2Value, public_buf_l); |
|||
lv_obj_align(labelY2Value, buttonY2Value, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[2][0]); |
|||
lv_label_set_text(labelX3Value, public_buf_l); |
|||
lv_obj_align(labelX3Value, buttonX3Value, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[2][1]); |
|||
lv_label_set_text(labelY3Value, public_buf_l); |
|||
lv_obj_align(labelY3Value, buttonY3Value, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[3][0]); |
|||
lv_label_set_text(labelX4Value, public_buf_l); |
|||
lv_obj_align(labelX4Value, buttonX4Value, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[3][1]); |
|||
lv_label_set_text(labelY4Value, public_buf_l); |
|||
lv_obj_align(labelY4Value, buttonY4Value, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
lv_label_set_text(labelTurnPage, machine_menu.next); |
|||
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0); |
|||
} |
|||
else { |
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[4][0]); |
|||
lv_label_set_text(labelX5Value, public_buf_l); |
|||
lv_obj_align(labelX5Value, buttonX5Value, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
ZERO(public_buf_l); |
|||
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[4][1]); |
|||
lv_label_set_text(labelY5Value, public_buf_l); |
|||
lv_obj_align(labelY5Value, buttonY5Value, LV_ALIGN_CENTER, 0, 0); |
|||
|
|||
lv_label_set_text(labelTurnPage, machine_menu.previous); |
|||
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0); |
|||
} |
|||
|
|||
lv_label_set_text(label_Back, common_menu.text_back); |
|||
lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0); |
|||
} |
|||
} |
|||
|
|||
void lv_clear_manual_level_pos_settings() { |
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); |
|||
#endif |
|||
lv_obj_del(scr); |
|||
} |
|||
|
|||
#endif // HAS_TFT_LVGL_UI
|
@ -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_manual_level_pos_settings(void); |
|||
extern void lv_clear_manual_level_pos_settings(); |
|||
|
|||
#ifdef __cplusplus |
|||
} /* C-declarations for C++ */ |
|||
#endif |
@ -0,0 +1,222 @@ |
|||
/**
|
|||
* 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 "lv_conf.h" |
|||
#include "draw_ui.h" |
|||
|
|||
#if ENABLED(USE_WIFI_FUNCTION) |
|||
|
|||
#include "../../../../../Configuration.h" |
|||
#include "../../../../module/temperature.h" |
|||
|
|||
extern lv_group_t * g; |
|||
static lv_obj_t *scr, *wifi_name_text, *wifi_key_text, *wifi_state_text, *wifi_ip_text; |
|||
|
|||
#define ID_W_RETURN 1 |
|||
#define ID_W_CLOUD 2 |
|||
#define ID_W_RECONNECT 3 |
|||
|
|||
static void event_handler(lv_obj_t * obj, lv_event_t event) { |
|||
switch (obj->mks_obj_id) { |
|||
case ID_W_RETURN: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
clear_cur_ui(); |
|||
lv_draw_set(); |
|||
} |
|||
break; |
|||
case ID_W_CLOUD: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
//clear_cur_ui();
|
|||
//draw_return_ui();
|
|||
} |
|||
break; |
|||
case ID_W_RECONNECT: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
clear_cur_ui(); |
|||
lv_draw_wifi_list(); |
|||
} |
|||
break; |
|||
} |
|||
} |
|||
|
|||
void lv_draw_wifi(void) { |
|||
lv_obj_t *buttonBack=NULL,*label_Back=NULL; |
|||
lv_obj_t *buttonCloud=NULL,*label_Cloud=NULL; |
|||
lv_obj_t *buttonReconnect=NULL,*label_Reconnect=NULL; |
|||
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_UI) { |
|||
disp_state_stack._disp_index++; |
|||
disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_UI; |
|||
} |
|||
disp_state = WIFI_UI; |
|||
|
|||
scr = lv_obj_create(NULL, NULL); |
|||
|
|||
lv_obj_set_style(scr, &tft_style_scr); |
|||
lv_scr_load(scr); |
|||
lv_obj_clean(scr); |
|||
|
|||
lv_obj_t * title = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(title, &tft_style_label_rel); |
|||
lv_obj_set_pos(title,TITLE_XPOS,TITLE_YPOS); |
|||
lv_label_set_text(title, creat_title_text()); |
|||
|
|||
lv_refr_now(lv_refr_get_disp_refreshing()); |
|||
|
|||
// Create an Image button
|
|||
buttonBack = lv_imgbtn_create(scr, NULL); |
|||
if (gCfgItems.wifi_mode_sel == STA_MODEL) { |
|||
//buttonCloud = lv_imgbtn_create(scr, NULL);
|
|||
buttonReconnect = lv_imgbtn_create(scr, NULL); |
|||
} |
|||
|
|||
lv_obj_set_event_cb_mks(buttonBack, event_handler,ID_W_RETURN, NULL,0); |
|||
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin"); |
|||
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin"); |
|||
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); |
|||
#endif |
|||
|
|||
lv_obj_set_pos(buttonBack,BTN_X_PIXEL*3+INTERVAL_V*4, BTN_Y_PIXEL+INTERVAL_H+titleHeight); |
|||
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); |
|||
|
|||
if (gCfgItems.wifi_mode_sel == STA_MODEL) { |
|||
|
|||
lv_obj_set_event_cb_mks(buttonReconnect, event_handler,ID_W_RECONNECT, NULL,0); |
|||
lv_imgbtn_set_src(buttonReconnect, LV_BTN_STATE_REL, "F:/bmp_wifi.bin"); |
|||
lv_imgbtn_set_src(buttonReconnect, LV_BTN_STATE_PR, "F:/bmp_wifi.bin"); |
|||
lv_imgbtn_set_style(buttonReconnect, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonReconnect, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
|
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonReconnect); |
|||
#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_Back = lv_label_create(buttonBack, NULL); |
|||
|
|||
if (gCfgItems.wifi_mode_sel == STA_MODEL) { |
|||
//label_Cloud = lv_label_create(buttonCloud, NULL);
|
|||
label_Reconnect = lv_label_create(buttonReconnect, NULL); |
|||
} |
|||
|
|||
if (gCfgItems.multiple_language !=0) { |
|||
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 (gCfgItems.wifi_mode_sel == STA_MODEL) { |
|||
//lv_label_set_text(label_Cloud, common_menu.text_back);
|
|||
//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_obj_align(label_Reconnect, buttonReconnect, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET); |
|||
} |
|||
} |
|||
|
|||
wifi_ip_text = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(wifi_ip_text, &tft_style_label_rel); |
|||
|
|||
wifi_name_text = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(wifi_name_text, &tft_style_label_rel); |
|||
|
|||
wifi_key_text = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(wifi_key_text, &tft_style_label_rel); |
|||
|
|||
wifi_state_text = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(wifi_state_text, &tft_style_label_rel); |
|||
|
|||
disp_wifi_state(); |
|||
} |
|||
|
|||
void disp_wifi_state() { |
|||
memset(public_buf_m, 0, sizeof(public_buf_m)); |
|||
strcpy(public_buf_m,wifi_menu.ip); |
|||
strcat(public_buf_m,ipPara.ip_addr); |
|||
lv_label_set_text(wifi_ip_text, public_buf_m); |
|||
lv_obj_align(wifi_ip_text, NULL, LV_ALIGN_CENTER,0, -100); |
|||
|
|||
memset(public_buf_m, 0, sizeof(public_buf_m)); |
|||
strcpy(public_buf_m,wifi_menu.wifi); |
|||
strcat(public_buf_m,wifiPara.ap_name); |
|||
lv_label_set_text(wifi_name_text, public_buf_m); |
|||
lv_obj_align(wifi_name_text, NULL, LV_ALIGN_CENTER,0, -70); |
|||
|
|||
if (wifiPara.mode == AP_MODEL) { |
|||
memset(public_buf_m, 0, sizeof(public_buf_m)); |
|||
strcpy(public_buf_m,wifi_menu.key); |
|||
strcat(public_buf_m,wifiPara.keyCode); |
|||
lv_label_set_text(wifi_key_text, public_buf_m); |
|||
lv_obj_align(wifi_key_text, NULL, LV_ALIGN_CENTER,0, -40); |
|||
|
|||
memset(public_buf_m, 0, sizeof(public_buf_m)); |
|||
strcpy(public_buf_m,wifi_menu.state_ap); |
|||
if (wifi_link_state == WIFI_CONNECTED) |
|||
strcat(public_buf_m,wifi_menu.connected); |
|||
else if (wifi_link_state == WIFI_NOT_CONFIG) |
|||
strcat(public_buf_m,wifi_menu.disconnected); |
|||
else |
|||
strcat(public_buf_m,wifi_menu.exception); |
|||
lv_label_set_text(wifi_state_text, public_buf_m); |
|||
lv_obj_align(wifi_state_text, NULL, LV_ALIGN_CENTER,0, -10); |
|||
} |
|||
else { |
|||
ZERO(public_buf_m); |
|||
strcpy(public_buf_m, wifi_menu.state_sta); |
|||
if (wifi_link_state == WIFI_CONNECTED) |
|||
strcat(public_buf_m, wifi_menu.connected); |
|||
else if (wifi_link_state == WIFI_NOT_CONFIG) |
|||
strcat(public_buf_m, wifi_menu.disconnected); |
|||
else |
|||
strcat(public_buf_m, wifi_menu.exception); |
|||
lv_label_set_text(wifi_state_text, public_buf_m); |
|||
lv_obj_align(wifi_state_text, NULL, LV_ALIGN_CENTER,0, -40); |
|||
|
|||
lv_label_set_text(wifi_key_text, ""); |
|||
lv_obj_align(wifi_key_text, NULL, LV_ALIGN_CENTER,0, -10); |
|||
} |
|||
} |
|||
|
|||
void lv_clear_wifi() { |
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); |
|||
#endif |
|||
lv_obj_del(scr); |
|||
} |
|||
|
|||
#endif // USE_WIFI_FUNCTION
|
|||
#endif // HAS_TFT_LVGL_UI
|
@ -0,0 +1,38 @@ |
|||
/**
|
|||
* 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_wifi(void); |
|||
extern void lv_clear_wifi(); |
|||
extern void disp_wifi_state(); |
|||
|
|||
#ifdef __cplusplus |
|||
} /* C-declarations for C++ */ |
|||
#endif |
|||
|
|||
|
|||
|
@ -0,0 +1,235 @@ |
|||
/**
|
|||
* 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 "lv_conf.h" |
|||
#include "draw_ui.h" |
|||
|
|||
#if ENABLED(USE_WIFI_FUNCTION) |
|||
|
|||
#include "../../../../../Configuration.h" |
|||
#include "../../../../module/temperature.h" |
|||
|
|||
#define NAME_BTN_X 330 |
|||
#define NAME_BTN_Y 48 |
|||
|
|||
#define MARK_BTN_X 0 |
|||
#define MARK_BTN_Y 68 |
|||
|
|||
WIFI_LIST wifi_list; |
|||
list_menu_def list_menu; |
|||
|
|||
extern lv_group_t * g; |
|||
static lv_obj_t * scr; |
|||
static lv_obj_t *buttonWifiN[NUMBER_OF_PAGE]; |
|||
static lv_obj_t *lableWifiText[NUMBER_OF_PAGE]; |
|||
static lv_obj_t *lablePageText; |
|||
|
|||
#define ID_WL_RETURN 11 |
|||
#define ID_WL_DOWN 12 |
|||
|
|||
static void event_handler(lv_obj_t * obj, lv_event_t event) { |
|||
if (obj->mks_obj_id == ID_WL_RETURN) { |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
clear_cur_ui(); |
|||
lv_draw_set(); |
|||
} |
|||
} |
|||
else if (obj->mks_obj_id == ID_WL_DOWN) { |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
if (wifi_list.getNameNum > 0) { |
|||
if ((wifi_list.nameIndex + NUMBER_OF_PAGE) >= wifi_list.getNameNum) { |
|||
wifi_list.nameIndex = 0; |
|||
wifi_list.currentWifipage = 1; |
|||
} |
|||
else { |
|||
wifi_list.nameIndex += NUMBER_OF_PAGE; |
|||
wifi_list.currentWifipage++; |
|||
} |
|||
disp_wifi_list(); |
|||
} |
|||
} |
|||
} |
|||
else { |
|||
for (uint8_t i = 0; i < NUMBER_OF_PAGE; i++) { |
|||
if (obj->mks_obj_id == i + 1) { |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
if (wifi_list.getNameNum != 0) { |
|||
const bool do_wifi = wifi_link_state == WIFI_CONNECTED && strcmp((const char *)wifi_list.wifiConnectedName, (const char *)wifi_list.wifiName[wifi_list.nameIndex + i]) == 0; |
|||
wifi_list.nameIndex += i; |
|||
last_disp_state = WIFI_LIST_UI; |
|||
lv_clear_wifi_list(); |
|||
if (do_wifi) |
|||
lv_draw_wifi(); |
|||
else { |
|||
keyboard_value = wifiConfig; |
|||
lv_draw_keyboard(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
void lv_draw_wifi_list(void) { |
|||
lv_obj_t *buttonBack = NULL, *buttonDown = NULL; |
|||
|
|||
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_LIST_UI) { |
|||
disp_state_stack._disp_index++; |
|||
disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_LIST_UI; |
|||
} |
|||
disp_state = WIFI_LIST_UI; |
|||
|
|||
scr = lv_obj_create(NULL, NULL); |
|||
|
|||
lv_obj_set_style(scr, &tft_style_scr); |
|||
lv_scr_load(scr); |
|||
lv_obj_clean(scr); |
|||
|
|||
lv_obj_t * title = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(title, &tft_style_label_rel); |
|||
lv_obj_set_pos(title,TITLE_XPOS,TITLE_YPOS); |
|||
lv_label_set_text(title, creat_title_text()); |
|||
|
|||
lv_refr_now(lv_refr_get_disp_refreshing()); |
|||
|
|||
buttonDown = lv_imgbtn_create(scr, NULL); |
|||
buttonBack = lv_imgbtn_create(scr, NULL); |
|||
|
|||
lv_obj_set_event_cb_mks(buttonDown, event_handler,ID_WL_DOWN,NULL,0); |
|||
lv_imgbtn_set_src(buttonDown, LV_BTN_STATE_REL, "F:/bmp_pageDown.bin"); |
|||
lv_imgbtn_set_src(buttonDown, LV_BTN_STATE_PR, "F:/bmp_pageDown.bin"); |
|||
lv_imgbtn_set_style(buttonDown, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonDown, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
|
|||
lv_obj_set_event_cb_mks(buttonBack, event_handler,ID_WL_RETURN,NULL,0); |
|||
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back.bin"); |
|||
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back.bin"); |
|||
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
|
|||
lv_obj_set_pos(buttonDown,OTHER_BTN_XPIEL*3+INTERVAL_V*4,titleHeight+OTHER_BTN_YPIEL+INTERVAL_H); |
|||
lv_obj_set_pos(buttonBack,OTHER_BTN_XPIEL*3+INTERVAL_V*4,titleHeight+OTHER_BTN_YPIEL*2+INTERVAL_H*2); |
|||
|
|||
lv_btn_set_layout(buttonDown, LV_LAYOUT_OFF); |
|||
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); |
|||
|
|||
for (uint8_t i = 0; i < NUMBER_OF_PAGE; i++) { |
|||
buttonWifiN[i] = lv_btn_create(scr, NULL); /*Add a button the current screen*/ |
|||
lv_obj_set_pos(buttonWifiN[i], 0,NAME_BTN_Y*i+10+titleHeight); /*Set its position*/ |
|||
lv_obj_set_size(buttonWifiN[i], NAME_BTN_X,NAME_BTN_Y); /*Set its size*/ |
|||
lv_obj_set_event_cb_mks(buttonWifiN[i], event_handler,(i+1),NULL,0); |
|||
lv_btn_set_style(buttonWifiN[i], LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/ |
|||
lv_btn_set_style(buttonWifiN[i], LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/ |
|||
lv_btn_set_layout(buttonWifiN[i], LV_LAYOUT_OFF); |
|||
lableWifiText[i] = lv_label_create(buttonWifiN[i], NULL); |
|||
#if HAS_ROTARY_ENCODER |
|||
uint8_t j = 0; |
|||
if (gCfgItems.encoder_enable) { |
|||
j = wifi_list.nameIndex + i; |
|||
if (j < wifi_list.getNameNum) lv_group_add_obj(g, buttonWifiN[i]); |
|||
} |
|||
#endif |
|||
} |
|||
|
|||
lablePageText = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(lablePageText, &tft_style_label_rel); |
|||
|
|||
wifi_list.nameIndex = 0; |
|||
wifi_list.currentWifipage = 1; |
|||
|
|||
if (wifi_link_state == WIFI_CONNECTED && wifiPara.mode == STA_MODEL) { |
|||
memset(wifi_list.wifiConnectedName, 0, sizeof(&wifi_list.wifiConnectedName)); |
|||
memcpy(wifi_list.wifiConnectedName, wifiPara.ap_name, sizeof(wifi_list.wifiConnectedName)); |
|||
} |
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) { |
|||
lv_group_add_obj(g, buttonDown); |
|||
lv_group_add_obj(g, buttonBack); |
|||
} |
|||
#endif |
|||
|
|||
disp_wifi_list(); |
|||
} |
|||
|
|||
void disp_wifi_list(void) { |
|||
int8_t tmpStr[WIFI_NAME_BUFFER_SIZE] = { 0 }; |
|||
uint8_t i, j; |
|||
|
|||
sprintf((char *)tmpStr, list_menu.file_pages, wifi_list.currentWifipage, wifi_list.getPage); |
|||
lv_label_set_text(lablePageText, (const char *)tmpStr); |
|||
lv_obj_align(lablePageText, NULL, LV_ALIGN_CENTER, 50, -100); |
|||
|
|||
for (i = 0; i < NUMBER_OF_PAGE; i++) { |
|||
memset(tmpStr, 0, sizeof(tmpStr)); |
|||
|
|||
j = wifi_list.nameIndex + i; |
|||
if (j >= wifi_list.getNameNum) { |
|||
lv_label_set_text(lableWifiText[i], (const char *)tmpStr); |
|||
lv_obj_align(lableWifiText[i], buttonWifiN[i], LV_ALIGN_IN_LEFT_MID, 20, 0); |
|||
} |
|||
else { |
|||
lv_label_set_text(lableWifiText[i], (char const *)wifi_list.wifiName[j]); |
|||
lv_obj_align(lableWifiText[i], buttonWifiN[i], LV_ALIGN_IN_LEFT_MID, 20, 0); |
|||
|
|||
if (wifi_link_state == WIFI_CONNECTED && strcmp((const char *)wifi_list.wifiConnectedName, (const char *)wifi_list.wifiName[j]) == 0) { |
|||
lv_btn_set_style(buttonWifiN[i], LV_BTN_STYLE_REL, &style_sel_text); |
|||
} |
|||
else { |
|||
lv_btn_set_style(buttonWifiN[i], LV_BTN_STYLE_REL, &tft_style_label_rel); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
void wifi_scan_handle() { |
|||
if (uiCfg.dialogType != WIFI_ENABLE_TIPS || uiCfg.command_send != 1) return; |
|||
last_disp_state = DIALOG_UI; |
|||
lv_clear_dialog(); |
|||
if (wifi_link_state == WIFI_CONNECTED && wifiPara.mode != AP_MODEL) |
|||
lv_draw_wifi(); |
|||
else |
|||
lv_draw_wifi_list(); |
|||
} |
|||
|
|||
void lv_clear_wifi_list() { |
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); |
|||
#endif |
|||
lv_obj_del(scr); |
|||
} |
|||
|
|||
#endif // USE_WIFI_FUNCTION
|
|||
|
|||
#endif // HAS_TFT_LVGL_UI
|
@ -0,0 +1,76 @@ |
|||
/**
|
|||
* 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_wifi_list(); |
|||
extern void lv_clear_wifi_list(); |
|||
extern void disp_wifi_list(void); |
|||
extern void cutWifiName(char *name, int len,char *outStr); |
|||
extern void wifi_scan_handle(); |
|||
|
|||
#define NUMBER_OF_PAGE 5 |
|||
|
|||
#define WIFI_TOTAL_NUMBER 20 |
|||
#define WIFI_NAME_BUFFER_SIZE 33 |
|||
|
|||
typedef struct { |
|||
int8_t getNameNum; |
|||
int8_t nameIndex; |
|||
int8_t currentWifipage; |
|||
int8_t getPage; |
|||
int8_t RSSI[WIFI_TOTAL_NUMBER]; |
|||
uint8_t wifiName[WIFI_TOTAL_NUMBER][WIFI_NAME_BUFFER_SIZE]; |
|||
uint8_t wifiConnectedName[WIFI_NAME_BUFFER_SIZE]; |
|||
} WIFI_LIST; |
|||
extern WIFI_LIST wifi_list; |
|||
|
|||
typedef struct list_menu_disp { |
|||
const char *title; |
|||
const char *file_pages; |
|||
} list_menu_def; |
|||
extern list_menu_def list_menu; |
|||
|
|||
typedef struct keyboard_menu_disp { |
|||
const char *title; |
|||
const char *apply; |
|||
const char *password; |
|||
const char *letter; |
|||
const char *digital; |
|||
const char *symbol; |
|||
const char *space; |
|||
} keyboard_menu_def; |
|||
extern keyboard_menu_def keyboard_menu; |
|||
|
|||
typedef struct tips_menu_disp { |
|||
const char *joining; |
|||
const char *failedJoin; |
|||
const char *wifiConected; |
|||
} tips_menu_def; |
|||
extern tips_menu_def tips_menu; |
|||
|
|||
#ifdef __cplusplus |
|||
} /* C-declarations for C++ */ |
|||
#endif |
@ -0,0 +1,299 @@ |
|||
/**
|
|||
* 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 "lv_conf.h" |
|||
#include "draw_ui.h" |
|||
|
|||
#if ENABLED(USE_WIFI_FUNCTION) |
|||
|
|||
#include "../../../../../Configuration.h" |
|||
#include "../../../../module/planner.h" |
|||
|
|||
extern lv_group_t * g; |
|||
static lv_obj_t *scr, *labelModelValue = NULL, *buttonModelValue = NULL, *labelCloudValue = NULL; |
|||
|
|||
#define ID_WIFI_RETURN 1 |
|||
#define ID_WIFI_MODEL 2 |
|||
#define ID_WIFI_NAME 3 |
|||
#define ID_WIFI_PASSWORD 4 |
|||
#define ID_WIFI_CLOUD 5 |
|||
#define ID_WIFI_CONFIG 6 |
|||
|
|||
static void event_handler(lv_obj_t * obj, lv_event_t event) { |
|||
switch (obj->mks_obj_id) { |
|||
case ID_WIFI_RETURN: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
lv_clear_wifi_settings(); |
|||
draw_return_ui(); |
|||
} |
|||
break; |
|||
case ID_WIFI_MODEL: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
if (gCfgItems.wifi_mode_sel == AP_MODEL) { |
|||
gCfgItems.wifi_mode_sel = STA_MODEL; |
|||
lv_label_set_text(labelModelValue, WIFI_STA_TEXT); |
|||
lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0); |
|||
update_spi_flash(); |
|||
} |
|||
else{ |
|||
gCfgItems.wifi_mode_sel = AP_MODEL; |
|||
lv_label_set_text(labelModelValue, WIFI_AP_TEXT); |
|||
lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0); |
|||
update_spi_flash(); |
|||
} |
|||
} |
|||
break; |
|||
case ID_WIFI_NAME: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
keyboard_value=wifiName; |
|||
lv_clear_wifi_settings(); |
|||
lv_draw_keyboard(); |
|||
} |
|||
break; |
|||
case ID_WIFI_PASSWORD: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
keyboard_value=wifiPassWord; |
|||
lv_clear_wifi_settings(); |
|||
lv_draw_keyboard(); |
|||
} |
|||
break; |
|||
case ID_WIFI_CLOUD: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
if (gCfgItems.cloud_enable) { |
|||
gCfgItems.cloud_enable = false; |
|||
lv_obj_set_event_cb_mks(obj, event_handler,ID_WIFI_CLOUD,"bmp_disable.bin",0); |
|||
lv_label_set_text(labelCloudValue, machine_menu.disable); |
|||
update_spi_flash(); |
|||
} |
|||
else { |
|||
gCfgItems.cloud_enable = true; |
|||
lv_obj_set_event_cb_mks(obj, event_handler,ID_WIFI_CLOUD,"bmp_enable.bin",0); |
|||
lv_label_set_text(labelCloudValue, machine_menu.enable); |
|||
update_spi_flash(); |
|||
} |
|||
} |
|||
break; |
|||
case ID_WIFI_CONFIG: |
|||
if (event == LV_EVENT_CLICKED) { |
|||
|
|||
} |
|||
else if (event == LV_EVENT_RELEASED) { |
|||
lv_clear_wifi_settings(); |
|||
lv_draw_dialog(DIALOG_WIFI_CONFIG_TIPS); |
|||
} |
|||
break; |
|||
} |
|||
} |
|||
|
|||
void lv_draw_wifi_settings(void) { |
|||
lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonConfig = NULL, *labelConfig = NULL; |
|||
lv_obj_t *labelModelText = NULL; |
|||
lv_obj_t *labelNameText = NULL, *buttonNameValue = NULL, *labelNameValue = NULL; |
|||
lv_obj_t *labelPassWordText = NULL, *buttonPassWordValue = NULL, *labelPassWordValue = NULL; |
|||
lv_obj_t *labelCloudText = NULL, *buttonCloudValue = NULL; |
|||
lv_obj_t * line1 = NULL, *line2 = NULL, *line3 = NULL, *line4 = NULL; |
|||
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_SETTINGS_UI) { |
|||
disp_state_stack._disp_index++; |
|||
disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_SETTINGS_UI; |
|||
} |
|||
disp_state = WIFI_SETTINGS_UI; |
|||
|
|||
scr = lv_obj_create(NULL, NULL); |
|||
|
|||
lv_obj_set_style(scr, &tft_style_scr); |
|||
lv_scr_load(scr); |
|||
lv_obj_clean(scr); |
|||
|
|||
lv_obj_t * title = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(title, &tft_style_label_rel); |
|||
lv_obj_set_pos(title,TITLE_XPOS,TITLE_YPOS); |
|||
lv_label_set_text(title, machine_menu.WifiConfTitle); |
|||
|
|||
lv_refr_now(lv_refr_get_disp_refreshing()); |
|||
|
|||
labelModelText = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelModelText, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelModelText, PARA_UI_POS_X, PARA_UI_POS_Y + 10); |
|||
lv_label_set_text(labelModelText, machine_menu.wifiMode); |
|||
|
|||
buttonModelValue = lv_imgbtn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonModelValue,PARA_UI_VALUE_POS_X,PARA_UI_POS_Y+PARA_UI_VALUE_V); |
|||
lv_obj_set_event_cb_mks(buttonModelValue, event_handler,ID_WIFI_MODEL, NULL,0); |
|||
lv_imgbtn_set_src(buttonModelValue, LV_BTN_STATE_REL, "F:/bmp_blank_sel.bin"); |
|||
lv_imgbtn_set_src(buttonModelValue, LV_BTN_STATE_PR, "F:/bmp_blank_sel.bin"); |
|||
lv_imgbtn_set_style(buttonModelValue, LV_BTN_STATE_PR, &style_para_value_pre); |
|||
lv_imgbtn_set_style(buttonModelValue, LV_BTN_STATE_REL, &style_para_value_pre); |
|||
lv_btn_set_layout(buttonModelValue, LV_LAYOUT_OFF); |
|||
labelModelValue = lv_label_create(buttonModelValue, NULL); |
|||
|
|||
line1 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line1,line_points[0]); |
|||
|
|||
labelNameText = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelNameText, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelNameText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10); |
|||
|
|||
buttonNameValue = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonNameValue,PARA_UI_VALUE_POS_X,PARA_UI_POS_Y*2+PARA_UI_VALUE_V); |
|||
lv_obj_set_size(buttonNameValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonNameValue, event_handler,ID_WIFI_NAME, NULL,0); |
|||
lv_btn_set_style(buttonNameValue, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonNameValue, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelNameValue = lv_label_create(buttonNameValue, NULL); |
|||
|
|||
line2 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line2,line_points[1]); |
|||
|
|||
labelPassWordText = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelPassWordText, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelPassWordText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10); |
|||
|
|||
buttonPassWordValue = lv_btn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonPassWordValue,PARA_UI_VALUE_POS_X,PARA_UI_POS_Y*3+PARA_UI_VALUE_V); |
|||
lv_obj_set_size(buttonPassWordValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); |
|||
lv_obj_set_event_cb_mks(buttonPassWordValue, event_handler,ID_WIFI_PASSWORD, NULL,0); |
|||
lv_btn_set_style(buttonPassWordValue, LV_BTN_STYLE_REL, &style_para_value); |
|||
lv_btn_set_style(buttonPassWordValue, LV_BTN_STYLE_PR, &style_para_value); |
|||
labelPassWordValue = lv_label_create(buttonPassWordValue, NULL); |
|||
|
|||
line3 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line3,line_points[2]); |
|||
|
|||
labelCloudText = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(labelCloudText, &tft_style_label_rel); |
|||
lv_obj_set_pos(labelCloudText, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10); |
|||
lv_label_set_text(labelCloudText, machine_menu.wifiCloud); |
|||
|
|||
buttonCloudValue = lv_imgbtn_create(scr, NULL); |
|||
lv_obj_set_pos(buttonCloudValue,PARA_UI_STATE_POS_X,PARA_UI_POS_Y*4+PARA_UI_STATE_V); |
|||
if (gCfgItems.cloud_enable) { |
|||
lv_imgbtn_set_src(buttonCloudValue, LV_BTN_STATE_REL, "F:/bmp_enable.bin"); |
|||
lv_imgbtn_set_src(buttonCloudValue, LV_BTN_STATE_PR, "F:/bmp_enable.bin"); |
|||
} |
|||
else { |
|||
lv_imgbtn_set_src(buttonCloudValue, LV_BTN_STATE_REL, "F:/bmp_disable.bin"); |
|||
lv_imgbtn_set_src(buttonCloudValue, LV_BTN_STATE_PR, "F:/bmp_disable.bin"); |
|||
} |
|||
lv_obj_set_event_cb_mks(buttonCloudValue, event_handler,ID_WIFI_CLOUD, NULL,0); |
|||
lv_imgbtn_set_style(buttonCloudValue, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonCloudValue, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
lv_btn_set_layout(buttonCloudValue, LV_LAYOUT_OFF); |
|||
labelCloudValue = lv_label_create(buttonCloudValue, NULL); |
|||
|
|||
line4 = lv_line_create(scr, NULL); |
|||
lv_ex_line(line4,line_points[3]); |
|||
|
|||
buttonConfig = lv_imgbtn_create(scr, NULL); |
|||
lv_obj_set_event_cb_mks(buttonConfig, event_handler,ID_WIFI_CONFIG, NULL,0); |
|||
lv_imgbtn_set_src(buttonConfig, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin"); |
|||
lv_imgbtn_set_src(buttonConfig, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin"); |
|||
lv_imgbtn_set_style(buttonConfig, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonConfig, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
lv_obj_set_pos(buttonConfig, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y); |
|||
lv_btn_set_layout(buttonConfig, LV_LAYOUT_OFF); |
|||
labelConfig = lv_label_create(buttonConfig, NULL); |
|||
|
|||
buttonBack = lv_imgbtn_create(scr, NULL); |
|||
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_WIFI_RETURN, NULL, 0); |
|||
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin"); |
|||
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin"); |
|||
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre); |
|||
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel); |
|||
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y); |
|||
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF); |
|||
label_Back = lv_label_create(buttonBack, NULL); |
|||
|
|||
if (gCfgItems.multiple_language !=0) { |
|||
if (gCfgItems.wifi_mode_sel == AP_MODEL) { |
|||
lv_label_set_text(labelModelValue, WIFI_AP_TEXT); |
|||
lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0); |
|||
} |
|||
else { |
|||
lv_label_set_text(labelModelValue, WIFI_STA_TEXT); |
|||
lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0); |
|||
} |
|||
memset(public_buf_m,0,sizeof(public_buf_m)); |
|||
strcat(public_buf_m,machine_menu.wifiName); |
|||
strcat(public_buf_m,(const char *)uiCfg.wifi_name); |
|||
lv_label_set_text(labelNameText,public_buf_m); |
|||
|
|||
lv_label_set_text(labelNameValue,machine_menu.wifiEdit); |
|||
lv_obj_align(labelNameValue, buttonNameValue, LV_ALIGN_CENTER,0, 0); |
|||
|
|||
memset(public_buf_m,0,sizeof(public_buf_m)); |
|||
strcat(public_buf_m,machine_menu.wifiPassWord); |
|||
strcat(public_buf_m,(const char *)uiCfg.wifi_key); |
|||
lv_label_set_text(labelPassWordText,public_buf_m); |
|||
|
|||
lv_label_set_text(labelPassWordValue,machine_menu.wifiEdit); |
|||
lv_obj_align(labelPassWordValue, buttonPassWordValue, LV_ALIGN_CENTER,0, 0); |
|||
|
|||
lv_label_set_text(labelCloudValue, gCfgItems.cloud_enable ? machine_menu.enable : machine_menu.disable); |
|||
lv_obj_align(labelCloudValue, buttonCloudValue, LV_ALIGN_CENTER,0, 0); |
|||
|
|||
lv_label_set_text(labelConfig,machine_menu.wifiConfig); |
|||
lv_obj_align(labelConfig, buttonConfig, LV_ALIGN_CENTER,0, 0); |
|||
|
|||
lv_label_set_text(label_Back, common_menu.text_back); |
|||
lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER,0, 0); |
|||
} |
|||
|
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) { |
|||
lv_group_add_obj(g, buttonModelValue); |
|||
lv_group_add_obj(g, buttonNameValue); |
|||
lv_group_add_obj(g, buttonPassWordValue); |
|||
lv_group_add_obj(g, buttonCloudValue); |
|||
lv_group_add_obj(g, buttonConfig); |
|||
lv_group_add_obj(g, buttonBack); |
|||
} |
|||
#endif |
|||
} |
|||
|
|||
void lv_clear_wifi_settings() { |
|||
#if HAS_ROTARY_ENCODER |
|||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); |
|||
#endif |
|||
lv_obj_del(scr); |
|||
} |
|||
|
|||
#endif // USE_WIFI_FUNCTION
|
|||
|
|||
#endif // HAS_TFT_LVGL_UI
|
@ -0,0 +1,36 @@ |
|||
/**
|
|||
* 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 |
|||
|
|||
#define WIFI_AP_TEXT "AP" |
|||
#define WIFI_STA_TEXT "STA" |
|||
|
|||
extern void lv_draw_wifi_settings(void); |
|||
extern void lv_clear_wifi_settings(); |
|||
|
|||
#ifdef __cplusplus |
|||
} /* C-declarations for C++ */ |
|||
#endif |
@ -0,0 +1,85 @@ |
|||
/**
|
|||
* 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 "lv_conf.h" |
|||
#include "draw_ui.h" |
|||
|
|||
#if ENABLED(USE_WIFI_FUNCTION) |
|||
|
|||
#include "../../../../../Configuration.h" |
|||
#include "../../../../module/temperature.h" |
|||
|
|||
static lv_obj_t * scr; |
|||
|
|||
TIPS_TYPE wifi_tips_type; |
|||
TIPS_DISP tips_disp; |
|||
tips_menu_def tips_menu; |
|||
|
|||
void lv_draw_wifi_tips(void) { |
|||
static lv_obj_t * text_tips,*wifi_name; |
|||
|
|||
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_TIPS_UI) { |
|||
disp_state_stack._disp_index++; |
|||
disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_TIPS_UI; |
|||
} |
|||
disp_state = WIFI_TIPS_UI; |
|||
|
|||
scr = lv_obj_create(NULL, NULL); |
|||
|
|||
lv_obj_set_style(scr, &tft_style_scr); |
|||
lv_scr_load(scr); |
|||
lv_obj_clean(scr); |
|||
lv_refr_now(lv_refr_get_disp_refreshing()); |
|||
|
|||
text_tips = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(text_tips, &tft_style_label_rel); |
|||
|
|||
wifi_name = lv_label_create(scr, NULL); |
|||
lv_obj_set_style(wifi_name, &tft_style_label_rel); |
|||
|
|||
if (wifi_tips_type == TIPS_TYPE_JOINING) { |
|||
lv_label_set_text(text_tips, tips_menu.joining); |
|||
lv_obj_align(text_tips, NULL, LV_ALIGN_CENTER,0, -60); |
|||
} |
|||
else if (wifi_tips_type == TIPS_TYPE_TAILED_JOIN) { |
|||
lv_label_set_text(text_tips, tips_menu.failedJoin); |
|||
lv_obj_align(text_tips, NULL, LV_ALIGN_CENTER,0, -60); |
|||
} |
|||
else if (wifi_tips_type == TIPS_TYPE_WIFI_CONECTED) { |
|||
lv_label_set_text(text_tips, tips_menu.wifiConected); |
|||
lv_obj_align(text_tips, NULL, LV_ALIGN_CENTER,0, -60); |
|||
} |
|||
|
|||
lv_label_set_text(wifi_name, (const char *)wifi_list.wifiName[wifi_list.nameIndex]); |
|||
lv_obj_align(wifi_name, NULL, LV_ALIGN_CENTER,0, -20); |
|||
|
|||
tips_disp.timer = TIPS_TIMER_START; |
|||
tips_disp.timer_count = 0; |
|||
} |
|||
|
|||
void lv_clear_wifi_tips() { lv_obj_del(scr); } |
|||
|
|||
#endif // USE_WIFI_FUNCTION
|
|||
#endif // HAS_TFT_LVGL_UI
|
@ -0,0 +1,51 @@ |
|||
/**
|
|||
* 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_wifi_tips(void); |
|||
extern void lv_clear_wifi_tips(); |
|||
|
|||
typedef enum { |
|||
TIPS_TYPE_JOINING, |
|||
TIPS_TYPE_TAILED_JOIN, |
|||
TIPS_TYPE_WIFI_CONECTED |
|||
} TIPS_TYPE; |
|||
extern TIPS_TYPE wifi_tips_type; |
|||
|
|||
typedef struct { |
|||
unsigned char timer; |
|||
unsigned int timer_count; |
|||
} TIPS_DISP; |
|||
extern TIPS_DISP tips_disp; |
|||
|
|||
#define TIPS_TIMER_START 1 |
|||
#define TIPS_TIMER_STOP 0 |
|||
|
|||
#ifdef __cplusplus |
|||
} /* C-declarations for C++ */ |
|||
#endif |
|||
|
@ -0,0 +1,69 @@ |
|||
/**
|
|||
* 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 "draw_ui.h" |
|||
|
|||
#if ENABLED(USE_WIFI_FUNCTION) |
|||
|
|||
#include "wifiSerial.h" |
|||
|
|||
#include <libmaple/libmaple.h> |
|||
#include <libmaple/gpio.h> |
|||
#include <libmaple/timer.h> |
|||
#include <libmaple/usart.h> |
|||
#include <libmaple/ring_buffer.h> |
|||
|
|||
#include "../../../../inc/MarlinConfig.h" |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { /* C-declarations for C++ */ |
|||
#endif |
|||
|
|||
#define WIFI_IO1_SET() WRITE(WIFI_IO1_PIN, HIGH); |
|||
#define WIFI_IO1_RESET() WRITE(WIFI_IO1_PIN, LOW); |
|||
|
|||
void __irq_usart1(void) { |
|||
WIFISERIAL.wifi_usart_irq(USART1_BASE); |
|||
if (wifi_link_state == WIFI_TRANS_FILE) { |
|||
if (WIFISERIAL.available() == (400)) WIFI_IO1_SET(); |
|||
if (WIFISERIAL.wifi_rb_is_full()) { |
|||
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 |
|||
} /* C-declarations for C++ */ |
|||
#endif |
|||
|
|||
#endif // USE_WIFI_FUNCTION
|
|||
#endif // HAS_TFT_LVGL_UI
|
File diff suppressed because it is too large
@ -0,0 +1,120 @@ |
|||
/**
|
|||
* 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 "draw_ui.h" |
|||
#include "wifiSerial.h" |
|||
|
|||
#if ENABLED(USE_WIFI_FUNCTION) |
|||
|
|||
#include <libmaple/libmaple.h> |
|||
#include <libmaple/gpio.h> |
|||
#include <libmaple/timer.h> |
|||
#include <libmaple/usart.h> |
|||
#include <libmaple/ring_buffer.h> |
|||
|
|||
#include "../../../../MarlinCore.h" |
|||
|
|||
DEFINE_WFSERIAL(WifiSerial1, 1); |
|||
|
|||
WifiSerial::WifiSerial(usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin) { |
|||
this->usart_device = usart_device; |
|||
this->tx_pin = tx_pin; |
|||
this->rx_pin = rx_pin; |
|||
} |
|||
|
|||
/**
|
|||
* Set up / tear down |
|||
*/ |
|||
#if STM32_MCU_SERIES == STM32_SERIES_F1 |
|||
/* F1 MCUs have no GPIO_AFR[HL], so turn off PWM if there's a conflict
|
|||
* on this GPIO bit. */ |
|||
static void disable_timer_if_necessary(timer_dev *dev, uint8 ch) { |
|||
if (dev != nullptr) timer_set_mode(dev, ch, TIMER_DISABLED); |
|||
} |
|||
#elif STM32_MCU_SERIES == STM32_SERIES_F2 || STM32_MCU_SERIES == STM32_SERIES_F4 |
|||
#define disable_timer_if_necessary(dev, ch) ((void)0) |
|||
#else |
|||
#warning "Unsupported STM32 series; timer conflicts are possible" |
|||
#endif |
|||
|
|||
void WifiSerial::begin(uint32 baud) { begin(baud, SERIAL_8N1); } |
|||
|
|||
/**
|
|||
* Roger Clark. |
|||
* Note. The config parameter is not currently used. This is a work in progress. |
|||
* Code needs to be written to set the config of the hardware serial control register in question. |
|||
*/ |
|||
|
|||
void WifiSerial::begin(uint32 baud, uint8_t config) { |
|||
//ASSERT(baud <= this->usart_device->max_baud); // Roger Clark. Assert doesn't do anything useful, we may as well save the space in flash and ram etc
|
|||
|
|||
if (baud > this->usart_device->max_baud) return; |
|||
|
|||
const stm32_pin_info *txi = &PIN_MAP[this->tx_pin], |
|||
*rxi = &PIN_MAP[this->rx_pin]; |
|||
|
|||
disable_timer_if_necessary(txi->timer_device, txi->timer_channel); |
|||
|
|||
usart_init(this->usart_device); |
|||
|
|||
// Reinitialize the receive buffer, mks_esp8266 fixed data frame length is 1k bytes
|
|||
rb_init(this->usart_device->rb, WIFI_RX_BUF_SIZE, wifiRxBuf); |
|||
|
|||
usart_config_gpios_async(this->usart_device, |
|||
rxi->gpio_device, rxi->gpio_bit, |
|||
txi->gpio_device, txi->gpio_bit, |
|||
config); |
|||
usart_set_baud_rate(this->usart_device, USART_USE_PCLK, baud); |
|||
usart_enable(this->usart_device); |
|||
} |
|||
|
|||
void WifiSerial::end(void) { |
|||
usart_disable(this->usart_device); |
|||
} |
|||
|
|||
int WifiSerial::available(void) { |
|||
return usart_data_available(this->usart_device); |
|||
} |
|||
|
|||
//
|
|||
// I/O
|
|||
//
|
|||
|
|||
int WifiSerial::read(void) { |
|||
if (usart_data_available(usart_device) <= 0) return -1; |
|||
return usart_getc(usart_device); |
|||
} |
|||
|
|||
int WifiSerial::write(unsigned char ch) { |
|||
usart_putc(this->usart_device, ch); |
|||
return 1; |
|||
} |
|||
|
|||
int WifiSerial::wifi_rb_is_full(void) { |
|||
return rb_is_full(this->usart_device->rb); |
|||
} |
|||
|
|||
#endif // USE_WIFI_FUNCTION
|
|||
#endif // HAS_TFT_LVGL_UI
|
@ -0,0 +1,102 @@ |
|||
/**
|
|||
* 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 |
|||
|
|||
#include "tft_lvgl_configuration.h" |
|||
|
|||
#if ENABLED(USE_WIFI_FUNCTION) |
|||
|
|||
#if SERIAL_PORT_2 != -1 |
|||
#error "SERIAL_PORT_2 must be set to -1 with HAS_TFT_LVGL_UI and USE_WIFI_FUNCTION." |
|||
#endif |
|||
|
|||
#define WIFI_BAUDRATE 115200 |
|||
#define WIFI_UPLOAD_BAUDRATE 1958400 |
|||
#define USART_SAFE_INSERT |
|||
|
|||
#define WIFI_RX_BUF_SIZE (1024+1) |
|||
|
|||
#include <libmaple/libmaple_types.h> |
|||
#include <libmaple/usart.h> |
|||
#include <libmaple/libmaple.h> |
|||
#include <libmaple/gpio.h> |
|||
#include <libmaple/timer.h> |
|||
#include <libmaple/ring_buffer.h> |
|||
|
|||
#define DEFINE_WFSERIAL(name, n)\ |
|||
WifiSerial name(USART##n, \ |
|||
BOARD_USART##n##_TX_PIN, \ |
|||
BOARD_USART##n##_RX_PIN) |
|||
|
|||
class WifiSerial { |
|||
public: |
|||
uint8 wifiRxBuf[WIFI_RX_BUF_SIZE]; |
|||
|
|||
public: |
|||
WifiSerial(struct usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin); |
|||
|
|||
/* Set up/tear down */ |
|||
void begin(uint32 baud); |
|||
void begin(uint32 baud,uint8_t config); |
|||
void end(); |
|||
int available(void); |
|||
int read(void); |
|||
int write(uint8_t); |
|||
inline void wifi_usart_irq(usart_reg_map *regs) { |
|||
/* Handling RXNEIE and TXEIE interrupts.
|
|||
* RXNE signifies availability of a byte in DR. |
|||
* |
|||
* See table 198 (sec 27.4, p809) in STM document RM0008 rev 15. |
|||
* We enable RXNEIE. |
|||
*/ |
|||
if ((regs->CR1 & USART_CR1_RXNEIE) && (regs->SR & USART_SR_RXNE)) { |
|||
#ifdef USART_SAFE_INSERT |
|||
/* If the buffer is full and the user defines USART_SAFE_INSERT,
|
|||
* ignore new bytes. */ |
|||
rb_safe_insert(this->usart_device->rb, (uint8)regs->DR); |
|||
#else |
|||
/* By default, push bytes around in the ring buffer. */ |
|||
rb_push_insert(this->usart_device->rb, (uint8)regs->DR); |
|||
#endif |
|||
} |
|||
/* TXE signifies readiness to send a byte to DR. */ |
|||
if ((regs->CR1 & USART_CR1_TXEIE) && (regs->SR & USART_SR_TXE)) { |
|||
if (!rb_is_empty(this->usart_device->wb)) |
|||
regs->DR=rb_remove(this->usart_device->wb); |
|||
else |
|||
regs->CR1 &= ~((uint32)USART_CR1_TXEIE); // disable TXEIE
|
|||
} |
|||
} |
|||
|
|||
int wifi_rb_is_full(void); |
|||
|
|||
private: |
|||
struct usart_dev *usart_device; |
|||
uint8 tx_pin; |
|||
uint8 rx_pin; |
|||
}; |
|||
|
|||
extern WifiSerial WifiSerial1; |
|||
|
|||
#define WIFISERIAL WifiSerial1 |
|||
|
|||
#endif // USE_WIFI_FUNCTION
|
File diff suppressed because it is too large
@ -0,0 +1,202 @@ |
|||
/**
|
|||
* 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 |
|||
|
|||
#include "../../inc/MarlinConfigPre.h" |
|||
|
|||
#include <math.h> |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
|
|||
#define UART_RX_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 IP_DHCP_FLAG 1 |
|||
|
|||
#define WIFI_AP_NAME "TP-LINK_MKS" |
|||
#define WIFI_KEY_CODE "makerbase" |
|||
|
|||
#define IP_ADDR "192.168.3.100" |
|||
#define IP_MASK "255.255.255.0" |
|||
#define IP_GATE "192.168.3.1" |
|||
#define IP_DNS "192.168.3.1" |
|||
|
|||
#define AP_IP_DHCP_FLAG 1 |
|||
#define AP_IP_ADDR "192.168.3.100" |
|||
#define AP_IP_MASK "255.255.255.0" |
|||
#define AP_IP_GATE "192.168.3.1" |
|||
#define AP_IP_DNS "192.168.3.1" |
|||
#define IP_START_IP "192.168.3.1" |
|||
#define IP_END_IP "192.168.3.255" |
|||
|
|||
#define UDISKBUFLEN 1024 |
|||
|
|||
typedef enum{ |
|||
udisk_buf_empty = 0, |
|||
udisk_buf_full, |
|||
} UDISK_DATA_BUFFER_STATE; |
|||
|
|||
#define TRANS_RCV_FIFO_BLOCK_NUM 8 |
|||
|
|||
typedef struct { |
|||
unsigned char *bufferAddr[TRANS_RCV_FIFO_BLOCK_NUM]; |
|||
unsigned char *p; |
|||
UDISK_DATA_BUFFER_STATE state[TRANS_RCV_FIFO_BLOCK_NUM]; |
|||
unsigned char read_cur; |
|||
unsigned char write_cur; |
|||
} WIFI_DMA_RCV_FIFO; |
|||
|
|||
typedef struct { |
|||
uint8_t flag; // 0x0: no error; 0x01: error
|
|||
uint32_t start_tick; //error start time
|
|||
uint32_t now_tick; |
|||
} WIFI_TRANS_ERROR; |
|||
|
|||
extern volatile WIFI_TRANS_ERROR wifiTransError; |
|||
|
|||
typedef struct { |
|||
char ap_name[32]; //wifi-name
|
|||
char keyCode[64]; //wifi password
|
|||
int decodeType; |
|||
int baud; |
|||
int mode; |
|||
} WIFI_PARA; |
|||
|
|||
typedef struct { |
|||
char state; |
|||
char hostUrl[96]; |
|||
int port; |
|||
char id[21]; |
|||
} CLOUD_PARA; |
|||
|
|||
typedef struct { |
|||
char dhcp_flag; |
|||
char ip_addr[16]; |
|||
char mask[16]; |
|||
char gate[16]; |
|||
char dns[16]; |
|||
|
|||
char dhcpd_flag; |
|||
char dhcpd_ip[16]; |
|||
char dhcpd_mask[16]; |
|||
char dhcpd_gate[16]; |
|||
char dhcpd_dns[16]; |
|||
char start_ip_addr[16]; |
|||
char end_ip_addr[16]; |
|||
} IP_PARA; |
|||
|
|||
typedef enum { |
|||
WIFI_NOT_CONFIG, |
|||
WIFI_CONFIG_MODE, |
|||
WIFI_CONFIG_DHCP, |
|||
WIFI_CONFIG_AP, |
|||
WIFI_CONFIG_IP_INF, |
|||
WIFI_CONFIG_DNS, |
|||
WIFI_CONFIG_TCP, |
|||
WIFI_CONFIG_SERVER, |
|||
WIFI_CONFIG_REMOTE_PORT, |
|||
WIFI_CONFIG_BAUD, |
|||
WIFI_CONFIG_COMMINT, |
|||
WIFI_CONFIG_OK, |
|||
WIFI_GET_IP_OK, |
|||
WIFI_RECONN, |
|||
WIFI_CONNECTED, |
|||
WIFI_WAIT_TRANS_START, |
|||
WIFI_TRANS_FILE, |
|||
WIFI_CONFIG_DHCPD, |
|||
WIFI_COFIG_DHCPD_IP, |
|||
WIFI_COFIG_DHCPD_DNS, |
|||
WIFI_EXCEPTION, |
|||
} WIFI_STATE; |
|||
|
|||
typedef enum { |
|||
TRANSFER_IDLE, |
|||
TRANSFERING, |
|||
TRANSFER_STORE, |
|||
} TRANSFER_STATE; |
|||
extern volatile TRANSFER_STATE esp_state; |
|||
|
|||
typedef struct { |
|||
char buf[20][80]; |
|||
int rd_index; |
|||
int wt_index; |
|||
} QUEUE; |
|||
|
|||
typedef enum { |
|||
WIFI_PARA_SET, // 0x0:net parameter
|
|||
WIFI_PRINT_INF, // 0x1:print message
|
|||
WIFI_TRANS_INF, // 0x2:Pass through information
|
|||
WIFI_EXCEP_INF, // 0x3:Exception information
|
|||
WIFI_CLOUD_CFG, // 0x4:cloud config
|
|||
WIFI_CLOUD_UNBIND, // 0x5:Unbind ID
|
|||
} WIFI_RET_TYPE; |
|||
|
|||
typedef struct { |
|||
uint32_t uart_read_point; |
|||
uint32_t uart_write_point; |
|||
uint8_t uartTxBuffer[UART_FIFO_BUFFER_SIZE]; |
|||
} SZ_USART_FIFO; |
|||
|
|||
#define WIFI_GCODE_BUFFER_LEAST_SIZE 96 |
|||
#define WIFI_GCODE_BUFFER_SIZE (WIFI_GCODE_BUFFER_LEAST_SIZE * 3) |
|||
typedef struct { |
|||
uint8_t wait_tick; |
|||
uint8_t Buffer[WIFI_GCODE_BUFFER_SIZE]; |
|||
uint32_t r; |
|||
uint32_t w; |
|||
} WIFI_GCODE_BUFFER; |
|||
|
|||
extern volatile WIFI_STATE wifi_link_state; |
|||
extern WIFI_PARA wifiPara; |
|||
extern IP_PARA ipPara; |
|||
extern CLOUD_PARA cloud_para; |
|||
|
|||
extern WIFI_GCODE_BUFFER espGcodeFifo; |
|||
|
|||
extern uint32_t getWifiTick(); |
|||
extern uint32_t getWifiTickDiff(int32_t lastTick, int32_t curTick); |
|||
|
|||
extern void mks_esp_wifi_init(); |
|||
extern int cfg_cloud_flag; |
|||
extern int send_to_wifi(char *buf, int len); |
|||
extern void wifi_looping(); |
|||
extern int raw_send_to_wifi(char *buf, int len); |
|||
extern int package_to_wifi(WIFI_RET_TYPE type,char *buf, int len); |
|||
extern void get_wifi_list_command_send(); |
|||
extern void get_wifi_commands(); |
|||
extern int readWifiBuf(int8_t *buf, int32_t len); |
|||
extern int storeRcvData(int32_t len); |
|||
|
|||
#ifdef __cplusplus |
|||
} /* C-declarations for C++ */ |
|||
#endif |
@ -0,0 +1,847 @@ |
|||
/**
|
|||
* 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 "draw_ui.h" |
|||
#include "wifi_module.h" |
|||
#include "wifi_upload.h" |
|||
|
|||
#include "../../../../MarlinCore.h" |
|||
|
|||
#define WIFI_SET() WRITE(WIFI_RESET_PIN, HIGH); |
|||
#define WIFI_RESET() WRITE(WIFI_RESET_PIN, LOW); |
|||
#define WIFI_IO1_SET() WRITE(WIFI_IO1_PIN, HIGH); |
|||
#define WIFI_IO1_RESET() WRITE(WIFI_IO1_PIN, LOW); |
|||
|
|||
extern SZ_USART_FIFO WifiRxFifo; |
|||
|
|||
extern int readUsartFifo(SZ_USART_FIFO *fifo, int8_t *buf, int32_t len); |
|||
extern int writeUsartFifo(SZ_USART_FIFO * fifo, int8_t * buf, int32_t len); |
|||
extern void esp_port_begin(uint8_t interrupt); |
|||
extern int usartFifoAvailable(SZ_USART_FIFO *fifo); |
|||
extern void wifi_delay(int n); |
|||
|
|||
#define ARRAY_SIZE(a) sizeof(a) / sizeof((a)[0]) |
|||
|
|||
//typedef signed char bool;
|
|||
|
|||
// ESP8266 command codes
|
|||
const uint8_t ESP_FLASH_BEGIN = 0x02; |
|||
const uint8_t ESP_FLASH_DATA = 0x03; |
|||
const uint8_t ESP_FLASH_END = 0x04; |
|||
const uint8_t ESP_MEM_BEGIN = 0x05; |
|||
const uint8_t ESP_MEM_END = 0x06; |
|||
const uint8_t ESP_MEM_DATA = 0x07; |
|||
const uint8_t ESP_SYNC = 0x08; |
|||
const uint8_t ESP_WRITE_REG = 0x09; |
|||
const uint8_t ESP_READ_REG = 0x0a; |
|||
|
|||
// MAC address storage locations
|
|||
const uint32_t ESP_OTP_MAC0 = 0x3ff00050; |
|||
const uint32_t ESP_OTP_MAC1 = 0x3ff00054; |
|||
const uint32_t ESP_OTP_MAC2 = 0x3ff00058; |
|||
const uint32_t ESP_OTP_MAC3 = 0x3ff0005c; |
|||
|
|||
const size_t EspFlashBlockSize = 0x0400; // 1K byte blocks
|
|||
|
|||
const uint8_t ESP_IMAGE_MAGIC = 0xe9; |
|||
const uint8_t ESP_CHECKSUM_MAGIC = 0xef; |
|||
|
|||
const uint32_t ESP_ERASE_CHIP_ADDR = 0x40004984; // &SPIEraseChip
|
|||
const uint32_t ESP_SEND_PACKET_ADDR = 0x40003c80; // &send_packet
|
|||
const uint32_t ESP_SPI_READ_ADDR = 0x40004b1c; // &SPIRead
|
|||
const uint32_t ESP_UNKNOWN_ADDR = 0x40001121; // not used
|
|||
const uint32_t ESP_USER_DATA_RAM_ADDR = 0x3ffe8000; // &user data ram
|
|||
const uint32_t ESP_IRAM_ADDR = 0x40100000; // instruction RAM
|
|||
const uint32_t ESP_FLASH_ADDR = 0x40200000; // address of start of Flash
|
|||
//const uint32_t ESP_FLASH_READ_STUB_BEGIN = IRAM_ADDR + 0x18;
|
|||
|
|||
UPLOAD_STRUCT esp_upload; |
|||
|
|||
static const unsigned int retriesPerReset = 3; |
|||
static const uint32_t connectAttemptInterval = 50; |
|||
static const unsigned int percentToReportIncrement = 5; // how often we report % complete
|
|||
static const uint32_t defaultTimeout = 500; |
|||
static const uint32_t eraseTimeout = 15000; |
|||
static const uint32_t blockWriteTimeout = 200; |
|||
static const uint32_t blockWriteInterval = 15; // 15ms is long enough, 10ms is mostly too short
|
|||
|
|||
// Messages corresponding to result codes, should make sense when followed by " error"
|
|||
const char *resultMessages[] = { |
|||
"no", |
|||
"timeout", |
|||
"comm write", |
|||
"connect", |
|||
"bad reply", |
|||
"file read", |
|||
"empty file", |
|||
"response header", |
|||
"slip frame", |
|||
"slip state", |
|||
"slip data" |
|||
}; |
|||
|
|||
// A note on baud rates.
|
|||
// The ESP8266 supports 921600, 460800, 230400, 115200, 74880 and some lower baud rates.
|
|||
// 921600b is not reliable because even though it sometimes succeeds in connecting, we get a bad response during uploading after a few blocks.
|
|||
// Probably our UART ISR cannot receive bytes fast enough, perhaps because of the latency of the system tick ISR.
|
|||
// 460800b doesn't always manage to connect, but if it does then uploading appears to be reliable.
|
|||
// 230400b always manages to connect.
|
|||
static const uint32_t uploadBaudRates[] = { 460800, 230400, 115200, 74880 }; |
|||
|
|||
|
|||
|
|||
signed char IsReady() { |
|||
return esp_upload.state == upload_idle; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void uploadPort_write(const uint8_t *buf, size_t len) { |
|||
#if 0 |
|||
int i; |
|||
|
|||
for(i = 0; i < len; i++) { |
|||
while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET); |
|||
|
|||
USART_SendData(USART1, *(buf + i)); |
|||
} |
|||
#endif |
|||
} |
|||
|
|||
char uploadPort_read() { |
|||
uint8_t retChar; |
|||
if (readUsartFifo(&WifiRxFifo, (int8_t *)&retChar, 1) == 1) |
|||
return retChar; |
|||
else |
|||
return 0; |
|||
|
|||
} |
|||
|
|||
int uploadPort_available() { |
|||
return usartFifoAvailable(&WifiRxFifo); |
|||
} |
|||
|
|||
|
|||
void uploadPort_begin() { |
|||
esp_port_begin(1); |
|||
} |
|||
|
|||
void uploadPort_close() { |
|||
|
|||
//WIFI_COM.end();
|
|||
//WIFI_COM.begin(115200, true);
|
|||
|
|||
esp_port_begin(0); |
|||
|
|||
} |
|||
|
|||
|
|||
void flushInput() { |
|||
while (uploadPort_available() != 0) { |
|||
(void)uploadPort_read(); |
|||
//IWDG_ReloadCounter();
|
|||
} |
|||
} |
|||
|
|||
// 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 val = 0; |
|||
|
|||
if (buf && byteCnt) { |
|||
unsigned int shiftCnt = 0; |
|||
if (byteCnt > 4) |
|||
byteCnt = 4; |
|||
do{ |
|||
val |= (uint32_t)buf[ofst++] << shiftCnt; |
|||
shiftCnt += 8; |
|||
} while (--byteCnt); |
|||
} |
|||
return(val); |
|||
} |
|||
|
|||
// 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) { |
|||
if (buf && byteCnt) { |
|||
if (byteCnt > 4) { |
|||
byteCnt = 4; |
|||
} |
|||
do { |
|||
buf[ofst++] = (uint8_t)(val & 0xff); |
|||
val >>= 8; |
|||
} while (--byteCnt); |
|||
} |
|||
} |
|||
|
|||
// Read a byte optionally performing SLIP decoding. The return values are:
|
|||
//
|
|||
// 2 - an escaped byte was read successfully
|
|||
// 1 - a non-escaped byte was read successfully
|
|||
// 0 - no data was available
|
|||
// -1 - the value 0xc0 was encountered (shouldn't happen)
|
|||
// -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
|
|||
int ReadByte(uint8_t *data, signed char slipDecode) { |
|||
if (uploadPort_available() == 0) { |
|||
return(0); |
|||
} |
|||
|
|||
// at least one byte is available
|
|||
*data = uploadPort_read(); |
|||
if (!slipDecode) { |
|||
return(1); |
|||
} |
|||
|
|||
if (*data == 0xc0) { |
|||
// this shouldn't happen
|
|||
return(-1); |
|||
} |
|||
|
|||
// if not the SLIP escape, we're done
|
|||
if (*data != 0xdb) { |
|||
return(1); |
|||
} |
|||
|
|||
// SLIP escape, check availability of subsequent byte
|
|||
if (uploadPort_available() == 0) { |
|||
return(-2); |
|||
} |
|||
|
|||
// process the escaped byte
|
|||
*data = uploadPort_read(); |
|||
if (*data == 0xdc) { |
|||
*data = 0xc0; |
|||
return(2); |
|||
} |
|||
|
|||
if (*data == 0xdd) { |
|||
*data = 0xdb; |
|||
return(2); |
|||
} |
|||
// invalid
|
|||
return(-3); |
|||
} |
|||
// 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.
|
|||
void _writePacketRaw(const uint8_t *buf, size_t len) { |
|||
uploadPort_write(buf, len); |
|||
} |
|||
|
|||
// Write a byte to the serial port optionally SLIP encoding. Return the number of bytes actually written.
|
|||
void WriteByteRaw(uint8_t b) { |
|||
uploadPort_write((const uint8_t *)&b, 1); |
|||
} |
|||
|
|||
// Write a byte to the serial port optionally SLIP encoding. Return the number of bytes actually written.
|
|||
void WriteByteSlip(uint8_t b) { |
|||
if (b == 0xC0) { |
|||
WriteByteRaw(0xDB); |
|||
WriteByteRaw(0xDC); |
|||
} |
|||
else if (b == 0xDB) { |
|||
WriteByteRaw(0xDB); |
|||
WriteByteRaw(0xDD); |
|||
} |
|||
else { |
|||
uploadPort_write((const uint8_t *)&b, 1); |
|||
} |
|||
} |
|||
|
|||
// Wait for a data packet to be returned. If the body of the packet is
|
|||
// non-zero length, return an allocated buffer indirectly containing the
|
|||
// data and return the data length. Note that if the pointer for returning
|
|||
// the data buffer is NULL, the response is expected to be two bytes of zero.
|
|||
//
|
|||
// If an error occurs, return a negative value. Otherwise, return the number
|
|||
// of bytes in the response (or zero if the response was not the standard "two bytes of zero").
|
|||
EspUploadResult readPacket(uint8_t op, uint32_t *valp, size_t *bodyLen, uint32_t msTimeout) { |
|||
typedef enum { |
|||
begin = 0, |
|||
header, |
|||
body, |
|||
end, |
|||
done |
|||
} PacketState; |
|||
|
|||
uint8_t resp, opRet; |
|||
|
|||
const size_t headerLength = 8; |
|||
|
|||
uint32_t startTime = getWifiTick(); |
|||
uint8_t hdr[headerLength]; |
|||
uint16_t hdrIdx = 0; |
|||
|
|||
uint16_t bodyIdx = 0; |
|||
uint8_t respBuf[2]; |
|||
|
|||
// wait for the response
|
|||
uint16_t needBytes = 1; |
|||
|
|||
PacketState state = begin; |
|||
|
|||
*bodyLen = 0; |
|||
|
|||
|
|||
while (state != done) { |
|||
uint8_t c; |
|||
EspUploadResult stat; |
|||
|
|||
//IWDG_ReloadCounter();
|
|||
|
|||
if (getWifiTickDiff(startTime, getWifiTick()) > msTimeout) { |
|||
return(timeout); |
|||
} |
|||
|
|||
if (uploadPort_available() < needBytes) { |
|||
// insufficient data available
|
|||
// preferably, return to Spin() here
|
|||
continue; |
|||
} |
|||
|
|||
// sufficient bytes have been received for the current state, process them
|
|||
switch(state) { |
|||
case begin: // expecting frame start
|
|||
c = uploadPort_read(); |
|||
if (c != (uint8_t)0xc0) { |
|||
break; |
|||
} |
|||
state = header; |
|||
needBytes = 2; |
|||
|
|||
break; |
|||
case end: // expecting frame end
|
|||
c = uploadPort_read(); |
|||
if (c != (uint8_t)0xc0) { |
|||
return slipFrame; |
|||
} |
|||
state = done; |
|||
|
|||
break; |
|||
|
|||
case header: // reading an 8-byte header
|
|||
case body: // reading the response body
|
|||
{ |
|||
int rslt; |
|||
// retrieve a byte with SLIP decoding
|
|||
rslt = ReadByte(&c, 1); |
|||
if (rslt != 1 && rslt != 2) { |
|||
// some error occurred
|
|||
stat = (rslt == 0 || rslt == -2) ? slipData : slipFrame; |
|||
return stat; |
|||
} |
|||
else if (state == header) { |
|||
//store the header byte
|
|||
hdr[hdrIdx++] = c; |
|||
if (hdrIdx >= headerLength) { |
|||
// get the body length, prepare a buffer for it
|
|||
*bodyLen = (uint16_t)getData(2, hdr, 2); |
|||
|
|||
// extract the value, if requested
|
|||
if (valp != 0) { |
|||
*valp = getData(4, hdr, 4); |
|||
} |
|||
|
|||
if (*bodyLen != 0) { |
|||
state = body; |
|||
} |
|||
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; |
|||
state = end; |
|||
} |
|||
} |
|||
} |
|||
break; |
|||
|
|||
default: // this shouldn't happen
|
|||
return slipState; |
|||
} |
|||
} |
|||
|
|||
// Extract elements from the header
|
|||
resp = (uint8_t)getData(1, hdr, 0); |
|||
opRet = (uint8_t)getData(1, hdr, 1); |
|||
// Sync packets often provoke a response with a zero opcode instead of ESP_SYNC
|
|||
if (resp != 0x01 || opRet != op) { |
|||
//debug//printf("resp %02x %02x\n", resp, opRet);
|
|||
return respHeader; |
|||
} |
|||
|
|||
return success; |
|||
} |
|||
|
|||
// Send a block of data performing SLIP encoding of the content.
|
|||
void _writePacket(const uint8_t *data, size_t len) { |
|||
unsigned char outBuf[2048] = {0}; |
|||
unsigned int outIndex = 0; |
|||
while (len != 0) { |
|||
if (*data == 0xC0) { |
|||
outBuf[outIndex++] = 0xDB; |
|||
outBuf[outIndex++] = 0xDC; |
|||
} |
|||
else if (*data == 0xDB) { |
|||
outBuf[outIndex++] = 0xDB; |
|||
outBuf[outIndex++] = 0xDD; |
|||
} |
|||
else { |
|||
outBuf[outIndex++] = *data; |
|||
|
|||
} |
|||
data++; |
|||
--len; |
|||
} |
|||
uploadPort_write((const uint8_t *)outBuf, outIndex); |
|||
} |
|||
|
|||
// Send a packet to the serial port while performing SLIP framing. The packet data comprises a header and an optional data block.
|
|||
// A SLIP packet begins and ends with 0xc0. The data encapsulated has the bytes
|
|||
// 0xc0 and 0xdb replaced by the two-byte sequences {0xdb, 0xdc} and {0xdb, 0xdd} respectively.
|
|||
|
|||
void writePacket(const uint8_t *hdr, size_t hdrLen, const uint8_t *data, size_t dataLen) { |
|||
|
|||
WriteByteRaw(0xc0); // send the packet start character
|
|||
_writePacket(hdr, hdrLen); // send the header
|
|||
_writePacket(data, dataLen); // send the data block
|
|||
WriteByteRaw(0xc0); // send the packet end character
|
|||
} |
|||
|
|||
// Send a packet to the serial port while performing SLIP framing. The packet data comprises a header and an optional data block.
|
|||
// This is like writePacket except that it does a fast block write for both the header and the main data with no SLIP encoding. Used to send sync commands.
|
|||
void writePacketRaw(const uint8_t *hdr, size_t hdrLen, const uint8_t *data, size_t dataLen) { |
|||
WriteByteRaw(0xc0); // send the packet start character
|
|||
_writePacketRaw(hdr, hdrLen); // send the header
|
|||
_writePacketRaw(data, dataLen); // send the data block in raw mode
|
|||
WriteByteRaw(0xc0); // send the packet end character
|
|||
} |
|||
|
|||
// Send a command to the attached device together with the supplied data, if any.
|
|||
// The data is supplied via a list of one or more segments.
|
|||
void sendCommand(uint8_t op, uint32_t checkVal, const uint8_t *data, size_t dataLen) { |
|||
// populate the header
|
|||
uint8_t hdr[8]; |
|||
putData(0, 1, hdr, 0); |
|||
putData(op, 1, hdr, 1); |
|||
putData(dataLen, 2, hdr, 2); |
|||
putData(checkVal, 4, hdr, 4); |
|||
|
|||
// send the packet
|
|||
//flushInput();
|
|||
if (op == ESP_SYNC) { |
|||
writePacketRaw(hdr, sizeof(hdr), data, dataLen); |
|||
} |
|||
else { |
|||
writePacket(hdr, sizeof(hdr), data, dataLen); |
|||
} |
|||
} |
|||
|
|||
// Send a command to the attached device together with the supplied data, if any, and get the response
|
|||
EspUploadResult doCommand(uint8_t op, const uint8_t *data, size_t dataLen, uint32_t checkVal, uint32_t *valp, uint32_t msTimeout) { |
|||
size_t bodyLen; |
|||
EspUploadResult stat; |
|||
|
|||
sendCommand(op, checkVal, data, dataLen); |
|||
|
|||
stat = readPacket(op, valp, &bodyLen, msTimeout); |
|||
if (stat == success && bodyLen != 2) { |
|||
stat = badReply; |
|||
} |
|||
|
|||
return stat; |
|||
} |
|||
|
|||
// Send a synchronising packet to the serial port in an attempt to induce
|
|||
// the ESP8266 to auto-baud lock on the baud rate.
|
|||
EspUploadResult Sync(uint16_t timeout) { |
|||
uint8_t buf[36]; |
|||
EspUploadResult stat; |
|||
int i ; |
|||
|
|||
// compose the data for the sync attempt
|
|||
memset(buf, 0x55, sizeof(buf)); |
|||
buf[0] = 0x07; |
|||
buf[1] = 0x07; |
|||
buf[2] = 0x12; |
|||
buf[3] = 0x20; |
|||
|
|||
stat = doCommand(ESP_SYNC, buf, sizeof(buf), 0, 0, timeout); |
|||
|
|||
// If we got a response other than sync, discard it and wait for a sync response. This happens at higher baud rates.
|
|||
for (i = 0; i < 10 && stat == respHeader; ++i) { |
|||
size_t bodyLen; |
|||
stat = readPacket(ESP_SYNC, 0, &bodyLen, timeout); |
|||
} |
|||
|
|||
if (stat == success) { |
|||
// Read and discard additional replies
|
|||
for (;;) { |
|||
size_t bodyLen; |
|||
EspUploadResult rc = readPacket(ESP_SYNC, 0, &bodyLen, defaultTimeout); |
|||
if (rc != success || bodyLen != 2) { |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
//DEBUG
|
|||
//else debug//printf("stat=%d\n", (int)stat);
|
|||
return stat; |
|||
} |
|||
|
|||
// Send a command to the device to begin the Flash process.
|
|||
EspUploadResult flashBegin(uint32_t addr, uint32_t size) { |
|||
// determine the number of blocks represented by the size
|
|||
uint32_t blkCnt; |
|||
uint8_t buf[16]; |
|||
uint32_t timeout; |
|||
|
|||
blkCnt = (size + EspFlashBlockSize - 1) / EspFlashBlockSize; |
|||
|
|||
// ensure that the address is on a block boundary
|
|||
addr &= ~(EspFlashBlockSize - 1); |
|||
|
|||
// begin the Flash process
|
|||
putData(size, 4, buf, 0); |
|||
putData(blkCnt, 4, buf, 4); |
|||
putData(EspFlashBlockSize, 4, buf, 8); |
|||
putData(addr, 4, buf, 12); |
|||
|
|||
timeout = (size != 0) ? eraseTimeout : defaultTimeout; |
|||
return doCommand(ESP_FLASH_BEGIN, buf, sizeof(buf), 0, 0, timeout); |
|||
} |
|||
|
|||
// Send a command to the device to terminate the Flash process
|
|||
EspUploadResult flashFinish(signed char reboot) { |
|||
uint8_t buf[4]; |
|||
putData(reboot ? 0 : 1, 4, buf, 0); |
|||
return doCommand(ESP_FLASH_END, buf, sizeof(buf), 0, 0, defaultTimeout); |
|||
} |
|||
|
|||
// Compute the checksum of a block of data
|
|||
uint16_t checksum(const uint8_t *data, uint16_t dataLen, uint16_t cksum) { |
|||
if (data != NULL) { |
|||
while (dataLen--) { |
|||
cksum ^= (uint16_t)*data++; |
|||
} |
|||
} |
|||
return(cksum); |
|||
} |
|||
|
|||
EspUploadResult flashWriteBlock(uint16_t flashParmVal, uint16_t flashParmMask) { |
|||
#if 0 |
|||
const uint32_t blkSize = EspFlashBlockSize; |
|||
int i; |
|||
|
|||
// Allocate a data buffer for the combined header and block data
|
|||
const uint16_t hdrOfst = 0; |
|||
const uint16_t dataOfst = 16; |
|||
const uint16_t blkBufSize = dataOfst + blkSize; |
|||
uint32_t blkBuf32[blkBufSize/4]; |
|||
uint8_t * const blkBuf = (uint8_t*)(blkBuf32); |
|||
uint32_t cnt; |
|||
uint16_t cksum; |
|||
EspUploadResult stat; |
|||
|
|||
// Prepare the header for the block
|
|||
putData(blkSize, 4, blkBuf, hdrOfst + 0); |
|||
putData(esp_upload.uploadBlockNumber, 4, blkBuf, hdrOfst + 4); |
|||
putData(0, 4, blkBuf, hdrOfst + 8); |
|||
putData(0, 4, blkBuf, hdrOfst + 12); |
|||
|
|||
// Get the data for the block
|
|||
f_read(&esp_upload.uploadFile, blkBuf + dataOfst, blkSize, &cnt );//->Read(reinterpret_cast<char *>(blkBuf + dataOfst), blkSize);
|
|||
if (cnt != blkSize) { |
|||
if (f_tell(&esp_upload.uploadFile) == esp_upload.fileSize) { |
|||
// partial last block, fill the remainder
|
|||
memset(blkBuf + dataOfst + cnt, 0xff, blkSize - cnt); |
|||
} |
|||
else { |
|||
return fileRead; |
|||
} |
|||
} |
|||
|
|||
// Patch the flash parameters into the first block if it is loaded at address 0
|
|||
if (esp_upload.uploadBlockNumber == 0 && esp_upload.uploadAddress == 0 && blkBuf[dataOfst] == ESP_IMAGE_MAGIC && flashParmMask != 0) { |
|||
// update the Flash parameters
|
|||
uint32_t flashParm = getData(2, blkBuf + dataOfst + 2, 0) & ~(uint32_t)flashParmMask; |
|||
putData(flashParm | flashParmVal, 2, blkBuf + dataOfst + 2, 0); |
|||
} |
|||
|
|||
// Calculate the block checksum
|
|||
cksum = checksum(blkBuf + dataOfst, blkSize, ESP_CHECKSUM_MAGIC); |
|||
|
|||
for (i = 0; i < 3; i++) { |
|||
if ((stat = doCommand(ESP_FLASH_DATA, blkBuf, blkBufSize, cksum, 0, blockWriteTimeout)) == success) { |
|||
break; |
|||
} |
|||
} |
|||
|
|||
//printf("Upload %d\%\n", ftell(&esp_upload.uploadFile) * 100 / esp_upload.fileSize);
|
|||
|
|||
return stat; |
|||
#endif |
|||
} |
|||
|
|||
void upload_spin() { |
|||
#if 0 |
|||
switch (esp_upload.state) { |
|||
case resetting: |
|||
|
|||
if (esp_upload.connectAttemptNumber == 9) { |
|||
// 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); |
|||
|
|||
if (numSectors < headSectors) { |
|||
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; |
|||
} |
|||
} |
|||
break; |
|||
|
|||
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) { |
|||
//MessageF("Flash block upload failed\n");
|
|||
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 { |
|||
esp_upload.state = done; |
|||
} |
|||
} |
|||
break; |
|||
|
|||
case done: |
|||
f_close(&esp_upload.uploadFile); |
|||
//uploadPort.end();
|
|||
//uploadPort_close();
|
|||
|
|||
//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; |
|||
} |
|||
#endif |
|||
} |
|||
|
|||
// Try to upload the given file at the given address
|
|||
void SendUpdateFile(const char *file, uint32_t address) { |
|||
#if 0 |
|||
FRESULT res = f_open(&esp_upload.uploadFile, file, FA_OPEN_EXISTING | FA_READ); |
|||
|
|||
if (res != FR_OK) return; |
|||
|
|||
esp_upload.fileSize = f_size(&esp_upload.uploadFile); |
|||
if (esp_upload.fileSize == 0) { |
|||
f_close(&esp_upload.uploadFile); |
|||
return; |
|||
} |
|||
f_lseek(&esp_upload.uploadFile, 0); |
|||
|
|||
esp_upload.uploadAddress = address; |
|||
esp_upload.connectAttemptNumber = 0; |
|||
esp_upload.state = resetting; |
|||
#endif |
|||
} |
|||
|
|||
static const uint32_t FirmwareAddress = 0x00000000, WebFilesAddress = 0x00100000; |
|||
|
|||
void ResetWiFiForUpload(int begin_or_end) { |
|||
#if 0 |
|||
uint32_t start, now; |
|||
|
|||
GPIO_InitTypeDef GPIO_InitStructure; |
|||
|
|||
#if V1_0_V1_1 |
|||
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH; |
|||
GPIO_InitStructure.Pin = GPIO_Pin_8; |
|||
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; |
|||
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); |
|||
#else |
|||
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) { |
|||
#if V1_0_V1_1 |
|||
HAL_GPIO_WritePin(GPIOA,GPIO_Pin_8,GPIO_PIN_RESET); //update mode
|
|||
#else |
|||
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) { |
|||
esp_upload.retriesPerBaudRate = 9; |
|||
|
|||
ResetWiFiForUpload(0); |
|||
|
|||
if (type == 0) |
|||
SendUpdateFile(ESP_FIRMWARE_FILE, FirmwareAddress); |
|||
else if (type == 1) |
|||
SendUpdateFile(ESP_WEB_FIRMWARE_FILE, FirmwareAddress); |
|||
else if (type == 2) |
|||
SendUpdateFile(ESP_WEB_FILE, WebFilesAddress); |
|||
else |
|||
return -1; |
|||
|
|||
while (esp_upload.state != upload_idle) { |
|||
upload_spin(); |
|||
//IWDG_ReloadCounter();
|
|||
} |
|||
|
|||
ResetWiFiForUpload(1); |
|||
|
|||
return esp_upload.uploadResult == success ? 0 : -1; |
|||
} |
|||
|
|||
#endif // HAS_TFT_LVGL_UI
|
@ -0,0 +1,74 @@ |
|||
/**
|
|||
* 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 |
|||
|
|||
#define ESP_FIRMWARE_FILE "1:/MksWifi.bin" |
|||
#define ESP_WEB_FIRMWARE_FILE "1:/MksWifi_Web.bin" |
|||
#define ESP_WEB_FILE "1:/MksWifi_WebView.bin" |
|||
|
|||
typedef enum { |
|||
upload_idle, |
|||
resetting, |
|||
connecting, |
|||
erasing, |
|||
uploading, |
|||
done |
|||
} UploadState; |
|||
|
|||
typedef enum { |
|||
success = 0, |
|||
timeout, |
|||
connected, |
|||
badReply, |
|||
fileRead, |
|||
emptyFile, |
|||
respHeader, |
|||
slipFrame, |
|||
slipState, |
|||
slipData, |
|||
} EspUploadResult; |
|||
|
|||
typedef struct { |
|||
//FIL uploadFile;
|
|||
uint32_t fileSize; |
|||
|
|||
uint32_t uploadAddress; |
|||
UploadState state; |
|||
uint32_t retriesPerBaudRate; |
|||
uint32_t connectAttemptNumber; |
|||
uint32_t lastAttemptTime; |
|||
uint32_t lastResetTime; |
|||
uint32_t uploadBlockNumber; |
|||
uint32_t uploadNextPercentToReport; |
|||
EspUploadResult uploadResult; |
|||
} UPLOAD_STRUCT; |
|||
|
|||
extern UPLOAD_STRUCT esp_upload; |
|||
int32_t wifi_upload(int type); |
|||
|
|||
#ifdef __cplusplus |
|||
} /* C-declarations for C++ */ |
|||
#endif |
@ -0,0 +1,377 @@ |
|||
/**
|
|||
* 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 |
|||
|
|||
/**
|
|||
* MKS Robin nano (STM32F130VET6) board pin assignments |
|||
*/ |
|||
|
|||
#ifndef __STM32F1__ |
|||
#error "Oops! Select an STM32F1 board in 'Tools > Board.'" |
|||
#elif HOTENDS > 1 || E_STEPPERS > 1 |
|||
#error "MKS Robin e3p supports up to 1 hotends / E-steppers. Comment out this line to continue." |
|||
#elif HAS_FSMC_TFT |
|||
#error "MKS Robin e3p doesn't support FSMC-based TFT displays." |
|||
#endif |
|||
|
|||
#define BOARD_INFO_NAME "MKS Robin e3p" |
|||
|
|||
//
|
|||
// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role
|
|||
//
|
|||
|
|||
#define DISABLE_DEBUG |
|||
|
|||
//
|
|||
// EEPROM
|
|||
//
|
|||
//#define FLASH_EEPROM_EMULATION
|
|||
//#define SDCARD_EEPROM_EMULATION
|
|||
|
|||
#if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) |
|||
#define I2C_EEPROM // EEPROM on I2C-0
|
|||
#define MARLIN_EEPROM_SIZE 0x1000 // 4KB
|
|||
#endif |
|||
|
|||
//
|
|||
// Note: MKS Robin board is using SPI2 interface.
|
|||
//
|
|||
//#define SPI_MODULE 2
|
|||
#define ENABLE_SPI2 |
|||
|
|||
//
|
|||
// Limit Switches
|
|||
//
|
|||
#define X_DIAG_PIN PA15 |
|||
#define Y_DIAG_PIN PA12 |
|||
#define Z_DIAG_PIN PA11 |
|||
#define E0_DIAG_PIN PC4 |
|||
|
|||
#define X_STOP_PIN PA15 |
|||
#define Y_STOP_PIN PA12 |
|||
#define Z_MIN_PIN PA11 |
|||
#define Z_MAX_PIN PC4 |
|||
|
|||
//
|
|||
// Steppers
|
|||
//
|
|||
#define X_ENABLE_PIN PE4 |
|||
#define X_STEP_PIN PE3 |
|||
#define X_DIR_PIN PE2 |
|||
#ifndef X_CS_PIN |
|||
#define X_CS_PIN PD5 |
|||
#endif |
|||
|
|||
#define Y_ENABLE_PIN PE1 |
|||
#define Y_STEP_PIN PE0 |
|||
#define Y_DIR_PIN PB9 |
|||
#ifndef Y_CS_PIN |
|||
#define Y_CS_PIN PD7 |
|||
#endif |
|||
|
|||
#define Z_ENABLE_PIN PB8 |
|||
#define Z_STEP_PIN PB5 |
|||
#define Z_DIR_PIN PB4 |
|||
#ifndef Z_CS_PIN |
|||
#define Z_CS_PIN PD4 |
|||
#endif |
|||
|
|||
#define E0_ENABLE_PIN PB3 |
|||
#define E0_STEP_PIN PD6 |
|||
#define E0_DIR_PIN PD3 |
|||
#ifndef E0_CS_PIN |
|||
#define E0_CS_PIN PD9 |
|||
#endif |
|||
|
|||
//
|
|||
// Software SPI pins for TMC2130 stepper drivers
|
|||
//
|
|||
#if ENABLED(TMC_USE_SW_SPI) |
|||
#ifndef TMC_SW_MOSI |
|||
#define TMC_SW_MOSI PD14 |
|||
#endif |
|||
#ifndef TMC_SW_MISO |
|||
#define TMC_SW_MISO PD1 |
|||
#endif |
|||
#ifndef TMC_SW_SCK |
|||
#define TMC_SW_SCK PD0 |
|||
#endif |
|||
#endif |
|||
|
|||
#if HAS_TMC_UART |
|||
/**
|
|||
* TMC2208/TMC2209 stepper drivers |
|||
* |
|||
* Hardware serial communication ports. |
|||
* If undefined software serial is used according to the pins below |
|||
*/ |
|||
//#define X_HARDWARE_SERIAL Serial
|
|||
//#define X2_HARDWARE_SERIAL Serial1
|
|||
//#define Y_HARDWARE_SERIAL Serial1
|
|||
//#define Y2_HARDWARE_SERIAL Serial1
|
|||
//#define Z_HARDWARE_SERIAL Serial1
|
|||
//#define Z2_HARDWARE_SERIAL Serial1
|
|||
//#define E0_HARDWARE_SERIAL Serial1
|
|||
//#define E1_HARDWARE_SERIAL Serial1
|
|||
//#define E2_HARDWARE_SERIAL Serial1
|
|||
//#define E3_HARDWARE_SERIAL Serial1
|
|||
//#define E4_HARDWARE_SERIAL Serial1
|
|||
|
|||
//
|
|||
// Software serial
|
|||
//
|
|||
|
|||
#define X_SERIAL_TX_PIN PD5 |
|||
#define X_SERIAL_RX_PIN PD5 |
|||
|
|||
#define Y_SERIAL_TX_PIN PD7 |
|||
#define Y_SERIAL_RX_PIN PD7 |
|||
|
|||
#define Z_SERIAL_TX_PIN PD4 |
|||
#define Z_SERIAL_RX_PIN PD4 |
|||
|
|||
#define E0_SERIAL_TX_PIN PD9 |
|||
#define E0_SERIAL_RX_PIN PD9 |
|||
|
|||
// Reduce baud rate to improve software serial reliability
|
|||
#define TMC_BAUD_RATE 19200 |
|||
#endif // TMC2208 || TMC2209
|
|||
|
|||
//
|
|||
// Temperature Sensors
|
|||
//
|
|||
#define TEMP_0_PIN PC1 // TH1
|
|||
#define TEMP_BED_PIN PC0 // TB1
|
|||
|
|||
//
|
|||
// Heaters / Fans
|
|||
//
|
|||
#define HEATER_0_PIN PC3 // HEATER1
|
|||
#define HEATER_BED_PIN PA0 // HOT BED
|
|||
|
|||
#define FAN_PIN PB1 // FAN
|
|||
|
|||
//
|
|||
// Misc. Functions
|
|||
//
|
|||
#if HAS_TFT_LVGL_UI |
|||
//#define MKSPWC
|
|||
#ifdef MKSPWC |
|||
#define SUICIDE_PIN PB2 // Enable MKSPWC SUICIDE PIN
|
|||
#define SUICIDE_PIN_INVERTING false // Enable MKSPWC PIN STATE
|
|||
#define KILL_PIN PA2 // Enable MKSPWC DET PIN
|
|||
#define KILL_PIN_STATE true // Enable MKSPWC PIN STATE
|
|||
#endif |
|||
|
|||
#define MT_DET_1_PIN PA4 // LVGL UI FILAMENT RUNOUT1 PIN
|
|||
#define MT_DET_PIN_INVERTING false // LVGL UI filament RUNOUT PIN STATE
|
|||
|
|||
#define WIFI_IO0_PIN PC13 // MKS ESP WIFI IO0 PIN
|
|||
#define WIFI_IO1_PIN PC7 // MKS ESP WIFI IO1 PIN
|
|||
#define WIFI_RESET_PIN PE9 // MKS ESP WIFI RESET PIN
|
|||
|
|||
#if ENABLED(MKS_TEST) |
|||
#define MKS_TEST_POWER_LOSS_PIN PA2 // PW_DET
|
|||
#define MKS_TEST_PS_ON_PIN PB0 // PW_OFF
|
|||
#endif |
|||
#else |
|||
//#define POWER_LOSS_PIN PA2 // PW_DET
|
|||
//#define PS_ON_PIN PB2 // PW_OFF
|
|||
#define FIL_RUNOUT_PIN PA4 |
|||
#endif |
|||
|
|||
#define SERVO0_PIN PA8 // Enable BLTOUCH
|
|||
|
|||
//#define LED_PIN PB2
|
|||
|
|||
//
|
|||
// SD Card
|
|||
//
|
|||
#ifndef SDCARD_CONNECTION |
|||
#define SDCARD_CONNECTION ONBOARD |
|||
#endif |
|||
|
|||
#define SDIO_SUPPORT |
|||
#define SDIO_CLOCK 4500000 // 4.5 MHz
|
|||
#define SD_DETECT_PIN PD12 |
|||
#define ONBOARD_SD_CS_PIN PC11 |
|||
|
|||
//
|
|||
// LCD / Controller
|
|||
//
|
|||
#ifndef BEEPER_PIN |
|||
#define BEEPER_PIN PC5 |
|||
#endif |
|||
|
|||
/**
|
|||
* Note: MKS Robin TFT screens use various TFT controllers. |
|||
* If the screen stays white, disable 'LCD_RESET_PIN' |
|||
* to let the bootloader init the screen. |
|||
*/ |
|||
|
|||
#if HAS_SPI_TFT |
|||
|
|||
// Shared SPI TFT
|
|||
|
|||
#define LCD_BACKLIGHT_PIN PD13 |
|||
|
|||
#define TOUCH_CS_PIN PE14 // SPI1_NSS
|
|||
#define TOUCH_SCK_PIN PA5 // SPI1_SCK
|
|||
#define TOUCH_MISO_PIN PA6 // SPI1_MISO
|
|||
#define TOUCH_MOSI_PIN PA7 // SPI1_MOSI
|
|||
|
|||
#define BTN_EN1 PE8 |
|||
#define BTN_EN2 PE11 |
|||
#define BTN_ENC PE13 |
|||
|
|||
#define TFT_CS_PIN PD11 |
|||
#define TFT_SCK_PIN PA5 |
|||
#define TFT_MISO_PIN PA6 |
|||
#define TFT_MOSI_PIN PA7 |
|||
#define TFT_DC_PIN PD10 |
|||
#define TFT_RST_PIN PC6 |
|||
#define TFT_A0_PIN TFT_DC_PIN |
|||
|
|||
#define TFT_RESET_PIN PC6 |
|||
#define TFT_BACKLIGHT_PIN PD13 |
|||
|
|||
#define TOUCH_BUTTONS_HW_SPI |
|||
#define TOUCH_BUTTONS_HW_SPI_DEVICE 1 |
|||
|
|||
#ifndef TFT_WIDTH |
|||
#define TFT_WIDTH 480 |
|||
#endif |
|||
#ifndef TFT_HEIGHT |
|||
#define TFT_HEIGHT 320 |
|||
#endif |
|||
|
|||
#define LCD_READ_ID 0xD3 |
|||
#define LCD_USE_DMA_SPI |
|||
|
|||
#endif |
|||
|
|||
#if ENABLED(TFT_LVGL_UI_SPI) |
|||
|
|||
// LVGL
|
|||
|
|||
#define XPT2046_X_CALIBRATION -17253 |
|||
#define XPT2046_Y_CALIBRATION 11579 |
|||
#define XPT2046_X_OFFSET 514 |
|||
#define XPT2046_Y_OFFSET -24 |
|||
|
|||
#elif ENABLED(SPI_GRAPHICAL_TFT) |
|||
|
|||
// Emulated DOGM SPI
|
|||
|
|||
#ifndef XPT2046_X_CALIBRATION |
|||
#define XPT2046_X_CALIBRATION -11386 |
|||
#endif |
|||
#ifndef XPT2046_Y_CALIBRATION |
|||
#define XPT2046_Y_CALIBRATION 8684 |
|||
#endif |
|||
#ifndef XPT2046_X_OFFSET |
|||
#define XPT2046_X_OFFSET 339 |
|||
#endif |
|||
#ifndef XPT2046_Y_OFFSET |
|||
#define XPT2046_Y_OFFSET -18 |
|||
#endif |
|||
|
|||
#ifndef GRAPHICAL_TFT_UPSCALE |
|||
#define GRAPHICAL_TFT_UPSCALE 3 |
|||
#endif |
|||
#ifndef TFT_PIXEL_OFFSET_Y |
|||
#define TFT_PIXEL_OFFSET_Y 32 |
|||
#endif |
|||
|
|||
#define BTN_ENC PE13 |
|||
#define BTN_EN1 PE8 |
|||
#define BTN_EN2 PE11 |
|||
|
|||
#define LCD_PINS_ENABLE PD13 |
|||
#define LCD_PINS_RS PC6 |
|||
|
|||
#elif ENABLED(TFT_480x320_SPI) |
|||
#define XPT2046_X_CALIBRATION -17253 |
|||
#define XPT2046_Y_CALIBRATION 11579 |
|||
#define XPT2046_X_OFFSET 514 |
|||
#define XPT2046_Y_OFFSET -24 |
|||
|
|||
#define TFT_DRIVER ST7796 |
|||
#define TFT_BUFFER_SIZE 14400 |
|||
|
|||
#endif |
|||
|
|||
#if HAS_SPI_LCD && !HAS_SPI_TFT |
|||
|
|||
// NON TFT Displays
|
|||
|
|||
#if ENABLED(MKS_MINI_12864) |
|||
|
|||
// MKS MINI12864 and MKS LCD12864B
|
|||
// If using MKS LCD12864A (Need to remove RPK2 resistor)
|
|||
|
|||
#define LCD_BACKLIGHT_PIN -1 |
|||
#define LCD_RESET_PIN -1 |
|||
#define DOGLCD_A0 PD11 |
|||
#define DOGLCD_CS PE15 |
|||
#define DOGLCD_SCK PA5 |
|||
#define DOGLCD_MOSI PA7 |
|||
|
|||
// Required for MKS_MINI_12864 with this board
|
|||
#define MKS_LCD12864B |
|||
#undef SHOW_BOOTSCREEN |
|||
|
|||
#else // !MKS_MINI_12864
|
|||
|
|||
#define LCD_PINS_D4 PE14 |
|||
#if ENABLED(ULTIPANEL) |
|||
#define LCD_PINS_D5 PE15 |
|||
#define LCD_PINS_D6 PD11 |
|||
#define LCD_PINS_D7 PD10 |
|||
#endif |
|||
|
|||
#ifndef BOARD_ST7920_DELAY_1 |
|||
#define BOARD_ST7920_DELAY_1 DELAY_NS(125) |
|||
#endif |
|||
#ifndef BOARD_ST7920_DELAY_2 |
|||
#define BOARD_ST7920_DELAY_2 DELAY_NS(125) |
|||
#endif |
|||
#ifndef BOARD_ST7920_DELAY_3 |
|||
#define BOARD_ST7920_DELAY_3 DELAY_NS(125) |
|||
#endif |
|||
|
|||
#endif // !MKS_MINI_12864
|
|||
|
|||
#endif // HAS_SPI_LCD && !HAS_SPI_TFT
|
|||
|
|||
#define HAS_SPI_FLASH 1 |
|||
#define SPI_FLASH_SIZE 0x1000000 // 16MB
|
|||
#if HAS_SPI_FLASH |
|||
#define W25QXX_CS_PIN PB12 |
|||
#define W25QXX_MOSI_PIN PB15 |
|||
#define W25QXX_MISO_PIN PB14 |
|||
#define W25QXX_SCK_PIN PB13 |
|||
#endif |
|||
|
|||
#if ENABLED(SPEAKER) && BEEPER_PIN == PC5 |
|||
#error "MKS Robin nano default BEEPER_PIN is not a SPEAKER." |
|||
#endif |
@ -0,0 +1,14 @@ |
|||
MEMORY |
|||
{ |
|||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K - 40 |
|||
rom (rx) : ORIGIN = 0x08007000, LENGTH = 512K - 28K - 4K |
|||
} |
|||
|
|||
/* Provide memory region aliases for common.inc */ |
|||
REGION_ALIAS("REGION_TEXT", rom); |
|||
REGION_ALIAS("REGION_DATA", ram); |
|||
REGION_ALIAS("REGION_BSS", ram); |
|||
REGION_ALIAS("REGION_RODATA", rom); |
|||
|
|||
/* Let common.inc handle the real work. */ |
|||
INCLUDE common.inc |
@ -0,0 +1,40 @@ |
|||
import os |
|||
Import("env") |
|||
|
|||
# Relocate firmware from 0x08000000 to 0x08007000 |
|||
for define in env['CPPDEFINES']: |
|||
if define[0] == "VECT_TAB_ADDR": |
|||
env['CPPDEFINES'].remove(define) |
|||
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000")) |
|||
|
|||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_e3p.ld") |
|||
for i, flag in enumerate(env["LINKFLAGS"]): |
|||
if "-Wl,-T" in flag: |
|||
env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script |
|||
elif flag == "-T": |
|||
env["LINKFLAGS"][i + 1] = custom_ld_script |
|||
|
|||
|
|||
# Encrypt ${PROGNAME}.bin and save it as 'mks_robin_e3p.bin' |
|||
def encrypt(source, target, env): |
|||
import sys |
|||
|
|||
key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] |
|||
|
|||
firmware = open(target[0].path, "rb") |
|||
robin = open(target[0].dir.path +'/Robin_e3p.bin', "wb") |
|||
length = os.path.getsize(target[0].path) |
|||
position = 0 |
|||
try: |
|||
while position < length: |
|||
byte = firmware.read(1) |
|||
if position >= 320 and position < 31040: |
|||
byte = chr(ord(byte) ^ key[position & 31]) |
|||
if sys.version_info[0] > 2: |
|||
byte = bytes(byte, 'latin1') |
|||
robin.write(byte) |
|||
position += 1 |
|||
finally: |
|||
firmware.close() |
|||
robin.close() |
|||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt); |
Loading…
Reference in new issue