More MKS UI cleanup, optimization (#19869)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Victor Oliveira 2020-10-24 01:37:45 -03:00 committed by GitHub
parent f53d5a0872
commit 9630c2683c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 2688 additions and 6566 deletions

View file

@ -103,9 +103,11 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
inline uint16_t get_microstep_counter() { return TMC::MSCNT(); } inline uint16_t get_microstep_counter() { return TMC::MSCNT(); }
#if HAS_STEALTHCHOP #if HAS_STEALTHCHOP
inline void refresh_stepping_mode() { this->en_pwm_mode(this->stored.stealthChop_enabled); } inline bool get_stealthChop() { return this->en_pwm_mode(); }
inline bool get_stealthChop() { return this->en_pwm_mode(); } inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; }
inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; } inline void refresh_stepping_mode() { this->en_pwm_mode(this->stored.stealthChop_enabled); }
inline void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); }
inline bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); }
#endif #endif
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
@ -170,9 +172,11 @@ class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
inline uint16_t get_microstep_counter() { return TMC2208Stepper::MSCNT(); } inline uint16_t get_microstep_counter() { return TMC2208Stepper::MSCNT(); }
#if HAS_STEALTHCHOP #if HAS_STEALTHCHOP
inline void refresh_stepping_mode() { en_spreadCycle(!this->stored.stealthChop_enabled); } inline bool get_stealthChop() { return !this->en_spreadCycle(); }
inline bool get_stealthChop() { return !this->en_spreadCycle(); } inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; }
inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; } inline void refresh_stepping_mode() { this->en_spreadCycle(!this->stored.stealthChop_enabled); }
inline void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); }
inline bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); }
#endif #endif
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
@ -216,9 +220,11 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
inline uint16_t get_microstep_counter() { return TMC2209Stepper::MSCNT(); } inline uint16_t get_microstep_counter() { return TMC2209Stepper::MSCNT(); }
#if HAS_STEALTHCHOP #if HAS_STEALTHCHOP
inline void refresh_stepping_mode() { en_spreadCycle(!this->stored.stealthChop_enabled); } inline bool get_stealthChop() { return !this->en_spreadCycle(); }
inline bool get_stealthChop() { return !this->en_spreadCycle(); } inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; }
inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; } inline void refresh_stepping_mode() { this->en_spreadCycle(!this->stored.stealthChop_enabled); }
inline void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); }
inline bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); }
#endif #endif
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)

View file

@ -183,10 +183,9 @@ void SPIFlashStorage::loadPage(uint8_t* buffer) {
// Test env // Test env
// char fname[256]; // char fname[256];
// memset(buffer, 0, SPI_FLASH_PageSize);
// snprintf(fname, sizeof(fname), "./pages/page-%03d.data", m_currentPage); // snprintf(fname, sizeof(fname), "./pages/page-%03d.data", m_currentPage);
// FILE *fp = fopen(fname, "rb"); // FILE *fp = fopen(fname, "rb");
// if (fp != NULL) { // if (fp != nullptr) {
// fread(buffer, 1, SPI_FLASH_PageSize, fp); // fread(buffer, 1, SPI_FLASH_PageSize, fp);
// fclose(fp); // fclose(fp);
// } // }

View file

@ -32,22 +32,18 @@
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
static lv_obj_t * fw_type, *board; //*fw_version; static lv_obj_t *fw_type, *board; //*fw_version;
#define ID_A_RETURN 1 enum { ID_A_RETURN = 1 };
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_A_RETURN: case ID_A_RETURN:
if (event == LV_EVENT_CLICKED) { clear_cur_ui();
// do nothing draw_return_ui();
}
else if (event == LV_EVENT_RELEASED) {
clear_cur_ui();
draw_return_ui();
}
break; break;
} }
} }
@ -59,11 +55,7 @@ void lv_draw_about(void) {
} }
disp_state = ABOUT_UI; disp_state = ABOUT_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
@ -84,13 +76,13 @@ void lv_draw_about(void) {
} }
//fw_version = lv_label_create(scr, SHORT_BUILD_VERSION); //fw_version = lv_label_create(scr, SHORT_BUILD_VERSION);
//lv_obj_align(fw_version, NULL, LV_ALIGN_CENTER, 0, -60); //lv_obj_align(fw_version, nullptr, LV_ALIGN_CENTER, 0, -60);
fw_type = lv_label_create(scr, "Firmware: Marlin " SHORT_BUILD_VERSION); fw_type = lv_label_create(scr, "Firmware: Marlin " SHORT_BUILD_VERSION);
lv_obj_align(fw_type, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(fw_type, nullptr, LV_ALIGN_CENTER, 0, -20);
board = lv_label_create(scr, "Board: " BOARD_INFO_NAME); board = lv_label_create(scr, "Board: " BOARD_INFO_NAME);
lv_obj_align(board, NULL, LV_ALIGN_CENTER, 0, -60); lv_obj_align(board, nullptr, LV_ALIGN_CENTER, 0, -60);
} }
void lv_clear_about() { void lv_clear_about() {

View file

@ -29,331 +29,128 @@
#include "../../../../module/planner.h" #include "../../../../module/planner.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_ACCE_RETURN 1 enum {
#define ID_ACCE_PRINT 2 ID_ACCE_RETURN = 1,
#define ID_ACCE_RETRA 3 ID_ACCE_PRINT,
#define ID_ACCE_TRAVEL 4 ID_ACCE_RETRA,
#define ID_ACCE_X 5 ID_ACCE_TRAVEL,
#define ID_ACCE_Y 6 ID_ACCE_X,
#define ID_ACCE_Z 7 ID_ACCE_Y,
#define ID_ACCE_E0 8 ID_ACCE_Z,
#define ID_ACCE_E1 9 ID_ACCE_E0,
#define ID_ACCE_UP 10 ID_ACCE_E1,
#define ID_ACCE_DOWN 11 ID_ACCE_UP,
ID_ACCE_DOWN
};
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_ACCE_RETURN: case ID_ACCE_RETURN:
if (event == LV_EVENT_CLICKED) { uiCfg.para_ui_page = 0;
lv_clear_acceleration_settings();
} draw_return_ui();
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 0;
lv_clear_acceleration_settings();
draw_return_ui();
}
break; break;
case ID_ACCE_PRINT: case ID_ACCE_PRINT:
if (event == LV_EVENT_CLICKED) { value = PrintAcceleration;
lv_clear_acceleration_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = PrintAcceleration;
lv_clear_acceleration_settings();
lv_draw_number_key();
}
break; break;
case ID_ACCE_RETRA: case ID_ACCE_RETRA:
if (event == LV_EVENT_CLICKED) { value = RetractAcceleration;
lv_clear_acceleration_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = RetractAcceleration;
lv_clear_acceleration_settings();
lv_draw_number_key();
}
break; break;
case ID_ACCE_TRAVEL: case ID_ACCE_TRAVEL:
if (event == LV_EVENT_CLICKED) { value = TravelAcceleration;
lv_clear_acceleration_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = TravelAcceleration;
lv_clear_acceleration_settings();
lv_draw_number_key();
}
break; break;
case ID_ACCE_X: case ID_ACCE_X:
if (event == LV_EVENT_CLICKED) { value = XAcceleration;
lv_clear_acceleration_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = XAcceleration;
lv_clear_acceleration_settings();
lv_draw_number_key();
}
break; break;
case ID_ACCE_Y: case ID_ACCE_Y:
if (event == LV_EVENT_CLICKED) { value = YAcceleration;
lv_clear_acceleration_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = YAcceleration;
lv_clear_acceleration_settings();
lv_draw_number_key();
}
break; break;
case ID_ACCE_Z: case ID_ACCE_Z:
if (event == LV_EVENT_CLICKED) { value = ZAcceleration;
lv_clear_acceleration_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = ZAcceleration;
lv_clear_acceleration_settings();
lv_draw_number_key();
}
break; break;
case ID_ACCE_E0: case ID_ACCE_E0:
if (event == LV_EVENT_CLICKED) { value = E0Acceleration;
lv_clear_acceleration_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = E0Acceleration;
lv_clear_acceleration_settings();
lv_draw_number_key();
}
break; break;
case ID_ACCE_E1: case ID_ACCE_E1:
if (event == LV_EVENT_CLICKED) { value = E1Acceleration;
lv_clear_acceleration_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = E1Acceleration;
lv_clear_acceleration_settings();
lv_draw_number_key();
}
break; break;
case ID_ACCE_UP: case ID_ACCE_UP:
if (event == LV_EVENT_CLICKED) { uiCfg.para_ui_page = 0;
lv_clear_acceleration_settings();
} lv_draw_acceleration_settings();
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 0;
lv_clear_acceleration_settings();
lv_draw_acceleration_settings();
}
break; break;
case ID_ACCE_DOWN: case ID_ACCE_DOWN:
if (event == LV_EVENT_CLICKED) { uiCfg.para_ui_page = 1;
lv_clear_acceleration_settings();
} lv_draw_acceleration_settings();
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 1;
lv_clear_acceleration_settings();
lv_draw_acceleration_settings();
}
break; break;
} }
} }
void lv_draw_acceleration_settings(void) { void lv_draw_acceleration_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL;
lv_obj_t *buttonPrintValue = NULL, *labelPrintValue = NULL;
lv_obj_t *buttonRetraValue = NULL, *labelRetraValue = NULL;
lv_obj_t *buttonTravelValue = NULL, *labelTravelValue = NULL;
lv_obj_t *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t *buttonE0Value = NULL, *labelE0Value = NULL;
lv_obj_t *buttonE1Value = NULL, *labelE1Value = NULL;
lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ACCELERATION_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ACCELERATION_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = ACCELERATION_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = ACCELERATION_UI;
} }
disp_state = ACCELERATION_UI; disp_state = ACCELERATION_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.AccelerationConfTitle); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.AccelerationConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
if (uiCfg.para_ui_page != 1) { if (uiCfg.para_ui_page != 1) {
sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.acceleration);
lv_screen_menu_item_1_edit(scr, machine_menu.PrintAcceleration, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_ACCE_PRINT, 0, public_buf_l);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.PrintAcceleration); sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.retract_acceleration);
lv_screen_menu_item_1_edit(scr, machine_menu.RetractAcceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_ACCE_RETRA, 1, public_buf_l);
buttonPrintValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_ACCE_PRINT); sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.travel_acceleration);
labelPrintValue = lv_label_create_empty(buttonPrintValue); lv_screen_menu_item_1_edit(scr, machine_menu.TravelAcceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_ACCE_TRAVEL, 2, public_buf_l);
line1 = lv_line_create(scr, NULL); sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[X_AXIS]);
lv_ex_line(line1, line_points[0]); lv_screen_menu_item_1_edit(scr, machine_menu.X_Acceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_ACCE_X, 3, public_buf_l);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, machine_menu.RetractAcceleration); lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_ACCE_DOWN, true);
buttonRetraValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_ACCE_RETRA);
labelRetraValue = lv_label_create_empty(buttonRetraValue);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, machine_menu.TravelAcceleration);
buttonTravelValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_ACCE_TRAVEL);
labelTravelValue = lv_label_create_empty(buttonTravelValue);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, machine_menu.X_Acceleration);
buttonXValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_ACCE_X);
labelXValue = lv_label_create_empty(buttonXValue);
line4 = lv_line_create(scr, NULL);
lv_ex_line(line4, line_points[3]);
buttonTurnPage = lv_btn_create_back(scr, event_handler, ID_ACCE_DOWN);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonPrintValue);
lv_group_add_obj(g, buttonRetraValue);
lv_group_add_obj(g, buttonTravelValue);
lv_group_add_obj(g, buttonXValue);
lv_group_add_obj(g, buttonTurnPage);
}
#endif
} }
else { else {
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.Y_Acceleration); sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[Y_AXIS]);
lv_screen_menu_item_1_edit(scr, machine_menu.Y_Acceleration, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_ACCE_Y, 0, public_buf_l);
buttonYValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_ACCE_Y); sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[Z_AXIS]);
labelYValue = lv_label_create_empty(buttonYValue); lv_screen_menu_item_1_edit(scr, machine_menu.Z_Acceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_ACCE_Z, 1, public_buf_l);
line1 = lv_line_create(scr, NULL); sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[E_AXIS]);
lv_ex_line(line1, line_points[0]); lv_screen_menu_item_1_edit(scr, machine_menu.E0_Acceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_ACCE_E0, 2, public_buf_l);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, machine_menu.Z_Acceleration); sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)]);
lv_screen_menu_item_1_edit(scr, machine_menu.E1_Acceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_ACCE_E1, 3, public_buf_l);
buttonZValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_ACCE_Z); lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_ACCE_UP, true);
labelZValue = lv_label_create_empty(buttonZValue);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, machine_menu.E0_Acceleration);
buttonE0Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_ACCE_E0);
labelE0Value = lv_label_create_empty(buttonE0Value);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, machine_menu.E1_Acceleration);
buttonE1Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_ACCE_E1);
labelE1Value = lv_label_create_empty(buttonE1Value);
line4 = lv_line_create(scr, NULL);
lv_ex_line(line4, line_points[3]);
buttonTurnPage = lv_btn_create_back(scr, event_handler, ID_ACCE_UP);
//lv_imgbtn_set_src_both(buttonTurnPage, "F:/bmp_back70x40.bin");
//lv_imgbtn_use_label_style(buttonTurnPage);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonYValue);
lv_group_add_obj(g, buttonZValue);
lv_group_add_obj(g, buttonE0Value);
lv_group_add_obj(g, buttonE1Value);
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_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_ACCE_RETURN, true);
//lv_btn_set_layout(buttonTurnPage, LV_LAYOUT_OFF);
//labelTurnPage = lv_label_create_empty(buttonTurnPage);
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_empty(buttonTurnPage);
buttonBack = lv_btn_create_back(scr, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE, event_handler, ID_ACCE_RETURN);
//lv_imgbtn_set_src_both(buttonBack, "F:/bmp_back70x40.bin");
//lv_imgbtn_use_label_style(buttonBack);
label_Back = lv_label_create_empty(buttonBack);
#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);
if (gCfgItems.multiple_language) {
if (uiCfg.para_ui_page != 1) {
lv_label_set_text(labelTurnPage, machine_menu.next);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.acceleration);
lv_label_set_text(labelPrintValue, public_buf_l);
lv_obj_align(labelPrintValue, buttonPrintValue, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.retract_acceleration);
lv_label_set_text(labelRetraValue, public_buf_l);
lv_obj_align(labelRetraValue, buttonRetraValue, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.travel_acceleration);
lv_label_set_text(labelTravelValue, public_buf_l);
lv_obj_align(labelTravelValue, buttonTravelValue, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[X_AXIS]);
lv_label_set_text(labelXValue, public_buf_l);
lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
}
else {
lv_label_set_text(labelTurnPage, machine_menu.previous);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[Y_AXIS]);
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"), (int)planner.settings.max_acceleration_mm_per_s2[Z_AXIS]);
lv_label_set_text(labelZValue, public_buf_l);
lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[E_AXIS]);
lv_label_set_text(labelE0Value, public_buf_l);
lv_obj_align(labelE0Value, buttonE0Value, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)]);
lv_label_set_text(labelE1Value, public_buf_l);
lv_obj_align(labelE1Value, buttonE1Value, 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_acceleration_settings() { void lv_clear_acceleration_settings() {

View file

@ -28,248 +28,71 @@
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_ADVANCE_RETURN 1 enum {
#define ID_PAUSE_POS 2 ID_ADVANCE_RETURN = 1,
#define ID_PAUSE_POS_ARROW 3 ID_PAUSE_POS,
#define ID_WIFI_PARA 4 ID_WIFI_PARA,
#define ID_WIFI_PARA_ARROW 5 ID_FILAMENT_SETTINGS,
#define ID_FILAMENT_SETTINGS 6 ID_ENCODER_SETTINGS
#define ID_FILAMENT_SETTINGS_ARROW 7 };
#define ID_ENCODER_SETTINGS 8
#define ID_ENCODER_SETTINGS_ARROW 9
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_ADVANCE_RETURN: case ID_ADVANCE_RETURN:
if (event == LV_EVENT_CLICKED) { lv_clear_advance_settings();
draw_return_ui();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_advance_settings();
draw_return_ui();
}
break; break;
case ID_PAUSE_POS: case ID_PAUSE_POS:
if (event == LV_EVENT_CLICKED) { lv_clear_advance_settings();
lv_draw_pause_position();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_advance_settings();
lv_draw_pause_position();
}
break;
case ID_PAUSE_POS_ARROW:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_advance_settings();
lv_draw_pause_position();
}
break; break;
case ID_FILAMENT_SETTINGS: case ID_FILAMENT_SETTINGS:
if (event == LV_EVENT_CLICKED) { lv_clear_advance_settings();
lv_draw_filament_settings();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_advance_settings();
lv_draw_filament_settings();
}
break;
case ID_FILAMENT_SETTINGS_ARROW:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_advance_settings();
lv_draw_filament_settings();
}
break; break;
#if ENABLED(USE_WIFI_FUNCTION) #if ENABLED(USE_WIFI_FUNCTION)
case ID_WIFI_PARA: case ID_WIFI_PARA:
if (event == LV_EVENT_CLICKED) { lv_clear_advance_settings();
lv_draw_wifi_settings();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_advance_settings();
lv_draw_wifi_settings();
}
break;
case ID_WIFI_PARA_ARROW:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_advance_settings();
lv_draw_wifi_settings();
}
break; break;
#endif #endif
#if HAS_ROTARY_ENCODER #if HAS_ROTARY_ENCODER
case ID_ENCODER_SETTINGS: case ID_ENCODER_SETTINGS:
if (event == LV_EVENT_CLICKED) { lv_clear_advance_settings();
lv_draw_encoder_settings();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_advance_settings();
lv_draw_encoder_settings();
}
break;
case ID_ENCODER_SETTINGS_ARROW:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_advance_settings();
lv_draw_encoder_settings();
}
break; break;
#endif #endif
} }
} }
void lv_draw_advance_settings(void) { void lv_draw_advance_settings(void) {
lv_obj_t *buttonBack, *label_Back;
lv_obj_t *buttonPausePos, *labelPausePos;
lv_obj_t *buttonFilamentSettings, *labelFilamentSettings;
lv_obj_t * line1,* line2;
#if ENABLED(USE_WIFI_FUNCTION)
lv_obj_t *buttonWifiSet, *labelWifiSet, *buttonWifiSetNarrow;
#endif
#if HAS_ROTARY_ENCODER
lv_obj_t *buttonEncoder, *labelEncoder, *buttonEncoderNarrow;
#endif
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ADVANCED_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ADVANCED_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = ADVANCED_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = ADVANCED_UI;
} }
disp_state = ADVANCED_UI; disp_state = ADVANCED_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.AdvancedConfTitle); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.AdvancedConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
buttonPausePos = lv_btn_create(scr, NULL); int index = 0;
lv_obj_set_pos(buttonPausePos, PARA_UI_POS_X, PARA_UI_POS_Y); lv_screen_menu_item(scr, machine_menu.PausePosition, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_PAUSE_POS, index++);
lv_obj_set_size(buttonPausePos, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); lv_screen_menu_item(scr, machine_menu.FilamentConf, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_FILAMENT_SETTINGS, index++);
//lv_obj_set_event_cb(buttonMachine, event_handler);
lv_obj_set_event_cb_mks(buttonPausePos, event_handler, ID_PAUSE_POS, NULL, 0);
lv_btn_use_label_style(buttonPausePos);
lv_btn_set_layout(buttonPausePos, LV_LAYOUT_OFF);
labelPausePos = lv_label_create_empty(buttonPausePos);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonPausePos);
#endif
(void)lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V, event_handler, ID_PAUSE_POS_ARROW);
line1 = lv_line_create(lv_scr_act(), NULL);
lv_ex_line(line1, line_points[0]);
buttonFilamentSettings = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonFilamentSettings, PARA_UI_POS_X, PARA_UI_POS_Y*2);
lv_obj_set_size(buttonFilamentSettings, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);
lv_obj_set_event_cb_mks(buttonFilamentSettings, event_handler, ID_FILAMENT_SETTINGS, NULL, 0);
lv_btn_use_label_style(buttonFilamentSettings);
lv_btn_set_layout(buttonFilamentSettings, LV_LAYOUT_OFF);
labelFilamentSettings = lv_label_create_empty(buttonFilamentSettings);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonFilamentSettings);
#endif
(void)lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y*2 + PARA_UI_ARROW_V, event_handler, ID_FILAMENT_SETTINGS_ARROW);
line2 = lv_line_create(lv_scr_act(), NULL);
lv_ex_line(line2, line_points[1]);
#if ENABLED(USE_WIFI_FUNCTION) #if ENABLED(USE_WIFI_FUNCTION)
lv_screen_menu_item(scr, machine_menu.WifiSettings, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_WIFI_PARA, index++);
buttonWifiSet = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonWifiSet, PARA_UI_POS_X,PARA_UI_POS_Y*3);
lv_obj_set_size(buttonWifiSet, PARA_UI_SIZE_X,PARA_UI_SIZE_Y);
lv_obj_set_event_cb_mks(buttonWifiSet, event_handler,ID_WIFI_PARA,NULL, 0);
lv_btn_use_label_style(buttonWifiSet);
lv_btn_set_layout(buttonWifiSet, LV_LAYOUT_OFF);
labelWifiSet = lv_label_create_empty(buttonWifiSet);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonWifiSet);
#endif
buttonWifiSetNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V, event_handler, ID_WIFI_PARA_ARROW);
lv_obj_t * line3 = lv_line_create(scr, NULL);
lv_ex_line(line3,line_points[2]);
#if HAS_ROTARY_ENCODER
buttonEncoder = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonEncoder, PARA_UI_POS_X,PARA_UI_POS_Y*4);
lv_obj_set_size(buttonEncoder, PARA_UI_SIZE_X,PARA_UI_SIZE_Y);
lv_obj_set_event_cb_mks(buttonEncoder, event_handler,ID_ENCODER_SETTINGS,NULL, 0);
lv_btn_use_label_style(buttonEncoder);
lv_btn_set_layout(buttonEncoder, LV_LAYOUT_OFF);
labelEncoder = lv_label_create_empty(buttonEncoder);
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonEncoder);
buttonEncoderNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 4 + PARA_UI_ARROW_V, event_handler, ID_ENCODER_SETTINGS_ARROW);
lv_obj_t * line4 = lv_line_create(scr, NULL);
lv_ex_line(line4,line_points[3]);
#endif
#elif HAS_ROTARY_ENCODER
buttonEncoder = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonEncoder, PARA_UI_POS_X,PARA_UI_POS_Y*3);
lv_obj_set_size(buttonEncoder, PARA_UI_SIZE_X,PARA_UI_SIZE_Y);
lv_obj_set_event_cb_mks(buttonEncoder, event_handler,ID_ENCODER_SETTINGS,NULL, 0);
lv_btn_use_label_style(buttonEncoder);
lv_btn_set_layout(buttonEncoder, LV_LAYOUT_OFF);
labelEncoder = lv_label_create_empty(buttonEncoder);
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonEncoder);
buttonEncoderNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V, event_handler, ID_ENCODER_SETTINGS_ARROW);
lv_obj_t * line3 = lv_line_create(scr, NULL);
lv_ex_line(line3,line_points[2]);
#endif #endif
buttonBack = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_ADVANCE_RETURN);
#if HAS_ROTARY_ENCODER #if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); lv_screen_menu_item(scr, machine_menu.EncoderSettings, PARA_UI_POS_X, PARA_UI_POS_Y * (index + 1), event_handler, ID_ENCODER_SETTINGS, index);
index++;
#endif #endif
label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.multiple_language) {
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(labelPausePos, machine_menu.PausePosition);
lv_obj_align(labelPausePos, buttonPausePos, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelFilamentSettings, machine_menu.FilamentConf);
lv_obj_align(labelFilamentSettings, buttonFilamentSettings, LV_ALIGN_IN_LEFT_MID, 0, 0);
#if ENABLED(USE_WIFI_FUNCTION)
lv_label_set_text(labelWifiSet, machine_menu.WifiSettings);
lv_obj_align(labelWifiSet, buttonWifiSet, LV_ALIGN_IN_LEFT_MID,0, 0);
#endif
#if HAS_ROTARY_ENCODER
lv_label_set_text(labelEncoder, machine_menu.EncoderSettings);
lv_obj_align(labelEncoder, buttonEncoder, LV_ALIGN_IN_LEFT_MID,0, 0);
#endif
}
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_ADVANCE_RETURN, true);
} }
void lv_clear_advance_settings() { void lv_clear_advance_settings() {

View file

@ -29,135 +29,64 @@
#include "../../../../module/probe.h" #include "../../../../module/probe.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_OFFSET_RETURN 1 enum {
#define ID_OFFSET_X 2 ID_OFFSET_RETURN = 1,
#define ID_OFFSET_Y 3 ID_OFFSET_X,
#define ID_OFFSET_Z 4 ID_OFFSET_Y,
ID_OFFSET_Z
};
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_OFFSET_RETURN: case ID_OFFSET_RETURN:
if (event == LV_EVENT_CLICKED) { lv_clear_auto_level_offset_settings();
draw_return_ui();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_auto_level_offset_settings();
draw_return_ui();
}
break; break;
case ID_OFFSET_X: case ID_OFFSET_X:
if (event == LV_EVENT_CLICKED) { value = x_offset;
lv_clear_auto_level_offset_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = x_offset;
lv_clear_auto_level_offset_settings();
lv_draw_number_key();
}
break; break;
case ID_OFFSET_Y: case ID_OFFSET_Y:
if (event == LV_EVENT_CLICKED) { value = y_offset;
lv_clear_auto_level_offset_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = y_offset;
lv_clear_auto_level_offset_settings();
lv_draw_number_key();
}
break; break;
case ID_OFFSET_Z: case ID_OFFSET_Z:
if (event == LV_EVENT_CLICKED) { value = z_offset;
lv_clear_auto_level_offset_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = z_offset;
lv_clear_auto_level_offset_settings();
lv_draw_number_key();
}
break; break;
} }
} }
void lv_draw_auto_level_offset_settings(void) { void lv_draw_auto_level_offset_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL;
lv_obj_t *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *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) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != NOZZLE_PROBE_OFFSET_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = NOZZLE_PROBE_OFFSET_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = NOZZLE_PROBE_OFFSET_UI;
} }
disp_state = NOZZLE_PROBE_OFFSET_UI; disp_state = NOZZLE_PROBE_OFFSET_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.OffsetConfTitle); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.OffsetConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.Xoffset); sprintf_P(public_buf_l, PSTR("%.1f"), TERN(HAS_PROBE_XY_OFFSET, probe.offset.x, 0));
lv_screen_menu_item_1_edit(scr, machine_menu.Xoffset, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_OFFSET_X, 0, public_buf_l);
buttonXValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_OFFSET_X); sprintf_P(public_buf_l, PSTR("%.1f"), TERN(HAS_PROBE_XY_OFFSET, probe.offset.y, 0));
labelXValue = lv_label_create_empty(buttonXValue); lv_screen_menu_item_1_edit(scr, machine_menu.Yoffset, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_OFFSET_Y, 1, public_buf_l);
line1 = lv_line_create(scr, NULL); sprintf_P(public_buf_l, PSTR("%.1f"), probe.offset.z);
lv_ex_line(line1, line_points[0]); lv_screen_menu_item_1_edit(scr, machine_menu.Zoffset, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_OFFSET_Z, 2, public_buf_l);
lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, machine_menu.Yoffset); lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_OFFSET_RETURN, true);
buttonYValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_OFFSET_Y);
labelYValue = lv_label_create_empty(buttonYValue);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, machine_menu.Zoffset);
buttonZValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_OFFSET_Z);
labelZValue = lv_label_create_empty(buttonZValue);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
buttonBack = lv_btn_create_back(scr, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE, event_handler, ID_OFFSET_RETURN);
label_Back = lv_label_create_empty(buttonBack);
#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) {
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() { void lv_clear_auto_level_offset_settings() {

View file

@ -38,113 +38,75 @@
#include "../../../../module/probe.h" #include "../../../../module/probe.h"
#endif #endif
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
static lv_obj_t *labelV, *buttonV, * zOffsetText; static lv_obj_t *labelV, *buttonV, *zOffsetText;
#define ID_BABY_STEP_X_P 1 enum {
#define ID_BABY_STEP_X_N 2 ID_BABY_STEP_X_P = 1,
#define ID_BABY_STEP_Y_P 3 ID_BABY_STEP_X_N,
#define ID_BABY_STEP_Y_N 4 ID_BABY_STEP_Y_P,
#define ID_BABY_STEP_Z_P 5 ID_BABY_STEP_Y_N,
#define ID_BABY_STEP_Z_N 6 ID_BABY_STEP_Z_P,
#define ID_BABY_STEP_DIST 7 ID_BABY_STEP_Z_N,
#define ID_BABY_STEP_RETURN 8 ID_BABY_STEP_DIST,
ID_BABY_STEP_RETURN
};
static float babystep_dist=0.01; static float babystep_dist=0.01;
static uint8_t has_adjust_z = 0; static uint8_t has_adjust_z = 0;
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
char baby_buf[30] = { 0 }; char baby_buf[30] = { 0 };
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_BABY_STEP_X_P: case ID_BABY_STEP_X_P:
if (event == LV_EVENT_CLICKED) { sprintf_P(baby_buf, PSTR("M290 X%.3f"), babystep_dist);
// nothing to do gcode.process_subcommands_now_P(PSTR(baby_buf));
} has_adjust_z = 1;
else if (event == LV_EVENT_RELEASED) {
sprintf_P(baby_buf, PSTR("M290 X%.3f"),babystep_dist);
gcode.process_subcommands_now_P(PSTR(baby_buf));
has_adjust_z = 1;
}
break; break;
case ID_BABY_STEP_X_N: case ID_BABY_STEP_X_N:
if (event == LV_EVENT_CLICKED) { sprintf_P(baby_buf, PSTR("M290 X%.3f"), -babystep_dist);
// nothing to do gcode.process_subcommands_now_P(PSTR(baby_buf));
} has_adjust_z = 1;
else if (event == LV_EVENT_RELEASED) {
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; break;
case ID_BABY_STEP_Y_P: case ID_BABY_STEP_Y_P:
if (event == LV_EVENT_CLICKED) { sprintf_P(baby_buf, PSTR("M290 Y%.3f"), babystep_dist);
// nothing to do gcode.process_subcommands_now_P(PSTR(baby_buf));
} has_adjust_z = 1;
else if (event == LV_EVENT_RELEASED) {
sprintf_P(baby_buf, PSTR("M290 Y%.3f"), babystep_dist);
gcode.process_subcommands_now_P(PSTR(baby_buf));
has_adjust_z = 1;
}
break; break;
case ID_BABY_STEP_Y_N: case ID_BABY_STEP_Y_N:
if (event == LV_EVENT_CLICKED) { sprintf_P(baby_buf, PSTR("M290 Y%.3f"), -babystep_dist);
// nothing to do gcode.process_subcommands_now_P(PSTR(baby_buf));
} has_adjust_z = 1;
else if (event == LV_EVENT_RELEASED) {
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; break;
case ID_BABY_STEP_Z_P: case ID_BABY_STEP_Z_P:
if (event == LV_EVENT_CLICKED) { sprintf_P(baby_buf, PSTR("M290 Z%.3f"), babystep_dist);
// nothing to do gcode.process_subcommands_now_P(PSTR(baby_buf));
} has_adjust_z = 1;
else if (event == LV_EVENT_RELEASED) {
sprintf_P(baby_buf, PSTR("M290 Z%.3f"), babystep_dist);
gcode.process_subcommands_now_P(PSTR(baby_buf));
has_adjust_z = 1;
}
break; break;
case ID_BABY_STEP_Z_N: case ID_BABY_STEP_Z_N:
if (event == LV_EVENT_CLICKED) { sprintf_P(baby_buf, PSTR("M290 Z%.3f"), babystep_dist);
// nothing to do gcode.process_subcommands_now_P(PSTR(baby_buf));
} has_adjust_z = 1;
else if (event == LV_EVENT_RELEASED) {
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; break;
case ID_BABY_STEP_DIST: case ID_BABY_STEP_DIST:
if (event == LV_EVENT_CLICKED) { if (abs((int)(100 * babystep_dist)) == 1)
// nothing to do babystep_dist = 0.05;
} else if (abs((int)(100 * babystep_dist)) == 5)
else if (event == LV_EVENT_RELEASED) { babystep_dist = 0.1;
if (abs((int)(100 * babystep_dist)) == 1) else
babystep_dist = 0.05; babystep_dist = 0.01;
else if (abs((int)(100 * babystep_dist)) == 5) disp_baby_step_dist();
babystep_dist = 0.1;
else
babystep_dist = 0.01;
disp_baby_step_dist();
}
break; break;
case ID_BABY_STEP_RETURN: case ID_BABY_STEP_RETURN:
if (event == LV_EVENT_CLICKED) { if (has_adjust_z == 1) {
// nothing to do TERN_(EEPROM_SETTINGS, (void)settings.save());
} has_adjust_z = 0;
else if (event == LV_EVENT_RELEASED) {
if (has_adjust_z == 1) {
TERN_(EEPROM_SETTINGS, (void)settings.save());
has_adjust_z = 0;
}
clear_cur_ui();
draw_return_ui();
} }
clear_cur_ui();
draw_return_ui();
break; break;
} }
} }
@ -156,75 +118,31 @@ void lv_draw_baby_stepping(void) {
} }
disp_state = BABY_STEP_UI; disp_state = BABY_STEP_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
// Create an Image button lv_big_button_create(scr, "F:/bmp_xAdd.bin", move_menu.x_add, INTERVAL_V, titleHeight, event_handler, ID_BABY_STEP_X_P);
lv_obj_t *buttonXI = lv_imgbtn_create(scr, "F:/bmp_xAdd.bin", INTERVAL_V, titleHeight, event_handler, ID_BABY_STEP_X_P); lv_big_button_create(scr, "F:/bmp_xDec.bin", move_menu.x_dec, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_X_N);
lv_obj_t *buttonXD = lv_imgbtn_create(scr, "F:/bmp_xDec.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_X_N); lv_big_button_create(scr, "F:/bmp_yAdd.bin", move_menu.y_add, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_BABY_STEP_Y_P);
lv_obj_t *buttonYI = lv_imgbtn_create(scr, "F:/bmp_yAdd.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_BABY_STEP_Y_P); lv_big_button_create(scr, "F:/bmp_yDec.bin", move_menu.y_dec, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_Y_N);
lv_obj_t *buttonYD = lv_imgbtn_create(scr, "F:/bmp_yDec.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_Y_N); lv_big_button_create(scr, "F:/bmp_zAdd.bin", move_menu.z_add, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_BABY_STEP_Z_P);
lv_obj_t *buttonZI = lv_imgbtn_create(scr, "F:/bmp_zAdd.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_BABY_STEP_Z_P); lv_big_button_create(scr, "F:/bmp_zDec.bin", move_menu.z_dec, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_Z_N);
lv_obj_t *buttonZD = lv_imgbtn_create(scr, "F:/bmp_zDec.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_Z_N); buttonV = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_BABY_STEP_DIST);
buttonV = lv_imgbtn_create(scr, NULL, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_BABY_STEP_DIST);
lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_RETURN);
// Create labels on the image buttons
lv_obj_t *labelXI = lv_label_create_empty(buttonXI);
lv_obj_t *labelXD = lv_label_create_empty(buttonXD);
lv_obj_t *labelYI = lv_label_create_empty(buttonYI);
lv_obj_t *labelYD = lv_label_create_empty(buttonYD);
lv_obj_t *labelZI = lv_label_create_empty(buttonZI);
lv_obj_t *labelZD = lv_label_create_empty(buttonZD);
labelV = lv_label_create_empty(buttonV); labelV = lv_label_create_empty(buttonV);
lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.multiple_language) {
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 HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) { 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, buttonV);
lv_group_add_obj(g, buttonBack);
} }
#endif #endif
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_RETURN);
disp_baby_step_dist(); disp_baby_step_dist();
zOffsetText = lv_label_create(scr, 290, TITLE_YPOS, NULL); zOffsetText = lv_label_create(scr, 290, TITLE_YPOS, nullptr);
disp_z_offset_value(); disp_z_offset_value();
} }
@ -255,7 +173,7 @@ void disp_baby_step_dist() {
void disp_z_offset_value() { void disp_z_offset_value() {
char buf[20]; char buf[20];
sprintf_P(buf, PSTR("offset Z: %.3f"), (double)TERN(HAS_BED_PROBE, probe.offset.z, 0)); sprintf_P(buf, PSTR("offset Z: %.3f"), (float)TERN(HAS_BED_PROBE, probe.offset.z, 0));
lv_label_set_text(zOffsetText, buf); lv_label_set_text(zOffsetText, buf);
} }

View file

@ -33,179 +33,136 @@
#include "../../../../module/planner.h" #include "../../../../module/planner.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
static lv_obj_t *labelStep, *buttonStep, *buttonMov, *buttonExt; static lv_obj_t *labelStep, *buttonStep, *buttonMov, *buttonExt;
static lv_obj_t *labelMov, *labelExt; static lv_obj_t *labelMov, *labelExt;
static lv_obj_t * printSpeedText; static lv_obj_t *printSpeedText;
#define ID_C_ADD 1 enum {
#define ID_C_DEC 2 ID_C_ADD = 1,
#define ID_C_MOVE 3 ID_C_DEC,
#define ID_C_EXT 4 ID_C_MOVE,
#define ID_C_STEP 5 ID_C_EXT,
#define ID_C_RETURN 6 ID_C_STEP,
ID_C_RETURN
};
static uint8_t speedType; static bool editingFlowrate;
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_C_ADD: case ID_C_ADD:
if (event == LV_EVENT_CLICKED) { if (!editingFlowrate) {
// nothing to do if (feedrate_percentage < MAX_EXT_SPEED_PERCENT - uiCfg.stepPrintSpeed)
feedrate_percentage += uiCfg.stepPrintSpeed;
else
feedrate_percentage = MAX_EXT_SPEED_PERCENT;
} }
else if (event == LV_EVENT_RELEASED) { else {
if (speedType == 0) { if (planner.flow_percentage[0] < MAX_EXT_SPEED_PERCENT - uiCfg.stepPrintSpeed)
if (feedrate_percentage < MAX_EXT_SPEED_PERCENT - uiCfg.stepPrintSpeed) planner.flow_percentage[0] += uiCfg.stepPrintSpeed;
feedrate_percentage += uiCfg.stepPrintSpeed; else
else planner.flow_percentage[0] = MAX_EXT_SPEED_PERCENT;
feedrate_percentage = MAX_EXT_SPEED_PERCENT; //planner.e_factor[0]= planner.flow_percentage[0]*0.01;
} //planner.flow_percentage[1] = planner.flow_percentage[0];
else if (speedType == 1) { //planner.e_factor[1]= planner.flow_percentage[1]*0.01;
if (planner.flow_percentage[0] < MAX_EXT_SPEED_PERCENT - uiCfg.stepPrintSpeed) planner.refresh_e_factor(0);
planner.flow_percentage[0] += uiCfg.stepPrintSpeed; #if HAS_MULTI_EXTRUDER
else planner.flow_percentage[1] = planner.flow_percentage[0];
planner.flow_percentage[0] = MAX_EXT_SPEED_PERCENT; planner.refresh_e_factor(1);
//planner.e_factor[0]= planner.flow_percentage[0]*0.01; #endif
//planner.flow_percentage[1] = planner.flow_percentage[0];
//planner.e_factor[1]= planner.flow_percentage[1]*0.01;
planner.refresh_e_factor(0);
#if HAS_MULTI_EXTRUDER
planner.flow_percentage[1] = planner.flow_percentage[0];
planner.refresh_e_factor(1);
#endif
}
disp_print_speed();
} }
disp_print_speed();
break; break;
case ID_C_DEC: case ID_C_DEC:
if (event == LV_EVENT_CLICKED) { if (!editingFlowrate) {
// nothing to do if (feedrate_percentage > MIN_EXT_SPEED_PERCENT + uiCfg.stepPrintSpeed)
feedrate_percentage -= uiCfg.stepPrintSpeed;
else
feedrate_percentage = MIN_EXT_SPEED_PERCENT;
} }
else if (event == LV_EVENT_RELEASED) { else {
if (speedType == 0) { if (planner.flow_percentage[0] > MIN_EXT_SPEED_PERCENT + uiCfg.stepPrintSpeed)
if (feedrate_percentage > MIN_EXT_SPEED_PERCENT + uiCfg.stepPrintSpeed) planner.flow_percentage[0] -= uiCfg.stepPrintSpeed;
feedrate_percentage -= uiCfg.stepPrintSpeed; else
else planner.flow_percentage[0] = MIN_EXT_SPEED_PERCENT;
feedrate_percentage = MIN_EXT_SPEED_PERCENT; //planner.e_factor[0]= planner.flow_percentage[0] * 0.01;
} //planner.flow_percentage[1] = planner.flow_percentage[0];
else if (speedType == 1) { //planner.e_factor[1]= planner.flow_percentage[1] * 0.01;
if (planner.flow_percentage[0] > MIN_EXT_SPEED_PERCENT + uiCfg.stepPrintSpeed) planner.refresh_e_factor(0);
planner.flow_percentage[0] -= uiCfg.stepPrintSpeed; #if HAS_MULTI_EXTRUDER
else planner.flow_percentage[1] = planner.flow_percentage[0];
planner.flow_percentage[0] = MIN_EXT_SPEED_PERCENT; planner.refresh_e_factor(1);
//planner.e_factor[0]= planner.flow_percentage[0] * 0.01; #endif
//planner.flow_percentage[1] = planner.flow_percentage[0];
//planner.e_factor[1]= planner.flow_percentage[1] * 0.01;
planner.refresh_e_factor(0);
#if HAS_MULTI_EXTRUDER
planner.flow_percentage[1] = planner.flow_percentage[0];
planner.refresh_e_factor(1);
#endif
}
disp_print_speed();
} }
disp_print_speed();
break; break;
case ID_C_MOVE: case ID_C_MOVE:
if (event == LV_EVENT_CLICKED) { editingFlowrate = false;
// nothing to do disp_speed_type();
} disp_print_speed();
else if (event == LV_EVENT_RELEASED) {
speedType = 0;
disp_speed_type();
disp_print_speed();
}
break; break;
case ID_C_EXT: case ID_C_EXT:
if (event == LV_EVENT_CLICKED) { editingFlowrate = true;
// nothing to do disp_speed_type();
} disp_print_speed();
else if (event == LV_EVENT_RELEASED) {
speedType = 1;
disp_speed_type();
disp_print_speed();
}
break; break;
case ID_C_STEP: case ID_C_STEP:
if (event == LV_EVENT_CLICKED) { if (uiCfg.stepPrintSpeed == 1)
uiCfg.stepPrintSpeed = 5;
} else if (uiCfg.stepPrintSpeed == 5)
else if (event == LV_EVENT_RELEASED) { uiCfg.stepPrintSpeed = 10;
if (uiCfg.stepPrintSpeed == 1) else
uiCfg.stepPrintSpeed = 5; uiCfg.stepPrintSpeed = 1;
else if (uiCfg.stepPrintSpeed == 5) disp_speed_step();
uiCfg.stepPrintSpeed = 10;
else
uiCfg.stepPrintSpeed = 1;
disp_speed_step();
}
break; break;
case ID_C_RETURN: case ID_C_RETURN:
if (event == LV_EVENT_CLICKED) { clear_cur_ui();
// nothing to do draw_return_ui();
}
else if (event == LV_EVENT_RELEASED) {
clear_cur_ui();
draw_return_ui();
}
break; break;
} }
} }
void lv_draw_change_speed(void) { void lv_draw_change_speed(void) {
lv_obj_t *buttonAdd, *buttonDec;
lv_obj_t *buttonBack;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != CHANGE_SPEED_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != CHANGE_SPEED_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = CHANGE_SPEED_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = CHANGE_SPEED_UI;
} }
disp_state = CHANGE_SPEED_UI; disp_state = CHANGE_SPEED_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
// Create an Image button // Create an Image button
buttonAdd = lv_imgbtn_create(scr, "F:/bmp_Add.bin", INTERVAL_V, titleHeight, event_handler, ID_C_ADD); lv_big_button_create(scr, "F:/bmp_Add.bin", speed_menu.add, INTERVAL_V, titleHeight, event_handler, ID_C_ADD);
buttonDec = lv_imgbtn_create(scr, "F:/bmp_Dec.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_C_DEC); lv_big_button_create(scr, "F:/bmp_Dec.bin", speed_menu.dec, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_C_DEC);
buttonMov = lv_imgbtn_create(scr, NULL, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_MOVE); buttonMov = lv_imgbtn_create(scr, nullptr, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_MOVE);
buttonExt = lv_imgbtn_create(scr, NULL, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_EXT); buttonExt = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_EXT);
buttonStep = lv_imgbtn_create(scr, NULL, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_STEP); buttonStep = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_STEP);
buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_RETURN); #if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
// Create labels on the image buttons lv_group_add_obj(g, buttonMov);
lv_obj_t *labelAdd = lv_label_create_empty(buttonAdd); lv_group_add_obj(g, buttonExt);
lv_obj_t *labelDec = lv_label_create_empty(buttonDec); lv_group_add_obj(g, buttonStep);
labelMov = lv_label_create_empty(buttonMov); }
labelExt = lv_label_create_empty(buttonExt); #endif
labelStep = lv_label_create_empty(buttonStep); lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_RETURN);
lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
// Create labels on the image buttons
if (gCfgItems.multiple_language) { labelMov = lv_label_create_empty(buttonMov);
lv_label_set_text(labelAdd, speed_menu.add); labelExt = lv_label_create_empty(buttonExt);
lv_obj_align(labelAdd, buttonAdd, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); labelStep = lv_label_create_empty(buttonStep);
lv_label_set_text(labelDec, speed_menu.dec);
lv_obj_align(labelDec, buttonDec, 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 HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) { if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonAdd);
lv_group_add_obj(g, buttonDec);
lv_group_add_obj(g, buttonMov); lv_group_add_obj(g, buttonMov);
lv_group_add_obj(g, buttonExt); lv_group_add_obj(g, buttonExt);
lv_group_add_obj(g, buttonStep); lv_group_add_obj(g, buttonStep);
lv_group_add_obj(g, buttonBack);
} }
#endif #endif
@ -246,34 +203,27 @@ void disp_print_speed() {
public_buf_l[0] = '\0'; public_buf_l[0] = '\0';
if (speedType == 0) { // move int16_t val;
strcat(public_buf_l, speed_menu.move_speed); const char *lbl;
strcat_P(public_buf_l, PSTR(": ")); if (editingFlowrate) {
sprintf_P(buf, PSTR("%d%%"), feedrate_percentage); lbl = speed_menu.extrude_speed;
strcat(public_buf_l, buf); val = planner.flow_percentage[0];
} }
else if (speedType == 1) { // e1 else {
strcat(public_buf_l, speed_menu.extrude_speed); lbl = speed_menu.move_speed;
strcat_P(public_buf_l, PSTR(": ")); val = feedrate_percentage;
sprintf_P(buf, PSTR("%d%%"), planner.flow_percentage[0]);
strcat(public_buf_l, buf);
} }
strcpy(public_buf_l, lbl);
strcat_P(public_buf_l, PSTR(": "));
sprintf_P(buf, PSTR("%d%%"), val);
strcat(public_buf_l, buf);
lv_label_set_text(printSpeedText, public_buf_l); lv_label_set_text(printSpeedText, public_buf_l);
lv_obj_align(printSpeedText, NULL, LV_ALIGN_CENTER, 0, -65); lv_obj_align(printSpeedText, nullptr, LV_ALIGN_CENTER, 0, -65);
} }
void disp_speed_type() { void disp_speed_type() {
switch (speedType) { lv_imgbtn_set_src_both(buttonMov, editingFlowrate ? "F:/bmp_mov_changeSpeed.bin" : "F:/bmp_mov_sel.bin");
case 1: lv_imgbtn_set_src_both(buttonExt, editingFlowrate ? "F:/bmp_extruct_sel.bin" : "F:/bmp_speed_extruct.bin");
lv_imgbtn_set_src_both(buttonMov, "F:/bmp_mov_changeSpeed.bin");
lv_imgbtn_set_src_both(buttonExt, "F:/bmp_extruct_sel.bin");
break;
default:
lv_imgbtn_set_src_both(buttonMov, "F:/bmp_mov_sel.bin");
lv_imgbtn_set_src_both(buttonExt, "F:/bmp_speed_extruct.bin");
break;
}
lv_obj_refresh_ext_draw_pad(buttonExt); lv_obj_refresh_ext_draw_pad(buttonExt);
lv_obj_refresh_ext_draw_pad(buttonMov); lv_obj_refresh_ext_draw_pad(buttonMov);

View file

@ -55,189 +55,162 @@
#include "../../../../feature/pause.h" #include "../../../../feature/pause.h"
#endif #endif
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr, *tempText1, *filament_bar;
static lv_obj_t * tempText1;
static lv_obj_t * filament_bar;
extern uint8_t sel_id; extern uint8_t sel_id;
extern bool once_flag, gcode_preview_over; extern bool once_flag, gcode_preview_over;
extern int upload_result ; extern int upload_result;
extern uint32_t upload_time; extern uint32_t upload_time;
extern uint32_t upload_size; extern uint32_t upload_size;
extern uint8_t temperature_change_frequency; extern bool temps_update_flag;
static void btn_ok_event_cb(lv_obj_t * btn, lv_event_t event) { static void btn_ok_event_cb(lv_obj_t *btn, lv_event_t event) {
if (event == LV_EVENT_CLICKED) { if (event != LV_EVENT_RELEASED) return;
// nothing to do if (DIALOG_IS(TYPE_PRINT_FILE)) {
} #if HAS_GCODE_PREVIEW
else if (event == LV_EVENT_RELEASED) { preview_gcode_prehandle(list_file.file_name[sel_id]);
if (uiCfg.dialogType == DIALOG_TYPE_PRINT_FILE) { #endif
#if HAS_GCODE_PREVIEW reset_print_time();
preview_gcode_prehandle(list_file.file_name[sel_id]); start_print_time();
#endif
reset_print_time();
start_print_time();
uiCfg.print_state = WORKING; uiCfg.print_state = WORKING;
lv_clear_dialog(); lv_clear_dialog();
lv_draw_printing(); lv_draw_printing();
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
if (!gcode_preview_over) { if (!gcode_preview_over) {
char *cur_name; char *cur_name;
cur_name = strrchr(list_file.file_name[sel_id], '/'); cur_name = strrchr(list_file.file_name[sel_id], '/');
SdFile file, *curDir; SdFile file, *curDir;
card.endFilePrint(); card.endFilePrint();
const char * const fname = card.diveToFile(true, curDir, cur_name); const char * const fname = card.diveToFile(true, curDir, cur_name);
if (!fname) return; if (!fname) return;
if (file.open(curDir, fname, O_READ)) { if (file.open(curDir, fname, O_READ)) {
gCfgItems.curFilesize = file.fileSize(); gCfgItems.curFilesize = file.fileSize();
file.close(); file.close();
update_spi_flash(); update_spi_flash();
} }
card.openFileRead(cur_name); card.openFileRead(cur_name);
if (card.isFileOpen()) { if (card.isFileOpen()) {
feedrate_percentage = 100; feedrate_percentage = 100;
//saved_feedrate_percentage = feedrate_percentage; //saved_feedrate_percentage = feedrate_percentage;
planner.flow_percentage[0] = 100; planner.flow_percentage[0] = 100;
planner.e_factor[0] = planner.flow_percentage[0] * 0.01f; planner.e_factor[0] = planner.flow_percentage[0] * 0.01f;
#if HAS_MULTI_EXTRUDER #if HAS_MULTI_EXTRUDER
planner.flow_percentage[1] = 100; planner.flow_percentage[1] = 100;
planner.e_factor[1] = planner.flow_percentage[1] * 0.01f; planner.e_factor[1] = planner.flow_percentage[1] * 0.01f;
#endif #endif
card.startFileprint(); card.startFileprint();
#if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(POWER_LOSS_RECOVERY)
recovery.prepare(); recovery.prepare();
#endif #endif
once_flag = false; once_flag = false;
}
} }
#endif
}
else if (uiCfg.dialogType == DIALOG_TYPE_STOP) {
wait_for_heatup = false;
stop_print_time();
lv_clear_dialog();
lv_draw_ready_print();
#if ENABLED(SDSUPPORT)
//card.endFilePrint();
//wait_for_heatup = false;
uiCfg.print_state = IDLE;
card.flag.abort_sd_printing = true;
//queue.clear();
//quickstop_stepper();
//print_job_timer.stop();
//thermalManager.disable_all_heaters();
//#if ENABLED(POWER_LOSS_RECOVERY)
// recovery.purge();
//#endif
//queue.enqueue_now_P(PSTR("G91\nG1 Z10\nG90\nG28 X0 Y0"));
//queue.inject_P(PSTR("G91\nG1 Z10\nG90\nG28 X0 Y0\nM84\nM107"));
#endif
}
else if (uiCfg.dialogType == DIALOG_TYPE_FINISH_PRINT) {
clear_cur_ui();
lv_draw_ready_print();
}
#if ENABLED(ADVANCED_PAUSE_FEATURE)
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_WAITING
|| uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_INSERT
|| uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEAT
) {
wait_for_user = false;
}
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE;
}
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_RESUME) {
clear_cur_ui();
draw_return_ui();
} }
#endif #endif
else if (uiCfg.dialogType == DIALOG_STORE_EEPROM_TIPS) { }
TERN_(EEPROM_SETTINGS, (void)settings.save()); else if (DIALOG_IS(TYPE_STOP)) {
clear_cur_ui(); wait_for_heatup = false;
draw_return_ui(); stop_print_time();
} lv_clear_dialog();
else if (uiCfg.dialogType == DIALOG_READ_EEPROM_TIPS) { lv_draw_ready_print();
TERN_(EEPROM_SETTINGS, (void)settings.load());
clear_cur_ui(); #if ENABLED(SDSUPPORT)
draw_return_ui(); //card.endFilePrint();
} //wait_for_heatup = false;
else if (uiCfg.dialogType == DIALOG_REVERT_EEPROM_TIPS) { uiCfg.print_state = IDLE;
TERN_(EEPROM_SETTINGS, (void)settings.reset()); card.flag.abort_sd_printing = true;
clear_cur_ui(); //queue.clear();
draw_return_ui(); //quickstop_stepper();
} //print_job_timer.stop();
else if (uiCfg.dialogType == DIALOG_WIFI_CONFIG_TIPS) { //thermalManager.disable_all_heaters();
uiCfg.configWifi = 1;
clear_cur_ui(); //#if ENABLED(POWER_LOSS_RECOVERY)
draw_return_ui(); // recovery.purge();
} //#endif
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED) { //queue.enqueue_now_P(PSTR("G91\nG1 Z10\nG90\nG28 X0 Y0"));
uiCfg.filament_heat_completed_load = 1; //queue.inject_P(PSTR("G91\nG1 Z10\nG90\nG28 X0 Y0\nM84\nM107"));
} #endif
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED) { }
uiCfg.filament_heat_completed_unload = 1; else if (DIALOG_IS(TYPE_FINISH_PRINT)) {
} clear_cur_ui();
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_COMPLETED lv_draw_ready_print();
|| uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED }
) { #if ENABLED(ADVANCED_PAUSE_FEATURE)
else if (DIALOG_IS(PAUSE_MESSAGE_WAITING, PAUSE_MESSAGE_INSERT, PAUSE_MESSAGE_HEAT))
wait_for_user = false;
else if (DIALOG_IS(PAUSE_MESSAGE_OPTION))
pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE;
else if (DIALOG_IS(PAUSE_MESSAGE_RESUME)) {
clear_cur_ui(); clear_cur_ui();
draw_return_ui(); draw_return_ui();
} }
#endif
else if (DIALOG_IS(STORE_EEPROM_TIPS)) {
TERN_(EEPROM_SETTINGS, (void)settings.save());
clear_cur_ui();
draw_return_ui();
}
else if (DIALOG_IS(READ_EEPROM_TIPS)) {
TERN_(EEPROM_SETTINGS, (void)settings.load());
clear_cur_ui();
draw_return_ui();
}
else if (DIALOG_IS(REVERT_EEPROM_TIPS)) {
TERN_(EEPROM_SETTINGS, (void)settings.reset());
clear_cur_ui();
draw_return_ui();
}
else if (DIALOG_IS(WIFI_CONFIG_TIPS)) {
uiCfg.configWifi = 1;
clear_cur_ui();
draw_return_ui();
}
else if (DIALOG_IS(TYPE_FILAMENT_HEAT_LOAD_COMPLETED))
uiCfg.filament_heat_completed_load = 1;
else if (DIALOG_IS(TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED))
uiCfg.filament_heat_completed_unload = 1;
else if (DIALOG_IS(TYPE_FILAMENT_LOAD_COMPLETED, TYPE_FILAMENT_UNLOAD_COMPLETED)) {
clear_cur_ui();
draw_return_ui();
} }
} }
static void btn_cancel_event_cb(lv_obj_t * btn, lv_event_t event) { static void btn_cancel_event_cb(lv_obj_t *btn, lv_event_t event) {
if (event == LV_EVENT_CLICKED) { if (event != LV_EVENT_RELEASED) return;
// nothing to do if (DIALOG_IS(PAUSE_MESSAGE_OPTION)) {
#if ENABLED(ADVANCED_PAUSE_FEATURE)
pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT;
#endif
} }
else if (event == LV_EVENT_RELEASED) { else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT, TYPE_FILAMENT_UNLOAD_HEAT, TYPE_FILAMENT_HEAT_LOAD_COMPLETED, TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED)) {
if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_OPTION) { thermalManager.temp_hotend[uiCfg.curSprayerChoose].target= uiCfg.desireSprayerTempBak;
#if ENABLED(ADVANCED_PAUSE_FEATURE) clear_cur_ui();
pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; draw_return_ui();
#endif }
} else if (DIALOG_IS(TYPE_FILAMENT_LOADING, TYPE_FILAMENT_UNLOADING)) {
else if ((uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_HEAT) queue.enqueue_one_P(PSTR("M410"));
|| (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_HEAT) uiCfg.filament_rate = 0;
|| (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED) uiCfg.filament_loading_completed = 0;
|| (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED) uiCfg.filament_unloading_completed = 0;
) { uiCfg.filament_loading_time_flg = 0;
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target= uiCfg.desireSprayerTempBak; uiCfg.filament_loading_time_cnt = 0;
clear_cur_ui(); uiCfg.filament_unloading_time_flg = 0;
draw_return_ui(); uiCfg.filament_unloading_time_cnt = 0;
} thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = uiCfg.desireSprayerTempBak;
else if ((uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOADING) clear_cur_ui();
|| (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOADING) draw_return_ui();
) { }
queue.enqueue_one_P(PSTR("M410")); else {
uiCfg.filament_rate = 0; clear_cur_ui();
uiCfg.filament_loading_completed = 0; draw_return_ui();
uiCfg.filament_unloading_completed = 0;
uiCfg.filament_loading_time_flg = 0;
uiCfg.filament_loading_time_cnt = 0;
uiCfg.filament_unloading_time_flg = 0;
uiCfg.filament_unloading_time_cnt = 0;
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = uiCfg.desireSprayerTempBak;
clear_cur_ui();
draw_return_ui();
}
else {
clear_cur_ui();
draw_return_ui();
}
} }
} }
void lv_draw_dialog(uint8_t type) { void lv_draw_dialog(uint8_t type) {
lv_obj_t *btnOk = nullptr, *btnCancel = nullptr;
lv_obj_t * btnOk = NULL;
lv_obj_t * btnCancel = NULL;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != DIALOG_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != DIALOG_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = DIALOG_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = DIALOG_UI;
@ -246,153 +219,70 @@ void lv_draw_dialog(uint8_t type) {
uiCfg.dialogType = type; uiCfg.dialogType = type;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
static lv_style_t style_btn_rel; // A variable to store the released style
lv_style_copy(&style_btn_rel, &lv_style_plain); // Initialize from a built-in style
style_btn_rel.body.border.color = lv_color_hex3(0x269);
style_btn_rel.body.border.width = 1;
style_btn_rel.body.main_color = lv_color_hex3(0xADF);
style_btn_rel.body.grad_color = lv_color_hex3(0x46B);
style_btn_rel.body.shadow.width = 4;
style_btn_rel.body.shadow.type = LV_SHADOW_BOTTOM;
style_btn_rel.body.radius = LV_RADIUS_CIRCLE;
style_btn_rel.text.color = lv_color_hex3(0xDEF);
style_btn_rel.text.font = &TERN(HAS_SPI_FLASH_FONT, gb2312_puhui32, lv_font_roboto_22);
static lv_style_t style_btn_pr; // A variable to store the pressed style
lv_style_copy(&style_btn_pr, &style_btn_rel); // Initialize from the released style
style_btn_pr.body.border.color = lv_color_hex3(0x46B);
style_btn_pr.body.main_color = lv_color_hex3(0x8BD);
style_btn_pr.body.grad_color = lv_color_hex3(0x24A);
style_btn_pr.body.shadow.width = 2;
style_btn_pr.text.color = lv_color_hex3(0xBCD);
style_btn_pr.text.font = &TERN(HAS_SPI_FLASH_FONT, gb2312_puhui32, lv_font_roboto_22);
// Set button styles for Released and Pressed
auto lv_btn_use_button_style = [&](lv_obj_t *btn) {
lv_btn_set_style(btn, LV_BTN_STYLE_REL, &style_btn_rel);
lv_btn_set_style(btn, LV_BTN_STYLE_PR, &style_btn_pr);
};
lv_obj_t *labelDialog = lv_label_create_empty(scr); lv_obj_t *labelDialog = lv_label_create_empty(scr);
if (uiCfg.dialogType == DIALOG_TYPE_FINISH_PRINT || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_RESUME) { if (DIALOG_IS(TYPE_FINISH_PRINT, PAUSE_MESSAGE_RESUME)) {
btnOk = lv_btn_create(scr, NULL); // Add a button the current screen btnOk = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_ok_event_cb);
lv_obj_set_pos(btnOk, BTN_OK_X + 90, BTN_OK_Y); // Set its position
lv_obj_set_size(btnOk, 100, 50); // Set its size
lv_obj_set_event_cb(btnOk, btn_ok_event_cb);
lv_btn_use_button_style(btnOk);
lv_obj_t *labelOk = lv_label_create_empty(btnOk); // Add a label to the button lv_obj_t *labelOk = lv_label_create_empty(btnOk); // Add a label to the button
lv_label_set_text(labelOk, print_file_dialog_menu.confirm); // Set the labels text lv_label_set_text(labelOk, print_file_dialog_menu.confirm); // Set the labels text
} }
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_WAITING else if (DIALOG_IS(PAUSE_MESSAGE_WAITING, PAUSE_MESSAGE_INSERT, PAUSE_MESSAGE_HEAT)) {
|| uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_INSERT btnOk = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_ok_event_cb);
|| uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEAT
) {
btnOk = lv_btn_create(scr, NULL); // Add a button the current screen
lv_obj_set_pos(btnOk, BTN_OK_X + 90, BTN_OK_Y); // Set its position
lv_obj_set_size(btnOk, 100, 50); // Set its size
lv_obj_set_event_cb(btnOk, btn_ok_event_cb);
lv_btn_use_button_style(btnOk);
lv_obj_t *labelOk = lv_label_create_empty(btnOk); // Add a label to the button lv_obj_t *labelOk = lv_label_create_empty(btnOk); // Add a label to the button
lv_label_set_text(labelOk, print_file_dialog_menu.confirm); // Set the labels text lv_label_set_text(labelOk, print_file_dialog_menu.confirm); // Set the labels text
} }
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_PAUSING else if (DIALOG_IS(PAUSE_MESSAGE_PAUSING, PAUSE_MESSAGE_CHANGING, PAUSE_MESSAGE_UNLOAD, PAUSE_MESSAGE_LOAD, PAUSE_MESSAGE_PURGE, PAUSE_MESSAGE_RESUME, PAUSE_MESSAGE_HEATING)) {
|| uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_CHANGING
|| uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_UNLOAD
|| uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_LOAD
|| uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_PURGE
|| uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_RESUME
|| uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEATING
) {
// nothing to do // nothing to do
} }
else if (uiCfg.dialogType == WIFI_ENABLE_TIPS) { else if (DIALOG_IS(WIFI_ENABLE_TIPS)) {
btnCancel = lv_btn_create(scr, NULL); btnCancel = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
lv_obj_set_pos(btnCancel, BTN_OK_X+90, BTN_OK_Y);
lv_obj_set_size(btnCancel, 100, 50);
lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb);
lv_btn_use_button_style(btnCancel);
lv_obj_t *labelCancel = lv_label_create_empty(btnCancel); lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancle); lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
} }
else if (uiCfg.dialogType == DIALOG_TRANSFER_NO_DEVICE) { else if (DIALOG_IS(TRANSFER_NO_DEVICE)) {
btnCancel = lv_btn_create(scr, NULL); btnCancel = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
lv_obj_set_pos(btnCancel, BTN_OK_X+90, BTN_OK_Y);
lv_obj_set_size(btnCancel, 100, 50);
lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb);
lv_btn_use_button_style(btnCancel);
lv_obj_t *labelCancel = lv_label_create_empty(btnCancel); lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancle); lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
} }
#if ENABLED(USE_WIFI_FUNCTION) #if ENABLED(USE_WIFI_FUNCTION)
else if (uiCfg.dialogType == DIALOG_TYPE_UPLOAD_FILE) { else if (DIALOG_IS(TYPE_UPLOAD_FILE)) {
if (upload_result == 2) { if (upload_result == 2) {
btnCancel = lv_btn_create(scr, NULL); btnCancel = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
lv_obj_set_pos(btnCancel, BTN_OK_X+90, BTN_OK_Y);
lv_obj_set_size(btnCancel, 100, 50);
lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb);
lv_btn_use_button_style(btnCancel);
lv_obj_t *labelCancel = lv_label_create_empty(btnCancel); lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancle); lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
} }
else if (upload_result == 3) { else if (upload_result == 3) {
btnOk = lv_btn_create(scr, NULL); btnOk = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_ok_event_cb);
lv_obj_set_pos(btnOk, BTN_OK_X+90, BTN_OK_Y);
lv_obj_set_size(btnOk, 100, 50);
lv_obj_set_event_cb(btnOk, btn_ok_event_cb);
lv_btn_use_button_style(btnOk);
lv_obj_t *labelOk = lv_label_create_empty(btnOk); lv_obj_t *labelOk = lv_label_create_empty(btnOk);
lv_label_set_text(labelOk, print_file_dialog_menu.confirm); lv_label_set_text(labelOk, print_file_dialog_menu.confirm);
} }
} }
#endif //USE_WIFI_FUNCTION #endif
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_HEAT else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT, TYPE_FILAMENT_UNLOAD_HEAT)) {
|| uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_HEAT btnCancel = lv_button_btn_create(scr, BTN_OK_X+90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
) {
btnCancel = lv_btn_create(scr, NULL);
lv_obj_set_pos(btnCancel, BTN_OK_X+90, BTN_OK_Y);
lv_obj_set_size(btnCancel, 100, 50);
lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb);
lv_btn_use_button_style(btnCancel);
lv_obj_t *labelCancel = lv_label_create_empty(btnCancel); lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancle); lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
tempText1 = lv_label_create_empty(scr); tempText1 = lv_label_create_empty(scr);
filament_sprayer_temp(); filament_sprayer_temp();
} }
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_COMPLETED else if (DIALOG_IS(TYPE_FILAMENT_LOAD_COMPLETED, TYPE_FILAMENT_UNLOAD_COMPLETED)) {
|| uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED btnOk = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_ok_event_cb);
) {
btnOk = lv_btn_create(scr, NULL);
lv_obj_set_pos(btnOk, BTN_OK_X + 90, BTN_OK_Y);
lv_obj_set_size(btnOk, 100, 50);
lv_obj_set_event_cb(btnOk, btn_ok_event_cb);
lv_btn_use_button_style(btnOk);
lv_obj_t *labelOk = lv_label_create_empty(btnOk); lv_obj_t *labelOk = lv_label_create_empty(btnOk);
lv_label_set_text(labelOk, print_file_dialog_menu.confirm); lv_label_set_text(labelOk, print_file_dialog_menu.confirm);
} }
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOADING else if (DIALOG_IS(TYPE_FILAMENT_LOADING, TYPE_FILAMENT_UNLOADING)) {
|| uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOADING btnCancel = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
) {
btnCancel = lv_btn_create(scr, NULL);
lv_obj_set_pos(btnCancel, BTN_OK_X+90, BTN_OK_Y);
lv_obj_set_size(btnCancel, 100, 50);
lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb);
lv_btn_use_button_style(btnCancel);
lv_obj_t *labelCancel = lv_label_create_empty(btnCancel); lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancle); lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
filament_bar = lv_bar_create(scr, NULL); filament_bar = lv_bar_create(scr, nullptr);
lv_obj_set_pos(filament_bar, (TFT_WIDTH-400)/2, ((TFT_HEIGHT - titleHeight)-40)/2); lv_obj_set_pos(filament_bar, (TFT_WIDTH-400)/2, ((TFT_HEIGHT - titleHeight)-40)/2);
lv_obj_set_size(filament_bar, 400, 25); lv_obj_set_size(filament_bar, 400, 25);
lv_bar_set_style(filament_bar, LV_BAR_STYLE_INDIC, &lv_bar_style_indic); lv_bar_set_style(filament_bar, LV_BAR_STYLE_INDIC, &lv_bar_style_indic);
@ -400,21 +290,13 @@ void lv_draw_dialog(uint8_t type) {
lv_bar_set_value(filament_bar, 0, LV_ANIM_ON); lv_bar_set_value(filament_bar, 0, LV_ANIM_ON);
} }
else { else {
btnOk = lv_btn_create(scr, NULL); // Add a button the current screen btnOk = lv_button_btn_create(scr, BTN_OK_X, BTN_OK_Y, 100, 50, btn_ok_event_cb);
lv_obj_set_pos(btnOk, BTN_OK_X, BTN_OK_Y); // Set its position
lv_obj_set_size(btnOk, 100, 50); // Set its size
lv_obj_set_event_cb(btnOk, btn_ok_event_cb);
lv_btn_use_button_style(btnOk);
lv_obj_t *labelOk = lv_label_create_empty(btnOk); // Add a label to the button lv_obj_t *labelOk = lv_label_create_empty(btnOk); // Add a label to the button
btnCancel = lv_btn_create(scr, NULL); // Add a button the current screen btnCancel = lv_button_btn_create(scr, BTN_CANCEL_X, BTN_CANCEL_Y, 100, 50, btn_cancel_event_cb);
lv_obj_set_pos(btnCancel, BTN_CANCEL_X, BTN_CANCEL_Y); // Set its position
lv_obj_set_size(btnCancel, 100, 50); // Set its size
lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb);
lv_btn_use_button_style(btnCancel);
lv_obj_t *labelCancel = lv_label_create_empty(btnCancel); // Add a label to the button lv_obj_t *labelCancel = lv_label_create_empty(btnCancel); // Add a label to the button
if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_OPTION) { if (DIALOG_IS(PAUSE_MESSAGE_OPTION)) {
lv_label_set_text(labelOk, pause_msg_menu.purgeMore); // Set the labels text lv_label_set_text(labelOk, pause_msg_menu.purgeMore); // Set the labels text
lv_label_set_text(labelCancel, pause_msg_menu.continuePrint); lv_label_set_text(labelCancel, pause_msg_menu.continuePrint);
} }
@ -423,105 +305,103 @@ void lv_draw_dialog(uint8_t type) {
lv_label_set_text(labelCancel, print_file_dialog_menu.cancle); lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
} }
} }
if (uiCfg.dialogType == DIALOG_TYPE_PRINT_FILE) { if (DIALOG_IS(TYPE_PRINT_FILE)) {
lv_label_set_text(labelDialog, print_file_dialog_menu.print_file); lv_label_set_text(labelDialog, print_file_dialog_menu.print_file);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
lv_obj_t *labelFile = lv_label_create(scr, list_file.long_name[sel_id]); lv_obj_t *labelFile = lv_label_create(scr, list_file.long_name[sel_id]);
lv_obj_align(labelFile, NULL, LV_ALIGN_CENTER, 0, -60); lv_obj_align(labelFile, nullptr, LV_ALIGN_CENTER, 0, -60);
} }
else if (uiCfg.dialogType == DIALOG_TYPE_STOP) { else if (DIALOG_IS(TYPE_STOP)) {
lv_label_set_text(labelDialog, print_file_dialog_menu.cancle_print); lv_label_set_text(labelDialog, print_file_dialog_menu.cancle_print);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_TYPE_FINISH_PRINT) { else if (DIALOG_IS(TYPE_FINISH_PRINT)) {
lv_label_set_text(labelDialog, print_file_dialog_menu.print_finish); lv_label_set_text(labelDialog, print_file_dialog_menu.print_finish);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_PAUSING) { else if (DIALOG_IS(PAUSE_MESSAGE_PAUSING)) {
lv_label_set_text(labelDialog, pause_msg_menu.pausing); lv_label_set_text(labelDialog, pause_msg_menu.pausing);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_CHANGING) { else if (DIALOG_IS(PAUSE_MESSAGE_CHANGING)) {
lv_label_set_text(labelDialog, pause_msg_menu.changing); lv_label_set_text(labelDialog, pause_msg_menu.changing);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_UNLOAD) { else if (DIALOG_IS(PAUSE_MESSAGE_UNLOAD)) {
lv_label_set_text(labelDialog, pause_msg_menu.unload); lv_label_set_text(labelDialog, pause_msg_menu.unload);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_WAITING) { else if (DIALOG_IS(PAUSE_MESSAGE_WAITING)) {
lv_label_set_text(labelDialog, pause_msg_menu.waiting); lv_label_set_text(labelDialog, pause_msg_menu.waiting);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_INSERT) { else if (DIALOG_IS(PAUSE_MESSAGE_INSERT)) {
lv_label_set_text(labelDialog, pause_msg_menu.insert); lv_label_set_text(labelDialog, pause_msg_menu.insert);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_LOAD) { else if (DIALOG_IS(PAUSE_MESSAGE_LOAD)) {
lv_label_set_text(labelDialog, pause_msg_menu.load); lv_label_set_text(labelDialog, pause_msg_menu.load);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_PURGE) { else if (DIALOG_IS(PAUSE_MESSAGE_PURGE)) {
lv_label_set_text(labelDialog, pause_msg_menu.purge); lv_label_set_text(labelDialog, pause_msg_menu.purge);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_RESUME) { else if (DIALOG_IS(PAUSE_MESSAGE_RESUME)) {
lv_label_set_text(labelDialog, pause_msg_menu.resume); lv_label_set_text(labelDialog, pause_msg_menu.resume);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEAT) { else if (DIALOG_IS(PAUSE_MESSAGE_HEAT)) {
lv_label_set_text(labelDialog, pause_msg_menu.heat); lv_label_set_text(labelDialog, pause_msg_menu.heat);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEATING) { else if (DIALOG_IS(PAUSE_MESSAGE_HEATING)) {
lv_label_set_text(labelDialog, pause_msg_menu.heating); lv_label_set_text(labelDialog, pause_msg_menu.heating);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_OPTION) { else if (DIALOG_IS(PAUSE_MESSAGE_OPTION)) {
lv_label_set_text(labelDialog, pause_msg_menu.option); lv_label_set_text(labelDialog, pause_msg_menu.option);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_STORE_EEPROM_TIPS) { else if (DIALOG_IS(STORE_EEPROM_TIPS)) {
lv_label_set_text(labelDialog, eeprom_menu.storeTips); lv_label_set_text(labelDialog, eeprom_menu.storeTips);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_READ_EEPROM_TIPS) { else if (DIALOG_IS(READ_EEPROM_TIPS)) {
lv_label_set_text(labelDialog, eeprom_menu.readTips); lv_label_set_text(labelDialog, eeprom_menu.readTips);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_REVERT_EEPROM_TIPS) { else if (DIALOG_IS(REVERT_EEPROM_TIPS)) {
lv_label_set_text(labelDialog, eeprom_menu.revertTips); lv_label_set_text(labelDialog, eeprom_menu.revertTips);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_WIFI_CONFIG_TIPS) { else if (DIALOG_IS(WIFI_CONFIG_TIPS)) {
lv_label_set_text(labelDialog, machine_menu.wifiConfigTips); lv_label_set_text(labelDialog, machine_menu.wifiConfigTips);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == WIFI_ENABLE_TIPS) { else if (DIALOG_IS(WIFI_ENABLE_TIPS)) {
lv_label_set_text(labelDialog, print_file_dialog_menu.wifi_enable_tips); lv_label_set_text(labelDialog, print_file_dialog_menu.wifi_enable_tips);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_TRANSFER_NO_DEVICE) { else if (DIALOG_IS(TRANSFER_NO_DEVICE)) {
lv_label_set_text(labelDialog, DIALOG_UPDATE_NO_DEVICE_EN); lv_label_set_text(labelDialog, DIALOG_UPDATE_NO_DEVICE_EN);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
#if ENABLED(USE_WIFI_FUNCTION) #if ENABLED(USE_WIFI_FUNCTION)
else if (uiCfg.dialogType == DIALOG_TYPE_UPLOAD_FILE) { else if (DIALOG_IS(TYPE_UPLOAD_FILE)) {
if (upload_result == 1) { if (upload_result == 1) {
lv_label_set_text(labelDialog, DIALOG_UPLOAD_ING_EN); lv_label_set_text(labelDialog, DIALOG_UPLOAD_ING_EN);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (upload_result == 2) { else if (upload_result == 2) {
lv_label_set_text(labelDialog, DIALOG_UPLOAD_ERROR_EN); lv_label_set_text(labelDialog, DIALOG_UPLOAD_ERROR_EN);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (upload_result == 3) { else if (upload_result == 3) {
char buf[200]; char buf[200];
int _index = 0; int _index = 0;
ZERO(buf);
strcpy(buf, DIALOG_UPLOAD_FINISH_EN); strcpy(buf, DIALOG_UPLOAD_FINISH_EN);
_index = strlen(buf); _index = strlen(buf);
buf[_index] = '\n'; buf[_index] = '\n';
@ -546,41 +426,41 @@ void lv_draw_dialog(uint8_t type) {
sprintf(&buf[_index], " %d KBytes/s\n", (int)(upload_size / upload_time / 1024)); sprintf(&buf[_index], " %d KBytes/s\n", (int)(upload_size / upload_time / 1024));
lv_label_set_text(labelDialog, buf); lv_label_set_text(labelDialog, buf);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
} }
#endif //USE_WIFI_FUNCTION #endif // USE_WIFI_FUNCTION
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_HEAT) { else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT)) {
lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_heat); lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_heat);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED) { else if (DIALOG_IS(TYPE_FILAMENT_HEAT_LOAD_COMPLETED)) {
lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_heat_confirm); lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_heat_confirm);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_HEAT) { else if (DIALOG_IS(TYPE_FILAMENT_UNLOAD_HEAT)) {
lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_heat); lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_heat);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED) { else if (DIALOG_IS(TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED)) {
lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_heat_confirm); lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_heat_confirm);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_COMPLETED) { else if (DIALOG_IS(TYPE_FILAMENT_LOAD_COMPLETED)) {
lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_completed); lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_completed);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED) { else if (DIALOG_IS(TYPE_FILAMENT_UNLOAD_COMPLETED)) {
lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_completed); lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_completed);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
} }
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOADING) { else if (DIALOG_IS(TYPE_FILAMENT_LOADING)) {
lv_label_set_text(labelDialog, filament_menu.filament_dialog_loading); lv_label_set_text(labelDialog, filament_menu.filament_dialog_loading);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -70); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -70);
} }
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOADING) { else if (DIALOG_IS(TYPE_FILAMENT_UNLOADING)) {
lv_label_set_text(labelDialog, filament_menu.filament_dialog_unloading); lv_label_set_text(labelDialog, filament_menu.filament_dialog_unloading);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -70); lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -70);
} }
#if HAS_ROTARY_ENCODER #if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) { if (gCfgItems.encoder_enable) {
@ -592,28 +472,19 @@ void lv_draw_dialog(uint8_t type) {
void filament_sprayer_temp() { void filament_sprayer_temp() {
char buf[20] = {0}; char buf[20] = {0};
sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target);
public_buf_l[0] = '\0'; strcpy(public_buf_l, uiCfg.curSprayerChoose < 1 ? extrude_menu.ext1 : extrude_menu.ext2);
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_P(public_buf_l, PSTR(": "));
strcat(public_buf_l, buf); strcat(public_buf_l, buf);
lv_label_set_text(tempText1, public_buf_l); lv_label_set_text(tempText1, public_buf_l);
lv_obj_align(tempText1, NULL, LV_ALIGN_CENTER, 0, -50); lv_obj_align(tempText1, nullptr, LV_ALIGN_CENTER, 0, -50);
} }
void filament_dialog_handle() { void filament_dialog_handle() {
if ((temperature_change_frequency == 1) if (temps_update_flag && (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT, TYPE_FILAMENT_UNLOAD_HEAT))) {
&& ((uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_HEAT)
|| (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_HEAT))
) {
filament_sprayer_temp(); filament_sprayer_temp();
temperature_change_frequency = 0; temps_update_flag = false;
} }
if (uiCfg.filament_heat_completed_load == 1) { if (uiCfg.filament_heat_completed_load == 1) {
uiCfg.filament_heat_completed_load = 0; uiCfg.filament_heat_completed_load = 0;
@ -667,9 +538,8 @@ void filament_dialog_handle() {
lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED); lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED);
} }
if ( uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOADING if (DIALOG_IS(TYPE_FILAMENT_LOADING, TYPE_FILAMENT_UNLOADING))
|| uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOADING lv_filament_setbar();
) lv_filament_setbar();
} }
void lv_filament_setbar() { void lv_filament_setbar() {

View file

@ -25,52 +25,55 @@
extern "C" { /* C-declarations for C++ */ extern "C" { /* C-declarations for C++ */
#endif #endif
#define DIALOG_TYPE_STOP 0 enum {
#define DIALOG_TYPE_PRINT_FILE 1 DIALOG_TYPE_STOP = 0,
#define DIALOG_TYPE_REPRINT_NO_FILE 2 DIALOG_TYPE_PRINT_FILE,
DIALOG_TYPE_REPRINT_NO_FILE,
#define DIALOG_TYPE_M80_FAIL 3 //** DIALOG_TYPE_M80_FAIL,
#define DIALOG_TYPE_MESSAGE_ERR1 4 //** DIALOG_TYPE_MESSAGE_ERR1,
#define DIALOG_TYPE_UPDATE_ESP_FIRMARE 5 DIALOG_TYPE_UPDATE_ESP_FIRMARE,
#define DIALOG_TYPE_UPDATE_ESP_DATA 6 DIALOG_TYPE_UPDATE_ESP_DATA,
#define DIALOG_TYPE_UPLOAD_FILE 7 DIALOG_TYPE_UPLOAD_FILE,
#define DIALOG_TYPE_UNBIND 8 DIALOG_TYPE_UNBIND,
#define DIALOG_TYPE_FILAMENT_LOAD_HEAT 9 DIALOG_TYPE_FILAMENT_LOAD_HEAT,
#define DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED 10 DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED,
#define DIALOG_TYPE_FILAMENT_LOADING 11 DIALOG_TYPE_FILAMENT_LOADING,
#define DIALOG_TYPE_FILAMENT_LOAD_COMPLETED 12 DIALOG_TYPE_FILAMENT_LOAD_COMPLETED,
#define DIALOG_TYPE_FILAMENT_UNLOAD_HEAT 13 DIALOG_TYPE_FILAMENT_UNLOAD_HEAT,
#define DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED 14 DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED,
#define DIALOG_TYPE_FILAMENT_UNLOADING 15 DIALOG_TYPE_FILAMENT_UNLOADING,
#define DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED 16 DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED,
#define DIALOG_TYPE_FILE_LOADING 17 //** DIALOG_TYPE_FILE_LOADING,
#define DIALOG_TYPE_FILAMENT_NO_PRESS 18 DIALOG_TYPE_FILAMENT_NO_PRESS,
#define DIALOG_TYPE_FINISH_PRINT 19 DIALOG_TYPE_FINISH_PRINT,
#define WIFI_ENABLE_TIPS 20 DIALOG_WIFI_ENABLE_TIPS,
#define DIALOG_PAUSE_MESSAGE_PAUSING 21 DIALOG_PAUSE_MESSAGE_PAUSING,
#define DIALOG_PAUSE_MESSAGE_CHANGING 22 DIALOG_PAUSE_MESSAGE_CHANGING,
#define DIALOG_PAUSE_MESSAGE_UNLOAD 23 DIALOG_PAUSE_MESSAGE_UNLOAD,
#define DIALOG_PAUSE_MESSAGE_WAITING 24 DIALOG_PAUSE_MESSAGE_WAITING,
#define DIALOG_PAUSE_MESSAGE_INSERT 25 DIALOG_PAUSE_MESSAGE_INSERT,
#define DIALOG_PAUSE_MESSAGE_LOAD 26 DIALOG_PAUSE_MESSAGE_LOAD,
#define DIALOG_PAUSE_MESSAGE_PURGE 27 DIALOG_PAUSE_MESSAGE_PURGE,
#define DIALOG_PAUSE_MESSAGE_RESUME 28 DIALOG_PAUSE_MESSAGE_RESUME,
#define DIALOG_PAUSE_MESSAGE_HEAT 29 DIALOG_PAUSE_MESSAGE_HEAT,
#define DIALOG_PAUSE_MESSAGE_HEATING 30 DIALOG_PAUSE_MESSAGE_HEATING,
#define DIALOG_PAUSE_MESSAGE_OPTION 31 DIALOG_PAUSE_MESSAGE_OPTION,
#define DIALOG_STORE_EEPROM_TIPS 32 DIALOG_STORE_EEPROM_TIPS,
#define DIALOG_READ_EEPROM_TIPS 33 DIALOG_READ_EEPROM_TIPS,
#define DIALOG_REVERT_EEPROM_TIPS 34 DIALOG_REVERT_EEPROM_TIPS,
DIALOG_WIFI_CONFIG_TIPS,
DIALOG_TRANSFER_NO_DEVICE
};
#define DIALOG_WIFI_CONFIG_TIPS 35
#define DIALOG_TRANSFER_NO_DEVICE 36
#define BTN_OK_X 100 #define BTN_OK_X 100
#define BTN_OK_Y 180 #define BTN_OK_Y 180
#define BTN_CANCEL_X 280 #define BTN_CANCEL_X 280

View file

@ -28,163 +28,58 @@
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_EEPROM_RETURN 1 enum {
#define ID_EEPROM_STORE 2 ID_EEPROM_RETURN = 1,
#define ID_EEPROM_STORE_ARROW 3 ID_EEPROM_STORE,
#define ID_EEPROM_READ 4 ID_EEPROM_STORE_ARROW,
#define ID_EEPROM_READ_ARROW 5 ID_EEPROM_READ,
#define ID_EEPROM_REVERT 6 ID_EEPROM_READ_ARROW,
#define ID_EEPROM_REVERT_ARROW 7 ID_EEPROM_REVERT,
ID_EEPROM_REVERT_ARROW
};
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_EEPROM_RETURN: case ID_EEPROM_RETURN:
if (event == LV_EVENT_CLICKED) { lv_clear_eeprom_settings();
} draw_return_ui();
else if (event == LV_EVENT_RELEASED) {
lv_clear_eeprom_settings();
draw_return_ui();
}
break; break;
case ID_EEPROM_STORE: case ID_EEPROM_STORE:
if (event == LV_EVENT_CLICKED) { lv_clear_eeprom_settings();
lv_draw_dialog(DIALOG_STORE_EEPROM_TIPS);
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_eeprom_settings();
lv_draw_dialog(DIALOG_STORE_EEPROM_TIPS);
}
break;
case ID_EEPROM_STORE_ARROW:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_eeprom_settings();
lv_draw_dialog(DIALOG_STORE_EEPROM_TIPS);
}
break; break;
#if 0 #if 0
case ID_EEPROM_READ: case ID_EEPROM_READ:
if (event == LV_EVENT_CLICKED) { lv_clear_eeprom_settings();
lv_draw_dialog(DIALOG_READ_EEPROM_TIPS);
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_eeprom_settings();
lv_draw_dialog(DIALOG_READ_EEPROM_TIPS);
}
break;
case ID_EEPROM_READ_ARROW:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_eeprom_settings();
lv_draw_dialog(DIALOG_READ_EEPROM_TIPS);
}
break; break;
#endif #endif
case ID_EEPROM_REVERT: case ID_EEPROM_REVERT:
if (event == LV_EVENT_CLICKED) { lv_clear_eeprom_settings();
lv_draw_dialog(DIALOG_REVERT_EEPROM_TIPS);
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_eeprom_settings();
lv_draw_dialog(DIALOG_REVERT_EEPROM_TIPS);
}
break;
case ID_EEPROM_REVERT_ARROW:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_eeprom_settings();
lv_draw_dialog(DIALOG_REVERT_EEPROM_TIPS);
}
break; break;
} }
} }
void lv_draw_eeprom_settings(void) { void lv_draw_eeprom_settings(void) {
lv_obj_t *buttonBack, *label_Back;
lv_obj_t *buttonStore, *labelStore;
//lv_obj_t *buttonRead,*labelRead,*buttonReadNarrow;
lv_obj_t *buttonRevert, *labelRevert;
lv_obj_t * line1, * line2; //* line3;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != EEPROM_SETTINGS_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != EEPROM_SETTINGS_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = EEPROM_SETTINGS_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = EEPROM_SETTINGS_UI;
} }
disp_state = EEPROM_SETTINGS_UI; disp_state = EEPROM_SETTINGS_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
buttonRevert = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_screen_menu_item(scr, eeprom_menu.revert, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_EEPROM_REVERT, 0);
lv_obj_set_pos(buttonRevert, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ lv_screen_menu_item(scr, eeprom_menu.store, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_EEPROM_STORE, 1);
lv_obj_set_size(buttonRevert, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_EEPROM_RETURN, true);
//lv_obj_set_event_cb(buttonMotor, event_handler);
lv_obj_set_event_cb_mks(buttonRevert, event_handler, ID_EEPROM_REVERT, NULL, 0);
lv_btn_use_label_style(buttonRevert);
lv_btn_set_layout(buttonRevert, LV_LAYOUT_OFF);
labelRevert = lv_label_create_empty(buttonRevert); /*Add a label to the button*/
(void)lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V, event_handler, ID_EEPROM_REVERT_ARROW);
//line3 = lv_line_create(scr, NULL);
//lv_ex_line(line3,line_points[2]);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonStore = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonStore, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/
lv_obj_set_size(buttonStore, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
//lv_obj_set_event_cb(buttonMotor, event_handler);
lv_obj_set_event_cb_mks(buttonStore, event_handler, ID_EEPROM_STORE, NULL, 0);
lv_btn_use_label_style(buttonStore);
lv_btn_set_layout(buttonStore, LV_LAYOUT_OFF);
labelStore = lv_label_create_empty(buttonStore); /*Add a label to the button*/
(void)lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V, event_handler, ID_EEPROM_STORE_ARROW);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
buttonBack = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_EEPROM_RETURN);
label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.multiple_language) {
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(labelStore, eeprom_menu.store);
lv_obj_align(labelStore, buttonStore, LV_ALIGN_IN_LEFT_MID,0, 0);
//lv_label_set_text(labelRead, eeprom_menu.read);
//lv_obj_align(labelRead, buttonRead, LV_ALIGN_IN_LEFT_MID,0, 0);
lv_label_set_text(labelRevert, eeprom_menu.revert);
lv_obj_align(labelRevert, buttonRevert, LV_ALIGN_IN_LEFT_MID, 0, 0);
}
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonRevert);
lv_group_add_obj(g, buttonStore);
lv_group_add_obj(g, buttonBack);
}
#endif
} }
void lv_clear_eeprom_settings() { void lv_clear_eeprom_settings() {

View file

@ -30,84 +30,44 @@
#if BUTTONS_EXIST(EN1, EN2) #if BUTTONS_EXIST(EN1, EN2)
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
static lv_obj_t * buttonEncoderState = NULL; static lv_obj_t *buttonEncoderState = nullptr;
static lv_obj_t *labelEncoderState = NULL;
#define ID_ENCODER_RETURN 1 enum {
#define ID_ENCODER_STATE 2 ID_ENCODER_RETURN = 1,
ID_ENCODER_STATE
};
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_ENCODER_RETURN: case ID_ENCODER_RETURN:
if (event == LV_EVENT_CLICKED) { lv_clear_encoder_settings();
draw_return_ui();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_encoder_settings();
draw_return_ui();
}
break; break;
case ID_ENCODER_STATE: case ID_ENCODER_STATE:
if (event == LV_EVENT_CLICKED) { gCfgItems.encoder_enable ^= true;
lv_screen_menu_item_onoff_update(buttonEncoderState, gCfgItems.encoder_enable);
} update_spi_flash();
else if (event == LV_EVENT_RELEASED) {
gCfgItems.encoder_enable ^= true;
lv_imgbtn_set_src_both(buttonEncoderState, gCfgItems.encoder_enable ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin");
lv_label_set_text(labelEncoderState, machine_menu.enable);
update_spi_flash();
}
break; break;
} }
} }
void lv_draw_encoder_settings(void) { 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) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ENCODER_SETTINGS_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = ENCODER_SETTINGS_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = ENCODER_SETTINGS_UI;
} }
disp_state = ENCODER_SETTINGS_UI; disp_state = ENCODER_SETTINGS_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.EncoderConfTitle); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.EncoderConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
labelEncoderTips = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.EncoderConfText); buttonEncoderState = lv_screen_menu_item_onoff(scr, machine_menu.EncoderConfText, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_ENCODER_STATE, 0, gCfgItems.encoder_enable);
buttonEncoderState = lv_imgbtn_create(scr, gCfgItems.encoder_enable ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin", PARA_UI_STATE_POS_X, PARA_UI_POS_Y + PARA_UI_STATE_V, event_handler, ID_ENCODER_STATE); lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_ENCODER_RETURN, true);
labelEncoderState = lv_label_create_empty(buttonEncoderState);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonBack = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_ENCODER_RETURN);
label_Back = lv_label_create_empty(buttonBack);
lv_label_set_text(labelEncoderState, gCfgItems.encoder_enable ? machine_menu.enable : 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() { void lv_clear_encoder_settings() {

View file

@ -36,35 +36,31 @@
#include "mks_hardware_test.h" #include "mks_hardware_test.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
static lv_obj_t * scr; static lv_obj_t *scr;
void lv_draw_error_message(PGM_P const msg) { void lv_draw_error_message(PGM_P const msg) {
#if 0 #if 0
static lv_obj_t * message = NULL, *kill_message = NULL, *reset_tips = NULL; static lv_obj_t *message = nullptr, *kill_message = nullptr, *reset_tips = nullptr;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ERROR_MESSAGE_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ERROR_MESSAGE_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = ERROR_MESSAGE_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = ERROR_MESSAGE_UI;
} }
disp_state = ERROR_MESSAGE_UI; disp_state = ERROR_MESSAGE_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
if (msg) { if (msg) {
message = lv_label_create(scr, msg); message = lv_label_create(scr, msg);
lv_obj_align(message, NULL, LV_ALIGN_CENTER, 0, -50); lv_obj_align(message, nullptr, LV_ALIGN_CENTER, 0, -50);
} }
kill_message = lv_label_create(scr, "PRINTER HALTED"); kill_message = lv_label_create(scr, "PRINTER HALTED");
lv_obj_align(kill_message, NULL, LV_ALIGN_CENTER, 0, -10); lv_obj_align(kill_message, nullptr, LV_ALIGN_CENTER, 0, -10);
reset_tips = lv_label_create(scr, "Please Reset"); reset_tips = lv_label_create(scr, "Please Reset");
lv_obj_align(reset_tips, NULL, LV_ALIGN_CENTER, 0, 30); lv_obj_align(reset_tips, nullptr, LV_ALIGN_CENTER, 0, 30);
lv_task_handler(); lv_task_handler();
#endif #endif

View file

@ -43,172 +43,121 @@ static lv_obj_t *labelSpeed;
static lv_obj_t *tempText; static lv_obj_t *tempText;
static lv_obj_t *ExtruText; static lv_obj_t *ExtruText;
#define ID_E_ADD 1 enum {
#define ID_E_DEC 2 ID_E_ADD = 1,
#define ID_E_TYPE 3 ID_E_DEC,
#define ID_E_STEP 4 ID_E_TYPE,
#define ID_E_SPEED 5 ID_E_STEP,
#define ID_E_RETURN 6 ID_E_SPEED,
ID_E_RETURN
};
static int32_t extructAmount; static int32_t extrudeAmount;
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_E_ADD: case ID_E_ADD:
if (event == LV_EVENT_CLICKED) { if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= EXTRUDE_MINTEMP) {
// nothing to do queue.enqueue_now_P(PSTR("G91"));
} sprintf_P((char *)public_buf_l, PSTR("G1 E%d F%d"), uiCfg.extruStep, 60 * uiCfg.extruSpeed);
else if (event == LV_EVENT_RELEASED) { queue.enqueue_one_now(public_buf_l);
if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= EXTRUDE_MINTEMP) { queue.enqueue_now_P(PSTR("G90"));
queue.enqueue_now_P(PSTR("G91")); extrudeAmount += uiCfg.extruStep;
ZERO(public_buf_l);
sprintf_P((char *)public_buf_l, PSTR("G1 E%d F%d"), uiCfg.extruStep, 60 * uiCfg.extruSpeed);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G90"));
extructAmount += uiCfg.extruStep;
disp_extru_amount();
}
}
break;
case ID_E_DEC:
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= EXTRUDE_MINTEMP) {
queue.enqueue_now_P(PSTR("G91"));
ZERO(public_buf_l);
sprintf_P((char *)public_buf_l, PSTR("G1 E%d F%d"), 0 - uiCfg.extruStep, 60 * uiCfg.extruSpeed);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G90"));
extructAmount -= uiCfg.extruStep;
disp_extru_amount();
}
}
break;
case ID_E_TYPE:
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
if (ENABLED(HAS_MULTI_EXTRUDER)) {
if (uiCfg.curSprayerChoose == 0) {
uiCfg.curSprayerChoose = 1;
queue.inject_P(PSTR("T1"));
}
else {
uiCfg.curSprayerChoose = 0;
queue.inject_P(PSTR("T0"));
}
}
else
uiCfg.curSprayerChoose = 0;
extructAmount = 0;
disp_hotend_temp();
disp_ext_type();
disp_extru_amount(); disp_extru_amount();
} }
break; break;
case ID_E_STEP: case ID_E_DEC:
if (event == LV_EVENT_CLICKED) { if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= EXTRUDE_MINTEMP) {
// nothing to do queue.enqueue_now_P(PSTR("G91"));
sprintf_P((char *)public_buf_l, PSTR("G1 E%d F%d"), 0 - uiCfg.extruStep, 60 * uiCfg.extruSpeed);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G90"));
extrudeAmount -= uiCfg.extruStep;
disp_extru_amount();
} }
else if (event == LV_EVENT_RELEASED) { break;
switch (abs(uiCfg.extruStep)) { case ID_E_TYPE:
case 1: uiCfg.extruStep = 5; break; if (ENABLED(HAS_MULTI_EXTRUDER)) {
case 5: uiCfg.extruStep = 10; break; if (uiCfg.curSprayerChoose == 0) {
case 10: uiCfg.extruStep = 1; break; uiCfg.curSprayerChoose = 1;
default: break; queue.inject_P(PSTR("T1"));
}
else {
uiCfg.curSprayerChoose = 0;
queue.inject_P(PSTR("T0"));
} }
disp_ext_step();
} }
else
uiCfg.curSprayerChoose = 0;
extrudeAmount = 0;
disp_hotend_temp();
disp_ext_type();
disp_extru_amount();
break;
case ID_E_STEP:
switch (abs(uiCfg.extruStep)) {
case 1: uiCfg.extruStep = 5; break;
case 5: uiCfg.extruStep = 10; break;
case 10: uiCfg.extruStep = 1; break;
default: break;
}
disp_ext_step();
break; break;
case ID_E_SPEED: case ID_E_SPEED:
if (event == LV_EVENT_CLICKED) { switch (uiCfg.extruSpeed) {
// nothing to do case 1: uiCfg.extruSpeed = 10; break;
} case 10: uiCfg.extruSpeed = 20; break;
else if (event == LV_EVENT_RELEASED) { case 20: uiCfg.extruSpeed = 1; break;
switch (uiCfg.extruSpeed) { default: break;
case 1: uiCfg.extruSpeed = 10; break;
case 10: uiCfg.extruSpeed = 20; break;
case 20: uiCfg.extruSpeed = 1; break;
default: break;
}
disp_ext_speed();
} }
disp_ext_speed();
break; break;
case ID_E_RETURN: case ID_E_RETURN:
if (event == LV_EVENT_CLICKED) { clear_cur_ui();
// nothing to do draw_return_ui();
}
else if (event == LV_EVENT_RELEASED) {
clear_cur_ui();
draw_return_ui();
}
break; break;
} }
} }
void lv_draw_extrusion(void) { void lv_draw_extrusion(void) {
lv_obj_t *buttonAdd, *buttonDec, *buttonBack;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != EXTRUSION_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != EXTRUSION_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = EXTRUSION_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = EXTRUSION_UI;
} }
disp_state = EXTRUSION_UI; disp_state = EXTRUSION_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
// Create image buttons // Create image buttons
buttonAdd = lv_imgbtn_create(scr, "F:/bmp_in.bin", INTERVAL_V, titleHeight, event_handler, ID_E_ADD); lv_obj_t *buttonAdd = lv_big_button_create(scr, "F:/bmp_in.bin", extrude_menu.in, INTERVAL_V, titleHeight, event_handler, ID_E_ADD);
lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW); lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW);
lv_big_button_create(scr, "F:/bmp_out.bin", extrude_menu.out, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_E_DEC);
buttonDec = lv_imgbtn_create(scr, "F:/bmp_out.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_E_DEC); buttonType = lv_imgbtn_create(scr, nullptr, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_E_TYPE);
buttonType = lv_imgbtn_create(scr, NULL, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_E_TYPE); buttonStep = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_E_STEP);
buttonStep = lv_imgbtn_create(scr, NULL, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_E_STEP); buttonSpeed = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_E_SPEED);
buttonSpeed = lv_imgbtn_create(scr, NULL, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_E_SPEED);
buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_E_RETURN);
// Create labels on the image buttons
lv_obj_t *labelAdd = lv_label_create_empty(buttonAdd);
lv_obj_t *labelDec = lv_label_create_empty(buttonDec);
labelType = lv_label_create_empty(buttonType);
labelStep = lv_label_create_empty(buttonStep);
labelSpeed = lv_label_create_empty(buttonSpeed);
lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.multiple_language) {
lv_label_set_text(labelAdd, extrude_menu.in);
lv_obj_align(labelAdd, buttonAdd, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(labelDec, extrude_menu.out);
lv_obj_align(labelDec, buttonDec, 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 HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) { if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonAdd);
lv_group_add_obj(g, buttonDec);
lv_group_add_obj(g, buttonType); lv_group_add_obj(g, buttonType);
lv_group_add_obj(g, buttonStep); lv_group_add_obj(g, buttonStep);
lv_group_add_obj(g, buttonSpeed); lv_group_add_obj(g, buttonSpeed);
lv_group_add_obj(g, buttonBack);
} }
#endif #endif
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_E_RETURN);
// Create labels on the image buttons
labelType = lv_label_create_empty(buttonType);
labelStep = lv_label_create_empty(buttonStep);
labelSpeed = lv_label_create_empty(buttonSpeed);
disp_ext_type(); disp_ext_type();
disp_ext_step(); disp_ext_step();
disp_ext_speed(); disp_ext_speed();
@ -265,12 +214,11 @@ void disp_ext_speed() {
void disp_hotend_temp() { void disp_hotend_temp() {
char buf[20] = {0}; char buf[20] = {0};
public_buf_l[0] = '\0';
strcat(public_buf_l, extrude_menu.temper_text);
sprintf(buf, extrude_menu.temp_value, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target); sprintf(buf, extrude_menu.temp_value, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target);
strcpy(public_buf_l, extrude_menu.temper_text);
strcat(public_buf_l, buf); strcat(public_buf_l, buf);
lv_label_set_text(tempText, public_buf_l); lv_label_set_text(tempText, public_buf_l);
lv_obj_align(tempText, NULL, LV_ALIGN_CENTER, 0, -50); lv_obj_align(tempText, nullptr, LV_ALIGN_CENTER, 0, -50);
} }
void disp_extru_amount() { void disp_extru_amount() {
@ -278,33 +226,17 @@ void disp_extru_amount() {
public_buf_l[0] = '\0'; public_buf_l[0] = '\0';
if (extructAmount < 999 && extructAmount > -99) { if (extrudeAmount < 999 && extrudeAmount > -99)
sprintf(buf1, extrude_menu.count_value_mm, extructAmount); sprintf(buf1, extrude_menu.count_value_mm, extrudeAmount);
if (uiCfg.curSprayerChoose < 1) else if (extrudeAmount < 9999 && extrudeAmount > -999)
strcat(public_buf_l, extrude_menu.ext1); sprintf(buf1, extrude_menu.count_value_cm, extrudeAmount / 10);
else else
strcat(public_buf_l, extrude_menu.ext2); sprintf(buf1, extrude_menu.count_value_m, extrudeAmount / 1000);
strcat(public_buf_l, buf1); strcat(public_buf_l, uiCfg.curSprayerChoose < 1 ? extrude_menu.ext1 : extrude_menu.ext2);
} strcat(public_buf_l, buf1);
else if (extructAmount < 9999 && extructAmount > -999) {
sprintf(buf1, extrude_menu.count_value_cm, extructAmount / 10);
if (uiCfg.curSprayerChoose < 1)
strcat(public_buf_l, extrude_menu.ext1);
else
strcat(public_buf_l, extrude_menu.ext2);
strcat(public_buf_l, buf1);
}
else {
sprintf(buf1, extrude_menu.count_value_m, extructAmount / 1000);
if (uiCfg.curSprayerChoose < 1)
strcat(public_buf_l, extrude_menu.ext1);
else
strcat(public_buf_l, extrude_menu.ext2);
strcat(public_buf_l, buf1);
}
lv_label_set_text(ExtruText, public_buf_l); lv_label_set_text(ExtruText, public_buf_l);
lv_obj_align(ExtruText, NULL, LV_ALIGN_CENTER, 0, -75); lv_obj_align(ExtruText, nullptr, LV_ALIGN_CENTER, 0, -75);
} }
void disp_ext_step() { void disp_ext_step() {

View file

@ -35,87 +35,56 @@
#include "../../../../gcode/gcode.h" #include "../../../../gcode/gcode.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
static lv_obj_t * fanText; static lv_obj_t *fanText;
#define ID_F_ADD 1 enum {
#define ID_F_DEC 2 ID_F_ADD = 1,
#define ID_F_HIGH 3 ID_F_DEC,
#define ID_F_MID 4 ID_F_HIGH,
#define ID_F_OFF 5 ID_F_MID,
#define ID_F_RETURN 6 ID_F_OFF,
ID_F_RETURN
};
static uint8_t fanSpeed; static uint8_t fanSpeed;
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_F_ADD: case ID_F_ADD:
if (event == LV_EVENT_CLICKED) { if (fanSpeed + 1 <= 255) {
// nothing to do fanSpeed++;
} sprintf_P(public_buf_l, PSTR("M106 S%d"), fanSpeed);
else if (event == LV_EVENT_RELEASED) { gcode.process_subcommands_now(public_buf_l);
if (fanSpeed + 1 <= 255) {
fanSpeed++;
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("M106 S%d"), fanSpeed);
gcode.process_subcommands_now(public_buf_l);
}
} }
break; break;
case ID_F_DEC: case ID_F_DEC:
if (event == LV_EVENT_CLICKED) { if (fanSpeed > 0) {
// nothing to do fanSpeed--;
sprintf_P(public_buf_l, PSTR("M106 S%d"), fanSpeed);
gcode.process_subcommands_now(public_buf_l);
} }
else if (event == LV_EVENT_RELEASED) {
if (fanSpeed > 0) {
fanSpeed--;
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("M106 S%d"), fanSpeed);
gcode.process_subcommands_now(public_buf_l);
}
}
break; break;
case ID_F_HIGH: case ID_F_HIGH:
if (event == LV_EVENT_CLICKED) { gcode.process_subcommands_now_P(PSTR("M106 S255"));
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
gcode.process_subcommands_now_P(PSTR("M106 S255"));
}
break; break;
case ID_F_MID: case ID_F_MID:
if (event == LV_EVENT_CLICKED) { gcode.process_subcommands_now_P(PSTR("M106 S127"));
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
gcode.process_subcommands_now_P(PSTR("M106 S127"));
}
break; break;
case ID_F_OFF: case ID_F_OFF:
if (event == LV_EVENT_CLICKED) { gcode.process_subcommands_now_P(PSTR("M107"));
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
gcode.process_subcommands_now_P(PSTR("M107"));
}
break; break;
case ID_F_RETURN: case ID_F_RETURN:
if (event == LV_EVENT_CLICKED) { clear_cur_ui();
// nothing to do draw_return_ui();
}
else if (event == LV_EVENT_RELEASED) {
clear_cur_ui();
draw_return_ui();
}
break; break;
} }
} }
void lv_draw_fan(void) { void lv_draw_fan(void) {
lv_obj_t *buttonAdd, *buttonDec, *buttonHigh, *buttonMid; lv_obj_t *buttonAdd;
lv_obj_t *buttonOff, *buttonBack;
#if HAS_FAN #if HAS_FAN
fanSpeed = thermalManager.fan_speed[0]; fanSpeed = thermalManager.fan_speed[0];
@ -126,63 +95,20 @@ void lv_draw_fan(void) {
} }
disp_state = FAN_UI; disp_state = FAN_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
// Create an Image button // Create an Image button
buttonAdd = lv_imgbtn_create(scr, "F:/bmp_Add.bin", INTERVAL_V, titleHeight, event_handler, ID_F_ADD); buttonAdd = lv_big_button_create(scr, "F:/bmp_Add.bin", fan_menu.add, INTERVAL_V, titleHeight, event_handler, ID_F_ADD);
lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW); lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW);
lv_big_button_create(scr, "F:/bmp_Dec.bin", fan_menu.dec, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_F_DEC);
buttonDec = lv_imgbtn_create(scr, "F:/bmp_Dec.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_F_DEC); lv_big_button_create(scr, "F:/bmp_speed255.bin", fan_menu.full, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_F_HIGH);
buttonHigh = lv_imgbtn_create(scr, "F:/bmp_speed255.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_F_HIGH); lv_big_button_create(scr, "F:/bmp_speed127.bin", fan_menu.half, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_F_MID);
buttonMid = lv_imgbtn_create(scr, "F:/bmp_speed127.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_F_MID); lv_big_button_create(scr, "F:/bmp_speed0.bin", fan_menu.off, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_F_OFF);
buttonOff = lv_imgbtn_create(scr, "F:/bmp_speed0.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_F_OFF); lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_F_RETURN);
buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_F_RETURN);
// Create labels on the image buttons
lv_obj_t *labelAdd = lv_label_create_empty(buttonAdd);
lv_obj_t *labelDec = lv_label_create_empty(buttonDec);
lv_obj_t *labelHigh = lv_label_create_empty(buttonHigh);
lv_obj_t *labelMid = lv_label_create_empty(buttonMid);
lv_obj_t *labelOff = lv_label_create_empty(buttonOff);
lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.multiple_language) {
lv_label_set_text(labelAdd, fan_menu.add);
lv_obj_align(labelAdd, buttonAdd, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(labelDec, fan_menu.dec);
lv_obj_align(labelDec, buttonDec, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(labelHigh, fan_menu.full);
lv_obj_align(labelHigh, buttonHigh, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(labelMid, fan_menu.half);
lv_obj_align(labelMid, buttonMid, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(labelOff, fan_menu.off);
lv_obj_align(labelOff, buttonOff, 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, buttonAdd);
lv_group_add_obj(g, buttonDec);
lv_group_add_obj(g, buttonHigh);
lv_group_add_obj(g, buttonMid);
lv_group_add_obj(g, buttonOff);
lv_group_add_obj(g, buttonBack);
}
#endif
fanText = lv_label_create_empty(scr); fanText = lv_label_create_empty(scr);
lv_obj_set_style(fanText, &tft_style_label_rel); lv_obj_set_style(fanText, &tft_style_label_rel);
@ -197,7 +123,7 @@ void disp_fan_value() {
sprintf_P(buf1, PSTR("%3d"), thermalManager.fan_speed[0]); sprintf_P(buf1, PSTR("%3d"), thermalManager.fan_speed[0]);
strcat(public_buf_l, buf1); strcat(public_buf_l, buf1);
lv_label_set_text(fanText, public_buf_l); lv_label_set_text(fanText, public_buf_l);
lv_obj_align(fanText, NULL, LV_ALIGN_CENTER, 0, -65); lv_obj_align(fanText, nullptr, LV_ALIGN_CENTER, 0, -65);
} }
void lv_clear_fan() { void lv_clear_fan() {

View file

@ -38,150 +38,109 @@ static lv_obj_t *buttonType;
static lv_obj_t *labelType; static lv_obj_t *labelType;
static lv_obj_t *tempText1; static lv_obj_t *tempText1;
#define ID_FILAMNT_IN 1 enum {
#define ID_FILAMNT_OUT 2 ID_FILAMNT_IN = 1,
#define ID_FILAMNT_TYPE 3 ID_FILAMNT_OUT,
#define ID_FILAMNT_RETURN 4 ID_FILAMNT_TYPE,
ID_FILAMNT_RETURN
};
extern feedRate_t feedrate_mm_s; extern feedRate_t feedrate_mm_s;
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_FILAMNT_IN: case ID_FILAMNT_IN:
if (event == LV_EVENT_CLICKED) { uiCfg.filament_load_heat_flg = 1;
// nothing to do 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 if (event == LV_EVENT_RELEASED) { else {
uiCfg.filament_load_heat_flg = 1; lv_clear_filament_change();
if ((abs(thermalManager.temp_hotend[uiCfg.curSprayerChoose].target - thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius) <= 1) lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_HEAT);
|| (gCfgItems.filament_limit_temper <= thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius)) { if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].target < gCfgItems.filament_limit_temper) {
lv_clear_filament_change(); thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = gCfgItems.filament_limit_temper;
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED); thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
}
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; break;
case ID_FILAMNT_OUT: case ID_FILAMNT_OUT:
if (event == LV_EVENT_CLICKED) { uiCfg.filament_unload_heat_flg=1;
// nothing to do 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 if (event == LV_EVENT_RELEASED) { else {
uiCfg.filament_unload_heat_flg=1; lv_clear_filament_change();
if ((thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > 0) lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_HEAT);
&& ((abs((int)((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target - thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius)) <= 1) if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].target < gCfgItems.filament_limit_temper) {
|| ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= gCfgItems.filament_limit_temper)) thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = gCfgItems.filament_limit_temper;
) { thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
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();
} }
filament_sprayer_temp();
} }
break; break;
case ID_FILAMNT_TYPE: case ID_FILAMNT_TYPE:
if (event == LV_EVENT_CLICKED) { #if HAS_MULTI_EXTRUDER
// nothing to do if (uiCfg.curSprayerChoose == 0)
} uiCfg.curSprayerChoose = 1;
else if (event == LV_EVENT_RELEASED) { else if (uiCfg.curSprayerChoose == 1)
#if HAS_MULTI_EXTRUDER uiCfg.curSprayerChoose = 0;
if (uiCfg.curSprayerChoose == 0) #endif
uiCfg.curSprayerChoose = 1; disp_filament_type();
else if (uiCfg.curSprayerChoose == 1)
uiCfg.curSprayerChoose = 0;
#endif
disp_filament_type();
}
break; break;
case ID_FILAMNT_RETURN: case ID_FILAMNT_RETURN:
if (event == LV_EVENT_CLICKED) { #if HAS_MULTI_EXTRUDER
// nothing to do if (uiCfg.print_state != IDLE && uiCfg.print_state != REPRINTED)
} gcode.process_subcommands_now_P(uiCfg.curSprayerChoose_bak == 1 ? PSTR("T1") : PSTR("T0"));
else if (event == LV_EVENT_RELEASED) { #endif
#if HAS_MULTI_EXTRUDER feedrate_mm_s = (float)uiCfg.moveSpeed_bak;
if (uiCfg.print_state != IDLE && uiCfg.print_state != REPRINTED) if (uiCfg.print_state == PAUSED)
gcode.process_subcommands_now_P(uiCfg.curSprayerChoose_bak == 1 ? PSTR("T1") : PSTR("T0")); planner.set_e_position_mm((destination.e = current_position.e = uiCfg.current_e_position_bak));
#endif //current_position.e = destination.e = uiCfg.current_e_position_bak;
feedrate_mm_s = (float)uiCfg.moveSpeed_bak; thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = uiCfg.desireSprayerTempBak;
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(); clear_cur_ui();
draw_return_ui(); draw_return_ui();
}
break; break;
} }
} }
void lv_draw_filament_change(void) { 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) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != FILAMENTCHANGE_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = FILAMENTCHANGE_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = FILAMENTCHANGE_UI;
} }
disp_state = FILAMENTCHANGE_UI; disp_state = FILAMENTCHANGE_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
// Create an Image button // Create an Image button
buttonIn = lv_imgbtn_create(scr, "F:/bmp_in.bin", INTERVAL_V, titleHeight, event_handler, ID_FILAMNT_IN); lv_obj_t *buttonIn = lv_big_button_create(scr, "F:/bmp_in.bin", filament_menu.in, INTERVAL_V, titleHeight, event_handler, ID_FILAMNT_IN);
lv_obj_clear_protect(buttonIn, LV_PROTECT_FOLLOW); lv_obj_clear_protect(buttonIn, LV_PROTECT_FOLLOW);
lv_big_button_create(scr, "F:/bmp_out.bin", filament_menu.out, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_FILAMNT_OUT);
buttonOut = lv_imgbtn_create(scr, "F:/bmp_out.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_FILAMNT_OUT); buttonType = lv_imgbtn_create(scr, nullptr, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_FILAMNT_TYPE);
buttonType = lv_imgbtn_create(scr, NULL, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_FILAMNT_TYPE);
buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_FILAMNT_RETURN);
// Create labels on the image buttons
lv_obj_t *labelIn = lv_label_create_empty(buttonIn);
lv_obj_t *labelOut = lv_label_create_empty(buttonOut);
labelType = lv_label_create_empty(buttonType);
lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.multiple_language) {
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 HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) { if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonIn);
lv_group_add_obj(g, buttonOut);
lv_group_add_obj(g, buttonType); lv_group_add_obj(g, buttonType);
lv_group_add_obj(g, buttonBack);
} }
#endif #endif
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_FILAMNT_RETURN);
// Create labels on the image buttons
labelType = lv_label_create_empty(buttonType);
disp_filament_type(); disp_filament_type();
tempText1 = lv_label_create_empty(scr); tempText1 = lv_label_create_empty(scr);
@ -211,16 +170,13 @@ void disp_filament_temp() {
public_buf_l[0] = '\0'; public_buf_l[0] = '\0';
if (uiCfg.curSprayerChoose < 1) strcat(public_buf_l, uiCfg.curSprayerChoose < 1 ? preheat_menu.ext1 : preheat_menu.ext2);
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); 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_P(public_buf_l, PSTR(": "));
strcat(public_buf_l, buf); strcat(public_buf_l, buf);
lv_label_set_text(tempText1, public_buf_l); lv_label_set_text(tempText1, public_buf_l);
lv_obj_align(tempText1, NULL, LV_ALIGN_CENTER, 0, -50); lv_obj_align(tempText1, nullptr, LV_ALIGN_CENTER, 0, -50);
} }
void lv_clear_filament_change() { void lv_clear_filament_change() {

View file

@ -28,233 +28,102 @@
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_FILAMENT_SET_RETURN 1 enum {
#define ID_FILAMENT_SET_IN_LENGTH 2 ID_FILAMENT_SET_RETURN = 1,
#define ID_FILAMENT_SET_IN_SPEED 3 ID_FILAMENT_SET_IN_LENGTH,
#define ID_FILAMENT_SET_OUT_LENGTH 4 ID_FILAMENT_SET_IN_SPEED,
#define ID_FILAMENT_SET_OUT_SPEED 5 ID_FILAMENT_SET_OUT_LENGTH,
#define ID_FILAMENT_SET_TEMP 6 ID_FILAMENT_SET_OUT_SPEED,
#define ID_FILAMENT_SET_DOWN 12 ID_FILAMENT_SET_TEMP,
#define ID_FILAMENT_SET_UP 13 ID_FILAMENT_SET_DOWN,
ID_FILAMENT_SET_UP
};
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_FILAMENT_SET_RETURN: case ID_FILAMENT_SET_RETURN:
if (event == LV_EVENT_CLICKED) { uiCfg.para_ui_page = 0;
lv_clear_filament_settings();
} draw_return_ui();
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 0;
lv_clear_filament_settings();
draw_return_ui();
}
break; break;
case ID_FILAMENT_SET_IN_LENGTH: case ID_FILAMENT_SET_IN_LENGTH:
if (event == LV_EVENT_CLICKED) { value = load_length;
lv_clear_filament_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = load_length;
lv_clear_filament_settings();
lv_draw_number_key();
}
break; break;
case ID_FILAMENT_SET_IN_SPEED: case ID_FILAMENT_SET_IN_SPEED:
if (event == LV_EVENT_CLICKED) { value = load_speed;
lv_clear_filament_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = load_speed;
lv_clear_filament_settings();
lv_draw_number_key();
}
break; break;
case ID_FILAMENT_SET_OUT_LENGTH: case ID_FILAMENT_SET_OUT_LENGTH:
if (event == LV_EVENT_CLICKED) { value = unload_length;
lv_clear_filament_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = unload_length;
lv_clear_filament_settings();
lv_draw_number_key();
}
break; break;
case ID_FILAMENT_SET_OUT_SPEED: case ID_FILAMENT_SET_OUT_SPEED:
if (event == LV_EVENT_CLICKED) { value = unload_speed;
lv_clear_filament_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = unload_speed;
lv_clear_filament_settings();
lv_draw_number_key();
}
break; break;
case ID_FILAMENT_SET_TEMP: case ID_FILAMENT_SET_TEMP:
if (event == LV_EVENT_CLICKED) { value = filament_temp;
lv_clear_filament_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = filament_temp;
lv_clear_filament_settings();
lv_draw_number_key();
}
break; break;
case ID_FILAMENT_SET_UP: case ID_FILAMENT_SET_UP:
if (event == LV_EVENT_CLICKED) { uiCfg.para_ui_page = 0;
lv_clear_filament_settings();
} lv_draw_filament_settings();
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 0;
lv_clear_filament_settings();
lv_draw_filament_settings();
}
break; break;
case ID_FILAMENT_SET_DOWN: case ID_FILAMENT_SET_DOWN:
if (event == LV_EVENT_CLICKED) { uiCfg.para_ui_page = 1;
lv_clear_filament_settings();
} lv_draw_filament_settings();
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 1;
lv_clear_filament_settings();
lv_draw_filament_settings();
}
break; break;
} }
} }
void lv_draw_filament_settings(void) { void lv_draw_filament_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL;
lv_obj_t *buttonInLengthValue = NULL, *labelInLengthValue = NULL;
lv_obj_t *buttonInSpeedValue = NULL, *labelInSpeedValue = NULL;
lv_obj_t *buttonOutLengthValue = NULL, *labelOutLengthValue = NULL;
lv_obj_t *buttonOutSpeedValue = NULL, *labelOutSpeedValue = NULL;
lv_obj_t *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) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != FILAMENT_SETTINGS_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = FILAMENT_SETTINGS_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = FILAMENT_SETTINGS_UI;
} }
disp_state = FILAMENT_SETTINGS_UI; disp_state = FILAMENT_SETTINGS_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.FilamentConfTitle); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.FilamentConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
if (uiCfg.para_ui_page != 1) { if (uiCfg.para_ui_page != 1) {
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.InLength); sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_load_length);
lv_screen_menu_item_1_edit(scr, machine_menu.InLength, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_FILAMENT_SET_IN_LENGTH, 0, public_buf_l);
buttonInLengthValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_FILAMENT_SET_IN_LENGTH); sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_load_speed);
labelInLengthValue = lv_label_create_empty(buttonInLengthValue); lv_screen_menu_item_1_edit(scr, machine_menu.InSpeed, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_FILAMENT_SET_IN_SPEED, 1, public_buf_l);
line1 = lv_line_create(scr, NULL); sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_unload_length);
lv_ex_line(line1, line_points[0]); lv_screen_menu_item_1_edit(scr, machine_menu.OutLength, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_FILAMENT_SET_OUT_LENGTH, 2, public_buf_l);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, machine_menu.InSpeed); sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_unload_speed);
lv_screen_menu_item_1_edit(scr, machine_menu.OutSpeed, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_FILAMENT_SET_OUT_SPEED, 3, public_buf_l);
buttonInSpeedValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_FILAMENT_SET_IN_SPEED); lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_FILAMENT_SET_DOWN, true);
labelInSpeedValue = lv_label_create_empty(buttonInSpeedValue);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 6, machine_menu.OutLength);
buttonOutLengthValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_FILAMENT_SET_OUT_LENGTH);
labelOutLengthValue = lv_label_create_empty(buttonOutLengthValue);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, machine_menu.OutSpeed);
buttonOutSpeedValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_FILAMENT_SET_OUT_SPEED);
labelOutSpeedValue = lv_label_create_empty(buttonOutSpeedValue);
line4 = lv_line_create(scr, NULL);
lv_ex_line(line4, line_points[3]);
buttonTurnPage = lv_btn_create_back(scr, event_handler, ID_FILAMENT_SET_DOWN);
#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 { else {
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.FilamentTemperature); sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filament_limit_temper);
lv_screen_menu_item_1_edit(scr, machine_menu.FilamentTemperature, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_FILAMENT_SET_TEMP, 0, public_buf_l);
buttonTemperValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_FILAMENT_SET_TEMP); lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_FILAMENT_SET_UP, true);
labelTemperValue = lv_label_create_empty(buttonTemperValue);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonTurnPage = lv_btn_create_back(scr, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE, event_handler, ID_FILAMENT_SET_UP);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonTemperValue);
lv_group_add_obj(g, buttonTurnPage);
}
#endif
} }
labelTurnPage = lv_label_create_empty(buttonTurnPage); lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_FILAMENT_SET_RETURN, true);
buttonBack = lv_btn_create_back(scr, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE, event_handler, ID_FILAMENT_SET_RETURN);
label_Back = lv_label_create_empty(buttonBack);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif
if (gCfgItems.multiple_language) {
if (uiCfg.para_ui_page != 1) {
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);
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);
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);
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 {
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() { void lv_clear_filament_settings() {

View file

@ -35,149 +35,67 @@
#include "../../../../gcode/queue.h" #include "../../../../gcode/queue.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_H_ALL 1 enum {
#define ID_H_X 2 ID_H_ALL = 1,
#define ID_H_Y 3 ID_H_X,
#define ID_H_Z 4 ID_H_Y,
#define ID_H_RETURN 5 ID_H_Z,
#define ID_H_OFF_ALL 6 ID_H_RETURN,
#define ID_H_OFF_XY 7 ID_H_OFF_ALL,
ID_H_OFF_XY
};
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_H_ALL: case ID_H_ALL:
if (event == LV_EVENT_CLICKED) { queue.inject_P(PSTR("G28"));
}
else if (event == LV_EVENT_RELEASED) {
queue.inject_P(PSTR("G28"));
}
break; break;
case ID_H_X: case ID_H_X:
if (event == LV_EVENT_CLICKED) { queue.inject_P(PSTR("G28 X0"));
}
else if (event == LV_EVENT_RELEASED) {
queue.inject_P(PSTR("G28 X0"));
}
break; break;
case ID_H_Y: case ID_H_Y:
if (event == LV_EVENT_CLICKED) { queue.inject_P(PSTR("G28 Y0"));
}
else if (event == LV_EVENT_RELEASED) {
queue.inject_P(PSTR("G28 Y0"));
}
break; break;
case ID_H_Z: case ID_H_Z:
if (event == LV_EVENT_CLICKED) { queue.inject_P(PSTR("G28 Z0"));
}
else if (event == LV_EVENT_RELEASED) {
queue.inject_P(PSTR("G28 Z0"));
}
break; break;
case ID_H_OFF_ALL: case ID_H_OFF_ALL:
if (event == LV_EVENT_CLICKED) { queue.inject_P(PSTR("M84"));
}
else if (event == LV_EVENT_RELEASED) {
queue.inject_P(PSTR("M84"));
}
break; break;
case ID_H_OFF_XY: case ID_H_OFF_XY:
if (event == LV_EVENT_CLICKED) { queue.inject_P(PSTR("M84 X Y"));
}
else if (event == LV_EVENT_RELEASED) {
queue.inject_P(PSTR("M84 X Y"));
}
break; break;
case ID_H_RETURN: case ID_H_RETURN:
if (event == LV_EVENT_CLICKED) { lv_clear_home();
} lv_draw_tool();
else if (event == LV_EVENT_RELEASED) {
lv_clear_home();
lv_draw_tool();
}
break; break;
} }
} }
void lv_draw_home(void) { void lv_draw_home(void) {
lv_obj_t *buttonHomeAll, *buttonHomeX, *buttonHomeY, *buttonHomeZ;
lv_obj_t *buttonBack;
lv_obj_t *buttonOffAll, *buttonOffXY;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ZERO_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ZERO_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = ZERO_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = ZERO_UI;
} }
disp_state = ZERO_UI; disp_state = ZERO_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
//static lv_style_t tool_style;
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
// Create image buttons lv_big_button_create(scr, "F:/bmp_zeroAll.bin", home_menu.home_all, INTERVAL_V, titleHeight, event_handler, ID_H_ALL);
//buttonWifi = lv_imgbtn_create(scr, NULL); lv_big_button_create(scr, "F:/bmp_zeroX.bin", home_menu.home_x, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_H_X);
//buttonContinue = lv_imgbtn_create(scr, NULL); lv_big_button_create(scr, "F:/bmp_zeroY.bin", home_menu.home_y, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_H_Y);
buttonHomeAll = lv_imgbtn_create(scr, "F:/bmp_zeroAll.bin", INTERVAL_V, titleHeight, event_handler, ID_H_ALL); lv_big_button_create(scr, "F:/bmp_zeroZ.bin", home_menu.home_z, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_H_Z);
buttonHomeX = lv_imgbtn_create(scr, "F:/bmp_zeroX.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_H_X); lv_big_button_create(scr, "F:/bmp_function1.bin", set_menu.motoroff, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_H_OFF_ALL);
buttonHomeY = lv_imgbtn_create(scr, "F:/bmp_zeroY.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_H_Y); lv_big_button_create(scr, "F:/bmp_function1.bin", set_menu.motoroffXY, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_H_OFF_XY);
buttonHomeZ = lv_imgbtn_create(scr, "F:/bmp_zeroZ.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_H_Z); lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_H_RETURN);
buttonOffAll = lv_imgbtn_create(scr, "F:/bmp_function1.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_H_OFF_ALL);
buttonOffXY = lv_imgbtn_create(scr, "F:/bmp_function1.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_H_OFF_XY);
buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_H_RETURN);
// Create labels on the image buttons
lv_obj_t *labelHomeAll = lv_label_create_empty(buttonHomeAll);
lv_obj_t *labelHomeX = lv_label_create_empty(buttonHomeX);
lv_obj_t *labelHomeY = lv_label_create_empty(buttonHomeY);
lv_obj_t *labelHomeZ = lv_label_create_empty(buttonHomeZ);
lv_obj_t *labelOffAll = lv_label_create_empty(buttonOffAll);
lv_obj_t *labelOffXY = lv_label_create_empty(buttonOffXY);
lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.multiple_language) {
lv_label_set_text(labelHomeAll, home_menu.home_all);
lv_obj_align(labelHomeAll, buttonHomeAll, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(labelHomeX, home_menu.home_x);
lv_obj_align(labelHomeX, buttonHomeX, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(labelHomeY, home_menu.home_y);
lv_obj_align(labelHomeY, buttonHomeY, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(labelHomeZ, home_menu.home_z);
lv_obj_align(labelHomeZ, buttonHomeZ, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(labelOffAll, set_menu.motoroff);
lv_obj_align(labelOffAll, buttonOffAll, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(labelOffXY, set_menu.motoroffXY);
lv_obj_align(labelOffXY, buttonOffXY, 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, buttonHomeAll);
lv_group_add_obj(g, buttonHomeX);
lv_group_add_obj(g, buttonHomeY);
lv_group_add_obj(g, buttonHomeZ);
lv_group_add_obj(g, buttonOffAll);
lv_group_add_obj(g, buttonOffXY);
lv_group_add_obj(g, buttonBack);
}
#endif
} }
void lv_clear_home() { void lv_clear_home() {

View file

@ -31,180 +31,75 @@
#include "../../../../module/stepper/indirection.h" #include "../../../../module/stepper/indirection.h"
#include "../../../../feature/tmc_util.h" #include "../../../../feature/tmc_util.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_SENSITIVITY_RETURN 1 enum {
#define ID_SENSITIVITY_X 2 ID_SENSITIVITY_RETURN = 1,
#define ID_SENSITIVITY_Y 3 ID_SENSITIVITY_X,
#define ID_SENSITIVITY_Z 4 ID_SENSITIVITY_Y,
#define ID_SENSITIVITY_Z2 5 ID_SENSITIVITY_Z,
ID_SENSITIVITY_Z2
};
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_SENSITIVITY_RETURN: case ID_SENSITIVITY_RETURN:
if (event == LV_EVENT_CLICKED) { lv_clear_homing_sensitivity_settings();
draw_return_ui();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_homing_sensitivity_settings();
draw_return_ui();
}
break; break;
case ID_SENSITIVITY_X: case ID_SENSITIVITY_X:
if (event == LV_EVENT_CLICKED) { value = x_sensitivity;
lv_clear_homing_sensitivity_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = x_sensitivity;
lv_clear_homing_sensitivity_settings();
lv_draw_number_key();
}
break; break;
case ID_SENSITIVITY_Y: case ID_SENSITIVITY_Y:
if (event == LV_EVENT_CLICKED) { value = y_sensitivity;
lv_clear_homing_sensitivity_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = y_sensitivity;
lv_clear_homing_sensitivity_settings();
lv_draw_number_key();
}
break; break;
case ID_SENSITIVITY_Z: case ID_SENSITIVITY_Z:
if (event == LV_EVENT_CLICKED) { value = z_sensitivity;
lv_clear_homing_sensitivity_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = z_sensitivity;
lv_clear_homing_sensitivity_settings();
lv_draw_number_key();
}
break; break;
#if Z2_SENSORLESS #if Z2_SENSORLESS
case ID_SENSITIVITY_Z2: case ID_SENSITIVITY_Z2:
if (event == LV_EVENT_CLICKED) { value = z2_sensitivity;
lv_clear_homing_sensitivity_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = z2_sensitivity;
lv_clear_homing_sensitivity_settings();
lv_draw_number_key();
}
break; break;
#endif #endif
} }
} }
void lv_draw_homing_sensitivity_settings(void) { void lv_draw_homing_sensitivity_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL;
lv_obj_t *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL;
#if Z2_SENSORLESS
lv_obj_t *buttonZ2Value = NULL, *labelZ2Value = NULL;
lv_obj_t *line4 = NULL;
#endif
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != HOMING_SENSITIVITY_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != HOMING_SENSITIVITY_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = HOMING_SENSITIVITY_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = HOMING_SENSITIVITY_UI;
} }
disp_state = HOMING_SENSITIVITY_UI; disp_state = HOMING_SENSITIVITY_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.HomingSensitivityConfTitle); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.HomingSensitivityConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.X_Sensitivity); sprintf_P(public_buf_l, PSTR("%d"), TERN(X_SENSORLESS, stepperX.homing_threshold(), 0));
lv_screen_menu_item_1_edit(scr, machine_menu.X_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_SENSITIVITY_X, 0, public_buf_l);
buttonXValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_SENSITIVITY_X); sprintf_P(public_buf_l, PSTR("%d"), TERN(Y_SENSORLESS, stepperY.homing_threshold(), 0));
labelXValue = lv_label_create_empty(buttonXValue); lv_screen_menu_item_1_edit(scr, machine_menu.Y_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_SENSITIVITY_Y, 1, public_buf_l);
#if HAS_ROTARY_ENCODER sprintf_P(public_buf_l, PSTR("%d"), TERN(Z_SENSORLESS, stepperZ.homing_threshold(), 0));
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonXValue); lv_screen_menu_item_1_edit(scr, machine_menu.Z_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_SENSITIVITY_Z, 2, public_buf_l);
#endif
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, machine_menu.Y_Sensitivity);
buttonYValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_SENSITIVITY_Y);
labelYValue = lv_label_create_empty(buttonYValue);
#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]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, machine_menu.Z_Sensitivity);
buttonZValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_SENSITIVITY_Z);
labelZValue = lv_label_create_empty(buttonZValue);
#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 #if Z2_SENSORLESS
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, machine_menu.Z2_Sensitivity); sprintf_P(public_buf_l, PSTR("%d"), TERN(Z2_SENSORLESS, stepperZ2.homing_threshold(), 0));
lv_screen_menu_item_1_edit(scr, machine_menu.Z2_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_SENSITIVITY_Z2, 3, public_buf_l);
buttonZ2Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_SENSITIVITY_Z2);
labelZ2Value = lv_label_create_empty(buttonZ2Value);
#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 #endif
buttonBack = lv_btn_create_back(scr, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE, event_handler, ID_SENSITIVITY_RETURN); lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_SENSITIVITY_RETURN, true);
label_Back = lv_label_create_empty(buttonBack);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif
if (gCfgItems.multiple_language) {
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() { void lv_clear_homing_sensitivity_settings() {

View file

@ -29,161 +29,71 @@
#include "../../../../module/planner.h" #include "../../../../module/planner.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_JERK_RETURN 1 enum {
#define ID_JERK_X 2 ID_JERK_RETURN = 1,
#define ID_JERK_Y 3 ID_JERK_X,
#define ID_JERK_Z 4 ID_JERK_Y,
#define ID_JERK_E 5 ID_JERK_Z,
ID_JERK_E
};
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_JERK_RETURN: case ID_JERK_RETURN:
if (event == LV_EVENT_CLICKED) { lv_clear_jerk_settings();
draw_return_ui();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_jerk_settings();
draw_return_ui();
}
break; break;
case ID_JERK_X: case ID_JERK_X:
if (event == LV_EVENT_CLICKED) { value = XJerk;
lv_clear_jerk_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = XJerk;
lv_clear_jerk_settings();
lv_draw_number_key();
}
break; break;
case ID_JERK_Y: case ID_JERK_Y:
if (event == LV_EVENT_CLICKED) { value = YJerk;
lv_clear_jerk_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = YJerk;
lv_clear_jerk_settings();
lv_draw_number_key();
}
break; break;
case ID_JERK_Z: case ID_JERK_Z:
if (event == LV_EVENT_CLICKED) { value = ZJerk;
lv_clear_jerk_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = ZJerk;
lv_clear_jerk_settings();
lv_draw_number_key();
}
break; break;
case ID_JERK_E: case ID_JERK_E:
if (event == LV_EVENT_CLICKED) { value = EJerk;
lv_clear_jerk_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = EJerk;
lv_clear_jerk_settings();
lv_draw_number_key();
}
break; break;
} }
} }
void lv_draw_jerk_settings(void) { void lv_draw_jerk_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL;
lv_obj_t *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t *buttonEValue = NULL, *labelEValue = NULL;
lv_obj_t *line1 = NULL, *line2 = NULL, *line3 = NULL, *line4 = NULL;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != JERK_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != JERK_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = JERK_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = JERK_UI;
} }
disp_state = JERK_UI; disp_state = JERK_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.JerkConfTitle); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.JerkConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.X_Jerk); sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[X_AXIS]);
lv_screen_menu_item_1_edit(scr, machine_menu.X_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_JERK_X, 0, public_buf_l);
buttonXValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_JERK_X); sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[Y_AXIS]);
labelXValue = lv_label_create_empty(buttonXValue); lv_screen_menu_item_1_edit(scr, machine_menu.Y_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_JERK_Y, 1, public_buf_l);
line1 = lv_line_create(scr, NULL); sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[Z_AXIS]);
lv_ex_line(line1, line_points[0]); lv_screen_menu_item_1_edit(scr, machine_menu.Z_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_JERK_Z, 2, public_buf_l);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, machine_menu.Y_Jerk); sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[E_AXIS]);
lv_screen_menu_item_1_edit(scr, machine_menu.E_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_JERK_E, 3, public_buf_l);
buttonYValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_JERK_Y); lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_JERK_RETURN, true);
labelYValue = lv_label_create_empty(buttonYValue);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, machine_menu.Z_Jerk);
buttonZValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_JERK_Z);
labelZValue = lv_label_create_empty(buttonZValue);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, machine_menu.E_Jerk);
buttonEValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_JERK_E);
labelEValue = lv_label_create_empty(buttonEValue);
line4 = lv_line_create(scr, NULL);
lv_ex_line(line4, line_points[3]);
buttonBack = lv_btn_create_back(scr, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE, event_handler, ID_JERK_RETURN);
label_Back = lv_label_create_empty(buttonBack);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable == true) {
lv_group_add_obj(g, buttonXValue);
lv_group_add_obj(g, buttonYValue);
lv_group_add_obj(g, buttonZValue);
lv_group_add_obj(g, buttonEValue);
lv_group_add_obj(g, buttonBack);
}
#endif
if (gCfgItems.multiple_language) {
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[X_AXIS]);
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"), planner.max_jerk[Y_AXIS]);
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"), planner.max_jerk[Z_AXIS]);
lv_label_set_text(labelZValue, public_buf_l);
lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[E_AXIS]);
lv_label_set_text(labelEValue, public_buf_l);
lv_obj_align(labelEValue, buttonEValue, 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_jerk_settings() { void lv_clear_jerk_settings() {

View file

@ -28,8 +28,8 @@
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define LV_KB_CTRL_BTN_FLAGS (LV_BTNM_CTRL_NO_REPEAT | LV_BTNM_CTRL_CLICK_TRIG) #define LV_KB_CTRL_BTN_FLAGS (LV_BTNM_CTRL_NO_REPEAT | LV_BTNM_CTRL_CLICK_TRIG)
@ -72,7 +72,7 @@ static const lv_btnm_ctrl_t kb_ctrl_num_map[] = {
1, 1, 1, 2, 1, 1, 1, 2,
1, 1, 1, 1, 1}; 1, 1, 1, 1, 1};
static void lv_kb_event_cb(lv_obj_t * kb, lv_event_t event) { static void lv_kb_event_cb(lv_obj_t *kb, lv_event_t event) {
//LV_ASSERT_OBJ(kb, LV_OBJX_NAME); //LV_ASSERT_OBJ(kb, LV_OBJX_NAME);
if (event != LV_EVENT_VALUE_CHANGED) return; if (event != LV_EVENT_VALUE_CHANGED) return;
@ -84,7 +84,7 @@ static void lv_kb_event_cb(lv_obj_t * kb, lv_event_t event) {
if (lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_NO_REPEAT) && event == LV_EVENT_LONG_PRESSED_REPEAT) 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); const char * txt = lv_btnm_get_active_btn_text(kb);
if (txt == NULL) return; if (txt == nullptr) return;
// Do the corresponding action according to the text of the button // Do the corresponding action according to the text of the button
if (strcmp(txt, "abc") == 0) { if (strcmp(txt, "abc") == 0) {
@ -104,13 +104,13 @@ static void lv_kb_event_cb(lv_obj_t * kb, lv_event_t event) {
} }
else if (strcmp(txt, LV_SYMBOL_CLOSE) == 0) { else if (strcmp(txt, LV_SYMBOL_CLOSE) == 0) {
if (kb->event_cb != lv_kb_def_event_cb) { if (kb->event_cb != lv_kb_def_event_cb) {
//lv_res_t res = lv_event_send(kb, LV_EVENT_CANCEL, NULL); //lv_res_t res = lv_event_send(kb, LV_EVENT_CANCEL, nullptr);
//if (res != LV_RES_OK) return; //if (res != LV_RES_OK) return;
lv_clear_keyboard(); lv_clear_keyboard();
draw_return_ui(); draw_return_ui();
} }
else { else {
lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/ lv_kb_set_ta(kb, nullptr); /*De-assign the text area to hide it cursor if needed*/
lv_obj_del(kb); lv_obj_del(kb);
return; return;
} }
@ -118,7 +118,7 @@ static void lv_kb_event_cb(lv_obj_t * kb, lv_event_t event) {
} }
else if (strcmp(txt, LV_SYMBOL_OK) == 0) { else if (strcmp(txt, LV_SYMBOL_OK) == 0) {
if (kb->event_cb != lv_kb_def_event_cb) { if (kb->event_cb != lv_kb_def_event_cb) {
//lv_res_t res = lv_event_send(kb, LV_EVENT_APPLY, NULL); //lv_res_t res = lv_event_send(kb, LV_EVENT_APPLY, nullptr);
//if (res != LV_RES_OK) return; //if (res != LV_RES_OK) return;
const char * ret_ta_txt = lv_ta_get_text(ext->ta); const char * ret_ta_txt = lv_ta_get_text(ext->ta);
switch (keyboard_value) { switch (keyboard_value) {
@ -134,18 +134,16 @@ static void lv_kb_event_cb(lv_obj_t * kb, lv_event_t event) {
draw_return_ui(); draw_return_ui();
break; break;
case wifiConfig: case wifiConfig:
memset((void *)uiCfg.wifi_name, 0, sizeof(uiCfg.wifi_name)); ZERO(uiCfg.wifi_name);
memcpy((void *)uiCfg.wifi_name, wifi_list.wifiName[wifi_list.nameIndex], 32); memcpy((void *)uiCfg.wifi_name, wifi_list.wifiName[wifi_list.nameIndex], 32);
memset((void *)uiCfg.wifi_key, 0, sizeof(uiCfg.wifi_key)); ZERO(uiCfg.wifi_key);
memcpy((void *)uiCfg.wifi_key, ret_ta_txt, sizeof(uiCfg.wifi_key)); memcpy((void *)uiCfg.wifi_key, ret_ta_txt, sizeof(uiCfg.wifi_key));
gCfgItems.wifi_mode_sel = STA_MODEL; gCfgItems.wifi_mode_sel = STA_MODEL;
package_to_wifi(WIFI_PARA_SET, (char *)0, 0); 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[0] = 0xA5;
public_buf_l[1] = 0x09; public_buf_l[1] = 0x09;
public_buf_l[2] = 0x01; public_buf_l[2] = 0x01;
@ -172,13 +170,13 @@ static void lv_kb_event_cb(lv_obj_t * kb, lv_event_t event) {
} }
} }
else { else {
lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/ lv_kb_set_ta(kb, nullptr); /*De-assign the text area to hide it cursor if needed*/
} }
return; return;
} }
/*Add the characters to the text area if set*/ /*Add the characters to the text area if set*/
if (ext->ta == NULL) return; if (ext->ta == nullptr) return;
if (strcmp(txt, "Enter") == 0 || strcmp(txt, LV_SYMBOL_NEW_LINE) == 0) if (strcmp(txt, "Enter") == 0 || strcmp(txt, LV_SYMBOL_NEW_LINE) == 0)
lv_ta_add_char(ext->ta, '\n'); lv_ta_add_char(ext->ta, '\n');
@ -221,11 +219,7 @@ void lv_draw_keyboard() {
} }
disp_state = KEY_BOARD_UI; disp_state = KEY_BOARD_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
@ -245,7 +239,7 @@ void lv_draw_keyboard() {
pr_style.body.grad_color = lv_color_make(0x6A, 0x3A, 0x0C); pr_style.body.grad_color = lv_color_make(0x6A, 0x3A, 0x0C);
/*Create a keyboard and apply the styles*/ /*Create a keyboard and apply the styles*/
lv_obj_t *kb = lv_kb_create(scr, NULL); lv_obj_t *kb = lv_kb_create(scr, nullptr);
lv_obj_set_event_cb(kb, lv_kb_event_cb); lv_obj_set_event_cb(kb, lv_kb_event_cb);
lv_kb_set_cursor_manage(kb, true); 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_BG, &lv_style_transp_tight);
@ -259,8 +253,8 @@ void lv_draw_keyboard() {
#endif #endif
/*Create a text area. The keyboard will write here*/ /*Create a text area. The keyboard will write here*/
lv_obj_t *ta = lv_ta_create(scr, NULL); lv_obj_t *ta = lv_ta_create(scr, nullptr);
lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_MID, 0, 10); lv_obj_align(ta, nullptr, LV_ALIGN_IN_TOP_MID, 0, 10);
if (keyboard_value == gcodeCommand) { if (keyboard_value == gcodeCommand) {
get_gcode_command(AUTO_LEVELING_COMMAND_ADDR,(uint8_t *)public_buf_m); get_gcode_command(AUTO_LEVELING_COMMAND_ADDR,(uint8_t *)public_buf_m);
public_buf_m[sizeof(public_buf_m)-1] = 0; public_buf_m[sizeof(public_buf_m)-1] = 0;

View file

@ -33,139 +33,98 @@
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
#include <string.h> #include <string.h>
//static lv_obj_t *buttonMoveZ,*buttonTest,*buttonZ0,*buttonStop,*buttonReturn; enum {
ID_CN = 1,
#define ID_CN 1 ID_T_CN,
#define ID_T_CN 2 ID_EN,
#define ID_EN 3 ID_RU,
#define ID_RU 4 ID_ES,
#define ID_ES 5 ID_FR,
#define ID_FR 6 ID_IT,
#define ID_IT 7 ID_L_RETURN
#define ID_L_RETURN 8 };
#define SELECTED 1 #define SELECTED 1
#define UNSELECTED 0 #define UNSELECTED 0
static void disp_language(uint8_t language, uint8_t state); static void disp_language(uint8_t language, uint8_t state);
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
static lv_obj_t *buttonCN, *buttonT_CN, *buttonEN, *buttonRU; static lv_obj_t *buttonCN, *buttonT_CN, *buttonEN, *buttonRU;
static lv_obj_t *buttonES, *buttonFR, *buttonIT, *buttonBack; static lv_obj_t *buttonES, *buttonFR, *buttonIT;
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_CN: case ID_CN:
if (event == LV_EVENT_CLICKED) { disp_language(gCfgItems.language, UNSELECTED);
// nothing to do lv_imgbtn_set_src_both(buttonCN, "F:/bmp_simplified_cn_sel.bin");
} lv_obj_refresh_ext_draw_pad(buttonCN);
else if (event == LV_EVENT_RELEASED) { gCfgItems.language = LANG_SIMPLE_CHINESE;
disp_language(gCfgItems.language, UNSELECTED); update_spi_flash();
lv_imgbtn_set_src_both(buttonCN, "F:/bmp_simplified_cn_sel.bin"); disp_language_init();
lv_obj_refresh_ext_draw_pad(buttonCN);
gCfgItems.language = LANG_SIMPLE_CHINESE;
update_spi_flash();
disp_language_init();
}
break; break;
case ID_T_CN: case ID_T_CN:
if (event == LV_EVENT_CLICKED) { disp_language(gCfgItems.language, UNSELECTED);
// nothing to do lv_imgbtn_set_src_both(buttonT_CN, "F:/bmp_traditional_cn_sel.bin");
} lv_obj_refresh_ext_draw_pad(buttonT_CN);
else if (event == LV_EVENT_RELEASED) { gCfgItems.language = LANG_COMPLEX_CHINESE;
disp_language(gCfgItems.language, UNSELECTED); update_spi_flash();
lv_imgbtn_set_src_both(buttonT_CN, "F:/bmp_traditional_cn_sel.bin"); disp_language_init();
lv_obj_refresh_ext_draw_pad(buttonT_CN);
gCfgItems.language = LANG_COMPLEX_CHINESE;
update_spi_flash();
disp_language_init();
}
break; break;
case ID_EN: case ID_EN:
if (event == LV_EVENT_CLICKED) { disp_language(gCfgItems.language, UNSELECTED);
// nothing to do lv_imgbtn_set_src_both(buttonEN, "F:/bmp_english_sel.bin");
} lv_obj_refresh_ext_draw_pad(buttonEN);
else if (event == LV_EVENT_RELEASED) { gCfgItems.language = LANG_ENGLISH;
disp_language(gCfgItems.language, UNSELECTED); update_spi_flash();
lv_imgbtn_set_src_both(buttonEN, "F:/bmp_english_sel.bin"); disp_language_init();
lv_obj_refresh_ext_draw_pad(buttonEN);
gCfgItems.language = LANG_ENGLISH;
update_spi_flash();
disp_language_init();
}
break; break;
case ID_RU: case ID_RU:
if (event == LV_EVENT_CLICKED) { disp_language(gCfgItems.language, UNSELECTED);
// nothing to do lv_imgbtn_set_src_both(buttonRU, "F:/bmp_russian_sel.bin");
} lv_obj_refresh_ext_draw_pad(buttonRU);
else if (event == LV_EVENT_RELEASED) { gCfgItems.language = LANG_RUSSIAN;
disp_language(gCfgItems.language, UNSELECTED); update_spi_flash();
lv_imgbtn_set_src_both(buttonRU, "F:/bmp_russian_sel.bin"); disp_language_init();
lv_obj_refresh_ext_draw_pad(buttonRU);
gCfgItems.language = LANG_RUSSIAN;
update_spi_flash();
disp_language_init();
}
break; break;
case ID_ES: case ID_ES:
if (event == LV_EVENT_CLICKED) { disp_language(gCfgItems.language, UNSELECTED);
// nothing to do lv_imgbtn_set_src_both(buttonES, "F:/bmp_spanish_sel.bin");
} lv_obj_refresh_ext_draw_pad(buttonES);
else if (event == LV_EVENT_RELEASED) { gCfgItems.language = LANG_SPANISH;
disp_language(gCfgItems.language, UNSELECTED); update_spi_flash();
lv_imgbtn_set_src_both(buttonES, "F:/bmp_spanish_sel.bin"); disp_language_init();
lv_obj_refresh_ext_draw_pad(buttonES);
gCfgItems.language = LANG_SPANISH;
update_spi_flash();
disp_language_init();
}
break; break;
case ID_FR: case ID_FR:
if (event == LV_EVENT_CLICKED) { disp_language(gCfgItems.language, UNSELECTED);
// nothing to do lv_imgbtn_set_src_both(buttonFR, "F:/bmp_french_sel.bin");
} lv_obj_refresh_ext_draw_pad(buttonFR);
else if (event == LV_EVENT_RELEASED) { gCfgItems.language = LANG_FRENCH;
disp_language(gCfgItems.language, UNSELECTED); update_spi_flash();
lv_imgbtn_set_src_both(buttonFR, "F:/bmp_french_sel.bin"); disp_language_init();
lv_obj_refresh_ext_draw_pad(buttonFR);
gCfgItems.language = LANG_FRENCH;
update_spi_flash();
disp_language_init();
}
break; break;
case ID_IT: case ID_IT:
if (event == LV_EVENT_CLICKED) { disp_language(gCfgItems.language, UNSELECTED);
// nothing to do lv_imgbtn_set_src_both(buttonIT, "F:/bmp_italy_sel.bin");
} lv_obj_refresh_ext_draw_pad(buttonIT);
else if (event == LV_EVENT_RELEASED) { gCfgItems.language = LANG_ITALY;
disp_language(gCfgItems.language, UNSELECTED); update_spi_flash();
lv_imgbtn_set_src_both(buttonIT, "F:/bmp_italy_sel.bin"); disp_language_init();
lv_obj_refresh_ext_draw_pad(buttonIT);
gCfgItems.language = LANG_ITALY;
update_spi_flash();
disp_language_init();
}
break; break;
case ID_L_RETURN: case ID_L_RETURN:
if (event == LV_EVENT_CLICKED) { buttonCN = nullptr;
buttonT_CN = nullptr;
} buttonEN = nullptr;
else if (event == LV_EVENT_RELEASED) { buttonRU = nullptr;
buttonCN = NULL; buttonES = nullptr;
buttonT_CN = NULL; buttonFR = nullptr;
buttonEN = NULL; buttonFR = nullptr;
buttonRU = NULL; buttonIT = nullptr;
buttonES = NULL; lv_clear_language();
buttonFR = NULL; lv_draw_set();
buttonFR = NULL;
buttonIT = NULL;
buttonBack = NULL;
lv_clear_language();
lv_draw_set();
}
break; break;
} }
} }
@ -222,7 +181,7 @@ static void disp_language(uint8_t language, uint8_t state) {
strcat_P(public_buf_l, PSTR(".bin")); strcat_P(public_buf_l, PSTR(".bin"));
lv_obj_set_event_cb_mks(obj, event_handler, id, NULL, 0); lv_obj_set_event_cb_mks(obj, event_handler, id, nullptr, 0);
lv_imgbtn_set_src_both(obj, public_buf_l); lv_imgbtn_set_src_both(obj, public_buf_l);
if (state == UNSELECTED) lv_obj_refresh_ext_draw_pad(obj); if (state == UNSELECTED) lv_obj_refresh_ext_draw_pad(obj);
@ -236,78 +195,24 @@ void lv_draw_language(void) {
} }
disp_state = LANGUAGE_UI; disp_state = LANGUAGE_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
// static lv_style_t tool_style;
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
// Create image buttons // Create image buttons
buttonCN = lv_imgbtn_create(scr, "F:/bmp_simplified_cn.bin", INTERVAL_V, titleHeight, event_handler, ID_CN); buttonCN = lv_big_button_create(scr, "F:/bmp_simplified_cn.bin", language_menu.chinese_s, INTERVAL_V, titleHeight, event_handler, ID_CN);
lv_obj_clear_protect(buttonCN, LV_PROTECT_FOLLOW); lv_obj_clear_protect(buttonCN, LV_PROTECT_FOLLOW);
buttonT_CN = lv_imgbtn_create(scr, "F:/bmp_traditional_cn.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_T_CN); buttonT_CN = lv_big_button_create(scr, "F:/bmp_traditional_cn.bin", language_menu.chinese_t, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_T_CN);
buttonEN = lv_imgbtn_create(scr, "F:/bmp_english.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_EN); buttonEN = lv_big_button_create(scr, "F:/bmp_english.bin", language_menu.english, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_EN);
buttonRU = lv_imgbtn_create(scr, "F:/bmp_russian.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_RU); buttonRU = lv_big_button_create(scr, "F:/bmp_russian.bin", language_menu.russian, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_RU);
buttonES = lv_imgbtn_create(scr, "F:/bmp_spanish.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_ES); buttonES = lv_big_button_create(scr, "F:/bmp_spanish.bin", language_menu.spanish, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_ES);
buttonFR = lv_imgbtn_create(scr, "F:/bmp_french.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_FR); buttonFR = lv_big_button_create(scr, "F:/bmp_french.bin", language_menu.french, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_FR);
buttonIT = lv_imgbtn_create(scr, "F:/bmp_italy.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_IT); buttonIT = lv_big_button_create(scr, "F:/bmp_italy.bin", language_menu.italy, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_IT);
buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_L_RETURN); lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_L_RETURN);
// Create labels on the image buttons
lv_obj_t *label_CN = lv_label_create_empty(buttonCN);
lv_obj_t *label_T_CN = lv_label_create_empty(buttonT_CN);
lv_obj_t *label_EN = lv_label_create_empty(buttonEN);
lv_obj_t *label_RU = lv_label_create_empty(buttonRU);
lv_obj_t *label_ES = lv_label_create_empty(buttonES);
lv_obj_t *label_FR = lv_label_create_empty(buttonFR);
lv_obj_t *label_IT = lv_label_create_empty(buttonIT);
lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
disp_language(gCfgItems.language, SELECTED); disp_language(gCfgItems.language, SELECTED);
if (gCfgItems.multiple_language) {
lv_label_set_text(label_CN, language_menu.chinese_s);
lv_obj_align(label_CN, buttonCN, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_T_CN, language_menu.chinese_t);
lv_obj_align(label_T_CN, buttonT_CN, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_EN, language_menu.english);
lv_obj_align(label_EN, buttonEN, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_RU, language_menu.russian);
lv_obj_align(label_RU, buttonRU, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_ES, language_menu.spanish);
lv_obj_align(label_ES, buttonES, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_FR, language_menu.french);
lv_obj_align(label_FR, buttonFR, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_IT, language_menu.italy);
lv_obj_align(label_IT, buttonIT, 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, buttonCN);
lv_group_add_obj(g, buttonT_CN);
lv_group_add_obj(g, buttonEN);
lv_group_add_obj(g, buttonRU);
lv_group_add_obj(g, buttonES);
lv_group_add_obj(g, buttonFR);
lv_group_add_obj(g, buttonIT);
lv_group_add_obj(g, buttonBack);
}
#endif
} }
void lv_clear_language() { void lv_clear_language() {

View file

@ -28,194 +28,57 @@
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_LEVEL_RETURN 1 enum {
#define ID_LEVEL_POSITION 2 ID_LEVEL_RETURN = 1,
#define ID_LEVEL_POSITION_ARROW 3 ID_LEVEL_POSITION,
#define ID_LEVEL_COMMAND 4 ID_LEVEL_COMMAND,
#define ID_LEVEL_COMMAND_ARROW 5 ID_LEVEL_ZOFFSET
#define ID_LEVEL_ZOFFSET 6 };
#define ID_LEVEL_ZOFFSET_ARROW 7
static void event_handler(lv_obj_t *obj, lv_event_t event) {
static void event_handler(lv_obj_t * obj, lv_event_t event) {
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_LEVEL_RETURN: case ID_LEVEL_RETURN:
if (event == LV_EVENT_CLICKED) { lv_clear_level_settings();
draw_return_ui();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_level_settings();
draw_return_ui();
}
break; break;
case ID_LEVEL_POSITION: case ID_LEVEL_POSITION:
if (event == LV_EVENT_CLICKED) { lv_clear_level_settings();
lv_draw_manual_level_pos_settings();
}
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; break;
case ID_LEVEL_COMMAND: case ID_LEVEL_COMMAND:
if (event == LV_EVENT_CLICKED) { keyboard_value = gcodeCommand;
lv_clear_level_settings();
} lv_draw_keyboard();
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; break;
#if HAS_BED_PROBE #if HAS_BED_PROBE
case ID_LEVEL_ZOFFSET: case ID_LEVEL_ZOFFSET:
if (event == LV_EVENT_CLICKED) { lv_clear_level_settings();
lv_draw_auto_level_offset_settings();
}
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; break;
#endif #endif
} }
} }
void lv_draw_level_settings(void) { 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) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != LEVELING_PARA_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = LEVELING_PARA_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = LEVELING_PARA_UI;
} }
disp_state = LEVELING_PARA_UI; disp_state = LEVELING_PARA_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.LevelingParaConfTitle); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.LevelingParaConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
lv_screen_menu_item(scr, machine_menu.LevelingManuPosConf, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_LEVEL_POSITION, 0);
buttonPosition = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_screen_menu_item(scr, machine_menu.LevelingAutoCommandConf, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_LEVEL_COMMAND, 1);
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_use_label_style(buttonPosition);
lv_btn_set_layout(buttonPosition, LV_LAYOUT_OFF);
labelPosition = lv_label_create_empty(buttonPosition); /*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, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V, event_handler, ID_LEVEL_POSITION_ARROW);
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_use_label_style(buttonCommand);
lv_btn_set_layout(buttonCommand, LV_LAYOUT_OFF);
labelCommand = lv_label_create_empty(buttonCommand);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonCommand);
#endif
buttonCommandNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V, event_handler, ID_LEVEL_COMMAND_ARROW);
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 #if HAS_BED_PROBE
lv_screen_menu_item(scr, machine_menu.LevelingAutoZoffsetConf, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_LEVEL_ZOFFSET, 2);
buttonZoffset = lv_btn_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3, PARA_UI_SIZE_X, PARA_UI_SIZE_Y, event_handler, ID_LEVEL_ZOFFSET);
lv_btn_set_layout(buttonZoffset, LV_LAYOUT_OFF);
labelZoffset = lv_label_create_empty(buttonZoffset); /*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, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V, event_handler, ID_LEVEL_ZOFFSET_ARROW);
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, "F:/bmp_back70x40.bin", event_handler, ID_LEVEL_RETURN);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif #endif
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_LEVEL_RETURN, true);
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_empty(buttonBack);
if (gCfgItems.multiple_language) {
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() { void lv_clear_level_settings() {

View file

@ -28,209 +28,60 @@
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_PARA_RETURN 1 enum {
#define ID_PARA_MACHINE 2 ID_PARA_RETURN = 1,
#define ID_PARA_MACHINE_ARROW 3 ID_PARA_MACHINE,
#define ID_PARA_MOTOR 4 ID_PARA_MOTOR,
#define ID_PARA_MOTOR_ARROW 5 ID_PARA_LEVEL,
#define ID_PARA_LEVEL 6 ID_PARA_ADVANCE
#define ID_PARA_LEVEL_ARROW 7 };
#define ID_PARA_ADVANCE 8
#define ID_PARA_ADVANCE_ARROW 9
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_PARA_RETURN: case ID_PARA_RETURN:
if (event == LV_EVENT_CLICKED) { lv_clear_machine_para();
draw_return_ui();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_machine_para();
draw_return_ui();
}
break; break;
case ID_PARA_MACHINE: case ID_PARA_MACHINE:
if (event == LV_EVENT_CLICKED) { lv_clear_machine_para();
lv_draw_machine_settings();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_machine_para();
lv_draw_machine_settings();
}
break;
case ID_PARA_MACHINE_ARROW:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_machine_para();
lv_draw_machine_settings();
}
break; break;
case ID_PARA_MOTOR: case ID_PARA_MOTOR:
if (event == LV_EVENT_CLICKED) { lv_clear_machine_para();
lv_draw_motor_settings();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_machine_para();
lv_draw_motor_settings();
}
break;
case ID_PARA_MOTOR_ARROW:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_machine_para();
lv_draw_motor_settings();
}
break; break;
case ID_PARA_LEVEL: case ID_PARA_LEVEL:
if (event == LV_EVENT_CLICKED) { lv_clear_machine_para();
lv_draw_level_settings();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_machine_para();
lv_draw_level_settings();
}
break;
case ID_PARA_LEVEL_ARROW:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_machine_para();
lv_draw_level_settings();
}
break; break;
case ID_PARA_ADVANCE: case ID_PARA_ADVANCE:
if (event == LV_EVENT_CLICKED) { lv_clear_machine_para();
lv_draw_advance_settings();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_machine_para();
lv_draw_advance_settings();
}
break;
case ID_PARA_ADVANCE_ARROW:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_machine_para();
lv_draw_advance_settings();
}
break; break;
} }
} }
void lv_draw_machine_para(void) { void lv_draw_machine_para(void) {
lv_obj_t *buttonBack, *label_Back;
lv_obj_t *buttonMachine, *labelMachine, *buttonMachineNarrow;
lv_obj_t *buttonMotor, *labelMotor, *buttonMotorNarrow;
lv_obj_t *buttonLevel, *labelLevel, *buttonLevelNarrow;
lv_obj_t *buttonAdvance, *labelAdvance, *buttonAdvanceNarrow;
lv_obj_t * line1, * line2, * line3, * line4;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MACHINE_PARA_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MACHINE_PARA_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = MACHINE_PARA_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = MACHINE_PARA_UI;
} }
disp_state = MACHINE_PARA_UI; disp_state = MACHINE_PARA_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
buttonMachine = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_screen_menu_item(scr, MachinePara_menu.MachineSetting, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_PARA_MACHINE, 0);
lv_obj_set_pos(buttonMachine, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ lv_screen_menu_item(scr, MachinePara_menu.MotorSetting, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_PARA_MOTOR, 1);
lv_obj_set_size(buttonMachine, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ lv_screen_menu_item(scr, MachinePara_menu.leveling, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_PARA_LEVEL, 2);
//lv_obj_set_event_cb(buttonMachine, event_handler); lv_screen_menu_item(scr, MachinePara_menu.AdvanceSetting, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_PARA_ADVANCE, 3);
lv_obj_set_event_cb_mks(buttonMachine, event_handler, ID_PARA_MACHINE, NULL, 0); lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_PARA_RETURN, true);
lv_btn_use_label_style(buttonMachine);
lv_btn_set_layout(buttonMachine, LV_LAYOUT_OFF);
labelMachine = lv_label_create_empty(buttonMachine); /*Add a label to the button*/
buttonMachineNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V, event_handler, ID_PARA_MACHINE_ARROW);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonMotor = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonMotor, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/
lv_obj_set_size(buttonMotor, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
//lv_obj_set_event_cb(buttonMotor, event_handler);
lv_obj_set_event_cb_mks(buttonMotor, event_handler, ID_PARA_MOTOR, NULL, 0);
lv_btn_use_label_style(buttonMotor);
lv_btn_set_layout(buttonMotor, LV_LAYOUT_OFF);
labelMotor = lv_label_create_empty(buttonMotor); /*Add a label to the button*/
buttonMotorNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V, event_handler, ID_PARA_MOTOR_ARROW);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
buttonLevel = lv_btn_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3, PARA_UI_SIZE_X, PARA_UI_SIZE_Y, event_handler, ID_PARA_LEVEL);
//lv_obj_set_event_cb(buttonMotor, event_handler);
lv_btn_set_layout(buttonLevel, LV_LAYOUT_OFF);
labelLevel = lv_label_create_empty(buttonLevel); /*Add a label to the button*/
buttonLevelNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V, event_handler, ID_PARA_LEVEL_ARROW);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
buttonAdvance = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonAdvance, PARA_UI_POS_X, PARA_UI_POS_Y * 4); /*Set its position*/
lv_obj_set_size(buttonAdvance, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
//lv_obj_set_event_cb(buttonMotor, event_handler);
lv_obj_set_event_cb_mks(buttonAdvance, event_handler, ID_PARA_ADVANCE, NULL, 0);
lv_btn_use_label_style(buttonAdvance);
lv_btn_set_layout(buttonAdvance, LV_LAYOUT_OFF);
labelAdvance = lv_label_create_empty(buttonAdvance); /*Add a label to the button*/
buttonAdvanceNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 4 + PARA_UI_ARROW_V, event_handler, ID_PARA_ADVANCE_ARROW);
lv_btn_set_layout(buttonAdvanceNarrow, LV_LAYOUT_OFF);
line4 = lv_line_create(scr, NULL);
lv_ex_line(line4, line_points[3]);
buttonBack = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_PARA_RETURN);
label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.multiple_language) {
lv_label_set_text(label_Back, common_menu.text_back);
lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, -2);
lv_label_set_text(labelMachine, MachinePara_menu.MachineSetting);
lv_obj_align(labelMachine, buttonMachine, LV_ALIGN_IN_LEFT_MID, 0, -3);
lv_label_set_text(labelMotor, MachinePara_menu.MotorSetting);
lv_obj_align(labelMotor, buttonMotor, LV_ALIGN_IN_LEFT_MID, 0, -3);
lv_label_set_text(labelLevel, MachinePara_menu.leveling);
lv_obj_align(labelLevel, buttonLevel, LV_ALIGN_IN_LEFT_MID, 0, -3);
lv_label_set_text(labelAdvance, MachinePara_menu.AdvanceSetting);
lv_obj_align(labelAdvance, buttonAdvance, LV_ALIGN_IN_LEFT_MID, 0, -3);
}
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonMachine);
lv_group_add_obj(g, buttonMotor);
lv_group_add_obj(g, buttonLevel);
lv_group_add_obj(g, buttonAdvance);
lv_group_add_obj(g, buttonBack);
}
#endif
} }
void lv_clear_machine_para() { void lv_clear_machine_para() {

View file

@ -28,188 +28,59 @@
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_MACHINE_RETURN 1 enum {
#define ID_MACHINE_ACCELERATION 2 ID_MACHINE_RETURN = 1,
#define ID_MACHINE_ACCELERATION_ARROW 3 ID_MACHINE_ACCELERATION,
#define ID_MACHINE_FEEDRATE 4 ID_MACHINE_FEEDRATE,
#define ID_MACHINE_FEEDRATE_ARROW 5 ID_MACHINE_JERK
#define ID_MACHINE_JERK 6 };
#define ID_MACHINE_JERK_ARROW 7
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_MACHINE_RETURN: case ID_MACHINE_RETURN:
if (event == LV_EVENT_CLICKED) { lv_clear_machine_settings();
draw_return_ui();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_machine_settings();
draw_return_ui();
}
break; break;
case ID_MACHINE_ACCELERATION: case ID_MACHINE_ACCELERATION:
if (event == LV_EVENT_CLICKED) { lv_clear_machine_settings();
lv_draw_acceleration_settings();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_machine_settings();
lv_draw_acceleration_settings();
}
break;
case ID_MACHINE_ACCELERATION_ARROW:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_machine_settings();
lv_draw_acceleration_settings();
}
break; break;
case ID_MACHINE_FEEDRATE: case ID_MACHINE_FEEDRATE:
if (event == LV_EVENT_CLICKED) { lv_clear_machine_settings();
lv_draw_max_feedrate_settings();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_machine_settings();
lv_draw_max_feedrate_settings();
}
break; break;
case ID_MACHINE_FEEDRATE_ARROW: #if HAS_CLASSIC_JERK
if (event == LV_EVENT_CLICKED) { case ID_MACHINE_JERK:
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_machine_settings(); lv_clear_machine_settings();
lv_draw_max_feedrate_settings(); lv_draw_jerk_settings();
} break;
break; #endif
#if HAS_CLASSIC_JERK
case ID_MACHINE_JERK:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_machine_settings();
lv_draw_jerk_settings();
}
break;
case ID_MACHINE_JERK_ARROW:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_machine_settings();
lv_draw_jerk_settings();
}
break;
#endif
} }
} }
void lv_draw_machine_settings(void) { void lv_draw_machine_settings(void) {
lv_obj_t *buttonBack, *label_Back;
lv_obj_t *buttonAcceleration, *labelAcceleration, *buttonAccelerationNarrow;
lv_obj_t *buttonMaxFeedrate, *labelMaxFeedrate, *buttonMaxFeedrateNarrow;
#if HAS_CLASSIC_JERK
lv_obj_t *buttonJerk, *labelJerk, *buttonJerkNarrow;
#endif
lv_obj_t * line1, * line2;
#if HAS_CLASSIC_JERK
lv_obj_t * line3;
#endif
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MACHINE_SETTINGS_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MACHINE_SETTINGS_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = MACHINE_SETTINGS_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = MACHINE_SETTINGS_UI;
} }
disp_state = MACHINE_SETTINGS_UI; disp_state = MACHINE_SETTINGS_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.MachineConfigTitle); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.MachineConfigTitle);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
buttonAcceleration = lv_btn_create(scr, NULL); // Add a button the current screen lv_screen_menu_item(scr, machine_menu.AccelerationConf, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MACHINE_ACCELERATION, 0);
lv_obj_set_pos(buttonAcceleration, PARA_UI_POS_X, PARA_UI_POS_Y); // Set its position lv_screen_menu_item(scr, machine_menu.MaxFeedRateConf, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_MACHINE_FEEDRATE, 1);
lv_obj_set_size(buttonAcceleration, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); // Set its size
//lv_obj_set_event_cb(buttonMachine, event_handler);
lv_obj_set_event_cb_mks(buttonAcceleration, event_handler, ID_MACHINE_ACCELERATION, NULL, 0);
lv_btn_use_label_style(buttonAcceleration);
lv_btn_set_layout(buttonAcceleration, LV_LAYOUT_OFF);
labelAcceleration = lv_label_create_empty(buttonAcceleration); // Add a label to the button
buttonAccelerationNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V, event_handler, ID_MACHINE_ACCELERATION_ARROW);
line1 = lv_line_create(lv_scr_act(), NULL);
lv_ex_line(line1, line_points[0]);
buttonMaxFeedrate = lv_btn_create(scr, NULL); // Add a button the current screen
lv_obj_set_pos(buttonMaxFeedrate, PARA_UI_POS_X, PARA_UI_POS_Y * 2); // Set its position
lv_obj_set_size(buttonMaxFeedrate, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); // Set its size
//lv_obj_set_event_cb(buttonMachine, event_handler);
lv_obj_set_event_cb_mks(buttonMaxFeedrate, event_handler, ID_MACHINE_FEEDRATE, NULL, 0);
lv_btn_use_label_style(buttonMaxFeedrate);
lv_btn_set_layout(buttonMaxFeedrate, LV_LAYOUT_OFF);
labelMaxFeedrate = lv_label_create_empty(buttonMaxFeedrate); // Add a label to the button
buttonMaxFeedrateNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V, event_handler, ID_MACHINE_FEEDRATE_ARROW);
line2 = lv_line_create(lv_scr_act(), NULL);
lv_ex_line(line2, line_points[1]);
#if HAS_CLASSIC_JERK #if HAS_CLASSIC_JERK
buttonJerk = lv_btn_create(scr, NULL); // Add a button the current screen lv_screen_menu_item(scr, machine_menu.JerkConf, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_MACHINE_JERK, 2);
lv_obj_set_pos(buttonJerk, PARA_UI_POS_X, PARA_UI_POS_Y * 3); // Set its position
lv_obj_set_size(buttonJerk, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); // Set its size
//lv_obj_set_event_cb(buttonMotor, event_handler);
lv_obj_set_event_cb_mks(buttonJerk, event_handler, ID_MACHINE_JERK, NULL, 0);
lv_btn_use_label_style(buttonJerk);
lv_btn_set_layout(buttonJerk, LV_LAYOUT_OFF);
labelJerk = lv_label_create_empty(buttonJerk); // Add a label to the button
buttonJerkNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V, event_handler, ID_MACHINE_JERK_ARROW);
line3 = lv_line_create(lv_scr_act(), NULL);
lv_ex_line(line3, line_points[2]);
#endif
buttonBack = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", event_handler, ID_MACHINE_RETURN);
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_empty(buttonBack);
if (gCfgItems.multiple_language) {
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(labelAcceleration, machine_menu.AccelerationConf);
lv_obj_align(labelAcceleration, buttonAcceleration, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelMaxFeedrate, machine_menu.MaxFeedRateConf);
lv_obj_align(labelMaxFeedrate, buttonMaxFeedrate, LV_ALIGN_IN_LEFT_MID, 0, 0);
#if HAS_CLASSIC_JERK
lv_label_set_text(labelJerk, machine_menu.JerkConf);
lv_obj_align(labelJerk, buttonJerk, LV_ALIGN_IN_LEFT_MID, 0, 0);
#endif
}
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonAcceleration);
lv_group_add_obj(g, buttonMaxFeedrate);
#if HAS_CLASSIC_JERK
lv_group_add_obj(g, buttonJerk);
#endif
lv_group_add_obj(g, buttonBack);
}
#endif #endif
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_MACHINE_RETURN, true);
} }
void lv_clear_machine_settings() { void lv_clear_machine_settings() {

View file

@ -33,201 +33,109 @@
#include "../../../../gcode/queue.h" #include "../../../../gcode/queue.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_M_POINT1 1 enum {
#define ID_M_POINT2 2 ID_M_POINT1 = 1,
#define ID_M_POINT3 3 ID_M_POINT2,
#define ID_M_POINT4 4 ID_M_POINT3,
#define ID_M_POINT5 5 ID_M_POINT4,
#define ID_MANUAL_RETURN 6 ID_M_POINT5,
ID_MANUAL_RETURN
};
static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
static void event_handler(lv_obj_t * obj, lv_event_t event) {
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_M_POINT1: case ID_M_POINT1:
if (event == LV_EVENT_CLICKED) { if (queue.length == 0) {
// nothing to do if (uiCfg.leveling_first_time) {
} queue.enqueue_now_P(PSTR("G28"));
else if (event == LV_EVENT_RELEASED) { uiCfg.leveling_first_time = 0;
if (queue.length == 0) {
if (uiCfg.leveling_first_time) {
queue.enqueue_now_P(PSTR("G28"));
uiCfg.leveling_first_time = 0;
}
queue.enqueue_now_P(PSTR("G1 Z10"));
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[0][0], (int)gCfgItems.levelingPos[0][1]);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G1 Z0"));
} }
queue.enqueue_now_P(PSTR("G1 Z10"));
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[0][0], (int)gCfgItems.levelingPos[0][1]);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G1 Z0"));
} }
break; break;
case ID_M_POINT2: case ID_M_POINT2:
if (event == LV_EVENT_CLICKED) { if (queue.length == 0) {
// nothing to do if (uiCfg.leveling_first_time) {
} queue.enqueue_now_P(PSTR("G28"));
else if (event == LV_EVENT_RELEASED) { uiCfg.leveling_first_time = 0;
if (queue.length == 0) {
if (uiCfg.leveling_first_time) {
queue.enqueue_now_P(PSTR("G28"));
uiCfg.leveling_first_time = 0;
}
queue.enqueue_now_P(PSTR("G1 Z10"));
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[1][0], (int)gCfgItems.levelingPos[1][1]);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G1 Z0"));
} }
queue.enqueue_now_P(PSTR("G1 Z10"));
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[1][0], (int)gCfgItems.levelingPos[1][1]);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G1 Z0"));
} }
break; break;
case ID_M_POINT3: case ID_M_POINT3:
if (event == LV_EVENT_CLICKED) { if (queue.length == 0) {
// nothing to do if (uiCfg.leveling_first_time) {
} queue.enqueue_now_P(PSTR("G28"));
else if (event == LV_EVENT_RELEASED) { uiCfg.leveling_first_time = 0;
if (queue.length == 0) {
if (uiCfg.leveling_first_time) {
queue.enqueue_now_P(PSTR("G28"));
uiCfg.leveling_first_time = 0;
}
queue.enqueue_now_P(PSTR("G1 Z10"));
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[2][0], (int)gCfgItems.levelingPos[2][1]);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G1 Z0"));
} }
queue.enqueue_now_P(PSTR("G1 Z10"));
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[2][0], (int)gCfgItems.levelingPos[2][1]);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G1 Z0"));
} }
break; break;
case ID_M_POINT4: case ID_M_POINT4:
if (event == LV_EVENT_CLICKED) { if (queue.length == 0) {
// nothing to do if (uiCfg.leveling_first_time) {
} queue.enqueue_now_P(PSTR("G28"));
else if (event == LV_EVENT_RELEASED) { uiCfg.leveling_first_time = 0;
if (queue.length == 0) {
if (uiCfg.leveling_first_time) {
queue.enqueue_now_P(PSTR("G28"));
uiCfg.leveling_first_time = 0;
}
queue.enqueue_now_P(PSTR("G1 Z10"));
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[3][0], (int)gCfgItems.levelingPos[3][1]);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G1 Z0"));
} }
queue.enqueue_now_P(PSTR("G1 Z10"));
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[3][0], (int)gCfgItems.levelingPos[3][1]);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G1 Z0"));
} }
break; break;
case ID_M_POINT5: case ID_M_POINT5:
if (event == LV_EVENT_CLICKED) { if (queue.length == 0) {
// nothing to do if (uiCfg.leveling_first_time) {
} queue.enqueue_now_P(PSTR("G28"));
else if (event == LV_EVENT_RELEASED) { uiCfg.leveling_first_time = 0;
if (queue.length == 0) {
if (uiCfg.leveling_first_time) {
queue.enqueue_now_P(PSTR("G28"));
uiCfg.leveling_first_time = 0;
}
queue.enqueue_now_P(PSTR("G1 Z10"));
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[4][0], (int)gCfgItems.levelingPos[4][1]);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G1 Z0"));
} }
queue.enqueue_now_P(PSTR("G1 Z10"));
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[4][0], (int)gCfgItems.levelingPos[4][1]);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G1 Z0"));
} }
break; break;
case ID_MANUAL_RETURN: case ID_MANUAL_RETURN:
if (event == LV_EVENT_CLICKED) { lv_clear_manualLevel();
// nothing to do lv_draw_tool();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_manualLevel();
lv_draw_tool();
}
break; break;
} }
} }
void lv_draw_manualLevel(void) { void lv_draw_manualLevel(void) {
lv_obj_t *buttonPoint1, *buttonPoint2, *buttonPoint3, *buttonPoint4, *buttonPoint5;
lv_obj_t *buttonBack;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != LEVELING_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != LEVELING_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = LEVELING_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = LEVELING_UI;
} }
disp_state = LEVELING_UI; disp_state = LEVELING_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
// static lv_style_t tool_style;
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
// Create an Image button // Create an Image button
buttonPoint1 = lv_imgbtn_create(scr, "F:/bmp_leveling1.bin", INTERVAL_V, titleHeight, event_handler, ID_M_POINT1); lv_obj_t *buttonPoint1 = lv_big_button_create(scr, "F:/bmp_leveling1.bin", leveling_menu.position1, INTERVAL_V, titleHeight, event_handler, ID_M_POINT1);
lv_obj_clear_protect(buttonPoint1, LV_PROTECT_FOLLOW); lv_obj_clear_protect(buttonPoint1, LV_PROTECT_FOLLOW);
buttonPoint2 = lv_imgbtn_create(scr, "F:/bmp_leveling2.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_M_POINT2); lv_big_button_create(scr, "F:/bmp_leveling2.bin", leveling_menu.position2, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_M_POINT2);
buttonPoint3 = lv_imgbtn_create(scr, "F:/bmp_leveling3.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_M_POINT3); lv_big_button_create(scr, "F:/bmp_leveling3.bin", leveling_menu.position3, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_M_POINT3);
buttonPoint4 = lv_imgbtn_create(scr, "F:/bmp_leveling4.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_M_POINT4); lv_big_button_create(scr, "F:/bmp_leveling4.bin", leveling_menu.position4, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_M_POINT4);
buttonPoint5 = lv_imgbtn_create(scr, "F:/bmp_leveling5.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_POINT5); lv_big_button_create(scr, "F:/bmp_leveling5.bin", leveling_menu.position5, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_POINT5);
buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_MANUAL_RETURN); lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_MANUAL_RETURN);
// Create labels on the image buttons
lv_obj_t *label_Point1 = lv_label_create_empty(buttonPoint1);
lv_obj_t *label_Point2 = lv_label_create_empty(buttonPoint2);
lv_obj_t *label_Point3 = lv_label_create_empty(buttonPoint3);
lv_obj_t *label_Point4 = lv_label_create_empty(buttonPoint4);
lv_obj_t *label_Point5 = lv_label_create_empty(buttonPoint5);
lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.multiple_language) {
lv_label_set_text(label_Point1, leveling_menu.position1);
lv_obj_align(label_Point1, buttonPoint1, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_Point2, leveling_menu.position2);
lv_obj_align(label_Point2, buttonPoint2, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_Point3, leveling_menu.position3);
lv_obj_align(label_Point3, buttonPoint3, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_Point4, leveling_menu.position4);
lv_obj_align(label_Point4, buttonPoint4, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_Point5, leveling_menu.position5);
lv_obj_align(label_Point5, buttonPoint5, 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, buttonPoint1);
lv_group_add_obj(g, buttonPoint2);
lv_group_add_obj(g, buttonPoint3);
lv_group_add_obj(g, buttonPoint4);
lv_group_add_obj(g, buttonPoint5);
lv_group_add_obj(g, buttonBack);
}
#endif
} }
void lv_clear_manualLevel() { void lv_clear_manualLevel() {

View file

@ -29,353 +29,136 @@
#include "../../../../module/planner.h" #include "../../../../module/planner.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_MANUAL_POS_RETURN 1 enum {
#define ID_MANUAL_POS_X1 2 ID_MANUAL_POS_RETURN = 1,
#define ID_MANUAL_POS_Y1 3 ID_MANUAL_POS_X1,
#define ID_MANUAL_POS_X2 4 ID_MANUAL_POS_Y1,
#define ID_MANUAL_POS_Y2 5 ID_MANUAL_POS_X2,
#define ID_MANUAL_POS_X3 6 ID_MANUAL_POS_Y2,
#define ID_MANUAL_POS_Y3 7 ID_MANUAL_POS_X3,
#define ID_MANUAL_POS_X4 8 ID_MANUAL_POS_Y3,
#define ID_MANUAL_POS_Y4 9 ID_MANUAL_POS_X4,
#define ID_MANUAL_POS_X5 10 ID_MANUAL_POS_Y4,
#define ID_MANUAL_POS_Y5 11 ID_MANUAL_POS_X5,
#define ID_MANUAL_POS_DOWN 12 ID_MANUAL_POS_Y5,
#define ID_MANUAL_POS_UP 13 ID_MANUAL_POS_DOWN,
ID_MANUAL_POS_UP
};
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_MANUAL_POS_RETURN: case ID_MANUAL_POS_RETURN:
if (event == LV_EVENT_CLICKED) { uiCfg.para_ui_page = 0;
lv_clear_manual_level_pos_settings();
} draw_return_ui();
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 0;
lv_clear_manual_level_pos_settings();
draw_return_ui();
}
break; break;
case ID_MANUAL_POS_X1: case ID_MANUAL_POS_X1:
if (event == LV_EVENT_CLICKED) { value = level_pos_x1;
lv_clear_manual_level_pos_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = level_pos_x1;
lv_clear_manual_level_pos_settings();
lv_draw_number_key();
}
break; break;
case ID_MANUAL_POS_Y1: case ID_MANUAL_POS_Y1:
if (event == LV_EVENT_CLICKED) { value = level_pos_y1;
lv_clear_manual_level_pos_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = level_pos_y1;
lv_clear_manual_level_pos_settings();
lv_draw_number_key();
}
break; break;
case ID_MANUAL_POS_X2: case ID_MANUAL_POS_X2:
if (event == LV_EVENT_CLICKED) { value = level_pos_x2;
lv_clear_manual_level_pos_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = level_pos_x2;
lv_clear_manual_level_pos_settings();
lv_draw_number_key();
}
break; break;
case ID_MANUAL_POS_Y2: case ID_MANUAL_POS_Y2:
if (event == LV_EVENT_CLICKED) { value = level_pos_y2;
lv_clear_manual_level_pos_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = level_pos_y2;
lv_clear_manual_level_pos_settings();
lv_draw_number_key();
}
break; break;
case ID_MANUAL_POS_X3: case ID_MANUAL_POS_X3:
if (event == LV_EVENT_CLICKED) { value = level_pos_x3;
lv_clear_manual_level_pos_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = level_pos_x3;
lv_clear_manual_level_pos_settings();
lv_draw_number_key();
}
break; break;
case ID_MANUAL_POS_Y3: case ID_MANUAL_POS_Y3:
if (event == LV_EVENT_CLICKED) { value = level_pos_y3;
lv_clear_manual_level_pos_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = level_pos_y3;
lv_clear_manual_level_pos_settings();
lv_draw_number_key();
}
break; break;
case ID_MANUAL_POS_X4: case ID_MANUAL_POS_X4:
if (event == LV_EVENT_CLICKED) { value = level_pos_x4;
lv_clear_manual_level_pos_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = level_pos_x4;
lv_clear_manual_level_pos_settings();
lv_draw_number_key();
}
break; break;
case ID_MANUAL_POS_Y4: case ID_MANUAL_POS_Y4:
if (event == LV_EVENT_CLICKED) { value = level_pos_y4;
lv_clear_manual_level_pos_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = level_pos_y4;
lv_clear_manual_level_pos_settings();
lv_draw_number_key();
}
break; break;
case ID_MANUAL_POS_X5: case ID_MANUAL_POS_X5:
if (event == LV_EVENT_CLICKED) { value = level_pos_y5;
lv_clear_manual_level_pos_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = level_pos_y5;
lv_clear_manual_level_pos_settings();
lv_draw_number_key();
}
break; break;
case ID_MANUAL_POS_Y5: case ID_MANUAL_POS_Y5:
if (event == LV_EVENT_CLICKED) { value = level_pos_y5;
lv_clear_manual_level_pos_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = level_pos_y5;
lv_clear_manual_level_pos_settings();
lv_draw_number_key();
}
break; break;
case ID_MANUAL_POS_UP: case ID_MANUAL_POS_UP:
if (event == LV_EVENT_CLICKED) { uiCfg.para_ui_page = 0;
lv_clear_manual_level_pos_settings();
} lv_draw_manual_level_pos_settings();
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 0;
lv_clear_manual_level_pos_settings();
lv_draw_manual_level_pos_settings();
}
break; break;
case ID_MANUAL_POS_DOWN: case ID_MANUAL_POS_DOWN:
if (event == LV_EVENT_CLICKED) { uiCfg.para_ui_page = 1;
lv_clear_manual_level_pos_settings();
} lv_draw_manual_level_pos_settings();
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 1;
lv_clear_manual_level_pos_settings();
lv_draw_manual_level_pos_settings();
}
break; break;
} }
} }
void lv_draw_manual_level_pos_settings(void) { void lv_draw_manual_level_pos_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL; char buf2[50];
lv_obj_t *buttonX1Value = NULL, *labelX1Value = NULL;
lv_obj_t *buttonY1Value = NULL, *labelY1Value = NULL;
lv_obj_t *buttonX2Value = NULL, *labelX2Value = NULL;
lv_obj_t *buttonY2Value = NULL, *labelY2Value = NULL;
lv_obj_t *buttonX3Value = NULL, *labelX3Value = NULL;
lv_obj_t *buttonY3Value = NULL, *labelY3Value = NULL;
lv_obj_t *buttonX4Value = NULL, *labelX4Value = NULL;
lv_obj_t *buttonY4Value = NULL, *labelY4Value = NULL;
lv_obj_t *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) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MANUAL_LEVELING_POSIGION_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = MANUAL_LEVELING_POSIGION_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = MANUAL_LEVELING_POSIGION_UI;
} }
disp_state = MANUAL_LEVELING_POSIGION_UI; disp_state = MANUAL_LEVELING_POSIGION_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.LevelingParaConfTitle); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.LevelingParaConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
if (uiCfg.para_ui_page != 1) { if (uiCfg.para_ui_page != 1) {
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, leveling_menu.position1); sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[0][0]);
sprintf_P(buf2, PSTR("%d"), gCfgItems.levelingPos[0][1]);
lv_screen_menu_item_2_edit(scr, leveling_menu.position1, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MANUAL_POS_Y1, 0, buf2, ID_MANUAL_POS_X1, public_buf_l);
buttonX1Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_MANUAL_POS_X1); sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[1][0]);
labelX1Value = lv_label_create_empty(buttonX1Value); sprintf_P(buf2, PSTR("%d"), gCfgItems.levelingPos[1][1]);
lv_screen_menu_item_2_edit(scr, leveling_menu.position2, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_MANUAL_POS_Y2, 1, buf2, ID_MANUAL_POS_X2, public_buf_l);
buttonY1Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_MANUAL_POS_Y1); sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[2][0]);
labelY1Value = lv_label_create_empty(buttonY1Value); sprintf_P(buf2, PSTR("%d"), gCfgItems.levelingPos[2][1]);
lv_screen_menu_item_2_edit(scr, leveling_menu.position3, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_MANUAL_POS_Y3, 2, buf2, ID_MANUAL_POS_X3, public_buf_l);
line1 = lv_line_create(scr, NULL); sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[3][0]);
lv_ex_line(line1, line_points[0]); sprintf_P(buf2, PSTR("%d"), gCfgItems.levelingPos[3][1]);
lv_screen_menu_item_2_edit(scr, leveling_menu.position4, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_MANUAL_POS_Y4, 3, buf2, ID_MANUAL_POS_X4, public_buf_l);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, leveling_menu.position2); lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_MANUAL_POS_DOWN, true);
buttonX2Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_MANUAL_POS_X2);
labelX2Value = lv_label_create_empty(buttonX2Value);
buttonY2Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_MANUAL_POS_Y2);
labelY2Value = lv_label_create_empty(buttonY2Value);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, leveling_menu.position3);
buttonX3Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_MANUAL_POS_X3);
labelX3Value = lv_label_create_empty(buttonX3Value);
buttonY3Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_MANUAL_POS_Y3);
labelY3Value = lv_label_create_empty(buttonY3Value);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, leveling_menu.position4);
buttonX4Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_MANUAL_POS_X4);
labelX4Value = lv_label_create_empty(buttonX4Value);
buttonY4Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_MANUAL_POS_Y4);
labelY4Value = lv_label_create_empty(buttonY4Value);
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_both(buttonTurnPage, &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 { else {
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, leveling_menu.position5); sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[4][0]);
sprintf_P(buf2, PSTR("%d"), gCfgItems.levelingPos[4][1]);
lv_screen_menu_item_2_edit(scr, leveling_menu.position4, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MANUAL_POS_Y5, 0, buf2, ID_MANUAL_POS_X5, public_buf_l);
buttonX5Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_MANUAL_POS_X5); lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_MANUAL_POS_UP, true);
labelX5Value = lv_label_create_empty(buttonX5Value);
buttonY5Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_MANUAL_POS_Y5);
labelY5Value = lv_label_create_empty(buttonY5Value);
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_both(buttonTurnPage, &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_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_MANUAL_POS_RETURN, true);
lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
labelTurnPage = lv_label_create_empty(buttonTurnPage);
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_both(buttonBack, &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_empty(buttonBack);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif
if (gCfgItems.multiple_language) {
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() { void lv_clear_manual_level_pos_settings() {

View file

@ -29,254 +29,100 @@
#include "../../../../module/planner.h" #include "../../../../module/planner.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_FEED_RETURN 1 enum {
#define ID_FEED_X 2 ID_FEED_RETURN = 1,
#define ID_FEED_Y 3 ID_FEED_X,
#define ID_FEED_Z 4 ID_FEED_Y,
#define ID_FEED_E0 5 ID_FEED_Z,
#define ID_FEED_E1 6 ID_FEED_E0,
#define ID_FEED_DOWN 7 ID_FEED_E1,
#define ID_FEED_UP 8 ID_FEED_DOWN,
ID_FEED_UP
};
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_FEED_RETURN: case ID_FEED_RETURN:
if (event == LV_EVENT_CLICKED) { uiCfg.para_ui_page = 0;
lv_clear_max_feedrate_settings();
} draw_return_ui();
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 0;
lv_clear_max_feedrate_settings();
draw_return_ui();
}
break; break;
case ID_FEED_X: case ID_FEED_X:
if (event == LV_EVENT_CLICKED) { value = XMaxFeedRate;
lv_clear_max_feedrate_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = XMaxFeedRate;
lv_clear_max_feedrate_settings();
lv_draw_number_key();
}
break; break;
case ID_FEED_Y: case ID_FEED_Y:
if (event == LV_EVENT_CLICKED) { value = YMaxFeedRate;
lv_clear_max_feedrate_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = YMaxFeedRate;
lv_clear_max_feedrate_settings();
lv_draw_number_key();
}
break; break;
case ID_FEED_Z: case ID_FEED_Z:
if (event == LV_EVENT_CLICKED) { value = ZMaxFeedRate;
lv_clear_max_feedrate_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = ZMaxFeedRate;
lv_clear_max_feedrate_settings();
lv_draw_number_key();
}
break; break;
case ID_FEED_E0: case ID_FEED_E0:
if (event == LV_EVENT_CLICKED) { value = E0MaxFeedRate;
lv_clear_max_feedrate_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = E0MaxFeedRate;
lv_clear_max_feedrate_settings();
lv_draw_number_key();
}
break; break;
case ID_FEED_E1: case ID_FEED_E1:
if (event == LV_EVENT_CLICKED) { value = E1MaxFeedRate;
lv_clear_max_feedrate_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = E1MaxFeedRate;
lv_clear_max_feedrate_settings();
lv_draw_number_key();
}
break; break;
case ID_FEED_UP: case ID_FEED_UP:
if (event == LV_EVENT_CLICKED) { uiCfg.para_ui_page = 0;
lv_clear_max_feedrate_settings();
} lv_draw_max_feedrate_settings();
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 0;
lv_clear_max_feedrate_settings();
lv_draw_max_feedrate_settings();
}
break; break;
case ID_FEED_DOWN: case ID_FEED_DOWN:
if (event == LV_EVENT_CLICKED) { uiCfg.para_ui_page = 1;
lv_clear_max_feedrate_settings();
} lv_draw_max_feedrate_settings();
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 1;
lv_clear_max_feedrate_settings();
lv_draw_max_feedrate_settings();
}
break; break;
} }
} }
void lv_draw_max_feedrate_settings(void) { void lv_draw_max_feedrate_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL;
lv_obj_t *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t *buttonE0Value = NULL, *labelE0Value = NULL;
lv_obj_t *buttonE1Value = NULL, *labelE1Value = NULL;
lv_obj_t *line1 = NULL, *line2 = NULL, *line3 = NULL, *line4 = NULL;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MAXFEEDRATE_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MAXFEEDRATE_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = MAXFEEDRATE_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = MAXFEEDRATE_UI;
} }
disp_state = MAXFEEDRATE_UI; disp_state = MAXFEEDRATE_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.MaxFeedRateConfTitle); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.MaxFeedRateConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
if (uiCfg.para_ui_page != 1) { if (uiCfg.para_ui_page != 1) {
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.XMaxFeedRate); sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[X_AXIS]);
lv_screen_menu_item_1_edit(scr, machine_menu.XMaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_FEED_X, 0, public_buf_l);
buttonXValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_FEED_X); sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[Y_AXIS]);
lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF); lv_screen_menu_item_1_edit(scr, machine_menu.YMaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_FEED_Y, 1, public_buf_l);
labelXValue = lv_label_create_empty(buttonXValue);
line1 = lv_line_create(scr, NULL); sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[Z_AXIS]);
lv_ex_line(line1, line_points[0]); lv_screen_menu_item_1_edit(scr, machine_menu.ZMaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_FEED_Z, 2, public_buf_l);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, machine_menu.YMaxFeedRate); sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS]);
lv_screen_menu_item_1_edit(scr, machine_menu.E0MaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_FEED_E0, 3, public_buf_l);
buttonYValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_FEED_Y); lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_FEED_DOWN, true);
lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF);
labelYValue = lv_label_create_empty(buttonYValue);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, machine_menu.ZMaxFeedRate);
buttonZValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_FEED_Z);
lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF);
labelZValue = lv_label_create_empty(buttonZValue);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, machine_menu.E0MaxFeedRate);
buttonE0Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_FEED_E0);
lv_btn_set_layout(buttonE0Value, LV_LAYOUT_OFF);
labelE0Value = lv_label_create_empty(buttonE0Value);
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_FEED_DOWN, NULL, 0);
lv_btn_set_style_both(buttonTurnPage, &style_para_back);
#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, buttonE0Value);
lv_group_add_obj(g, buttonTurnPage);
}
#endif
} }
else { else {
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.E1MaxFeedRate); sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS_N(1)]);
lv_screen_menu_item_1_edit(scr, machine_menu.E1MaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_FEED_E1, 0, public_buf_l);
buttonE1Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_FEED_E1); lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_FEED_UP, true);
lv_btn_set_layout(buttonE1Value, LV_LAYOUT_OFF);
labelE1Value = lv_label_create_empty(buttonE1Value);
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_FEED_UP, NULL, 0);
lv_btn_set_style_both(buttonTurnPage, &style_para_back);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonE1Value);
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_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_FEED_RETURN, true);
lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
labelTurnPage = lv_label_create_empty(buttonTurnPage);
buttonBack = lv_btn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_FEED_RETURN, NULL, 0);
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);
lv_btn_set_style_both(buttonBack, &style_para_back);
label_Back = lv_label_create_empty(buttonBack);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif
if (gCfgItems.multiple_language) {
if (uiCfg.para_ui_page != 1) {
lv_label_set_text(labelTurnPage, machine_menu.next);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[X_AXIS]);
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"), planner.settings.max_feedrate_mm_s[Y_AXIS]);
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"), planner.settings.max_feedrate_mm_s[Z_AXIS]);
lv_label_set_text(labelZValue, public_buf_l);
lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS]);
lv_label_set_text(labelE0Value, public_buf_l);
lv_obj_align(labelE0Value, buttonE0Value, LV_ALIGN_CENTER, 0, 0);
}
else {
lv_label_set_text(labelTurnPage, machine_menu.previous);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS_N(1)]);
lv_label_set_text(labelE1Value, public_buf_l);
lv_obj_align(labelE1Value, buttonE1Value, 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_max_feedrate_settings() { void lv_clear_max_feedrate_settings() {

View file

@ -28,258 +28,78 @@
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_MOTOR_RETURN 1 enum {
#define ID_MOTOR_STEPS 2 ID_MOTOR_RETURN = 1,
#define ID_MOTOR_STEPS_ARROW 3 ID_MOTOR_STEPS,
#define ID_MOTOR_TMC_CURRENT 4 ID_MOTOR_TMC_CURRENT,
#define ID_MOTOR_TMC_CURRENT_ARROW 5 ID_MOTOR_STEP_MODE,
#define ID_MOTOR_STEP_MODE 6 ID_HOME_SENSE
#define ID_MOTOR_STEP_MODE_ARROW 7 };
#define ID_HOME_SENSE 8
#define ID_HOME_SENSE_ARROW 9
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_MOTOR_RETURN: case ID_MOTOR_RETURN:
if (event == LV_EVENT_CLICKED) { lv_clear_motor_settings();
draw_return_ui();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_motor_settings();
draw_return_ui();
}
break; break;
case ID_MOTOR_STEPS: case ID_MOTOR_STEPS:
if (event == LV_EVENT_CLICKED) { lv_clear_motor_settings();
lv_draw_step_settings();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_motor_settings();
lv_draw_step_settings();
}
break;
case ID_MOTOR_STEPS_ARROW:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_motor_settings();
lv_draw_step_settings();
}
break; break;
#if USE_SENSORLESS #if USE_SENSORLESS
case ID_HOME_SENSE: case ID_HOME_SENSE:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_motor_settings(); lv_clear_motor_settings();
lv_draw_homing_sensitivity_settings(); lv_draw_homing_sensitivity_settings();
} break;
break;
case ID_HOME_SENSE_ARROW:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_motor_settings();
lv_draw_homing_sensitivity_settings();
}
break;
#endif #endif
#if HAS_TRINAMIC_CONFIG
case ID_MOTOR_TMC_CURRENT:
if (event == LV_EVENT_CLICKED) {
} #if HAS_TRINAMIC_CONFIG
else if (event == LV_EVENT_RELEASED) { case ID_MOTOR_TMC_CURRENT:
lv_clear_motor_settings(); lv_clear_motor_settings();
lv_draw_tmc_current_settings(); lv_draw_tmc_current_settings();
} break;
#if HAS_STEALTHCHOP
case ID_MOTOR_STEP_MODE:
lv_clear_motor_settings();
lv_draw_tmc_step_mode_settings();
break; break;
case ID_MOTOR_TMC_CURRENT_ARROW:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_motor_settings();
lv_draw_tmc_current_settings();
}
break;
#if HAS_STEALTHCHOP
case ID_MOTOR_STEP_MODE:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_motor_settings();
lv_draw_tmc_step_mode_settings();
}
break;
case ID_MOTOR_STEP_MODE_ARROW:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_motor_settings();
lv_draw_tmc_step_mode_settings();
}
break;
#endif
#endif #endif
#endif
} }
} }
void lv_draw_motor_settings(void) { void lv_draw_motor_settings(void) {
lv_obj_t *buttonBack, *label_Back;
lv_obj_t *buttonSteps, *labelSteps, *buttonStepsNarrow;
lv_obj_t * line1;
#if USE_SENSORLESS
lv_obj_t *buttonSensitivity, *labelSensitivity, *buttonSensitivityNarrow;
lv_obj_t * line2;
#endif
#if HAS_TRINAMIC_CONFIG
#if USE_SENSORLESS
lv_obj_t * line3;
#else
lv_obj_t * line2;
#endif
lv_obj_t *buttonTMCcurrent, *labelTMCcurrent, *buttonTMCcurrentNarrow;
#if HAS_STEALTHCHOP
#if USE_SENSORLESS
lv_obj_t * line4;
#else
lv_obj_t * line3;
#endif
lv_obj_t *buttonStepMode, *labelStepMode, *buttonStepModeNarrow;
#endif
#endif
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MOTOR_SETTINGS_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MOTOR_SETTINGS_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = MOTOR_SETTINGS_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = MOTOR_SETTINGS_UI;
} }
disp_state = MOTOR_SETTINGS_UI; disp_state = MOTOR_SETTINGS_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.MotorConfTitle); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.MotorConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
buttonSteps = lv_btn_create(scr, NULL); /*Add a button the current screen*/ int index = 0;
lv_obj_set_pos(buttonSteps, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/ lv_screen_menu_item(scr, machine_menu.StepsConf, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MOTOR_STEPS, index++);
lv_obj_set_size(buttonSteps, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
//lv_obj_set_event_cb(buttonMachine, event_handler);
lv_obj_set_event_cb_mks(buttonSteps, event_handler, ID_MOTOR_STEPS, NULL, 0);
lv_btn_use_label_style(buttonSteps);
lv_btn_set_layout(buttonSteps, LV_LAYOUT_OFF);
labelSteps = lv_label_create_empty(buttonSteps); /*Add a label to the button*/
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonSteps);
#endif
buttonStepsNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V, event_handler, ID_MOTOR_STEPS_ARROW);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
#if USE_SENSORLESS #if USE_SENSORLESS
buttonSensitivity = lv_btn_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2, PARA_UI_SIZE_X, PARA_UI_SIZE_Y, event_handler, ID_HOME_SENSE); lv_screen_menu_item(scr, machine_menu.HomingSensitivityConf, PARA_UI_POS_X, PARA_UI_POS_Y * (index + 1), event_handler, ID_HOME_SENSE, index);
//lv_obj_set_event_cb(buttonMachine, event_handler); index++;
labelSensitivity = lv_label_create_empty(buttonSensitivity); /*Add a label to the button*/
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonSensitivity);
#endif
buttonSensitivityNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V, event_handler, ID_HOME_SENSE_ARROW);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
#endif #endif
#if HAS_TRINAMIC_CONFIG #if HAS_TRINAMIC_CONFIG
buttonTMCcurrent = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_screen_menu_item(scr, machine_menu.TMCcurrentConf, PARA_UI_POS_X, PARA_UI_POS_Y * (index + 1), event_handler, ID_MOTOR_TMC_CURRENT, index);
lv_obj_set_pos(buttonTMCcurrent, PARA_UI_POS_X, TERN(USE_SENSORLESS, PARA_UI_POS_Y * 3, PARA_UI_POS_Y * 2)); index++;
lv_obj_set_size(buttonTMCcurrent, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
//lv_obj_set_event_cb(buttonMachine, event_handler);
lv_obj_set_event_cb_mks(buttonTMCcurrent, event_handler, ID_MOTOR_TMC_CURRENT, NULL, 0);
lv_btn_use_label_style(buttonTMCcurrent);
lv_btn_set_layout(buttonTMCcurrent, LV_LAYOUT_OFF);
labelTMCcurrent = lv_label_create_empty(buttonTMCcurrent); /*Add a label to the button*/
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonTMCcurrent);
#endif
buttonTMCcurrentNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, TERN(USE_SENSORLESS, PARA_UI_POS_Y * 3, PARA_UI_POS_Y * 2) + PARA_UI_ARROW_V, event_handler, ID_MOTOR_TMC_CURRENT_ARROW);
#if USE_SENSORLESS
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
#else
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
#endif
#if HAS_STEALTHCHOP #if HAS_STEALTHCHOP
buttonStepMode = lv_btn_create(scr, NULL, PARA_UI_POS_X, TERN(USE_SENSORLESS, PARA_UI_POS_Y * 4, PARA_UI_POS_Y * 3), PARA_UI_SIZE_X, PARA_UI_SIZE_Y, event_handler, ID_MOTOR_STEP_MODE); lv_screen_menu_item(scr, machine_menu.TMCStepModeConf, PARA_UI_POS_X, PARA_UI_POS_Y * (index + 1), event_handler, ID_MOTOR_STEP_MODE, index);
labelStepMode = lv_label_create_empty(buttonStepMode); /*Add a label to the button*/ index++;
#endif
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonStepMode);
#endif
buttonStepModeNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, TERN(USE_SENSORLESS, PARA_UI_POS_Y * 4, PARA_UI_POS_Y * 3) + PARA_UI_ARROW_V, event_handler, ID_MOTOR_STEP_MODE_ARROW);
#if USE_SENSORLESS
line4 = lv_line_create(scr, NULL);
lv_ex_line(line4, line_points[3]);
#else
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
#endif
#endif // HAS_STEALTHCHOP
#endif // HAS_TRINAMIC_CONFIG
buttonBack = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_MOTOR_RETURN);
label_Back = lv_label_create_empty(buttonBack);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif #endif
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_MOTOR_RETURN, true);
if (gCfgItems.multiple_language) {
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(labelSteps, machine_menu.StepsConf);
lv_obj_align(labelSteps, buttonSteps, LV_ALIGN_IN_LEFT_MID, 0, 0);
#if USE_SENSORLESS
lv_label_set_text(labelSensitivity, machine_menu.HomingSensitivityConf);
lv_obj_align(labelSensitivity, buttonSensitivity, LV_ALIGN_IN_LEFT_MID, 0, 0);
#endif
#if HAS_TRINAMIC_CONFIG
lv_label_set_text(labelTMCcurrent, machine_menu.TMCcurrentConf);
lv_obj_align(labelTMCcurrent, buttonTMCcurrent, LV_ALIGN_IN_LEFT_MID, 0, 0);
#if HAS_STEALTHCHOP
lv_label_set_text(labelStepMode, machine_menu.TMCStepModeConf);
lv_obj_align(labelStepMode, buttonStepMode, LV_ALIGN_IN_LEFT_MID, 0, 0);
#endif
#endif
}
} }
void lv_clear_motor_settings() { void lv_clear_motor_settings() {

View file

@ -33,210 +33,119 @@
#include "../../../../gcode/queue.h" #include "../../../../gcode/queue.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
static lv_obj_t *labelV, *buttonV; static lv_obj_t *labelV, *buttonV;
#define ID_M_X_P 1 enum {
#define ID_M_X_N 2 ID_M_X_P = 1,
#define ID_M_Y_P 3 ID_M_X_N,
#define ID_M_Y_N 4 ID_M_Y_P,
#define ID_M_Z_P 5 ID_M_Y_N,
#define ID_M_Z_N 6 ID_M_Z_P,
#define ID_M_STEP 7 ID_M_Z_N,
#define ID_M_RETURN 8 ID_M_STEP,
ID_M_RETURN
};
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_M_X_P: case ID_M_X_P:
if (event == LV_EVENT_CLICKED) { if (queue.length <= (BUFSIZE - 3)) {
// nothing to do queue.enqueue_one_P(PSTR("G91"));
} sprintf_P(public_buf_l, PSTR("G1 X%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
else if (event == LV_EVENT_RELEASED) { queue.enqueue_one_now(public_buf_l);
if (queue.length <= (BUFSIZE - 3)) { queue.enqueue_one_P(PSTR("G90"));
ZERO(public_buf_l);
queue.enqueue_one_P(PSTR("G91"));
sprintf_P(public_buf_l, PSTR("G1 X%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_one_P(PSTR("G90"));
}
} }
break; break;
case ID_M_X_N: case ID_M_X_N:
if (event == LV_EVENT_CLICKED) { if (queue.length <= (BUFSIZE - 3)) {
// nothing to do queue.enqueue_now_P(PSTR("G91"));
} sprintf_P(public_buf_l, PSTR("G1 X-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
else if (event == LV_EVENT_RELEASED) { queue.enqueue_one_now(public_buf_l);
if (queue.length <= (BUFSIZE - 3)) { queue.enqueue_now_P(PSTR("G90"));
ZERO(public_buf_l);
queue.enqueue_now_P(PSTR("G91"));
sprintf_P(public_buf_l, PSTR("G1 X-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G90"));
}
} }
break; break;
case ID_M_Y_P: case ID_M_Y_P:
if (event == LV_EVENT_CLICKED) { if (queue.length <= (BUFSIZE - 3)) {
// nothing to do queue.enqueue_now_P(PSTR("G91"));
} sprintf_P(public_buf_l, PSTR("G1 Y%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
else if (event == LV_EVENT_RELEASED) { queue.enqueue_one_now(public_buf_l);
if (queue.length <= (BUFSIZE - 3)) { queue.enqueue_now_P(PSTR("G90"));
ZERO(public_buf_l);
queue.enqueue_now_P(PSTR("G91"));
sprintf_P(public_buf_l, PSTR("G1 Y%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G90"));
}
} }
break; break;
case ID_M_Y_N: case ID_M_Y_N:
if (event == LV_EVENT_CLICKED) { if (queue.length <= (BUFSIZE - 3)) {
// nothing to do queue.enqueue_now_P(PSTR("G91"));
} sprintf_P(public_buf_l, PSTR("G1 Y-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
else if (event == LV_EVENT_RELEASED) { queue.enqueue_one_now(public_buf_l);
if (queue.length <= (BUFSIZE - 3)) { queue.enqueue_now_P(PSTR("G90"));
ZERO(public_buf_l);
queue.enqueue_now_P(PSTR("G91"));
sprintf_P(public_buf_l, PSTR("G1 Y-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G90"));
}
} }
break; break;
case ID_M_Z_P: case ID_M_Z_P:
if (event == LV_EVENT_CLICKED) { if (queue.length <= (BUFSIZE - 3)) {
// nothing to do queue.enqueue_now_P(PSTR("G91"));
} sprintf_P(public_buf_l, PSTR("G1 Z%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
else if (event == LV_EVENT_RELEASED) { queue.enqueue_one_now(public_buf_l);
if (queue.length <= (BUFSIZE - 3)) { queue.enqueue_now_P(PSTR("G90"));
ZERO(public_buf_l);
queue.enqueue_now_P(PSTR("G91"));
sprintf_P(public_buf_l, PSTR("G1 Z%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G90"));
}
} }
break; break;
case ID_M_Z_N: case ID_M_Z_N:
if (event == LV_EVENT_CLICKED) { if (queue.length <= (BUFSIZE - 3)) {
// nothing to do queue.enqueue_now_P(PSTR("G91"));
} sprintf_P(public_buf_l, PSTR("G1 Z-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
else if (event == LV_EVENT_RELEASED) { queue.enqueue_one_now(public_buf_l);
if (queue.length <= (BUFSIZE - 3)) { queue.enqueue_now_P(PSTR("G90"));
ZERO(public_buf_l);
queue.enqueue_now_P(PSTR("G91"));
sprintf_P(public_buf_l, PSTR("G1 Z-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
queue.enqueue_one_now(public_buf_l);
queue.enqueue_now_P(PSTR("G90"));
}
} }
break; break;
case ID_M_STEP: case ID_M_STEP:
if (event == LV_EVENT_CLICKED) { if (abs(10 * (int)uiCfg.move_dist) == 100)
// nothing to do uiCfg.move_dist = 0.1;
} else
else if (event == LV_EVENT_RELEASED) { uiCfg.move_dist *= (float)10;
if (abs(10 * (int)uiCfg.move_dist) == 100) disp_move_dist();
uiCfg.move_dist = 0.1;
else
uiCfg.move_dist *= (float)10;
disp_move_dist();
}
break; break;
case ID_M_RETURN: case ID_M_RETURN:
if (event == LV_EVENT_CLICKED) { clear_cur_ui();
// nothing to do draw_return_ui();
}
else if (event == LV_EVENT_RELEASED) {
clear_cur_ui();
draw_return_ui();
}
break; break;
} }
} }
void lv_draw_move_motor(void) { void lv_draw_move_motor(void) {
lv_obj_t *buttonXI, *buttonXD, *buttonYI, *buttonYD, *buttonZI, *buttonZD, *buttonBack;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MOVE_MOTOR_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MOVE_MOTOR_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = MOVE_MOTOR_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = MOVE_MOTOR_UI;
} }
disp_state = MOVE_MOTOR_UI; disp_state = MOVE_MOTOR_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
// Create an Image button lv_obj_t *buttonXI = lv_big_button_create(scr, "F:/bmp_xAdd.bin", move_menu.x_add, INTERVAL_V, titleHeight, event_handler, ID_M_X_P);
buttonXI = lv_imgbtn_create(scr, "F:/bmp_xAdd.bin", INTERVAL_V, titleHeight, event_handler, ID_M_X_P);
lv_obj_clear_protect(buttonXI, LV_PROTECT_FOLLOW); lv_obj_clear_protect(buttonXI, LV_PROTECT_FOLLOW);
buttonXD = lv_imgbtn_create(scr, "F:/bmp_xDec.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_X_N); lv_big_button_create(scr, "F:/bmp_xDec.bin", move_menu.x_dec, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_X_N);
buttonYI = lv_imgbtn_create(scr, "F:/bmp_yAdd.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_M_Y_P); lv_big_button_create(scr, "F:/bmp_yAdd.bin", move_menu.y_add, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_M_Y_P);
buttonYD = lv_imgbtn_create(scr, "F:/bmp_yDec.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_Y_N); lv_big_button_create(scr, "F:/bmp_yDec.bin", move_menu.y_dec, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_Y_N);
buttonZI = lv_imgbtn_create(scr, "F:/bmp_zAdd.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_M_Z_P); lv_big_button_create(scr, "F:/bmp_zAdd.bin", move_menu.z_add, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_M_Z_P);
buttonZD = lv_imgbtn_create(scr, "F:/bmp_zDec.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_Z_N); lv_big_button_create(scr, "F:/bmp_zDec.bin", move_menu.z_dec, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_Z_N);
buttonV = lv_imgbtn_create(scr, NULL, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_M_STEP); // button with image and label changed dinamycally by disp_move_dist
//lv_obj_set_event_cb_mks(buttonV, event_handler,ID_T_MORE,"bmp_More.bin",0); buttonV = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_M_STEP);
buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_RETURN);
// Create labels on the image buttons
lv_obj_t *labelXI = lv_label_create_empty(buttonXI);
lv_obj_t *labelXD = lv_label_create_empty(buttonXD);
lv_obj_t *labelYI = lv_label_create_empty(buttonYI);
lv_obj_t *labelYD = lv_label_create_empty(buttonYD);
lv_obj_t *labelZI = lv_label_create_empty(buttonZI);
lv_obj_t *labelZD = lv_label_create_empty(buttonZD);
labelV = lv_label_create_empty(buttonV); labelV = lv_label_create_empty(buttonV);
lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.multiple_language) {
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 HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) { 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, buttonV);
lv_group_add_obj(g, buttonBack);
} }
#endif #endif
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_RETURN);
disp_move_dist(); disp_move_dist();
} }

View file

@ -49,30 +49,32 @@
#include "../../../../module/probe.h" #include "../../../../module/probe.h"
#endif #endif
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
static lv_obj_t *buttonValue = NULL; static lv_obj_t *buttonValue = nullptr;
static lv_obj_t *labelValue = NULL; static lv_obj_t *labelValue = nullptr;
static char key_value[11] = {0}; static char key_value[11] = { 0 };
static uint8_t cnt = 0; static uint8_t cnt = 0;
static char point_flg = 1; static bool point_flag = true;
#define ID_NUM_KEY1 1 enum {
#define ID_NUM_KEY2 2 ID_NUM_KEY1 = 1,
#define ID_NUM_KEY3 3 ID_NUM_KEY2,
#define ID_NUM_KEY4 4 ID_NUM_KEY3,
#define ID_NUM_KEY5 5 ID_NUM_KEY4,
#define ID_NUM_KEY6 6 ID_NUM_KEY5,
#define ID_NUM_KEY7 7 ID_NUM_KEY6,
#define ID_NUM_KEY8 8 ID_NUM_KEY7,
#define ID_NUM_KEY9 9 ID_NUM_KEY8,
#define ID_NUM_KEY0 10 ID_NUM_KEY9,
#define ID_NUM_BACK 11 ID_NUM_KEY0,
#define ID_NUM_RESET 12 ID_NUM_BACK,
#define ID_NUM_CONFIRM 13 ID_NUM_RESET,
#define ID_NUM_POINT 14 ID_NUM_CONFIRM,
#define ID_NUM_NAGETIVE 15 ID_NUM_POINT,
ID_NUM_NEGATIVE
};
static void disp_key_value() { static void disp_key_value() {
char *temp; char *temp;
@ -80,8 +82,6 @@ static void disp_key_value() {
float milliamps; float milliamps;
#endif #endif
ZERO(public_buf_m);
switch (value) { switch (value) {
case PrintAcceleration: case PrintAcceleration:
sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.acceleration); sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.acceleration);
@ -289,14 +289,11 @@ static void disp_key_value() {
#endif #endif
break; break;
} }
ZERO(key_value);
strcpy(key_value, public_buf_m); strcpy(key_value, public_buf_m);
cnt = strlen(key_value); cnt = strlen(key_value);
temp = strchr(key_value, '.'); temp = strchr(key_value, '.');
if (temp) point_flag = !temp;
point_flg = 0;
else
point_flg = 1;
lv_label_set_text(labelValue, key_value); lv_label_set_text(labelValue, key_value);
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0); lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
@ -540,406 +537,218 @@ static void set_value_confirm() {
gcode.process_subcommands_now_P(PSTR("M500")); gcode.process_subcommands_now_P(PSTR("M500"));
} }
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_NUM_KEY1: case ID_NUM_KEY1:
if (event == LV_EVENT_CLICKED) { if (cnt <= 10) {
key_value[cnt] = (char)'1';
} lv_label_set_text(labelValue, key_value);
else if (event == LV_EVENT_RELEASED) { lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
if (cnt <= 10) { cnt++;
key_value[cnt] = (char)'1';
lv_label_set_text(labelValue, key_value);
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
cnt++;
}
} }
break; break;
case ID_NUM_KEY2: case ID_NUM_KEY2:
if (event == LV_EVENT_CLICKED) { if (cnt <= 10) {
key_value[cnt] = (char)'2';
} lv_label_set_text(labelValue, key_value);
else if (event == LV_EVENT_RELEASED) { lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
if (cnt <= 10) { cnt++;
key_value[cnt] = (char)'2';
lv_label_set_text(labelValue, key_value);
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
cnt++;
}
} }
break; break;
case ID_NUM_KEY3: case ID_NUM_KEY3:
if (event == LV_EVENT_CLICKED) { if (cnt <= 10) {
key_value[cnt] = (char)'3';
} lv_label_set_text(labelValue, key_value);
else if (event == LV_EVENT_RELEASED) { lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
if (cnt <= 10) { cnt++;
key_value[cnt] = (char)'3';
lv_label_set_text(labelValue, key_value);
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
cnt++;
}
} }
break; break;
case ID_NUM_KEY4: case ID_NUM_KEY4:
if (event == LV_EVENT_CLICKED) { if (cnt <= 10) {
key_value[cnt] = (char)'4';
} lv_label_set_text(labelValue, key_value);
else if (event == LV_EVENT_RELEASED) { lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
if (cnt <= 10) { cnt++;
key_value[cnt] = (char)'4';
lv_label_set_text(labelValue, key_value);
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
cnt++;
}
} }
break; break;
case ID_NUM_KEY5: case ID_NUM_KEY5:
if (event == LV_EVENT_CLICKED) { if (cnt <= 10) {
key_value[cnt] = (char)'5';
} lv_label_set_text(labelValue, key_value);
else if (event == LV_EVENT_RELEASED) { lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
if (cnt <= 10) { cnt++;
key_value[cnt] = (char)'5';
lv_label_set_text(labelValue, key_value);
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
cnt++;
}
} }
break; break;
case ID_NUM_KEY6: case ID_NUM_KEY6:
if (event == LV_EVENT_CLICKED) { if (cnt <= 10) {
key_value[cnt] = (char)'6';
} lv_label_set_text(labelValue, key_value);
else if (event == LV_EVENT_RELEASED) { lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
if (cnt <= 10) { cnt++;
key_value[cnt] = (char)'6';
lv_label_set_text(labelValue, key_value);
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
cnt++;
}
} }
break; break;
case ID_NUM_KEY7: case ID_NUM_KEY7:
if (event == LV_EVENT_CLICKED) { if (cnt <= 10) {
key_value[cnt] = (char)'7';
} lv_label_set_text(labelValue, key_value);
else if (event == LV_EVENT_RELEASED) { lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
if (cnt <= 10) { cnt++;
key_value[cnt] = (char)'7';
lv_label_set_text(labelValue, key_value);
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
cnt++;
}
} }
break; break;
case ID_NUM_KEY8: case ID_NUM_KEY8:
if (event == LV_EVENT_CLICKED) { if (cnt <= 10) {
key_value[cnt] = (char)'8';
} lv_label_set_text(labelValue, key_value);
else if (event == LV_EVENT_RELEASED) { lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
if (cnt <= 10) { cnt++;
key_value[cnt] = (char)'8';
lv_label_set_text(labelValue, key_value);
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
cnt++;
}
} }
break; break;
case ID_NUM_KEY9: case ID_NUM_KEY9:
if (event == LV_EVENT_CLICKED) { if (cnt <= 10) {
key_value[cnt] = (char)'9';
} lv_label_set_text(labelValue, key_value);
else if (event == LV_EVENT_RELEASED) { lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
if (cnt <= 10) { cnt++;
key_value[cnt] = (char)'9';
lv_label_set_text(labelValue, key_value);
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
cnt++;
}
} }
break; break;
case ID_NUM_KEY0: case ID_NUM_KEY0:
if (event == LV_EVENT_CLICKED) { if (cnt <= 10) {
key_value[cnt] = (char)'0';
} lv_label_set_text(labelValue, key_value);
else if (event == LV_EVENT_RELEASED) { lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
if (cnt <= 10) { cnt++;
key_value[cnt] = (char)'0';
lv_label_set_text(labelValue, key_value);
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
cnt++;
}
} }
break; break;
case ID_NUM_BACK: case ID_NUM_BACK:
if (event == LV_EVENT_CLICKED) { if (cnt > 0) cnt--;
if (key_value[cnt] == (char)'.') point_flag = true;
} key_value[cnt] = (char)'\0';
else if (event == LV_EVENT_RELEASED) { lv_label_set_text(labelValue, key_value);
if (cnt > 0) lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
cnt--;
if (key_value[cnt] == (char)'.') point_flg = 1;
key_value[cnt] = (char)'\0';
lv_label_set_text(labelValue, key_value);
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
}
break; break;
case ID_NUM_RESET: case ID_NUM_RESET:
if (event == LV_EVENT_CLICKED) { ZERO(key_value);
cnt = 0;
} key_value[cnt] = (char)'0';
else if (event == LV_EVENT_RELEASED) { point_flag = true;
ZERO(key_value); lv_label_set_text(labelValue, key_value);
cnt = 0; lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
key_value[cnt] = (char)'0';
point_flg = 1;
lv_label_set_text(labelValue, key_value);
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
}
break; break;
case ID_NUM_POINT: case ID_NUM_POINT:
if (event == LV_EVENT_CLICKED) { if (cnt != 0 && point_flag) {
point_flag = false;
} key_value[cnt] = (char)'.';
else if (event == LV_EVENT_RELEASED) { lv_label_set_text(labelValue, key_value);
if ((cnt != 0) && (point_flg == 1)) { lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
point_flg = 0; cnt++;
key_value[cnt] = (char)'.';
lv_label_set_text(labelValue, key_value);
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
cnt++;
}
} }
break; break;
case ID_NUM_NAGETIVE: case ID_NUM_NEGATIVE:
if (event == LV_EVENT_CLICKED) { if (cnt == 0) {
key_value[cnt] = (char)'-';
} lv_label_set_text(labelValue, key_value);
else if (event == LV_EVENT_RELEASED) { lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
if (cnt == 0) { cnt++;
key_value[cnt] = (char)'-';
lv_label_set_text(labelValue, key_value);
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
cnt++;
}
} }
break; break;
case ID_NUM_CONFIRM: case ID_NUM_CONFIRM:
if (event == LV_EVENT_CLICKED) { last_disp_state = NUMBER_KEY_UI;
if (strlen(key_value) != 0) set_value_confirm();
} lv_clear_number_key();
else if (event == LV_EVENT_RELEASED) { draw_return_ui();
last_disp_state = NUMBER_KEY_UI;
if (strlen(key_value) != 0)
set_value_confirm();
lv_clear_number_key();
draw_return_ui();
}
break; break;
} }
} }
void lv_draw_number_key(void) { void lv_draw_number_key(void) {
lv_obj_t *NumberKey_1 = NULL, *NumberKey_2 = NULL, *NumberKey_3 = NULL, *NumberKey_4 = NULL, *NumberKey_5 = NULL;
lv_obj_t *NumberKey_6 = NULL, *NumberKey_7 = NULL, *NumberKey_8 = NULL, *NumberKey_9 = NULL, *NumberKey_0 = NULL;
lv_obj_t *KeyPoint = NULL, *KeyConfirm = NULL, *KeyReset = NULL, *KeyBack = NULL;
lv_obj_t *Minus = NULL;
lv_obj_t *labelKey_1 = NULL, *labelKey_2 = NULL, *labelKey_3 = NULL, *labelKey_4 = NULL, *labelKey_5 = NULL;
lv_obj_t *labelKey_6 = NULL, *labelKey_7 = NULL, *labelKey_8 = NULL, *labelKey_9 = NULL, *labelKey_0 = NULL;
lv_obj_t *labelKeyPoint = NULL, *labelKeyConfirm = NULL, *labelKeyReset = NULL, *labelKeyBack = NULL;
lv_obj_t *labelMinus = NULL;
buttonValue = NULL;
labelValue = NULL;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != NUMBER_KEY_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != NUMBER_KEY_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = NUMBER_KEY_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = NUMBER_KEY_UI;
} }
disp_state = NUMBER_KEY_UI; disp_state = NUMBER_KEY_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
//(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); //(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
buttonValue = lv_btn_create(scr, NULL); /*Add a button the current screen*/ buttonValue = lv_btn_create(scr, 92, 40, 296, 40, event_handler, ID_NUM_KEY1, &style_num_text);
lv_obj_set_pos(buttonValue, 92, 40); /*Set its position*/ labelValue = lv_label_create_empty(buttonValue);
lv_obj_set_size(buttonValue, 296, 40);
lv_obj_set_event_cb_mks(buttonValue, event_handler, ID_NUM_KEY1, NULL, 0);
lv_btn_set_style(buttonValue, LV_BTN_STYLE_REL, &style_num_text); /*Set the button's released style*/
lv_btn_set_style(buttonValue, LV_BTN_STYLE_PR, &style_num_text); /*Set the button's pressed style*/
//lv_btn_set_layout(buttonValue, LV_LAYOUT_OFF);
labelValue = lv_label_create_empty(buttonValue); /*Add a label to the button*/
NumberKey_1 = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_t *NumberKey_1 = lv_btn_create(scr, 92, 90, 68, 40, event_handler, ID_NUM_KEY1, &style_num_key_pre);
lv_obj_set_pos(NumberKey_1, 92, 90); /*Set its position*/ lv_obj_t *labelKey_1 = lv_label_create_empty(NumberKey_1);
lv_obj_set_size(NumberKey_1, 68, 40);
lv_obj_set_event_cb_mks(NumberKey_1, event_handler, ID_NUM_KEY1, NULL, 0);
lv_btn_set_style(NumberKey_1, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/
lv_btn_set_style(NumberKey_1, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/
//lv_btn_set_layout(NumberKey_1, LV_LAYOUT_OFF);
labelKey_1 = lv_label_create_empty(NumberKey_1); /*Add a label to the button*/
lv_label_set_text(labelKey_1, machine_menu.key_1); lv_label_set_text(labelKey_1, machine_menu.key_1);
lv_obj_align(labelKey_1, NumberKey_1, LV_ALIGN_CENTER, 0, 0); lv_obj_align(labelKey_1, NumberKey_1, LV_ALIGN_CENTER, 0, 0);
NumberKey_2 = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_t *NumberKey_2 = lv_btn_create(scr, 168, 90, 68, 40, event_handler, ID_NUM_KEY2, &style_num_key_pre);
lv_obj_set_pos(NumberKey_2, 168, 90); /*Set its position*/ lv_obj_t *labelKey_2 = lv_label_create_empty(NumberKey_2);
lv_obj_set_size(NumberKey_2, 68, 40);
lv_obj_set_event_cb_mks(NumberKey_2, event_handler, ID_NUM_KEY2, NULL, 0);
lv_btn_set_style(NumberKey_2, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/
lv_btn_set_style(NumberKey_2, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/
//lv_btn_set_layout(NumberKey_2, LV_LAYOUT_OFF);
labelKey_2 = lv_label_create_empty(NumberKey_2); /*Add a label to the button*/
lv_label_set_text(labelKey_2, machine_menu.key_2); lv_label_set_text(labelKey_2, machine_menu.key_2);
lv_obj_align(labelKey_2, NumberKey_2, LV_ALIGN_CENTER, 0, 0); lv_obj_align(labelKey_2, NumberKey_2, LV_ALIGN_CENTER, 0, 0);
NumberKey_3 = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_t *NumberKey_3 = lv_btn_create(scr, 244, 90, 68, 40, event_handler, ID_NUM_KEY3, &style_num_key_pre);
lv_obj_set_pos(NumberKey_3, 244, 90); /*Set its position*/ lv_obj_t *labelKey_3 = lv_label_create_empty(NumberKey_3);
lv_obj_set_size(NumberKey_3, 68, 40);
lv_obj_set_event_cb_mks(NumberKey_3, event_handler, ID_NUM_KEY3, NULL, 0);
lv_btn_set_style(NumberKey_3, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/
lv_btn_set_style(NumberKey_3, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/
//lv_btn_set_layout(NumberKey_3, LV_LAYOUT_OFF);
labelKey_3 = lv_label_create_empty(NumberKey_3); /*Add a label to the button*/
lv_label_set_text(labelKey_3, machine_menu.key_3); lv_label_set_text(labelKey_3, machine_menu.key_3);
lv_obj_align(labelKey_3, NumberKey_3, LV_ALIGN_CENTER, 0, 0); lv_obj_align(labelKey_3, NumberKey_3, LV_ALIGN_CENTER, 0, 0);
NumberKey_4 = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_t *NumberKey_4 = lv_btn_create(scr, 92, 140, 68, 40, event_handler, ID_NUM_KEY4, &style_num_key_pre);
lv_obj_set_pos(NumberKey_4, 92, 140); /*Set its position*/ lv_obj_t *labelKey_4 = lv_label_create_empty(NumberKey_4);
lv_obj_set_size(NumberKey_4, 68, 40);
lv_obj_set_event_cb_mks(NumberKey_4, event_handler, ID_NUM_KEY4, NULL, 0);
lv_btn_set_style(NumberKey_4, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/
lv_btn_set_style(NumberKey_4, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/
//lv_btn_set_layout(NumberKey_4, LV_LAYOUT_OFF);
labelKey_4 = lv_label_create_empty(NumberKey_4); /*Add a label to the button*/
lv_label_set_text(labelKey_4, machine_menu.key_4); lv_label_set_text(labelKey_4, machine_menu.key_4);
lv_obj_align(labelKey_4, NumberKey_4, LV_ALIGN_CENTER, 0, 0); lv_obj_align(labelKey_4, NumberKey_4, LV_ALIGN_CENTER, 0, 0);
NumberKey_5 = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_t *NumberKey_5 = lv_btn_create(scr, 168, 140, 68, 40, event_handler, ID_NUM_KEY5, &style_num_key_pre);
lv_obj_set_pos(NumberKey_5, 168, 140); /*Set its position*/ lv_obj_t *labelKey_5 = lv_label_create_empty(NumberKey_5);
lv_obj_set_size(NumberKey_5, 68, 40);
lv_obj_set_event_cb_mks(NumberKey_5, event_handler, ID_NUM_KEY5, NULL, 0);
lv_btn_set_style(NumberKey_5, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/
lv_btn_set_style(NumberKey_5, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/
//lv_btn_set_layout(NumberKey_5, LV_LAYOUT_OFF);
labelKey_5 = lv_label_create_empty(NumberKey_5); /*Add a label to the button*/
lv_label_set_text(labelKey_5, machine_menu.key_5); lv_label_set_text(labelKey_5, machine_menu.key_5);
lv_obj_align(labelKey_5, NumberKey_5, LV_ALIGN_CENTER, 0, 0); lv_obj_align(labelKey_5, NumberKey_5, LV_ALIGN_CENTER, 0, 0);
NumberKey_6 = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_t *NumberKey_6 = lv_btn_create(scr, 244, 140, 68, 40, event_handler, ID_NUM_KEY6, &style_num_key_pre);
lv_obj_set_pos(NumberKey_6, 244, 140); /*Set its position*/ lv_obj_t *labelKey_6 = lv_label_create_empty(NumberKey_6);
lv_obj_set_size(NumberKey_6, 68, 40);
lv_obj_set_event_cb_mks(NumberKey_6, event_handler, ID_NUM_KEY6, NULL, 0);
lv_btn_set_style(NumberKey_6, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/
lv_btn_set_style(NumberKey_6, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/
//lv_btn_set_layout(NumberKey_6, LV_LAYOUT_OFF);
labelKey_6 = lv_label_create_empty(NumberKey_6); /*Add a label to the button*/
lv_label_set_text(labelKey_6, machine_menu.key_6); lv_label_set_text(labelKey_6, machine_menu.key_6);
lv_obj_align(labelKey_6, NumberKey_6, LV_ALIGN_CENTER, 0, 0); lv_obj_align(labelKey_6, NumberKey_6, LV_ALIGN_CENTER, 0, 0);
NumberKey_7 = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_t *NumberKey_7 = lv_btn_create(scr, 92, 190, 68, 40, event_handler, ID_NUM_KEY7, &style_num_key_pre);
lv_obj_set_pos(NumberKey_7, 92, 190); /*Set its position*/ lv_obj_t *labelKey_7 = lv_label_create_empty(NumberKey_7);
lv_obj_set_size(NumberKey_7, 68, 40);
lv_obj_set_event_cb_mks(NumberKey_7, event_handler, ID_NUM_KEY7, NULL, 0);
lv_btn_set_style(NumberKey_7, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/
lv_btn_set_style(NumberKey_7, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/
//lv_btn_set_layout(NumberKey_7, LV_LAYOUT_OFF);
labelKey_7 = lv_label_create_empty(NumberKey_7); /*Add a label to the button*/
lv_label_set_text(labelKey_7, machine_menu.key_7); lv_label_set_text(labelKey_7, machine_menu.key_7);
lv_obj_align(labelKey_7, NumberKey_7, LV_ALIGN_CENTER, 0, 0); lv_obj_align(labelKey_7, NumberKey_7, LV_ALIGN_CENTER, 0, 0);
NumberKey_8 = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_t *NumberKey_8 = lv_btn_create(scr, 168, 190, 68, 40, event_handler, ID_NUM_KEY8, &style_num_key_pre);
lv_obj_set_pos(NumberKey_8, 168, 190); /*Set its position*/ lv_obj_t *labelKey_8 = lv_label_create_empty(NumberKey_8);
lv_obj_set_size(NumberKey_8, 68, 40);
lv_obj_set_event_cb_mks(NumberKey_8, event_handler, ID_NUM_KEY8, NULL, 0);
lv_btn_set_style(NumberKey_8, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/
lv_btn_set_style(NumberKey_8, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/
//lv_btn_set_layout(NumberKey_8, LV_LAYOUT_OFF);
labelKey_8 = lv_label_create_empty(NumberKey_8); /*Add a label to the button*/
lv_label_set_text(labelKey_8, machine_menu.key_8); lv_label_set_text(labelKey_8, machine_menu.key_8);
lv_obj_align(labelKey_8, NumberKey_8, LV_ALIGN_CENTER, 0, 0); lv_obj_align(labelKey_8, NumberKey_8, LV_ALIGN_CENTER, 0, 0);
NumberKey_9 = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_t *NumberKey_9 = lv_btn_create(scr, 244, 190, 68, 40, event_handler, ID_NUM_KEY9, &style_num_key_pre);
lv_obj_set_pos(NumberKey_9, 244, 190); /*Set its position*/ lv_obj_t *labelKey_9 = lv_label_create_empty(NumberKey_9);
lv_obj_set_size(NumberKey_9, 68, 40);
lv_obj_set_event_cb_mks(NumberKey_9, event_handler, ID_NUM_KEY9, NULL, 0);
lv_btn_set_style(NumberKey_9, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/
lv_btn_set_style(NumberKey_9, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/
//lv_btn_set_layout(NumberKey_9, LV_LAYOUT_OFF);
labelKey_9 = lv_label_create_empty(NumberKey_9); /*Add a label to the button*/
lv_label_set_text(labelKey_9, machine_menu.key_9); lv_label_set_text(labelKey_9, machine_menu.key_9);
lv_obj_align(labelKey_9, NumberKey_9, LV_ALIGN_CENTER, 0, 0); lv_obj_align(labelKey_9, NumberKey_9, LV_ALIGN_CENTER, 0, 0);
NumberKey_0 = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_t *NumberKey_0 = lv_btn_create(scr, 92, 240, 68, 40, event_handler, ID_NUM_KEY0, &style_num_key_pre);
lv_obj_set_pos(NumberKey_0, 92, 240); /*Set its position*/ lv_obj_t *labelKey_0 = lv_label_create_empty(NumberKey_0);
lv_obj_set_size(NumberKey_0, 68, 40);
lv_obj_set_event_cb_mks(NumberKey_0, event_handler, ID_NUM_KEY0, NULL, 0);
lv_btn_set_style(NumberKey_0, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/
lv_btn_set_style(NumberKey_0, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/
//lv_btn_set_layout(NumberKey_0, LV_LAYOUT_OFF);
labelKey_0 = lv_label_create_empty(NumberKey_0); /*Add a label to the button*/
lv_label_set_text(labelKey_0, machine_menu.key_0); lv_label_set_text(labelKey_0, machine_menu.key_0);
lv_obj_align(labelKey_0, NumberKey_0, LV_ALIGN_CENTER, 0, 0); lv_obj_align(labelKey_0, NumberKey_0, LV_ALIGN_CENTER, 0, 0);
KeyBack = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_t *KeyBack = lv_btn_create(scr, 320, 90, 68, 40, event_handler, ID_NUM_BACK, &style_num_key_pre);
lv_obj_set_pos(KeyBack, 320, 90); /*Set its position*/ lv_obj_t *labelKeyBack = lv_label_create_empty(KeyBack);
lv_obj_set_size(KeyBack, 68, 40);
lv_obj_set_event_cb_mks(KeyBack, event_handler, ID_NUM_BACK, NULL, 0);
lv_btn_set_style(KeyBack, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/
lv_btn_set_style(KeyBack, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/
//lv_btn_set_layout(KeyBack, LV_LAYOUT_OFF);
labelKeyBack = lv_label_create_empty(KeyBack); /*Add a label to the button*/
lv_label_set_text(labelKeyBack, machine_menu.key_back); lv_label_set_text(labelKeyBack, machine_menu.key_back);
lv_obj_align(labelKeyBack, KeyBack, LV_ALIGN_CENTER, 0, 0); lv_obj_align(labelKeyBack, KeyBack, LV_ALIGN_CENTER, 0, 0);
KeyReset = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_t *KeyReset = lv_btn_create(scr, 320, 140, 68, 40, event_handler, ID_NUM_RESET, &style_num_key_pre);
lv_obj_set_pos(KeyReset, 320, 140); /*Set its position*/ lv_obj_t *labelKeyReset = lv_label_create_empty(KeyReset);
lv_obj_set_size(KeyReset, 68, 40);
lv_obj_set_event_cb_mks(KeyReset, event_handler, ID_NUM_RESET, NULL, 0);
lv_btn_set_style(KeyReset, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/
lv_btn_set_style(KeyReset, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/
//lv_btn_set_layout(KeyReset, LV_LAYOUT_OFF);
labelKeyReset = lv_label_create_empty(KeyReset); /*Add a label to the button*/
lv_label_set_text(labelKeyReset, machine_menu.key_reset); lv_label_set_text(labelKeyReset, machine_menu.key_reset);
lv_obj_align(labelKeyReset, KeyReset, LV_ALIGN_CENTER, 0, 0); lv_obj_align(labelKeyReset, KeyReset, LV_ALIGN_CENTER, 0, 0);
KeyConfirm = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_t *KeyConfirm = lv_btn_create(scr, 320, 190, 68, 90, event_handler, ID_NUM_CONFIRM, &style_num_key_pre);
lv_obj_set_pos(KeyConfirm, 320, 190); /*Set its position*/ lv_obj_t *labelKeyConfirm = lv_label_create_empty(KeyConfirm);
lv_obj_set_size(KeyConfirm, 68, 90);
lv_obj_set_event_cb_mks(KeyConfirm, event_handler, ID_NUM_CONFIRM, NULL, 0);
lv_btn_set_style(KeyConfirm, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/
lv_btn_set_style(KeyConfirm, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/
//lv_btn_set_layout(KeyConfirm, LV_LAYOUT_OFF);
labelKeyConfirm = lv_label_create_empty(KeyConfirm); /*Add a label to the button*/
lv_label_set_text(labelKeyConfirm, machine_menu.key_confirm); lv_label_set_text(labelKeyConfirm, machine_menu.key_confirm);
lv_obj_align(labelKeyConfirm, KeyConfirm, LV_ALIGN_CENTER, 0, 0); lv_obj_align(labelKeyConfirm, KeyConfirm, LV_ALIGN_CENTER, 0, 0);
KeyPoint = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_t *KeyPoint = lv_btn_create(scr, 244, 240, 68, 40, event_handler, ID_NUM_POINT, &style_num_key_pre);
lv_obj_set_pos(KeyPoint, 244, 240); /*Set its position*/ lv_obj_t *labelKeyPoint = lv_label_create_empty(KeyPoint);
lv_obj_set_size(KeyPoint, 68, 40);
lv_obj_set_event_cb_mks(KeyPoint, event_handler, ID_NUM_POINT, NULL, 0);
lv_btn_set_style(KeyPoint, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/
lv_btn_set_style(KeyPoint, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/
//lv_btn_set_layout(KeyPoint, LV_LAYOUT_OFF);
labelKeyPoint = lv_label_create_empty(KeyPoint); /*Add a label to the button*/
lv_label_set_text(labelKeyPoint, machine_menu.key_point); lv_label_set_text(labelKeyPoint, machine_menu.key_point);
lv_obj_align(labelKeyPoint, KeyPoint, LV_ALIGN_CENTER, 0, 0); lv_obj_align(labelKeyPoint, KeyPoint, LV_ALIGN_CENTER, 0, 0);
Minus = lv_btn_create(scr, NULL); /*Add a button the current screen*/ lv_obj_t *Minus = lv_btn_create(scr, 168, 240, 68, 40, event_handler, ID_NUM_NEGATIVE, &style_num_key_pre);
lv_obj_set_pos(Minus, 168, 240); /*Set its position*/ lv_obj_t *labelMinus = lv_label_create_empty(Minus);
lv_obj_set_size(Minus, 68, 40);
lv_obj_set_event_cb_mks(Minus, event_handler, ID_NUM_NAGETIVE, NULL, 0);
lv_btn_set_style(Minus, LV_BTN_STYLE_REL, &style_num_key_pre); /*Set the button's released style*/
lv_btn_set_style(Minus, LV_BTN_STYLE_PR, &style_num_key_rel); /*Set the button's pressed style*/
//lv_btn_set_layout(Minus, LV_LAYOUT_OFF);
labelMinus = lv_label_create_empty(Minus); /*Add a label to the button*/
lv_label_set_text(labelMinus, machine_menu.negative); lv_label_set_text(labelMinus, machine_menu.negative);
lv_obj_align(labelMinus, Minus, LV_ALIGN_CENTER, 0, 0); lv_obj_align(labelMinus, Minus, LV_ALIGN_CENTER, 0, 0);

View file

@ -35,141 +35,99 @@
#include "../../../../sd/cardreader.h" #include "../../../../sd/cardreader.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_O_PRE_HEAT 1 enum {
#define ID_O_EXTRUCT 2 ID_O_PRE_HEAT = 1,
#define ID_O_MOV 3 ID_O_EXTRUCT,
#define ID_O_FILAMENT 4 ID_O_MOV,
#define ID_O_SPEED 5 ID_O_FILAMENT,
#define ID_O_RETURN 6 ID_O_SPEED,
#define ID_O_FAN 7 ID_O_RETURN,
#define ID_O_POWER_OFF 8 ID_O_FAN,
#define ID_O_BABY_STEP 9 ID_O_POWER_OFF,
ID_O_BABY_STEP
};
static lv_obj_t *label_PowerOff; static lv_obj_t *label_PowerOff;
static lv_obj_t *buttonPowerOff; static lv_obj_t *buttonPowerOff;
extern feedRate_t feedrate_mm_s; extern feedRate_t feedrate_mm_s;
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_O_PRE_HEAT: case ID_O_PRE_HEAT:
if (event == LV_EVENT_CLICKED) { lv_clear_operation();
// nothing to do lv_draw_preHeat();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_operation();
lv_draw_preHeat();
}
break; break;
case ID_O_EXTRUCT: case ID_O_EXTRUCT:
if (event == LV_EVENT_CLICKED) { lv_clear_operation();
// nothing to do lv_draw_extrusion();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_operation();
lv_draw_extrusion();
}
break; break;
case ID_O_MOV: case ID_O_MOV:
if (event == LV_EVENT_CLICKED) { lv_clear_operation();
// nothing to do lv_draw_move_motor();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_operation();
lv_draw_move_motor();
}
break; break;
case ID_O_FILAMENT: case ID_O_FILAMENT:
if (event == LV_EVENT_CLICKED) { #if HAS_MULTI_EXTRUDER
// nothing to do uiCfg.curSprayerChoose_bak = active_extruder;
} #endif
else if (event == LV_EVENT_RELEASED) { if (uiCfg.print_state == WORKING) {
#if HAS_MULTI_EXTRUDER #if ENABLED(SDSUPPORT)
uiCfg.curSprayerChoose_bak = active_extruder; card.pauseSDPrint();
stop_print_time();
uiCfg.print_state = PAUSING;
#endif #endif
if (uiCfg.print_state == WORKING) {
#if ENABLED(SDSUPPORT)
card.pauseSDPrint();
stop_print_time();
uiCfg.print_state = PAUSING;
#endif
}
uiCfg.moveSpeed_bak = (uint16_t)feedrate_mm_s;
uiCfg.desireSprayerTempBak = thermalManager.temp_hotend[active_extruder].target;
lv_clear_operation();
lv_draw_filament_change();
} }
uiCfg.moveSpeed_bak = (uint16_t)feedrate_mm_s;
uiCfg.desireSprayerTempBak = thermalManager.temp_hotend[active_extruder].target;
lv_clear_operation();
lv_draw_filament_change();
break; break;
case ID_O_FAN: case ID_O_FAN:
if (event == LV_EVENT_CLICKED) { lv_clear_operation();
// nothing to do lv_draw_fan();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_operation();
lv_draw_fan();
}
break; break;
case ID_O_SPEED: case ID_O_SPEED:
if (event == LV_EVENT_CLICKED) { lv_clear_operation();
// nothing to do lv_draw_change_speed();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_operation();
lv_draw_change_speed();
}
break; break;
case ID_O_RETURN: case ID_O_RETURN:
if (event == LV_EVENT_CLICKED) { clear_cur_ui();
// nothing to do draw_return_ui();
}
else if (event == LV_EVENT_RELEASED) {
clear_cur_ui();
draw_return_ui();
}
break; break;
case ID_O_POWER_OFF: case ID_O_POWER_OFF:
if (event == LV_EVENT_CLICKED) { if (gCfgItems.finish_power_off) {
// nothing to do gCfgItems.finish_power_off = false;
lv_imgbtn_set_src_both(buttonPowerOff, "F:/bmp_manual_off.bin");
lv_label_set_text(label_PowerOff, printing_more_menu.manual);
} }
else if (event == LV_EVENT_RELEASED) { else {
if (gCfgItems.finish_power_off) { gCfgItems.finish_power_off = true;
gCfgItems.finish_power_off = false; lv_imgbtn_set_src_both(buttonPowerOff, "F:/bmp_auto_off.bin");
lv_imgbtn_set_src_both(buttonPowerOff, "F:/bmp_manual_off.bin"); lv_label_set_text(label_PowerOff, printing_more_menu.auto_close);
lv_label_set_text(label_PowerOff, printing_more_menu.manual);
}
else {
gCfgItems.finish_power_off = true;
lv_imgbtn_set_src_both(buttonPowerOff, "F:/bmp_auto_off.bin");
lv_label_set_text(label_PowerOff, printing_more_menu.auto_close);
}
lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_obj_refresh_ext_draw_pad(label_PowerOff);
update_spi_flash();
} }
lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_obj_refresh_ext_draw_pad(label_PowerOff);
update_spi_flash();
break; break;
case ID_O_BABY_STEP: case ID_O_BABY_STEP:
if (event == LV_EVENT_CLICKED) { lv_clear_operation();
// nothing to do lv_draw_baby_stepping();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_operation();
lv_draw_baby_stepping();
}
break; break;
} }
} }
void lv_draw_operation(void) { void lv_draw_operation(void) {
lv_obj_t *buttonPreHeat = NULL, *buttonExtrusion = NULL, *buttonSpeed = NULL; lv_obj_t *buttonExtrusion = nullptr, *buttonSpeed = nullptr,
lv_obj_t *buttonBack = NULL, *buttonFan = NULL; *buttonBack = nullptr,
lv_obj_t *labelPreHeat = NULL, *labelExtrusion = NULL; *labelPreHeat = nullptr, *labelExtrusion = nullptr,
lv_obj_t *label_Back = NULL, *label_Speed = NULL, *label_Fan = NULL; *label_Back = nullptr, *label_Speed = nullptr, *label_Fan = nullptr,
lv_obj_t *buttonMove = NULL, *label_Move = NULL; *buttonMove = nullptr, *label_Move = nullptr,
lv_obj_t *buttonBabyStep = NULL, *label_BabyStep = NULL; *buttonBabyStep = nullptr, *label_BabyStep = nullptr,
lv_obj_t *buttonFilament = NULL, *label_Filament = NULL; *label_Filament = nullptr;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != OPERATE_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != OPERATE_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
@ -177,20 +135,16 @@ void lv_draw_operation(void) {
} }
disp_state = OPERATE_UI; disp_state = OPERATE_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
// Create image buttons // Create image buttons
buttonPreHeat = lv_imgbtn_create(scr, "F:/bmp_temp.bin", INTERVAL_V, titleHeight, event_handler, ID_O_PRE_HEAT); lv_obj_t *buttonPreHeat = lv_imgbtn_create(scr, "F:/bmp_temp.bin", INTERVAL_V, titleHeight, event_handler, ID_O_PRE_HEAT);
buttonFilament = lv_imgbtn_create(scr, "F:/bmp_filamentchange.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_O_FILAMENT); lv_obj_t *buttonFilament = lv_imgbtn_create(scr, "F:/bmp_filamentchange.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_O_FILAMENT);
buttonFan = lv_imgbtn_create(scr, "F:/bmp_fan.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_O_FAN); lv_obj_t *buttonFan = lv_imgbtn_create(scr, "F:/bmp_fan.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_O_FAN);
buttonPowerOff = lv_imgbtn_create(scr, gCfgItems.finish_power_off ? "F:/bmp_auto_off.bin" : "F:/bmp_manual_off.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_O_POWER_OFF); buttonPowerOff = lv_imgbtn_create(scr, gCfgItems.finish_power_off ? "F:/bmp_auto_off.bin" : "F:/bmp_manual_off.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_O_POWER_OFF);
#if HAS_ROTARY_ENCODER #if HAS_ROTARY_ENCODER

View file

@ -29,132 +29,62 @@
#include "../../../../module/planner.h" #include "../../../../module/planner.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_PAUSE_RETURN 1 enum {
#define ID_PAUSE_X 2 ID_PAUSE_RETURN = 1,
#define ID_PAUSE_Y 3 ID_PAUSE_X,
#define ID_PAUSE_Z 4 ID_PAUSE_Y,
ID_PAUSE_Z
};
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_PAUSE_RETURN: case ID_PAUSE_RETURN:
if (event == LV_EVENT_CLICKED) { lv_clear_pause_position();
draw_return_ui();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_pause_position();
draw_return_ui();
}
break; break;
case ID_PAUSE_X: case ID_PAUSE_X:
if (event == LV_EVENT_CLICKED) { value = pause_pos_x;
lv_clear_pause_position();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = pause_pos_x;
lv_clear_pause_position();
lv_draw_number_key();
}
break; break;
case ID_PAUSE_Y: case ID_PAUSE_Y:
if (event == LV_EVENT_CLICKED) { value = pause_pos_y;
lv_clear_pause_position();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = pause_pos_y;
lv_clear_pause_position();
lv_draw_number_key();
}
break; break;
case ID_PAUSE_Z: case ID_PAUSE_Z:
if (event == LV_EVENT_CLICKED) { value = pause_pos_z;
lv_clear_pause_position();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = pause_pos_z;
lv_clear_pause_position();
lv_draw_number_key();
}
break; break;
} }
} }
void lv_draw_pause_position(void) { void lv_draw_pause_position(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL;
lv_obj_t *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != PAUSE_POS_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != PAUSE_POS_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = PAUSE_POS_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = PAUSE_POS_UI;
} }
disp_state = PAUSE_POS_UI; disp_state = PAUSE_POS_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.PausePosText); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.PausePosText);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.xPos); sprintf_P(public_buf_l, PSTR("%.1f"), gCfgItems.pausePosX);
lv_screen_menu_item_1_edit(scr, machine_menu.xPos, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_PAUSE_X, 0, public_buf_l);
buttonXValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_PAUSE_X); sprintf_P(public_buf_l, PSTR("%.1f"), gCfgItems.pausePosY);
labelXValue = lv_label_create_empty(buttonXValue); lv_screen_menu_item_1_edit(scr, machine_menu.yPos, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_PAUSE_Y, 1, public_buf_l);
line1 = lv_line_create(scr, NULL); sprintf_P(public_buf_l, PSTR("%.1f"), gCfgItems.pausePosZ);
lv_ex_line(line1, line_points[0]); lv_screen_menu_item_1_edit(scr, machine_menu.zPos, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_PAUSE_Z, 2, public_buf_l);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, machine_menu.yPos); lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_PAUSE_RETURN, true);
buttonYValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_PAUSE_Y);
labelYValue = lv_label_create_empty(buttonYValue);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, machine_menu.zPos);
buttonZValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_PAUSE_Z);
labelZValue = lv_label_create_empty(buttonZValue);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
buttonBack = lv_btn_create_back(scr, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE, event_handler, ID_PAUSE_RETURN);
label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.multiple_language) {
sprintf_P(public_buf_l, PSTR("%.1f"), gCfgItems.pausePosX);
lv_label_set_text(labelXValue, public_buf_l);
lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
sprintf_P(public_buf_l, PSTR("%.1f"), gCfgItems.pausePosY);
lv_label_set_text(labelYValue, public_buf_l);
lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0);
sprintf_P(public_buf_l, PSTR("%.1f"), gCfgItems.pausePosZ);
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);
}
#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
} }
void lv_clear_pause_position() { void lv_clear_pause_position() {

View file

@ -33,221 +33,163 @@
#include "../../../../module/temperature.h" #include "../../../../module/temperature.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
static lv_obj_t * scr; static lv_obj_t *scr;
extern lv_group_t* g; extern lv_group_t* g;
static lv_obj_t *buttonType, *buttonStep; static lv_obj_t *buttonType, *buttonStep;
static lv_obj_t *labelType; static lv_obj_t *labelType;
static lv_obj_t *labelStep; static lv_obj_t *labelStep;
static lv_obj_t * tempText1; static lv_obj_t *tempText1;
#define ID_P_ADD 1 enum {
#define ID_P_DEC 2 ID_P_ADD = 1,
#define ID_P_TYPE 3 ID_P_DEC,
#define ID_P_STEP 4 ID_P_TYPE,
#define ID_P_OFF 5 ID_P_STEP,
#define ID_P_RETURN 6 ID_P_OFF,
ID_P_RETURN
};
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_P_ADD: case ID_P_ADD:
if (event == LV_EVENT_CLICKED) { if (uiCfg.curTempType == 0) {
// nothing to do thermalManager.temp_hotend[uiCfg.curSprayerChoose].target += uiCfg.stepHeat;
} if (uiCfg.curSprayerChoose == 0) {
else if (event == LV_EVENT_RELEASED) { if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > (HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1))) {
if (uiCfg.curTempType == 0) { thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1);
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target += uiCfg.stepHeat;
if (uiCfg.curSprayerChoose == 0) {
if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > (HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1))) {
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1);
}
} }
#if !defined(SINGLENOZZLE) && HAS_MULTI_EXTRUDER
else if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > (HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1))) {
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1);
}
#endif
thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
} }
#if HAS_HEATED_BED #if !defined(SINGLENOZZLE) && HAS_MULTI_EXTRUDER
else { else if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > (HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1))) {
thermalManager.temp_bed.target += uiCfg.stepHeat; thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1);
if ((int)thermalManager.temp_bed.target > BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1)) {
thermalManager.temp_bed.target = (float)BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1);
}
thermalManager.start_watching_bed();
} }
#endif #endif
disp_desire_temp(); thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
} }
#if HAS_HEATED_BED
else {
thermalManager.temp_bed.target += uiCfg.stepHeat;
if ((int)thermalManager.temp_bed.target > BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1)) {
thermalManager.temp_bed.target = (float)BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1);
}
thermalManager.start_watching_bed();
}
#endif
disp_desire_temp();
break; break;
case ID_P_DEC: case ID_P_DEC:
if (event == LV_EVENT_CLICKED) { if (uiCfg.curTempType == 0) {
// nothing to do if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > uiCfg.stepHeat)
} thermalManager.temp_hotend[uiCfg.curSprayerChoose].target -= uiCfg.stepHeat;
else if (event == LV_EVENT_RELEASED) { else
if (uiCfg.curTempType == 0) { thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = 0;
if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > uiCfg.stepHeat) {
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target -= uiCfg.stepHeat;
}
else {
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)0;
}
thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
}
#if HAS_HEATED_BED
else {
if ((int)thermalManager.temp_bed.target > uiCfg.stepHeat) {
thermalManager.temp_bed.target -= uiCfg.stepHeat;
}
else {
thermalManager.temp_bed.target = (float)0;
}
thermalManager.start_watching_bed();
}
#endif
disp_desire_temp();
}
thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
}
#if HAS_HEATED_BED
else {
if ((int)thermalManager.temp_bed.target > uiCfg.stepHeat)
thermalManager.temp_bed.target -= uiCfg.stepHeat;
else
thermalManager.temp_bed.target = 0;
thermalManager.start_watching_bed();
}
#endif
disp_desire_temp();
break; break;
case ID_P_TYPE: case ID_P_TYPE:
if (event == LV_EVENT_CLICKED) { if (uiCfg.curTempType == 0) {
// nothing to do if (ENABLED(HAS_MULTI_EXTRUDER)) {
} if (uiCfg.curSprayerChoose == 0) {
else if (event == LV_EVENT_RELEASED) { uiCfg.curSprayerChoose = 1;
if (uiCfg.curTempType == 0) {
if (ENABLED(HAS_MULTI_EXTRUDER)) {
if (uiCfg.curSprayerChoose == 0) {
uiCfg.curSprayerChoose = 1;
}
else if (uiCfg.curSprayerChoose == 1) {
if (TEMP_SENSOR_BED != 0) {
uiCfg.curTempType = 1;
}
else {
uiCfg.curTempType = 0;
uiCfg.curSprayerChoose = 0;
}
}
} }
else if (uiCfg.curSprayerChoose == 0) { else if (uiCfg.curSprayerChoose == 1) {
if (TEMP_SENSOR_BED != 0) if (TEMP_SENSOR_BED != 0) {
uiCfg.curTempType = 1; uiCfg.curTempType = 1;
else }
uiCfg.curTempType = 0; else {
uiCfg.curTempType = 0;
uiCfg.curSprayerChoose = 0;
}
} }
} }
else if (uiCfg.curTempType == 1) { else if (uiCfg.curSprayerChoose == 0) {
uiCfg.curSprayerChoose = 0; if (TEMP_SENSOR_BED != 0)
uiCfg.curTempType = 0; uiCfg.curTempType = 1;
else
uiCfg.curTempType = 0;
} }
disp_temp_type();
} }
else if (uiCfg.curTempType == 1) {
uiCfg.curSprayerChoose = 0;
uiCfg.curTempType = 0;
}
disp_temp_type();
break; break;
case ID_P_STEP: case ID_P_STEP:
if (event == LV_EVENT_CLICKED) { switch (uiCfg.stepHeat) {
// nothing to do case 1: uiCfg.stepHeat = 5; break;
} case 5: uiCfg.stepHeat = 10; break;
else if (event == LV_EVENT_RELEASED) { case 10: uiCfg.stepHeat = 1; break;
switch (uiCfg.stepHeat) { default: break;
case 1: uiCfg.stepHeat = 5; break;
case 5: uiCfg.stepHeat = 10; break;
case 10: uiCfg.stepHeat = 1; break;
default: break;
}
disp_step_heat();
} }
disp_step_heat();
break; break;
case ID_P_OFF: case ID_P_OFF:
if (event == LV_EVENT_CLICKED) { if (uiCfg.curTempType == 0) {
// nothing to do thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = 0;
thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
} }
else if (event == LV_EVENT_RELEASED) { #if HAS_HEATED_BED
if (uiCfg.curTempType == 0) { else {
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)0; thermalManager.temp_bed.target = 0;
thermalManager.start_watching_hotend(uiCfg.curSprayerChoose); thermalManager.start_watching_bed();
} }
#if HAS_HEATED_BED #endif
else { disp_desire_temp();
thermalManager.temp_bed.target = (float)0;
thermalManager.start_watching_bed();
}
#endif
disp_desire_temp();
}
break; break;
case ID_P_RETURN: case ID_P_RETURN:
if (event == LV_EVENT_CLICKED) { clear_cur_ui();
// nothing to do draw_return_ui();
}
else if (event == LV_EVENT_RELEASED) {
clear_cur_ui();
draw_return_ui();
}
break; break;
} }
} }
void lv_draw_preHeat(void) { void lv_draw_preHeat(void) {
lv_obj_t *buttonAdd, *buttonDec;
lv_obj_t *buttonOff, *buttonBack;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != PRE_HEAT_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != PRE_HEAT_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = PRE_HEAT_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = PRE_HEAT_UI;
} }
disp_state = PRE_HEAT_UI; disp_state = PRE_HEAT_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
// Create image buttons // Create image buttons
buttonAdd = lv_imgbtn_create(scr, "F:/bmp_Add.bin", INTERVAL_V, titleHeight, event_handler, ID_P_ADD); lv_big_button_create(scr, "F:/bmp_Add.bin", preheat_menu.add, INTERVAL_V, titleHeight, event_handler, ID_P_ADD);
lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW); lv_big_button_create(scr, "F:/bmp_Dec.bin", preheat_menu.dec, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_P_DEC);
buttonDec = lv_imgbtn_create(scr, "F:/bmp_Dec.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_P_DEC);
buttonType = lv_imgbtn_create(scr, NULL, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_TYPE);
buttonStep = lv_imgbtn_create(scr, NULL, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_STEP);
buttonOff = lv_imgbtn_create(scr, "F:/bmp_speed0.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_OFF);
buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_RETURN);
// Create labels on the image buttons buttonType = lv_imgbtn_create(scr, nullptr, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_TYPE);
lv_obj_t *labelAdd = lv_label_create_empty(buttonAdd); buttonStep = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_STEP);
lv_obj_t *labelDec = lv_label_create_empty(buttonDec);
labelType = lv_label_create_empty(buttonType);
labelStep = lv_label_create_empty(buttonStep);
lv_obj_t *labelOff = lv_label_create_empty(buttonOff);
lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.multiple_language) {
lv_label_set_text(labelAdd, preheat_menu.add);
lv_obj_align(labelAdd, buttonAdd, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(labelDec, preheat_menu.dec);
lv_obj_align(labelDec, buttonDec, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(labelOff, preheat_menu.off);
lv_obj_align(labelOff, buttonOff, 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 HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) { if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonAdd);
lv_group_add_obj(g, buttonDec);
lv_group_add_obj(g, buttonType); lv_group_add_obj(g, buttonType);
lv_group_add_obj(g, buttonStep); lv_group_add_obj(g, buttonStep);
lv_group_add_obj(g, buttonOff);
lv_group_add_obj(g, buttonBack);
} }
#endif #endif
lv_big_button_create(scr, "F:/bmp_speed0.bin", preheat_menu.off, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_OFF);
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_RETURN);
// Create labels on the image buttons
labelType = lv_label_create_empty(buttonType);
labelStep = lv_label_create_empty(buttonStep);
disp_temp_type(); disp_temp_type();
disp_step_heat(); disp_step_heat();
@ -289,10 +231,7 @@ void disp_desire_temp() {
public_buf_l[0] = '\0'; public_buf_l[0] = '\0';
if (uiCfg.curTempType == 0) { if (uiCfg.curTempType == 0) {
if (uiCfg.curSprayerChoose < 1) strcat(public_buf_l, uiCfg.curSprayerChoose < 1 ? preheat_menu.ext1 : preheat_menu.ext2);
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); sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target);
} }
#if HAS_HEATED_BED #if HAS_HEATED_BED
@ -304,7 +243,7 @@ void disp_desire_temp() {
strcat_P(public_buf_l, PSTR(": ")); strcat_P(public_buf_l, PSTR(": "));
strcat(public_buf_l, buf); strcat(public_buf_l, buf);
lv_label_set_text(tempText1, public_buf_l); lv_label_set_text(tempText1, public_buf_l);
lv_obj_align(tempText1, NULL, LV_ALIGN_CENTER, 0, -50); lv_obj_align(tempText1, nullptr, LV_ALIGN_CENTER, 0, -50);
} }
void disp_step_heat() { void disp_step_heat() {

View file

@ -33,15 +33,17 @@
#include "../../../../sd/cardreader.h" #include "../../../../sd/cardreader.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
static lv_obj_t * scr; static lv_obj_t *scr;
extern lv_group_t* g; extern lv_group_t* g;
static lv_obj_t *buttonPageUp, *buttonPageDown, *buttonBack, static lv_obj_t *buttonPageUp, *buttonPageDown, *buttonBack,
*buttonGcode[FILE_BTN_CNT], *labelPageUp[FILE_BTN_CNT], *buttonText[FILE_BTN_CNT]; *buttonGcode[FILE_BTN_CNT], *labelPageUp[FILE_BTN_CNT], *buttonText[FILE_BTN_CNT];
#define ID_P_UP 7 enum {
#define ID_P_DOWN 8 ID_P_UP = 7,
#define ID_P_RETURN 9 ID_P_DOWN,
ID_P_RETURN
};
int8_t curDirLever = 0; int8_t curDirLever = 0;
LIST_FILE list_file; LIST_FILE list_file;
@ -74,38 +76,21 @@ uint8_t sel_id = 0;
const uint16_t nr = SD_ORDER(i, fileCnt); const uint16_t nr = SD_ORDER(i, fileCnt);
card.getfilename_sorted(nr); card.getfilename_sorted(nr);
if (card.flag.filenameIsDir) { list_file.IsFolder[valid_name_cnt] = card.flag.filenameIsDir;
//SERIAL_ECHOLN(card.longest_filename); strcpy(list_file.file_name[valid_name_cnt], list_file.curDirPath);
list_file.IsFolder[valid_name_cnt] = 1; strcat_P(list_file.file_name[valid_name_cnt], PSTR("/"));
} strcat(list_file.file_name[valid_name_cnt], card.filename);
else { strcpy(list_file.long_name[valid_name_cnt], card.longest_filename());
//SERIAL_ECHOLN(card.longFilename);
list_file.IsFolder[valid_name_cnt] = 0;
}
#if 1 valid_name_cnt++;
// if (valid_name_cnt == 1)
memset(list_file.file_name[valid_name_cnt], 0, strlen(list_file.file_name[valid_name_cnt])); dir_offset[curDirLever].cur_page_first_offset = list_file.Sd_file_offset;
strcpy(list_file.file_name[valid_name_cnt], list_file.curDirPath); if (valid_name_cnt >= FILE_NUM) {
strcat_P(list_file.file_name[valid_name_cnt], PSTR("/")); dir_offset[curDirLever].cur_page_last_offset = list_file.Sd_file_offset;
strcat(list_file.file_name[valid_name_cnt], card.filename);
//
memset(list_file.long_name[valid_name_cnt], 0, strlen(list_file.long_name[valid_name_cnt]));
if (card.longFilename[0] == 0)
strncpy(list_file.long_name[valid_name_cnt], card.filename, strlen(card.filename));
else
strncpy(list_file.long_name[valid_name_cnt], card.longFilename, strlen(card.longFilename));
valid_name_cnt++;
if (valid_name_cnt == 1)
dir_offset[curDirLever].cur_page_first_offset = list_file.Sd_file_offset;
if (valid_name_cnt >= FILE_NUM) {
dir_offset[curDirLever].cur_page_last_offset = list_file.Sd_file_offset;
list_file.Sd_file_offset++;
break;
}
list_file.Sd_file_offset++; list_file.Sd_file_offset++;
#endif break;
}
list_file.Sd_file_offset++;
} }
list_file.Sd_file_cnt++; list_file.Sd_file_cnt++;
} }
@ -115,125 +100,105 @@ uint8_t sel_id = 0;
#endif // SDSUPPORT #endif // SDSUPPORT
uint8_t have_pre_pic(char *path) { bool have_pre_pic(char *path) {
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
char *ps1, *ps2, *cur_name = strrchr(path, '/'); char *ps1, *ps2, *cur_name = strrchr(path, '/');
card.openFileRead(cur_name); card.openFileRead(cur_name);
card.read(public_buf, 512); card.read(public_buf, 512);
ps1 = strstr((char *)public_buf, ";simage:"); ps1 = strstr((char *)public_buf, ";simage:");
card.read(public_buf, 512); card.read(public_buf, 512);
ps2 = strstr((char *)public_buf, ";simage:"); ps2 = strstr((char *)public_buf, ";simage:");
if (ps1 || ps2) {
card.closefile();
return 1;
}
card.closefile(); card.closefile();
if (ps1 || ps2) return true;
#endif #endif
return 0; return false;
} }
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
uint8_t i, file_count = 0; uint8_t i, file_count = 0;
//switch (obj->mks_obj_id) //switch (obj->mks_obj_id)
//{ //{
if (obj->mks_obj_id == ID_P_UP) { if (obj->mks_obj_id == ID_P_UP) {
if (event == LV_EVENT_CLICKED) { if (dir_offset[curDirLever].curPage > 0) {
} // 2015.05.19
else if (event == LV_EVENT_RELEASED) { list_file.Sd_file_cnt = 0;
if (dir_offset[curDirLever].curPage > 0) {
// 2015.05.19
list_file.Sd_file_cnt = 0;
if (dir_offset[curDirLever].cur_page_first_offset >= FILE_NUM) if (dir_offset[curDirLever].cur_page_first_offset >= FILE_NUM)
list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset - FILE_NUM; list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset - FILE_NUM;
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
file_count = search_file(); file_count = search_file();
#endif #endif
if (file_count != 0) { if (file_count != 0) {
dir_offset[curDirLever].curPage--; dir_offset[curDirLever].curPage--;
lv_clear_print_file(); lv_clear_print_file();
disp_gcode_icon(file_count); disp_gcode_icon(file_count);
}
} }
} }
} }
else if (obj->mks_obj_id == ID_P_DOWN) { else if (obj->mks_obj_id == ID_P_DOWN) {
if (event == LV_EVENT_CLICKED) { if (dir_offset[curDirLever].cur_page_last_offset > 0) {
} list_file.Sd_file_cnt = 0;
else if (event == LV_EVENT_RELEASED) { list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_last_offset + 1;
if (dir_offset[curDirLever].cur_page_last_offset > 0) { #if ENABLED(SDSUPPORT)
list_file.Sd_file_cnt = 0; file_count = search_file();
list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_last_offset + 1; #endif
#if ENABLED(SDSUPPORT) if (file_count != 0) {
file_count = search_file(); dir_offset[curDirLever].curPage++;
#endif lv_clear_print_file();
if (file_count != 0) { disp_gcode_icon(file_count);
dir_offset[curDirLever].curPage++;
lv_clear_print_file();
disp_gcode_icon(file_count);
}
if (file_count < FILE_NUM)
dir_offset[curDirLever].cur_page_last_offset = 0;
} }
if (file_count < FILE_NUM)
dir_offset[curDirLever].cur_page_last_offset = 0;
} }
} }
else if (obj->mks_obj_id == ID_P_RETURN) { else if (obj->mks_obj_id == ID_P_RETURN) {
if (event == LV_EVENT_CLICKED) { if (curDirLever > 0) {
} int8_t *ch = (int8_t *)strrchr(list_file.curDirPath, '/');
else if (event == LV_EVENT_RELEASED) { if (ch) {
if (curDirLever > 0) { *ch = 0;
int8_t *ch = (int8_t *)strrchr(list_file.curDirPath, '/'); #if ENABLED(SDSUPPORT)
if (ch) { card.cdup();
*ch = 0; #endif
#if ENABLED(SDSUPPORT) dir_offset[curDirLever].curPage = 0;
card.cdup(); dir_offset[curDirLever].cur_page_first_offset = 0;
#endif dir_offset[curDirLever].cur_page_last_offset = 0;
dir_offset[curDirLever].curPage = 0; curDirLever--;
dir_offset[curDirLever].cur_page_first_offset = 0; list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset;
dir_offset[curDirLever].cur_page_last_offset = 0; #if ENABLED(SDSUPPORT)
curDirLever--; file_count = search_file();
list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset; #endif
#if ENABLED(SDSUPPORT)
file_count = search_file();
#endif
lv_clear_print_file();
disp_gcode_icon(file_count);
}
}
else {
lv_clear_print_file(); lv_clear_print_file();
lv_draw_ready_print(); disp_gcode_icon(file_count);
} }
} }
else {
lv_clear_print_file();
lv_draw_ready_print();
}
} }
else { else {
for (i = 0; i < FILE_BTN_CNT; i++) { for (i = 0; i < FILE_BTN_CNT; i++) {
if (obj->mks_obj_id == (i + 1)) { if (obj->mks_obj_id == (i + 1)) {
if (event == LV_EVENT_CLICKED) { if (list_file.file_name[i][0] != 0) {
} if (list_file.IsFolder[i]) {
else if (event == LV_EVENT_RELEASED) { strcpy(list_file.curDirPath, list_file.file_name[i]);
if (list_file.file_name[i][0] != 0) { curDirLever++;
if (list_file.IsFolder[i] == 1) { list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset;
ZERO(list_file.curDirPath); #if ENABLED(SDSUPPORT)
strcpy(list_file.curDirPath, list_file.file_name[i]); file_count = search_file();
curDirLever++; #endif
list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset; lv_clear_print_file();
#if ENABLED(SDSUPPORT) disp_gcode_icon(file_count);
file_count = search_file();
#endif
lv_clear_print_file();
disp_gcode_icon(file_count);
}
else {
sel_id = i;
lv_clear_print_file();
lv_draw_dialog(DIALOG_TYPE_PRINT_FILE);
}
break;
} }
else {
sel_id = i;
lv_clear_print_file();
lv_draw_dialog(DIALOG_TYPE_PRINT_FILE);
}
break;
} }
} }
} }
@ -249,11 +214,11 @@ void lv_draw_print_file(void) {
} }
disp_state = PRINT_FILE_UI; disp_state = PRINT_FILE_UI;
curDirLever = 0; curDirLever = 0;
dir_offset[curDirLever].curPage = 0; dir_offset[curDirLever].curPage = 0;
list_file.Sd_file_offset = 0; list_file.Sd_file_offset = 0;
list_file.Sd_file_cnt = 0; list_file.Sd_file_cnt = 0;
ZERO(dir_offset); ZERO(dir_offset);
ZERO(list_file.IsFolder); ZERO(list_file.IsFolder);
@ -287,14 +252,7 @@ static char test_public_buf_l[40];
void disp_gcode_icon(uint8_t file_num) { void disp_gcode_icon(uint8_t file_num) {
uint8_t i; uint8_t i;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
//static lv_style_t tool_style;
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
@ -319,17 +277,17 @@ void disp_gcode_icon(uint8_t file_num) {
if (i >= file_num) break; if (i >= file_num) break;
#ifdef TFT35 #ifdef TFT35
buttonGcode[i] = lv_imgbtn_create(scr, NULL); buttonGcode[i] = lv_imgbtn_create(scr, nullptr);
lv_imgbtn_use_label_style(buttonGcode[i]); lv_imgbtn_use_label_style(buttonGcode[i]);
lv_obj_clear_protect(buttonGcode[i], LV_PROTECT_FOLLOW); lv_obj_clear_protect(buttonGcode[i], LV_PROTECT_FOLLOW);
lv_btn_set_layout(buttonGcode[i], LV_LAYOUT_OFF); lv_btn_set_layout(buttonGcode[i], LV_LAYOUT_OFF);
ZERO(public_buf_m); ZERO(public_buf_m);
cutFileName((char *)list_file.long_name[i], 16, 8, (char *)public_buf_m); cutFileName((char *)list_file.long_name[i], 16, 8, (char *)public_buf_m);
if (list_file.IsFolder[i] == 1) { if (list_file.IsFolder[i]) {
lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), NULL, 0); lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), nullptr, 0);
lv_imgbtn_set_src_both(buttonGcode[i], "F:/bmp_dir.bin"); lv_imgbtn_set_src_both(buttonGcode[i], "F:/bmp_dir.bin");
if (i < 3) if (i < 3)
lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight); lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight);
@ -344,34 +302,33 @@ void disp_gcode_icon(uint8_t file_num) {
//lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), list_file.file_name[i], 1); //lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), list_file.file_name[i], 1);
ZERO(test_public_buf_l); strcpy(test_public_buf_l, "S:");
strcat(test_public_buf_l,"S:"); strcat(test_public_buf_l, list_file.file_name[i]);
strcat(test_public_buf_l,list_file.file_name[i]); char *temp = strstr(test_public_buf_l, ".GCO");
char *temp = strstr(test_public_buf_l,".GCO"); if (temp) strcpy(temp, ".bin");
if (temp) { strcpy(temp,".bin"); } lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), nullptr, 0);
lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), NULL, 0);
lv_imgbtn_set_src_both(buttonGcode[i], test_public_buf_l); lv_imgbtn_set_src_both(buttonGcode[i], test_public_buf_l);
if (i < 3) { if (i < 3) {
lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1) + FILE_PRE_PIC_X_OFFSET, titleHeight + FILE_PRE_PIC_Y_OFFSET); lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1) + FILE_PRE_PIC_X_OFFSET, titleHeight + FILE_PRE_PIC_Y_OFFSET);
buttonText[i] = lv_btn_create(scr, NULL); buttonText[i] = lv_btn_create(scr, nullptr);
//lv_obj_set_event_cb(buttonText[i], event_handler); //lv_obj_set_event_cb(buttonText[i], event_handler);
lv_btn_use_label_style(buttonText[i]); lv_btn_use_label_style(buttonText[i]);
lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW); lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW);
lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF); lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF);
//lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),NULL, 0); //lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),nullptr, 0);
lv_obj_set_pos(buttonText[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1) + FILE_PRE_PIC_X_OFFSET, titleHeight + FILE_PRE_PIC_Y_OFFSET + 100); lv_obj_set_pos(buttonText[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1) + FILE_PRE_PIC_X_OFFSET, titleHeight + FILE_PRE_PIC_Y_OFFSET + 100);
lv_obj_set_size(buttonText[i], 100, 40); lv_obj_set_size(buttonText[i], 100, 40);
} }
else { else {
lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * (i - 3) + INTERVAL_V * ((i - 3) + 1) + FILE_PRE_PIC_X_OFFSET, BTN_Y_PIXEL + INTERVAL_H + titleHeight + FILE_PRE_PIC_Y_OFFSET); lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * (i - 3) + INTERVAL_V * ((i - 3) + 1) + FILE_PRE_PIC_X_OFFSET, BTN_Y_PIXEL + INTERVAL_H + titleHeight + FILE_PRE_PIC_Y_OFFSET);
buttonText[i] = lv_btn_create(scr, NULL); buttonText[i] = lv_btn_create(scr, nullptr);
//lv_obj_set_event_cb(buttonText[i], event_handler); //lv_obj_set_event_cb(buttonText[i], event_handler);
lv_btn_use_label_style(buttonText[i]); lv_btn_use_label_style(buttonText[i]);
lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW); lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW);
lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF); lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF);
//lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),NULL, 0); //lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),nullptr, 0);
lv_obj_set_pos(buttonText[i], BTN_X_PIXEL * (i - 3) + INTERVAL_V * ((i - 3) + 1) + FILE_PRE_PIC_X_OFFSET, BTN_Y_PIXEL + INTERVAL_H + titleHeight + FILE_PRE_PIC_Y_OFFSET + 100); lv_obj_set_pos(buttonText[i], BTN_X_PIXEL * (i - 3) + INTERVAL_V * ((i - 3) + 1) + FILE_PRE_PIC_X_OFFSET, BTN_Y_PIXEL + INTERVAL_H + titleHeight + FILE_PRE_PIC_Y_OFFSET + 100);
lv_obj_set_size(buttonText[i], 100, 40); lv_obj_set_size(buttonText[i], 100, 40);
} }
@ -379,7 +336,7 @@ void disp_gcode_icon(uint8_t file_num) {
lv_obj_align(labelPageUp[i], buttonText[i], LV_ALIGN_IN_BOTTOM_MID, 0, 0); lv_obj_align(labelPageUp[i], buttonText[i], LV_ALIGN_IN_BOTTOM_MID, 0, 0);
} }
else { else {
lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), NULL, 0); lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), nullptr, 0);
lv_imgbtn_set_src_both(buttonGcode[i], "F:/bmp_file.bin"); lv_imgbtn_set_src_both(buttonGcode[i], "F:/bmp_file.bin");
if (i < 3) if (i < 3)
lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight); lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight);
@ -502,7 +459,7 @@ void lv_gcode_file_seek(uint32_t pos) {
card.setIndex(pos); card.setIndex(pos);
} }
void cutFileName(char *path, int len, int bytePerLine, char *outStr) { void cutFileName(char *path, int len, int bytePerLine, char *outStr) {
#if _LFN_UNICODE #if _LFN_UNICODE
TCHAR *tmpFile; TCHAR *tmpFile;
TCHAR *strIndex1 = 0, *strIndex2 = 0, *beginIndex; TCHAR *strIndex1 = 0, *strIndex2 = 0, *beginIndex;

View file

@ -43,7 +43,7 @@ typedef struct {
char file_name[FILE_NUM][SHORT_NEME_LEN * MAX_DIR_LEVEL + 1]; char file_name[FILE_NUM][SHORT_NEME_LEN * MAX_DIR_LEVEL + 1];
char curDirPath[SHORT_NEME_LEN * MAX_DIR_LEVEL + 1]; char curDirPath[SHORT_NEME_LEN * MAX_DIR_LEVEL + 1];
char long_name[FILE_NUM][SHORT_NEME_LEN * 2 + 1]; char long_name[FILE_NUM][SHORT_NEME_LEN * 2 + 1];
char IsFolder[FILE_NUM]; bool IsFolder[FILE_NUM];
char Sd_file_cnt; char Sd_file_cnt;
char sd_file_index; char sd_file_index;
char Sd_file_offset; char Sd_file_offset;
@ -55,7 +55,7 @@ extern void lv_draw_print_file(void);
extern uint32_t lv_open_gcode_file(char *path); extern uint32_t lv_open_gcode_file(char *path);
extern void lv_gcode_file_read(uint8_t *data_buf); extern void lv_gcode_file_read(uint8_t *data_buf);
extern void lv_close_gcode_file(); extern void lv_close_gcode_file();
extern void cutFileName(char *path, int len, int bytePerLine, char *outStr); extern void cutFileName(char *path, int len, int bytePerLine, char *outStr);
extern int ascii2dec_test(char *ascii); extern int ascii2dec_test(char *ascii);
extern void lv_clear_print_file(); extern void lv_clear_print_file();
extern void lv_gcode_file_seek(uint32_t pos); extern void lv_gcode_file_seek(uint32_t pos);

View file

@ -59,78 +59,61 @@ TERN_(HAS_MULTI_EXTRUDER, static lv_obj_t *labelExt2);
static lv_obj_t* labelBed; static lv_obj_t* labelBed;
#endif #endif
#define ID_PAUSE 1 enum {
#define ID_STOP 2 ID_PAUSE = 1,
#define ID_OPTION 3 ID_STOP,
ID_OPTION
};
bool once_flag; // = false bool once_flag; // = false
extern bool flash_preview_begin, default_preview_flg, gcode_preview_over; extern bool flash_preview_begin, default_preview_flg, gcode_preview_over;
extern uint32_t To_pre_view; extern uint32_t To_pre_view;
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
if (gcode_preview_over) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_PAUSE: case ID_PAUSE:
if (event == LV_EVENT_CLICKED) { if (uiCfg.print_state == WORKING) {
// nothing to do // #if ENABLED(PARK_HEAD_ON_PAUSE)
// queue.inject_P(PSTR("M25 P\nM24"));
#if ENABLED(SDSUPPORT)
// queue.inject_P(PSTR("M25\nG91\nG1 Z10\nG90"));
card.pauseSDPrint();
stop_print_time();
uiCfg.print_state = PAUSING;
#endif
lv_imgbtn_set_src_both(buttonPause, "F:/bmp_resume.bin");
lv_label_set_text(labelPause, printing_menu.resume);
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
} }
else if (event == LV_EVENT_RELEASED) { else if (uiCfg.print_state == PAUSED) {
if (!gcode_preview_over) { uiCfg.print_state = RESUMING;
if (uiCfg.print_state == WORKING) { lv_imgbtn_set_src_both(obj, "F:/bmp_pause.bin");
// #if ENABLED(PARK_HEAD_ON_PAUSE) lv_label_set_text(labelPause, printing_menu.pause);
// queue.inject_P(PSTR("M25 P\nM24")); lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
#if ENABLED(SDSUPPORT) }
// queue.inject_P(PSTR("M25\nG91\nG1 Z10\nG90")); #if ENABLED(POWER_LOSS_RECOVERY)
card.pauseSDPrint(); else if (uiCfg.print_state == REPRINTING) {
stop_print_time(); uiCfg.print_state = REPRINTED;
uiCfg.print_state = PAUSING; lv_imgbtn_set_src_both(obj, "F:/bmp_pause.bin");
#endif lv_label_set_text(labelPause, printing_menu.pause);
lv_imgbtn_set_src_both(buttonPause, "F:/bmp_resume.bin"); lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
lv_label_set_text(labelPause, printing_menu.resume); // recovery.resume();
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0); print_time.minutes = recovery.info.print_job_elapsed / 60;
} print_time.seconds = recovery.info.print_job_elapsed % 60;
else if (uiCfg.print_state == PAUSED) { print_time.hours = print_time.minutes / 60;
uiCfg.print_state = RESUMING;
lv_imgbtn_set_src_both(obj, "F:/bmp_pause.bin");
lv_label_set_text(labelPause, printing_menu.pause);
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
}
#if ENABLED(POWER_LOSS_RECOVERY)
else if (uiCfg.print_state == REPRINTING) {
uiCfg.print_state = REPRINTED;
lv_imgbtn_set_src_both(obj, "F:/bmp_pause.bin");
lv_label_set_text(labelPause, printing_menu.pause);
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
// recovery.resume();
print_time.minutes = recovery.info.print_job_elapsed / 60;
print_time.seconds = recovery.info.print_job_elapsed % 60;
print_time.hours = print_time.minutes / 60;
}
#endif
} }
} #endif
break; break;
case ID_STOP: case ID_STOP:
if (event == LV_EVENT_CLICKED) { lv_clear_printing();
// nothing to do lv_draw_dialog(DIALOG_TYPE_STOP);
}
else if (event == LV_EVENT_RELEASED) {
if (!gcode_preview_over) {
lv_clear_printing();
lv_draw_dialog(DIALOG_TYPE_STOP);
}
}
break; break;
case ID_OPTION: case ID_OPTION:
if (event == LV_EVENT_CLICKED) { lv_clear_printing();
// nothing to do lv_draw_operation();
}
else if (event == LV_EVENT_RELEASED) {
if (!gcode_preview_over) {
lv_clear_printing();
lv_draw_operation();
}
}
break; break;
} }
} }
@ -142,44 +125,38 @@ void lv_draw_printing(void) {
disp_state = PRINTING_UI; disp_state = PRINTING_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
// static lv_style_t tool_style;
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
// Create image buttons // Create image buttons
lv_obj_t *buttonExt1 = lv_img_create(scr, NULL); lv_obj_t *buttonExt1 = lv_img_create(scr, nullptr);
lv_img_set_src(buttonExt1, "F:/bmp_ext1_state.bin"); lv_img_set_src(buttonExt1, "F:/bmp_ext1_state.bin");
lv_obj_set_pos(buttonExt1, 205, 136); lv_obj_set_pos(buttonExt1, 205, 136);
#if HAS_MULTI_EXTRUDER #if HAS_MULTI_EXTRUDER
lv_obj_t *buttonExt2 = lv_img_create(scr, NULL); lv_obj_t *buttonExt2 = lv_img_create(scr, nullptr);
lv_img_set_src(buttonExt2, "F:/bmp_ext2_state.bin"); lv_img_set_src(buttonExt2, "F:/bmp_ext2_state.bin");
lv_obj_set_pos(buttonExt2, 350, 136); lv_obj_set_pos(buttonExt2, 350, 136);
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
lv_obj_t *buttonBedstate = lv_img_create(scr, NULL); lv_obj_t *buttonBedstate = lv_img_create(scr, nullptr);
lv_img_set_src(buttonBedstate, "F:/bmp_bed_state.bin"); lv_img_set_src(buttonBedstate, "F:/bmp_bed_state.bin");
lv_obj_set_pos(buttonBedstate, 205, 186); lv_obj_set_pos(buttonBedstate, 205, 186);
#endif #endif
lv_obj_t *buttonFanstate = lv_img_create(scr, NULL); lv_obj_t *buttonFanstate = lv_img_create(scr, nullptr);
lv_img_set_src(buttonFanstate, "F:/bmp_fan_state.bin"); lv_img_set_src(buttonFanstate, "F:/bmp_fan_state.bin");
lv_obj_set_pos(buttonFanstate, 350, 186); lv_obj_set_pos(buttonFanstate, 350, 186);
lv_obj_t *buttonTime = lv_img_create(scr, NULL); lv_obj_t *buttonTime = lv_img_create(scr, nullptr);
lv_img_set_src(buttonTime, "F:/bmp_time_state.bin"); lv_img_set_src(buttonTime, "F:/bmp_time_state.bin");
lv_obj_set_pos(buttonTime, 205, 86); lv_obj_set_pos(buttonTime, 205, 86);
lv_obj_t *buttonZpos = lv_img_create(scr, NULL); lv_obj_t *buttonZpos = lv_img_create(scr, nullptr);
lv_img_set_src(buttonZpos, "F:/bmp_zpos_state.bin"); lv_img_set_src(buttonZpos, "F:/bmp_zpos_state.bin");
lv_obj_set_pos(buttonZpos, 350, 86); lv_obj_set_pos(buttonZpos, 350, 86);
@ -209,19 +186,19 @@ void lv_draw_printing(void) {
//lv_btn_set_layout(buttonTime, LV_LAYOUT_OFF); //lv_btn_set_layout(buttonTime, LV_LAYOUT_OFF);
//lv_btn_set_layout(buttonZpos, LV_LAYOUT_OFF); //lv_btn_set_layout(buttonZpos, LV_LAYOUT_OFF);
labelExt1 = lv_label_create(scr, 250, 146, NULL); labelExt1 = lv_label_create(scr, 250, 146, nullptr);
#if HAS_MULTI_EXTRUDER #if HAS_MULTI_EXTRUDER
labelExt2 = lv_label_create(scr, 395, 146, NULL); labelExt2 = lv_label_create(scr, 395, 146, nullptr);
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
labelBed = lv_label_create(scr, 250, 196, NULL); labelBed = lv_label_create(scr, 250, 196, nullptr);
#endif #endif
labelFan = lv_label_create(scr, 395, 196, NULL); labelFan = lv_label_create(scr, 395, 196, nullptr);
labelTime = lv_label_create(scr, 250, 96, NULL); labelTime = lv_label_create(scr, 250, 96, nullptr);
labelZpos = lv_label_create(scr, 395, 96, NULL); labelZpos = lv_label_create(scr, 395, 96, nullptr);
labelPause = lv_label_create_empty(buttonPause); labelPause = lv_label_create_empty(buttonPause);
labelStop = lv_label_create_empty(buttonStop); labelStop = lv_label_create_empty(buttonStop);
@ -238,7 +215,7 @@ void lv_draw_printing(void) {
lv_obj_align(labelOperat, buttonOperat, LV_ALIGN_CENTER, 20, 0); lv_obj_align(labelOperat, buttonOperat, LV_ALIGN_CENTER, 20, 0);
} }
bar1 = lv_bar_create(scr, NULL); bar1 = lv_bar_create(scr, nullptr);
lv_obj_set_pos(bar1, 205, 36); lv_obj_set_pos(bar1, 205, 36);
lv_obj_set_size(bar1, 270, 40); lv_obj_set_size(bar1, 270, 40);
lv_bar_set_style(bar1, LV_BAR_STYLE_INDIC, &lv_bar_style_indic); lv_bar_set_style(bar1, LV_BAR_STYLE_INDIC, &lv_bar_style_indic);
@ -256,12 +233,10 @@ void lv_draw_printing(void) {
} }
void disp_ext_temp() { void disp_ext_temp() {
ZERO(public_buf_l);
sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[0].celsius, (int)thermalManager.temp_hotend[0].target); sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[0].celsius, (int)thermalManager.temp_hotend[0].target);
lv_label_set_text(labelExt1, public_buf_l); lv_label_set_text(labelExt1, public_buf_l);
#if HAS_MULTI_EXTRUDER #if HAS_MULTI_EXTRUDER
ZERO(public_buf_l);
sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[1].celsius, (int)thermalManager.temp_hotend[1].target); sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[1].celsius, (int)thermalManager.temp_hotend[1].target);
lv_label_set_text(labelExt2, public_buf_l); lv_label_set_text(labelExt2, public_buf_l);
#endif #endif
@ -269,20 +244,17 @@ void disp_ext_temp() {
void disp_bed_temp() { void disp_bed_temp() {
#if HAS_HEATED_BED #if HAS_HEATED_BED
ZERO(public_buf_l);
sprintf(public_buf_l, printing_menu.bed_temp, (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target); sprintf(public_buf_l, printing_menu.bed_temp, (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target);
lv_label_set_text(labelBed, public_buf_l); lv_label_set_text(labelBed, public_buf_l);
#endif #endif
} }
void disp_fan_speed() { void disp_fan_speed() {
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%3d"), thermalManager.fan_speed[0]); sprintf_P(public_buf_l, PSTR("%3d"), thermalManager.fan_speed[0]);
lv_label_set_text(labelFan, public_buf_l); lv_label_set_text(labelFan, public_buf_l);
} }
void disp_print_time() { void disp_print_time() {
ZERO(public_buf_l);
#if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME) #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME)
const uint32_t r = ui.get_remaining_time(); const uint32_t r = ui.get_remaining_time();
sprintf_P(public_buf_l, PSTR("%02d:%02d R"), r / 3600, (r % 3600) / 60); sprintf_P(public_buf_l, PSTR("%02d:%02d R"), r / 3600, (r % 3600) / 60);
@ -293,7 +265,6 @@ void disp_print_time() {
} }
void disp_fan_Zpos() { void disp_fan_Zpos() {
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.3f"), current_position[Z_AXIS]); sprintf_P(public_buf_l, PSTR("%.3f"), current_position[Z_AXIS]);
lv_label_set_text(labelZpos, public_buf_l); lv_label_set_text(labelZpos, public_buf_l);
} }
@ -333,7 +304,6 @@ void setProBarRate() {
if (disp_state == PRINTING_UI) { if (disp_state == PRINTING_UI) {
lv_bar_set_value(bar1, rate, LV_ANIM_ON); lv_bar_set_value(bar1, rate, LV_ANIM_ON);
ZERO(public_buf_l);
sprintf_P(public_buf_l, "%d%%", rate); sprintf_P(public_buf_l, "%d%%", rate);
lv_label_set_text(bar1ValueText,public_buf_l); lv_label_set_text(bar1ValueText,public_buf_l);
lv_obj_align(bar1ValueText, bar1, LV_ALIGN_CENTER, 0, 0); lv_obj_align(bar1ValueText, bar1, LV_ALIGN_CENTER, 0, 0);

View file

@ -25,14 +25,16 @@
extern "C" { /* C-declarations for C++ */ extern "C" { /* C-declarations for C++ */
#endif #endif
#define IDLE 0 enum {
#define WORKING 1 IDLE,
#define PAUSING 2 WORKING,
#define PAUSED 3 PAUSING,
#define REPRINTING 4 PAUSED,
#define REPRINTED 5 REPRINTING,
#define RESUMING 6 REPRINTED,
#define STOP 7 RESUMING,
STOP
};
extern void lv_draw_printing(void); extern void lv_draw_printing(void);
extern void lv_clear_printing(); extern void lv_clear_printing();

View file

@ -43,44 +43,31 @@
//static lv_obj_t *buttonPrint, *buttonTool, *buttonSet; //static lv_obj_t *buttonPrint, *buttonTool, *buttonSet;
extern lv_group_t* g; extern lv_group_t* g;
static lv_obj_t * scr; static lv_obj_t *scr;
#if ENABLED(MKS_TEST) #if ENABLED(MKS_TEST)
uint8_t curent_disp_ui = 0; uint8_t curent_disp_ui = 0;
#endif #endif
#define ID_TOOL 1 enum {
#define ID_SET 2 ID_TOOL = 1,
#define ID_PRINT 3 ID_SET,
ID_PRINT
};
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_TOOL: case ID_TOOL:
if (event == LV_EVENT_CLICKED) { lv_clear_ready_print();
// nothing to do lv_draw_tool();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_ready_print();
lv_draw_tool();
}
break; break;
case ID_SET: case ID_SET:
if (event == LV_EVENT_CLICKED) { lv_clear_ready_print();
// nothing to do lv_draw_set();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_ready_print();
lv_draw_set();
}
break; break;
case ID_PRINT: case ID_PRINT:
if (event == LV_EVENT_CLICKED) { lv_clear_ready_print();
// nothing to do lv_draw_print_file();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_ready_print();
lv_draw_print_file();
}
break; break;
} }
} }
@ -114,20 +101,16 @@ void mks_disp_test() {
char buf[30] = {0}; char buf[30] = {0};
//lv_obj_t *label_tool2 = lv_label_create_empty(scr); //lv_obj_t *label_tool2 = lv_label_create_empty(scr);
//lv_obj_set_pos(label_tool, 20, 50); //lv_obj_set_pos(label_tool, 20, 50);
ZERO(buf);
sprintf_P(buf, PSTR("e1:%d"), (int)thermalManager.temp_hotend[0].celsius); sprintf_P(buf, PSTR("e1:%d"), (int)thermalManager.temp_hotend[0].celsius);
lv_label_set_text(e1, buf); lv_label_set_text(e1, buf);
#if HAS_MULTI_HOTEND #if HAS_MULTI_HOTEND
ZERO(buf);
sprintf_P(buf, PSTR("e2:%d"), (int)thermalManager.temp_hotend[1].celsius); sprintf_P(buf, PSTR("e2:%d"), (int)thermalManager.temp_hotend[1].celsius);
lv_label_set_text(e2, buf); lv_label_set_text(e2, buf);
#endif #endif
//ZERO(buf);
//sprintf_P(buf, PSTR("e3:%d"), (int)thermalManager.temp_hotend[2].celsius); //sprintf_P(buf, PSTR("e3:%d"), (int)thermalManager.temp_hotend[2].celsius);
//lv_label_set_text(e3, buf); //lv_label_set_text(e3, buf);
#if HAS_HEATED_BED #if HAS_HEATED_BED
ZERO(buf);
sprintf_P(buf, PSTR("bed:%d"), (int)thermalManager.temp_bed.celsius); sprintf_P(buf, PSTR("bed:%d"), (int)thermalManager.temp_bed.celsius);
lv_label_set_text(bed, buf); lv_label_set_text(bed, buf);
#endif #endif
@ -135,7 +118,7 @@ void mks_disp_test() {
void lv_draw_ready_print(void) { void lv_draw_ready_print(void) {
char buf[30] = {0}; char buf[30] = {0};
lv_obj_t *buttonPrint, *buttonTool, *buttonSet; lv_obj_t *buttonTool;
disp_state_stack._disp_index = 0; disp_state_stack._disp_index = 0;
ZERO(disp_state_stack._disp_state); ZERO(disp_state_stack._disp_state);
@ -143,11 +126,7 @@ void lv_draw_ready_print(void) {
disp_state = PRINT_READY_UI; disp_state = PRINT_READY_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
//lv_obj_set_hidden(scr, true); //lv_obj_set_hidden(scr, true);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
@ -155,12 +134,12 @@ void lv_draw_ready_print(void) {
//(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); //(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
// Create image buttons // Create image buttons
//buttonPrint = lv_imgbtn_create(scr, NULL); //buttonPrint = lv_imgbtn_create(scr, nullptr);
buttonTool = lv_imgbtn_create(scr, "F:/bmp_tool.bin", event_handler, ID_TOOL); buttonTool = lv_imgbtn_create(scr, "F:/bmp_tool.bin", event_handler, ID_TOOL);
lv_obj_set_pos(buttonTool, 360, 180); lv_obj_set_pos(buttonTool, 360, 180);
//buttonSet = lv_imgbtn_create(scr, NULL); //buttonSet = lv_imgbtn_create(scr, nullptr);
//lv_obj_set_pos(buttonSet, 180, 90); //lv_obj_set_pos(buttonSet, 180, 90);
//lv_obj_set_pos(buttonPrint, 340, 90); //lv_obj_set_pos(buttonPrint, 340, 90);
@ -237,34 +216,9 @@ void lv_draw_ready_print(void) {
} }
else { else {
// Create an Image button lv_big_button_create(scr, "F:/bmp_tool.bin", main_menu.tool, 20, 90, event_handler, ID_TOOL);
buttonTool = lv_imgbtn_create(scr, "F:/bmp_tool.bin", 20, 90, event_handler, ID_TOOL); lv_big_button_create(scr, "F:/bmp_set.bin", main_menu.set, 180, 90, event_handler, ID_SET);
lv_obj_t *label_tool = lv_label_create_empty(buttonTool); lv_big_button_create(scr, "F:/bmp_printing.bin", main_menu.print, 340, 90, event_handler, ID_PRINT);
buttonSet = lv_imgbtn_create(scr, "F:/bmp_set.bin", 180, 90, event_handler, ID_SET);
lv_obj_t *label_set = lv_label_create_empty(buttonSet);
buttonPrint = lv_imgbtn_create(scr, "F:/bmp_printing.bin", 340, 90, event_handler, ID_PRINT);
lv_obj_t *label_print = lv_label_create_empty(buttonPrint);
if (gCfgItems.multiple_language) {
lv_label_set_text(label_print, main_menu.print);
lv_obj_align(label_print, buttonPrint, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_set, main_menu.set);
lv_obj_align(label_set, buttonSet, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_tool, main_menu.tool);
lv_obj_align(label_tool, buttonTool, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
}
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable == true) {
lv_group_add_obj(g, buttonTool);
lv_group_add_obj(g, buttonSet);
lv_group_add_obj(g, buttonPrint);
}
#endif
} }
} }

View file

@ -37,100 +37,58 @@
#include "../../../../gcode/queue.h" #include "../../../../gcode/queue.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
static lv_obj_t * scr; static lv_obj_t *scr;
extern lv_group_t* g; extern lv_group_t* g;
#define ID_S_WIFI 1 enum {
#define ID_S_FAN 2 ID_S_WIFI = 1,
#define ID_S_ABOUT 3 ID_S_FAN,
#define ID_S_CONTINUE 4 ID_S_ABOUT,
#define ID_S_MOTOR_OFF 5 ID_S_CONTINUE,
#define ID_S_LANGUAGE 6 ID_S_MOTOR_OFF,
#define ID_S_MACHINE_PARA 7 ID_S_LANGUAGE,
#define ID_S_EEPROM_SET 8 ID_S_MACHINE_PARA,
#define ID_S_RETURN 9 ID_S_EEPROM_SET,
ID_S_RETURN
};
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
#if ENABLED(USE_WIFI_FUNCTION) #if ENABLED(USE_WIFI_FUNCTION)
char buf[6] = { 0 }; char buf[6] = { 0 };
#endif #endif
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_S_FAN: case ID_S_FAN:
if (event == LV_EVENT_CLICKED) { lv_clear_set();
// nothing to do lv_draw_fan();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_set();
lv_draw_fan();
}
break; break;
case ID_S_ABOUT: case ID_S_ABOUT:
if (event == LV_EVENT_CLICKED) { lv_clear_set();
// nothing to do lv_draw_about();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_set();
lv_draw_about();
}
break;
case ID_S_CONTINUE:
break; break;
case ID_S_CONTINUE: break;
case ID_S_MOTOR_OFF: case ID_S_MOTOR_OFF:
if (event == LV_EVENT_CLICKED) { TERN(HAS_SUICIDE, suicide(), queue.enqueue_now_P(PSTR("M84")));
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
#if HAS_SUICIDE
suicide();
#else
queue.enqueue_now_P(PSTR("M84"));
#endif
}
break; break;
case ID_S_LANGUAGE: case ID_S_LANGUAGE:
if (event == LV_EVENT_CLICKED) { lv_clear_set();
// nothing to do lv_draw_language();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_set();
lv_draw_language();
}
break; break;
case ID_S_MACHINE_PARA: case ID_S_MACHINE_PARA:
if (event == LV_EVENT_CLICKED) { lv_clear_set();
lv_draw_machine_para();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_set();
lv_draw_machine_para();
}
break; break;
case ID_S_EEPROM_SET: case ID_S_EEPROM_SET:
if (event == LV_EVENT_CLICKED) { lv_clear_set();
lv_draw_eeprom_settings();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_set();
lv_draw_eeprom_settings();
}
break; break;
case ID_S_RETURN: case ID_S_RETURN:
if (event == LV_EVENT_CLICKED) { lv_clear_set();
// nothing to do lv_draw_ready_print();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_set();
lv_draw_ready_print();
}
break; break;
#if ENABLED(USE_WIFI_FUNCTION) #if ENABLED(USE_WIFI_FUNCTION)
case ID_S_WIFI: case ID_S_WIFI:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
if (gCfgItems.wifi_mode_sel == STA_MODEL) { if (gCfgItems.wifi_mode_sel == STA_MODEL) {
if (wifi_link_state == WIFI_CONNECTED) { if (wifi_link_state == WIFI_CONNECTED) {
last_disp_state = SET_UI; last_disp_state = SET_UI;
@ -153,7 +111,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
else { else {
last_disp_state = SET_UI; last_disp_state = SET_UI;
lv_clear_set(); lv_clear_set();
lv_draw_dialog(WIFI_ENABLE_TIPS); lv_draw_dialog(DIALOG_WIFI_ENABLE_TIPS);
} }
} }
} }
@ -162,131 +120,36 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
lv_clear_set(); lv_clear_set();
lv_draw_wifi(); lv_draw_wifi();
} }
} break;
break;
#endif #endif
} }
} }
void lv_draw_set(void) { void lv_draw_set(void) {
lv_obj_t *buttonFan, *buttonAbout;
lv_obj_t *buMotorOff, *buttonBack;
#if HAS_LANG_SELECT_SCREEN
lv_obj_t *buttonLanguage;
#endif
lv_obj_t *buttonMachinePara;
lv_obj_t *buttonEepromSet;
#if ENABLED(USE_WIFI_FUNCTION)
lv_obj_t *buttonWifi;
#endif
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != SET_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != SET_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = SET_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = SET_UI;
} }
disp_state = SET_UI; disp_state = SET_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
//static lv_style_t tool_style;
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
// Create image buttons lv_big_button_create(scr, "F:/bmp_eeprom_settings.bin", set_menu.eepromSet, INTERVAL_V, titleHeight, event_handler, ID_S_EEPROM_SET);
buttonEepromSet = lv_imgbtn_create(scr, "F:/bmp_eeprom_settings.bin", INTERVAL_V, titleHeight, event_handler, ID_S_EEPROM_SET); lv_big_button_create(scr, "F:/bmp_fan.bin", set_menu.fan, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_S_FAN);
//buttonWifi = lv_imgbtn_create(scr, NULL); lv_big_button_create(scr, "F:/bmp_about.bin", set_menu.about, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_S_ABOUT);
buttonFan = lv_imgbtn_create(scr, "F:/bmp_fan.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_S_FAN); lv_big_button_create(scr, ENABLED(HAS_SUICIDE) ? "F:/bmp_manual_off.bin" : "F:/bmp_function1.bin", set_menu.TERN(HAS_SUICIDE, shutdown, motoroff), BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_S_MOTOR_OFF);
buttonAbout = lv_imgbtn_create(scr, "F:/bmp_about.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_S_ABOUT); lv_big_button_create(scr, "F:/bmp_machine_para.bin", set_menu.machine_para, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_MACHINE_PARA);
//buttonContinue = lv_imgbtn_create(scr, NULL);
buMotorOff = lv_imgbtn_create(scr, ENABLED(HAS_SUICIDE) ? "F:/bmp_manual_off.bin" : "F:/bmp_function1.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_S_MOTOR_OFF);
buttonMachinePara = lv_imgbtn_create(scr, "F:/bmp_machine_para.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_MACHINE_PARA);
#if HAS_LANG_SELECT_SCREEN #if HAS_LANG_SELECT_SCREEN
buttonLanguage = lv_imgbtn_create(scr, "F:/bmp_language.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_LANGUAGE); lv_big_button_create(scr, "F:/bmp_language.bin", set_menu.language, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_LANGUAGE);
#endif #endif
#if ENABLED(USE_WIFI_FUNCTION) #if ENABLED(USE_WIFI_FUNCTION)
buttonWifi = lv_imgbtn_create(scr, "F:/bmp_wifi.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_WIFI); lv_big_button_create(scr, "F:/bmp_wifi.bin", set_menu.wifi, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_WIFI);
#endif
buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_RETURN);
/*lv_obj_set_pos(buttonWifi,INTERVAL_V,titleHeight);
lv_obj_set_pos(buttonFan,BTN_X_PIXEL+INTERVAL_V*2,titleHeight);
lv_obj_set_pos(buttonAbout,BTN_X_PIXEL*2+INTERVAL_V*3,titleHeight);
lv_obj_set_pos(buttonContinue,BTN_X_PIXEL*3+INTERVAL_V*4,titleHeight);
lv_obj_set_pos(buMotorOff,INTERVAL_V, BTN_Y_PIXEL+INTERVAL_H+titleHeight);
lv_obj_set_pos(buttonLanguage,BTN_X_PIXEL+INTERVAL_V*2,BTN_Y_PIXEL+INTERVAL_H+titleHeight);
lv_obj_set_pos(buttonBack,BTN_X_PIXEL*3+INTERVAL_V*4, BTN_Y_PIXEL+INTERVAL_H+titleHeight);*/
//lv_obj_set_pos(buttonWifi,INTERVAL_V,titleHeight);
//lv_obj_set_pos(buttonContinue,BTN_X_PIXEL*3+INTERVAL_V*4,titleHeight);
/// Create labels on the buttons
//lv_obj_t *labelWifi= lv_label_create_empty(buttonWifi);
lv_obj_t *label_EepromSet = lv_label_create_empty(buttonEepromSet);
lv_obj_t *labelFan = lv_label_create_empty(buttonFan);
lv_obj_t *label_About = lv_label_create_empty(buttonAbout);
//lv_obj_t *label_Continue = lv_label_create_empty(buttonContinue);
lv_obj_t *label_MotorOff = lv_label_create_empty(buMotorOff);
lv_obj_t *label_MachinePara = lv_label_create_empty(buttonMachinePara);
#if HAS_LANG_SELECT_SCREEN
lv_obj_t *label_Language = lv_label_create_empty(buttonLanguage);
#endif
#if ENABLED(USE_WIFI_FUNCTION)
lv_obj_t *label_Wifi = lv_label_create_empty(buttonWifi);
#endif
lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.multiple_language) {
lv_label_set_text(label_EepromSet, set_menu.eepromSet);
lv_obj_align(label_EepromSet, buttonEepromSet, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(labelFan, set_menu.fan);
lv_obj_align(labelFan, buttonFan, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_About, set_menu.about);
lv_obj_align(label_About, buttonAbout, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
//lv_label_set_text(label_Continue, set_menu.breakpoint);
//lv_obj_align(label_Continue, buttonContinue, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_MotorOff, set_menu.TERN(HAS_SUICIDE, shutdown, motoroff));
lv_obj_align(label_MotorOff, buMotorOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_MachinePara, set_menu.machine_para);
lv_obj_align(label_MachinePara, buttonMachinePara, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
#if HAS_LANG_SELECT_SCREEN
lv_label_set_text(label_Language, set_menu.language);
lv_obj_align(label_Language, buttonLanguage, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
#endif
#if ENABLED(USE_WIFI_FUNCTION)
lv_label_set_text(label_Wifi, set_menu.wifi);
lv_obj_align(label_Wifi, buttonWifi, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
#endif
lv_label_set_text(label_Back, common_menu.text_back);
lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
}
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonEepromSet);
lv_group_add_obj(g, buttonFan);
lv_group_add_obj(g, buttonAbout);
lv_group_add_obj(g, buMotorOff);
lv_group_add_obj(g, buttonMachinePara);
lv_group_add_obj(g, buttonLanguage);
#if ENABLED(USE_WIFI_FUNCTION)
lv_group_add_obj(g, buttonWifi);
#endif
lv_group_add_obj(g, buttonBack);
}
#endif #endif
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_RETURN);
} }
void lv_clear_set() { void lv_clear_set() {

View file

@ -29,243 +29,100 @@
#include "../../../../module/planner.h" #include "../../../../module/planner.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_STEP_RETURN 1 enum {
#define ID_STEP_X 2 ID_STEP_RETURN = 1,
#define ID_STEP_Y 3 ID_STEP_X,
#define ID_STEP_Z 4 ID_STEP_Y,
#define ID_STEP_E0 5 ID_STEP_Z,
#define ID_STEP_E1 6 ID_STEP_E0,
#define ID_STEP_DOWN 7 ID_STEP_E1,
#define ID_STEP_UP 8 ID_STEP_DOWN,
ID_STEP_UP
};
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_STEP_RETURN: case ID_STEP_RETURN:
if (event == LV_EVENT_CLICKED) { uiCfg.para_ui_page = 0;
lv_clear_step_settings();
} draw_return_ui();
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 0;
lv_clear_step_settings();
draw_return_ui();
}
break; break;
case ID_STEP_X: case ID_STEP_X:
if (event == LV_EVENT_CLICKED) { value = Xstep;
lv_clear_step_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = Xstep;
lv_clear_step_settings();
lv_draw_number_key();
}
break; break;
case ID_STEP_Y: case ID_STEP_Y:
if (event == LV_EVENT_CLICKED) { value = Ystep;
lv_clear_step_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = Ystep;
lv_clear_step_settings();
lv_draw_number_key();
}
break; break;
case ID_STEP_Z: case ID_STEP_Z:
if (event == LV_EVENT_CLICKED) { value = Zstep;
lv_clear_step_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = Zstep;
lv_clear_step_settings();
lv_draw_number_key();
}
break; break;
case ID_STEP_E0: case ID_STEP_E0:
if (event == LV_EVENT_CLICKED) { value = E0step;
lv_clear_step_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = E0step;
lv_clear_step_settings();
lv_draw_number_key();
}
break; break;
case ID_STEP_E1: case ID_STEP_E1:
if (event == LV_EVENT_CLICKED) { value = E1step;
lv_clear_step_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = E1step;
lv_clear_step_settings();
lv_draw_number_key();
}
break; break;
case ID_STEP_UP: case ID_STEP_UP:
if (event == LV_EVENT_CLICKED) { uiCfg.para_ui_page = 0;
lv_clear_step_settings();
} lv_draw_step_settings();
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 0;
lv_clear_step_settings();
lv_draw_step_settings();
}
break; break;
case ID_STEP_DOWN: case ID_STEP_DOWN:
if (event == LV_EVENT_CLICKED) { uiCfg.para_ui_page = 1;
lv_clear_step_settings();
} lv_draw_step_settings();
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 1;
lv_clear_step_settings();
lv_draw_step_settings();
}
break; break;
} }
} }
void lv_draw_step_settings(void) { void lv_draw_step_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL;
lv_obj_t *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t *buttonE0Value = NULL, *labelE0Value = NULL;
lv_obj_t *buttonE1Value = NULL, *labelE1Value = NULL;
lv_obj_t *line1 = NULL, *line2 = NULL, *line3 = NULL, *line4 = NULL;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != STEPS_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != STEPS_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = STEPS_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = STEPS_UI;
} }
disp_state = STEPS_UI; disp_state = STEPS_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.StepsConfTitle); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.StepsConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
if (uiCfg.para_ui_page != 1) { if (uiCfg.para_ui_page != 1) {
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.X_Steps); sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[X_AXIS]);
lv_screen_menu_item_1_edit(scr, machine_menu.X_Steps, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_STEP_X, 0, public_buf_l);
buttonXValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_STEP_X); sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[Y_AXIS]);
labelXValue = lv_label_create_empty(buttonXValue); lv_screen_menu_item_1_edit(scr, machine_menu.Y_Steps, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_STEP_Y, 1, public_buf_l);
line1 = lv_line_create(scr, NULL); sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[Z_AXIS]);
lv_ex_line(line1, line_points[0]); lv_screen_menu_item_1_edit(scr, machine_menu.Z_Steps, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_STEP_Z, 2, public_buf_l);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, machine_menu.Y_Steps); sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[E_AXIS]);
lv_screen_menu_item_1_edit(scr, machine_menu.E0_Steps, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_STEP_E0, 3, public_buf_l);
buttonYValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_STEP_Y); lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_STEP_DOWN, true);
labelYValue = lv_label_create_empty(buttonYValue);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, machine_menu.Z_Steps);
buttonZValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_STEP_Z);
labelZValue = lv_label_create_empty(buttonZValue);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, machine_menu.E0_Steps);
buttonE0Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_STEP_E0);
labelE0Value = lv_label_create_empty(buttonE0Value);
line4 = lv_line_create(scr, NULL);
lv_ex_line(line4, line_points[3]);
buttonTurnPage = lv_btn_create(scr, event_handler, ID_STEP_DOWN);
#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, buttonE0Value);
lv_group_add_obj(g, buttonTurnPage);
}
#endif
} }
else { else {
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.E1_Steps); sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[E_AXIS_N(1)]);
lv_screen_menu_item_1_edit(scr, machine_menu.E1_Steps, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_STEP_E1, 0, public_buf_l);
buttonE1Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_STEP_E1); lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_STEP_UP, true);
labelE1Value = lv_label_create_empty(buttonE1Value);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonTurnPage = lv_btn_create(scr, event_handler, ID_STEP_UP);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonE1Value);
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_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_STEP_RETURN, true);
lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
labelTurnPage = lv_label_create_empty(buttonTurnPage);
buttonBack = lv_btn_create(scr, NULL);
lv_btn_set_style_both(buttonBack, &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);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_STEP_RETURN, NULL, 0);
label_Back = lv_label_create_empty(buttonBack);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif
if (gCfgItems.multiple_language) {
if (uiCfg.para_ui_page != 1) {
lv_label_set_text(labelTurnPage, machine_menu.next);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[X_AXIS]);
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"), planner.settings.axis_steps_per_mm[Y_AXIS]);
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"), planner.settings.axis_steps_per_mm[Z_AXIS]);
lv_label_set_text(labelZValue, public_buf_l);
lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[E_AXIS]);
lv_label_set_text(labelE0Value, public_buf_l);
lv_obj_align(labelE0Value, buttonE0Value, LV_ALIGN_CENTER, 0, 0);
}
else {
lv_label_set_text(labelTurnPage, machine_menu.previous);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[E_AXIS_N(1)]);
lv_label_set_text(labelE1Value, public_buf_l);
lv_obj_align(labelE1Value, buttonE1Value, 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_step_settings() { void lv_clear_step_settings() {

View file

@ -30,304 +30,138 @@
#include "../../../../feature/tmc_util.h" #include "../../../../feature/tmc_util.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_TMC_CURRENT_RETURN 1 enum {
#define ID_TMC_CURRENT_X 2 ID_TMC_CURRENT_RETURN = 1,
#define ID_TMC_CURRENT_Y 3 ID_TMC_CURRENT_X,
#define ID_TMC_CURRENT_Z 4 ID_TMC_CURRENT_Y,
#define ID_TMC_CURRENT_E0 5 ID_TMC_CURRENT_Z,
#define ID_TMC_CURRENT_E1 6 ID_TMC_CURRENT_E0,
#define ID_TMC_CURRENT_DOWN 7 ID_TMC_CURRENT_E1,
#define ID_TMC_CURRENT_UP 8 ID_TMC_CURRENT_DOWN,
ID_TMC_CURRENT_UP
};
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_TMC_CURRENT_RETURN: case ID_TMC_CURRENT_RETURN:
if (event == LV_EVENT_CLICKED) { uiCfg.para_ui_page = 0;
lv_clear_tmc_current_settings();
} draw_return_ui();
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 0;
lv_clear_tmc_current_settings();
draw_return_ui();
}
break; break;
#if AXIS_IS_TMC(X) #if AXIS_IS_TMC(X)
case ID_TMC_CURRENT_X: case ID_TMC_CURRENT_X:
if (event == LV_EVENT_CLICKED) { value = Xcurrent;
lv_clear_tmc_current_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = Xcurrent;
lv_clear_tmc_current_settings();
lv_draw_number_key();
}
break; break;
#endif #endif
#if AXIS_IS_TMC(Y) #if AXIS_IS_TMC(Y)
case ID_TMC_CURRENT_Y: case ID_TMC_CURRENT_Y:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = Ycurrent; value = Ycurrent;
lv_clear_tmc_current_settings(); lv_clear_tmc_current_settings();
lv_draw_number_key(); lv_draw_number_key();
} break;
break;
#endif #endif
#if AXIS_IS_TMC(Z) #if AXIS_IS_TMC(Z)
case ID_TMC_CURRENT_Z: case ID_TMC_CURRENT_Z:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = Zcurrent; value = Zcurrent;
lv_clear_tmc_current_settings(); lv_clear_tmc_current_settings();
lv_draw_number_key(); lv_draw_number_key();
} break;
break;
#endif #endif
#if AXIS_IS_TMC(E0) #if AXIS_IS_TMC(E0)
case ID_TMC_CURRENT_E0: case ID_TMC_CURRENT_E0:
if (event == LV_EVENT_CLICKED) { value = E0current;
lv_clear_tmc_current_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = E0current;
lv_clear_tmc_current_settings();
lv_draw_number_key();
}
break; break;
#endif #endif
#if AXIS_IS_TMC(E1) #if AXIS_IS_TMC(E1)
case ID_TMC_CURRENT_E1: case ID_TMC_CURRENT_E1:
if (event == LV_EVENT_CLICKED) { value = E1current;
lv_clear_tmc_current_settings();
} lv_draw_number_key();
else if (event == LV_EVENT_RELEASED) {
value = E1current;
lv_clear_tmc_current_settings();
lv_draw_number_key();
}
break; break;
#endif #endif
case ID_TMC_CURRENT_UP:
if (event == LV_EVENT_CLICKED) {
} case ID_TMC_CURRENT_UP:
else if (event == LV_EVENT_RELEASED) { uiCfg.para_ui_page = 0;
uiCfg.para_ui_page = 0; lv_clear_tmc_current_settings();
lv_clear_tmc_current_settings(); lv_draw_tmc_current_settings();
lv_draw_tmc_current_settings();
}
break; break;
case ID_TMC_CURRENT_DOWN: case ID_TMC_CURRENT_DOWN:
if (event == LV_EVENT_CLICKED) { uiCfg.para_ui_page = 1;
lv_clear_tmc_current_settings();
} lv_draw_tmc_current_settings();
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 1;
lv_clear_tmc_current_settings();
lv_draw_tmc_current_settings();
}
break; break;
} }
} }
void lv_draw_tmc_current_settings(void) { void lv_draw_tmc_current_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL;
lv_obj_t *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t *buttonE0Value = NULL, *labelE0Value = NULL;
lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
//#if AXIS_IS_TMC(E1)
lv_obj_t *buttonTurnPage = NULL, *labelTurnPage = NULL;
lv_obj_t *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL;
//#endif
float milliamps;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != TMC_CURRENT_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != TMC_CURRENT_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = TMC_CURRENT_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = TMC_CURRENT_UI;
} }
disp_state = TMC_CURRENT_UI; disp_state = TMC_CURRENT_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.TmcCurrentConfTitle); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.TmcCurrentConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
float milliamps;
if (uiCfg.para_ui_page != 1) { if (uiCfg.para_ui_page != 1) {
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.X_Current); #if AXIS_IS_TMC(X)
milliamps = stepperX.getMilliamps();
buttonXValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_TMC_CURRENT_X); #else
labelXValue = lv_label_create_empty(buttonXValue); milliamps = -1;
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, machine_menu.Y_Current);
buttonYValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_TMC_CURRENT_Y);
labelYValue = lv_label_create_empty(buttonYValue);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, machine_menu.Z_Current);
buttonZValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_TMC_CURRENT_Z);
labelZValue = lv_label_create_empty(buttonZValue);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
(void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, machine_menu.E0_Current);
buttonE0Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_TMC_CURRENT_E0);
labelE0Value = lv_label_create_empty(buttonE0Value);
#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, buttonE0Value);
}
#endif #endif
sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
lv_screen_menu_item_1_edit(scr, machine_menu.X_Current, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_TMC_CURRENT_X, 0, public_buf_l);
line4 = lv_line_create(scr, NULL); #if AXIS_IS_TMC(Y)
lv_ex_line(line4, line_points[3]); milliamps = stepperY.getMilliamps();
#else
milliamps = -1;
#endif
sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
lv_screen_menu_item_1_edit(scr, machine_menu.Y_Current, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_TMC_CURRENT_Y, 1, public_buf_l);
//#if AXIS_IS_TMC(E1) #if AXIS_IS_TMC(Z)
buttonTurnPage = lv_btn_create(scr, NULL); milliamps = stepperZ.getMilliamps();
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_CURRENT_DOWN, NULL, 0); #else
lv_btn_set_style_both(buttonTurnPage, &style_para_back); milliamps = -1;
#endif
sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
lv_screen_menu_item_1_edit(scr, machine_menu.Z_Current, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_TMC_CURRENT_Z, 2, public_buf_l);
#if HAS_ROTARY_ENCODER #if AXIS_IS_TMC(E0)
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonTurnPage); milliamps = stepperE0.getMilliamps();
#endif #else
//#endif milliamps = -1;
#endif
sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
lv_screen_menu_item_1_edit(scr, machine_menu.E0_Current, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_TMC_CURRENT_E0, 3, public_buf_l);
lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_TMC_CURRENT_DOWN, true);
} }
else { else {
//#if AXIS_IS_TMC(E1) #if AXIS_IS_TMC(E1)
labelE1Text = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.E1_Current); milliamps = stepperE1.getMilliamps();
#else
milliamps = -1;
#endif
sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
lv_screen_menu_item_1_edit(scr, machine_menu.E1_Current, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_TMC_CURRENT_E1, 0, public_buf_l);
buttonE1Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_TMC_CURRENT_E1); lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_TMC_CURRENT_UP, true);
labelE1Value = lv_label_create_empty(buttonE1Value);
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_TMC_CURRENT_UP, NULL, 0);
lv_btn_set_style_both(buttonTurnPage, &style_para_back);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonE1Value);
lv_group_add_obj(g, buttonTurnPage);
}
#endif
//#endif
} }
//#if AXIS_IS_TMC(E1)
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_empty(buttonTurnPage);
//#endif
buttonBack = lv_btn_create(scr, NULL); lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_TMC_CURRENT_RETURN, true);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_TMC_CURRENT_RETURN, NULL, 0);
lv_btn_set_style_both(buttonBack, &style_para_back);
#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_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.multiple_language) {
if (uiCfg.para_ui_page != 1) {
//#if AXIS_IS_TMC(E1)
lv_label_set_text(labelTurnPage, machine_menu.next);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
//#endif
#if AXIS_IS_TMC(X)
milliamps = stepperX.getMilliamps();
#else
milliamps = -1;
#endif
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
lv_label_set_text(labelXValue, public_buf_l);
lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
#if AXIS_IS_TMC(Y)
milliamps = stepperY.getMilliamps();
#else
milliamps = -1;
#endif
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
lv_label_set_text(labelYValue, public_buf_l);
lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0);
#if AXIS_IS_TMC(Z)
milliamps = stepperZ.getMilliamps();
#else
milliamps = -1;
#endif
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
lv_label_set_text(labelZValue, public_buf_l);
lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
#if AXIS_IS_TMC(E0)
milliamps = stepperE0.getMilliamps();
#else
milliamps = -1;
#endif
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
lv_label_set_text(labelE0Value, public_buf_l);
lv_obj_align(labelE0Value, buttonE0Value, LV_ALIGN_CENTER, 0, 0);
}
else {
//#if AXIS_IS_TMC(E1)
lv_label_set_text(labelTurnPage, machine_menu.previous);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
#if AXIS_IS_TMC(E1)
milliamps = stepperE1.getMilliamps();
#else
milliamps = -1;
#endif
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
lv_label_set_text(labelE1Value, public_buf_l);
lv_obj_align(labelE1Value, buttonE1Value, 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_tmc_current_settings() { void lv_clear_tmc_current_settings() {

View file

@ -34,185 +34,83 @@
#include "../../../../module/settings.h" #include "../../../../module/settings.h"
#endif #endif
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_TMC_MODE_RETURN 1 enum {
#define ID_TMC_MODE_X 2 ID_TMC_MODE_RETURN = 1,
#define ID_TMC_MODE_Y 3 ID_TMC_MODE_X,
#define ID_TMC_MODE_Z 4 ID_TMC_MODE_Y,
#define ID_TMC_MODE_E0 5 ID_TMC_MODE_Z,
#define ID_TMC_MODE_E1 6 ID_TMC_MODE_E0,
#define ID_TMC_MODE_DOWN 7 ID_TMC_MODE_E1,
#define ID_TMC_MODE_UP 8 ID_TMC_MODE_DOWN,
ID_TMC_MODE_UP
};
static lv_obj_t *labelXState = NULL, *labelYState = NULL, *labelZState = NULL, *labelE0State = NULL; static lv_obj_t *buttonXState = nullptr, *buttonYState = nullptr, *buttonZState = nullptr, *buttonE0State = nullptr;
static lv_obj_t *buttonXState = NULL, *buttonYState = NULL, *buttonZState = NULL, *buttonE0State = NULL;
//#if AXIS_HAS_STEALTHCHOP(E1) //#if AXIS_HAS_STEALTHCHOP(E1)
static lv_obj_t *labelE1State = NULL, *buttonE1State = NULL; static lv_obj_t *buttonE1State = nullptr;
//#endif //#endif
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
auto toggle_chop = [&](auto &stepper, auto &button) {
const bool isena = stepper.toggle_stepping_mode();
lv_screen_menu_item_onoff_update(button, isena);
TERN_(EEPROM_SETTINGS, (void)settings.save());
};
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_TMC_MODE_RETURN: case ID_TMC_MODE_RETURN:
if (event == LV_EVENT_CLICKED) { uiCfg.para_ui_page = 0;
lv_clear_tmc_step_mode_settings();
} draw_return_ui();
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 0;
lv_clear_tmc_step_mode_settings();
draw_return_ui();
}
break; break;
#if AXIS_HAS_STEALTHCHOP(X) #if AXIS_HAS_STEALTHCHOP(X)
case ID_TMC_MODE_X: case ID_TMC_MODE_X:
if (event == LV_EVENT_CLICKED) { toggle_chop(stepperX, buttonXState);
}
else if (event == LV_EVENT_RELEASED) {
if (stepperX.toggle_stepping_mode()) {
lv_imgbtn_set_src_both(buttonXState, "F:/bmp_enable.bin");
lv_label_set_text(labelXState, machine_menu.enable);
}
else {
lv_imgbtn_set_src_both(buttonXState, "F:/bmp_disable.bin");
lv_label_set_text(labelXState, machine_menu.disable);
//lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
}
TERN_(EEPROM_SETTINGS, (void)settings.save());
}
break; break;
#endif // if AXIS_HAS_STEALTHCHOP(X) #endif
#if AXIS_HAS_STEALTHCHOP(Y) #if AXIS_HAS_STEALTHCHOP(Y)
case ID_TMC_MODE_Y: case ID_TMC_MODE_Y:
if (event == LV_EVENT_CLICKED) { toggle_chop(stepperY, buttonYState);
}
else if (event == LV_EVENT_RELEASED) {
if (stepperY.toggle_stepping_mode()) {
lv_imgbtn_set_src_both(buttonYState, "F:/bmp_enable.bin");
lv_label_set_text(labelYState, machine_menu.enable);
}
else {
lv_imgbtn_set_src_both(buttonYState, "F:/bmp_disable.bin");
lv_label_set_text(labelYState, machine_menu.disable);
//lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
}
TERN_(EEPROM_SETTINGS, (void)settings.save());
}
break; break;
#endif // if AXIS_HAS_STEALTHCHOP(Y) #endif
#if AXIS_HAS_STEALTHCHOP(Z) #if AXIS_HAS_STEALTHCHOP(Z)
case ID_TMC_MODE_Z: case ID_TMC_MODE_Z:
if (event == LV_EVENT_CLICKED) { toggle_chop(stepperZ, buttonZState);
}
else if (event == LV_EVENT_RELEASED) {
if (stepperZ.toggle_stepping_mode()) {
lv_imgbtn_set_src_both(buttonZState, "F:/bmp_enable.bin");
lv_label_set_text(labelZState, machine_menu.enable);
}
else {
lv_imgbtn_set_src_both(buttonZState, "F:/bmp_disable.bin");
lv_label_set_text(labelZState, machine_menu.disable);
//lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
}
TERN_(EEPROM_SETTINGS, (void)settings.save());
}
break; break;
#endif // if AXIS_HAS_STEALTHCHOP(Z) #endif
#if AXIS_HAS_STEALTHCHOP(E0) #if AXIS_HAS_STEALTHCHOP(E0)
case ID_TMC_MODE_E0: case ID_TMC_MODE_E0:
if (event == LV_EVENT_CLICKED) { toggle_chop(stepperE0, buttonE0State);
}
else if (event == LV_EVENT_RELEASED) {
if (stepperE0.toggle_stepping_mode()) {
lv_imgbtn_set_src_both(buttonE0State, "F:/bmp_enable.bin");
lv_label_set_text(labelE0State, machine_menu.enable);
}
else {
lv_imgbtn_set_src_both(buttonE0State, "F:/bmp_disable.bin");
lv_label_set_text(labelE0State, machine_menu.disable);
//lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
}
TERN_(EEPROM_SETTINGS, (void)settings.save());
}
break; break;
#endif // if AXIS_HAS_STEALTHCHOP(E0) #endif
#if AXIS_HAS_STEALTHCHOP(E1) #if AXIS_HAS_STEALTHCHOP(E1)
case ID_TMC_MODE_E1: case ID_TMC_MODE_E1:
if (event == LV_EVENT_CLICKED) { toggle_chop(stepperE1, buttonE1State);
}
else if (event == LV_EVENT_RELEASED) {
if (stepperE1.toggle_stepping_mode()) {
lv_imgbtn_set_src_both(buttonE1State, "F:/bmp_enable.bin");
lv_label_set_text(labelE1State, machine_menu.enable);
}
else {
lv_imgbtn_set_src_both(buttonE1State, "F:/bmp_disable.bin");
lv_label_set_text(labelE1State, machine_menu.disable);
//lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
}
TERN_(EEPROM_SETTINGS, (void)settings.save());
}
break; break;
#endif // if AXIS_HAS_STEALTHCHOP(E1) #endif
case ID_TMC_MODE_UP:
if (event == LV_EVENT_CLICKED) {
} case ID_TMC_MODE_UP:
else if (event == LV_EVENT_RELEASED) { uiCfg.para_ui_page = 0;
uiCfg.para_ui_page = 0; lv_clear_tmc_step_mode_settings();
lv_clear_tmc_step_mode_settings(); lv_draw_tmc_step_mode_settings();
lv_draw_tmc_step_mode_settings();
}
break; break;
case ID_TMC_MODE_DOWN: case ID_TMC_MODE_DOWN:
if (event == LV_EVENT_CLICKED) { uiCfg.para_ui_page = 1;
lv_clear_tmc_step_mode_settings();
} lv_draw_tmc_step_mode_settings();
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 1;
lv_clear_tmc_step_mode_settings();
lv_draw_tmc_step_mode_settings();
}
break; break;
} }
} }
void lv_draw_tmc_step_mode_settings(void) { void lv_draw_tmc_step_mode_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL; buttonXState = buttonYState = buttonZState = buttonE0State = buttonE1State = nullptr;
lv_obj_t *buttonXText = NULL, *labelXText = NULL;
lv_obj_t *buttonYText = NULL, *labelYText = NULL;
lv_obj_t *buttonZText = NULL, *labelZText = NULL;
lv_obj_t *buttonE0Text = NULL, *labelE0Text = NULL;
lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
//#if AXIS_HAS_STEALTHCHOP(E1)
lv_obj_t *buttonTurnPage = NULL, *labelTurnPage = NULL;
lv_obj_t *buttonE1Text = NULL, *labelE1Text = NULL;
//#endif
labelXState = NULL;
buttonXState = NULL;
labelYState = NULL;
buttonYState = NULL;
labelZState = NULL;
buttonZState = NULL;
labelE0State = NULL;
buttonE0State = NULL;
//#if AXIS_HAS_STEALTHCHOP(E1)
labelE1State = NULL;
buttonE1State = NULL;
//#endif
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != TMC_MODE_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != TMC_MODE_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
@ -220,14 +118,8 @@ void lv_draw_tmc_step_mode_settings(void) {
} }
disp_state = TMC_MODE_UI; disp_state = TMC_MODE_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.TmcStepModeConfTitle); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.TmcStepModeConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
bool stealth_X = false, stealth_Y = false, stealth_Z = false, stealth_E0 = false, stealth_E1 = false; bool stealth_X = false, stealth_Y = false, stealth_Z = false, stealth_E0 = false, stealth_E1 = false;
@ -248,136 +140,18 @@ void lv_draw_tmc_step_mode_settings(void) {
#endif #endif
if (uiCfg.para_ui_page != 1) { if (uiCfg.para_ui_page != 1) {
buttonXText = lv_btn_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y, event_handler, 0); buttonXState = lv_screen_menu_item_onoff(scr, machine_menu.X_StepMode, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_TMC_MODE_X, 0, stealth_X);
labelXText = lv_label_create_empty(buttonXText); /*Add a label to the button*/ buttonYState = lv_screen_menu_item_onoff(scr, machine_menu.Y_StepMode, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_TMC_MODE_Y, 1, stealth_Y);
buttonZState = lv_screen_menu_item_onoff(scr, machine_menu.Z_StepMode, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_TMC_MODE_Z, 2, stealth_Z);
buttonXState = lv_imgbtn_create(scr, stealth_X ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin", PARA_UI_STATE_POS_X, PARA_UI_POS_Y + PARA_UI_STATE_V, event_handler, ID_TMC_MODE_X); buttonE0State = lv_screen_menu_item_onoff(scr, machine_menu.E0_StepMode, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_TMC_MODE_E0, 2, stealth_E0);
labelXState = lv_label_create_empty(buttonXState); lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_TMC_MODE_DOWN, true);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonXState);
#endif
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonYText = lv_btn_create(scr, NULL, PARA_UI_POS_X, PARA_UI_POS_Y * 2, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y, event_handler, 0);
labelYText = lv_label_create_empty(buttonYText); /*Add a label to the button*/
buttonYState = lv_imgbtn_create(scr, stealth_Y ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin", PARA_UI_STATE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_STATE_V, event_handler, ID_TMC_MODE_Y);
labelYState = lv_label_create_empty(buttonYState);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonYState);
#endif
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
buttonZText = lv_btn_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y, event_handler, 0);
labelZText = lv_label_create_empty(buttonZText); /*Add a label to the button*/
buttonZState = lv_imgbtn_create(scr, stealth_Z ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin", PARA_UI_STATE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_STATE_V, event_handler, ID_TMC_MODE_Z);
labelZState = lv_label_create_empty(buttonZState);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonZState);
#endif
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
buttonE0Text = lv_btn_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y, event_handler, 0);
labelE0Text = lv_label_create_empty(buttonE0Text); /*Add a label to the button*/
buttonE0State = lv_imgbtn_create(scr, stealth_E0 ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin", PARA_UI_STATE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_STATE_V, event_handler, ID_TMC_MODE_E0);
labelE0State = lv_label_create_empty(buttonE0State);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonE0State);
#endif
line4 = lv_line_create(scr, NULL);
lv_ex_line(line4, line_points[3]);
//#if AXIS_HAS_STEALTHCHOP(E1)
buttonTurnPage = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", event_handler, ID_TMC_MODE_DOWN);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonTurnPage);
#endif
//#endif
} }
else { else {
//#if AXIS_HAS_STEALTHCHOP(E1) buttonE1State = lv_screen_menu_item_onoff(scr, machine_menu.E1_StepMode, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_TMC_MODE_E1, 0, stealth_E1);
buttonE1Text = lv_btn_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y, event_handler, 0); lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_TMC_MODE_UP, true);
labelE1Text = lv_label_create_empty(buttonE1Text); /*Add a label to the button*/
buttonE1State = lv_imgbtn_create(scr, stealth_E1 ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin", PARA_UI_STATE_POS_X, PARA_UI_POS_Y + PARA_UI_STATE_V, event_handler, ID_TMC_MODE_E1);
labelE1State = lv_label_create_empty(buttonE1State);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonE1State);
#endif
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonTurnPage = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", event_handler, ID_TMC_MODE_UP);
//#endif
} }
//#if AXIS_HAS_STEALTHCHOP(E1)
lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
lv_btn_set_layout(buttonTurnPage, LV_LAYOUT_OFF);
labelTurnPage = lv_label_create_empty(buttonTurnPage);
//#endif
buttonBack = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_TMC_MODE_RETURN); lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_TMC_MODE_RETURN, true);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif
label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.multiple_language) {
if (uiCfg.para_ui_page != 1) {
lv_label_set_text(labelXText, machine_menu.X_StepMode);
lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelYText, machine_menu.Y_StepMode);
lv_obj_align(labelYText, buttonYText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelZText, machine_menu.Z_StepMode);
lv_obj_align(labelZText, buttonZText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelE0Text, machine_menu.E0_StepMode);
lv_obj_align(labelE0Text, buttonE0Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelXState, stealth_X ? machine_menu.enable : machine_menu.disable);
lv_obj_align(labelXState, buttonXState, LV_ALIGN_CENTER, 0, 0);
lv_label_set_text(labelYState, stealth_Y ? machine_menu.enable : machine_menu.disable);
lv_obj_align(labelYState, buttonYState, LV_ALIGN_CENTER, 0, 0);
lv_label_set_text(labelZState, stealth_Z ? machine_menu.enable : machine_menu.disable);
lv_obj_align(labelZState, buttonZState, LV_ALIGN_CENTER, 0, 0);
lv_label_set_text(labelE0State, stealth_E0 ? machine_menu.enable : machine_menu.disable);
lv_obj_align(labelE0State, buttonE0State, LV_ALIGN_CENTER, 0, 0);
//#if AXIS_HAS_STEALTHCHOP(E1)
lv_label_set_text(labelTurnPage, machine_menu.next);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
//#endif
}
else {
//#if AXIS_HAS_STEALTHCHOP(E1)
lv_label_set_text(labelE1Text, machine_menu.E1_StepMode);
lv_obj_align(labelE1Text, buttonE1Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelE1State, stealth_E1 ? machine_menu.enable : machine_menu.disable);
lv_obj_align(labelE1State, buttonE1State, LV_ALIGN_CENTER, 0, 0);
lv_label_set_text(labelTurnPage, machine_menu.previous);
lv_obj_align(labelTurnPage, buttonTurnPage, 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_tmc_step_mode_settings() { void lv_clear_tmc_step_mode_settings() {

View file

@ -34,182 +34,92 @@
#include "../../../../module/temperature.h" #include "../../../../module/temperature.h"
#include "../../../../inc/MarlinConfig.h" #include "../../../../inc/MarlinConfig.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
#define ID_T_PRE_HEAT 1 enum {
#define ID_T_EXTRUCT 2 ID_T_PRE_HEAT = 1,
#define ID_T_MOV 3 ID_T_EXTRUCT,
#define ID_T_HOME 4 ID_T_MOV,
#define ID_T_LEVELING 5 ID_T_HOME,
#define ID_T_FILAMENT 6 ID_T_LEVELING,
#define ID_T_MORE 7 ID_T_FILAMENT,
#define ID_T_RETURN 8 ID_T_MORE,
ID_T_RETURN
};
#if ENABLED(MKS_TEST) #if ENABLED(MKS_TEST)
extern uint8_t curent_disp_ui; extern uint8_t curent_disp_ui;
#endif #endif
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_T_PRE_HEAT: case ID_T_PRE_HEAT:
if (event == LV_EVENT_CLICKED) { lv_clear_tool();
// nothing to do lv_draw_preHeat();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_tool();
lv_draw_preHeat();
}
break; break;
case ID_T_EXTRUCT: case ID_T_EXTRUCT:
if (event == LV_EVENT_CLICKED) { lv_clear_tool();
// nothing to do lv_draw_extrusion();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_tool();
lv_draw_extrusion();
}
break; break;
case ID_T_MOV: case ID_T_MOV:
if (event == LV_EVENT_CLICKED) { lv_clear_tool();
// nothing to do lv_draw_move_motor();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_tool();
lv_draw_move_motor();
}
break; break;
case ID_T_HOME: case ID_T_HOME:
if (event == LV_EVENT_CLICKED) { lv_clear_tool();
// nothing to do lv_draw_home();
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_tool();
lv_draw_home();
}
break; break;
case ID_T_LEVELING: case ID_T_LEVELING:
if (event == LV_EVENT_CLICKED) { #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
// nothing to do //queue.enqueue_one_P(PSTR("G28"));
} //queue.enqueue_one_P(PSTR("G29"));
else if (event == LV_EVENT_RELEASED) { get_gcode_command(AUTO_LEVELING_COMMAND_ADDR,(uint8_t *)public_buf_m);
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) public_buf_m[sizeof(public_buf_m)-1] = 0;
//queue.enqueue_one_P(PSTR("G28")); queue.inject_P(PSTR(public_buf_m));
//queue.enqueue_one_P(PSTR("G29")); #else
get_gcode_command(AUTO_LEVELING_COMMAND_ADDR,(uint8_t *)public_buf_m); uiCfg.leveling_first_time = 1;
public_buf_m[sizeof(public_buf_m)-1] = 0; lv_clear_tool();
queue.inject_P(PSTR(public_buf_m)); lv_draw_manualLevel();
#else #endif
uiCfg.leveling_first_time = 1;
lv_clear_tool();
lv_draw_manualLevel();
#endif
}
break; break;
case ID_T_FILAMENT: case ID_T_FILAMENT:
if (event == LV_EVENT_CLICKED) { uiCfg.desireSprayerTempBak = thermalManager.temp_hotend[uiCfg.curSprayerChoose].target;
// nothing to do lv_clear_tool();
} lv_draw_filament_change();
else if (event == LV_EVENT_RELEASED) {
uiCfg.desireSprayerTempBak = thermalManager.temp_hotend[uiCfg.curSprayerChoose].target;
lv_clear_tool();
lv_draw_filament_change();
}
break; break;
case ID_T_MORE: break; case ID_T_MORE: break;
case ID_T_RETURN: case ID_T_RETURN:
if (event == LV_EVENT_CLICKED) { TERN_(MKS_TEST, curent_disp_ui = 1);
// nothing to do lv_clear_tool();
} lv_draw_ready_print();
else if (event == LV_EVENT_RELEASED) {
TERN_(MKS_TEST, curent_disp_ui = 1);
lv_clear_tool();
lv_draw_ready_print();
}
break; break;
} }
} }
void lv_draw_tool(void) { void lv_draw_tool(void) {
lv_obj_t *buttonPreHeat, *buttonExtrusion, *buttonMove, *buttonHome, *buttonLevel;
lv_obj_t *buttonFilament;
lv_obj_t *buttonBack;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != TOOL_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != TOOL_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = TOOL_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = TOOL_UI;
} }
disp_state = TOOL_UI; disp_state = TOOL_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
//static lv_style_t tool_style;
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
// Create image buttons lv_big_button_create(scr, "F:/bmp_preHeat.bin", tool_menu.preheat, INTERVAL_V, titleHeight, event_handler, ID_T_PRE_HEAT);
buttonPreHeat = lv_imgbtn_create(scr, "F:/bmp_preHeat.bin", INTERVAL_V, titleHeight, event_handler, ID_T_PRE_HEAT); lv_big_button_create(scr, "F:/bmp_extruct.bin", tool_menu.extrude, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_T_EXTRUCT);
buttonExtrusion = lv_imgbtn_create(scr, "F:/bmp_extruct.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_T_EXTRUCT);
buttonMove = lv_imgbtn_create(scr, "F:/bmp_mov.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_T_MOV);
buttonHome = lv_imgbtn_create(scr, "F:/bmp_zero.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_T_HOME);
buttonLevel = lv_imgbtn_create(scr, "F:/bmp_leveling.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_T_LEVELING);
buttonFilament = lv_imgbtn_create(scr, "F:/bmp_filamentchange.bin",BTN_X_PIXEL+INTERVAL_V*2,BTN_Y_PIXEL+INTERVAL_H+titleHeight, event_handler,ID_T_FILAMENT);
//buttonMore = lv_imgbtn_createx(scr, NULL);
//lv_obj_set_pos(buttonMore,BTN_X_PIXEL*2+INTERVAL_V*3, BTN_Y_PIXEL+INTERVAL_H+titleHeight);
buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_T_RETURN);
// Create labels on the image buttons lv_big_button_create(scr, "F:/bmp_mov.bin", tool_menu.move, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_T_MOV);
lv_obj_t *labelPreHeat = lv_label_create_empty(buttonPreHeat); lv_big_button_create(scr, "F:/bmp_zero.bin", tool_menu.home, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_T_HOME);
lv_obj_t *labelExtrusion = lv_label_create_empty(buttonExtrusion);
lv_obj_t *label_Move = lv_label_create_empty(buttonMove);
lv_obj_t *label_Home = lv_label_create_empty(buttonHome);
lv_obj_t *label_Level = lv_label_create_empty(buttonLevel);
lv_obj_t *label_Filament = lv_label_create_empty(buttonFilament);
//lv_obj_t *label_More = lv_label_create_empty(buttonMore);
lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.multiple_language) { lv_big_button_create(scr, "F:/bmp_leveling.bin", tool_menu.TERN(AUTO_BED_LEVELING_BILINEAR, autoleveling, leveling), INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_T_LEVELING);
lv_label_set_text(labelPreHeat, tool_menu.preheat); lv_big_button_create(scr, "F:/bmp_filamentchange.bin", tool_menu.filament, BTN_X_PIXEL+INTERVAL_V*2,BTN_Y_PIXEL+INTERVAL_H+titleHeight, event_handler,ID_T_FILAMENT);
lv_obj_align(labelPreHeat, buttonPreHeat, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_T_RETURN);
lv_label_set_text(labelExtrusion, tool_menu.extrude);
lv_obj_align(labelExtrusion, buttonExtrusion, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_Move, tool_menu.move);
lv_obj_align(label_Move, buttonMove, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_Home, tool_menu.home);
lv_obj_align(label_Home, buttonHome, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_Level, tool_menu.TERN(AUTO_BED_LEVELING_BILINEAR, autoleveling, leveling));
lv_obj_align(label_Level, buttonLevel, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_Filament, tool_menu.filament);
lv_obj_align(label_Filament, buttonFilament, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
//lv_label_set_text(label_More, tool_menu.more);
//lv_obj_align(label_More, buttonMore, 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, buttonPreHeat);
lv_group_add_obj(g, buttonExtrusion);
lv_group_add_obj(g, buttonMove);
lv_group_add_obj(g, buttonHome);
lv_group_add_obj(g, buttonLevel);
lv_group_add_obj(g, buttonFilament);
lv_group_add_obj(g, buttonBack);
}
#endif
} }
void lv_clear_tool() { void lv_clear_tool() {

View file

@ -61,13 +61,14 @@ uint32_t To_pre_view;
bool gcode_preview_over, flash_preview_begin, default_preview_flg; bool gcode_preview_over, flash_preview_begin, default_preview_flg;
uint32_t size = 809; uint32_t size = 809;
uint16_t row; uint16_t row;
uint8_t temperature_change_frequency; bool temps_update_flag;
uint8_t printing_rate_update_flag; uint8_t printing_rate_update_flag;
extern bool once_flag; extern bool once_flag;
extern uint8_t sel_id; extern uint8_t sel_id;
extern uint8_t public_buf[512]; extern uint8_t public_buf[512];
extern uint8_t bmp_public_buf[17 * 1024]; extern uint8_t bmp_public_buf[17 * 1024];
extern lv_group_t *g;
extern void LCD_IO_WriteData(uint16_t RegValue); extern void LCD_IO_WriteData(uint16_t RegValue);
@ -282,6 +283,9 @@ lv_style_t style_para_back;
lv_style_t lv_bar_style_indic; lv_style_t lv_bar_style_indic;
lv_style_t style_btn_pr;
lv_style_t style_btn_rel;
void tft_style_init() { void tft_style_init() {
lv_style_copy(&tft_style_scr, &lv_style_scr); lv_style_copy(&tft_style_scr, &lv_style_scr);
tft_style_scr.body.main_color = LV_COLOR_BACKGROUND; tft_style_scr.body.main_color = LV_COLOR_BACKGROUND;
@ -399,6 +403,25 @@ void tft_style_init() {
style_para_back.text.color = LV_COLOR_WHITE; style_para_back.text.color = LV_COLOR_WHITE;
style_para_back.text.font = &TERN(HAS_SPI_FLASH_FONT, gb2312_puhui32, lv_font_roboto_22); style_para_back.text.font = &TERN(HAS_SPI_FLASH_FONT, gb2312_puhui32, lv_font_roboto_22);
lv_style_copy(&style_btn_rel, &lv_style_plain);
style_btn_rel.body.border.color = lv_color_hex3(0x269);
style_btn_rel.body.border.width = 1;
style_btn_rel.body.main_color = lv_color_hex3(0xADF);
style_btn_rel.body.grad_color = lv_color_hex3(0x46B);
style_btn_rel.body.shadow.width = 4;
style_btn_rel.body.shadow.type = LV_SHADOW_BOTTOM;
style_btn_rel.body.radius = LV_RADIUS_CIRCLE;
style_btn_rel.text.color = lv_color_hex3(0xDEF);
style_btn_rel.text.font = &TERN(HAS_SPI_FLASH_FONT, gb2312_puhui32, lv_font_roboto_22);
lv_style_copy(&style_btn_pr, &style_btn_rel);
style_btn_pr.body.border.color = lv_color_hex3(0x46B);
style_btn_pr.body.main_color = lv_color_hex3(0x8BD);
style_btn_pr.body.grad_color = lv_color_hex3(0x24A);
style_btn_pr.body.shadow.width = 2;
style_btn_pr.text.color = lv_color_hex3(0xBCD);
style_btn_pr.text.font = &TERN(HAS_SPI_FLASH_FONT, gb2312_puhui32, lv_font_roboto_22);
lv_style_copy(&lv_bar_style_indic, &lv_style_pretty_color); lv_style_copy(&lv_bar_style_indic, &lv_style_pretty_color);
lv_bar_style_indic.text.color = lv_color_hex3(0xADF); lv_bar_style_indic.text.color = lv_color_hex3(0xADF);
lv_bar_style_indic.image.color = lv_color_hex3(0xADF); lv_bar_style_indic.image.color = lv_color_hex3(0xADF);
@ -421,7 +444,6 @@ void titleText_cat(char *str, int strSize, char *addPart) {
char *getDispText(int index) { char *getDispText(int index) {
ZERO(public_buf_l);
switch (disp_state_stack._disp_state[index]) { switch (disp_state_stack._disp_state[index]) {
case PRINT_READY_UI: case PRINT_READY_UI:
@ -926,30 +948,30 @@ void print_time_run() {
} }
void GUI_RefreshPage() { void GUI_RefreshPage() {
if ((systick_uptime_millis % 1000) == 0) temperature_change_frequency = 1; if ((systick_uptime_millis % 1000) == 0) temps_update_flag = true;
if ((systick_uptime_millis % 3000) == 0) printing_rate_update_flag = 1; if ((systick_uptime_millis % 3000) == 0) printing_rate_update_flag = true;
switch (disp_state) { switch (disp_state) {
case MAIN_UI: case MAIN_UI:
//lv_draw_ready_print(); //lv_draw_ready_print();
break; break;
case EXTRUSION_UI: case EXTRUSION_UI:
if (temperature_change_frequency == 1) { if (temps_update_flag) {
temperature_change_frequency = 0; temps_update_flag = false;
disp_hotend_temp(); disp_hotend_temp();
} }
break; break;
case PRE_HEAT_UI: case PRE_HEAT_UI:
if (temperature_change_frequency == 1) { if (temps_update_flag) {
temperature_change_frequency = 0; temps_update_flag = false;
disp_desire_temp(); disp_desire_temp();
} }
break; break;
case PRINT_READY_UI: case PRINT_READY_UI:
/* /*
if (gCfgItems.display_style == 2) { if (gCfgItems.display_style == 2) {
if (temperature_change_frequency) { if (temps_update_flag) {
temperature_change_frequency = 0; temps_update_flag = false;
disp_restro_state(); disp_restro_state();
} }
} }
@ -959,8 +981,8 @@ void GUI_RefreshPage() {
case PRINT_FILE_UI: break; case PRINT_FILE_UI: break;
case PRINTING_UI: case PRINTING_UI:
if (temperature_change_frequency) { if (temps_update_flag) {
temperature_change_frequency = 0; temps_update_flag = false;
disp_ext_temp(); disp_ext_temp();
disp_bed_temp(); disp_bed_temp();
disp_fan_speed(); disp_fan_speed();
@ -968,15 +990,15 @@ void GUI_RefreshPage() {
disp_fan_Zpos(); disp_fan_Zpos();
} }
if (printing_rate_update_flag || marlin_state == MF_SD_COMPLETE) { if (printing_rate_update_flag || marlin_state == MF_SD_COMPLETE) {
printing_rate_update_flag = 0; printing_rate_update_flag = false;
if (!gcode_preview_over) setProBarRate(); if (!gcode_preview_over) setProBarRate();
} }
break; break;
case OPERATE_UI: case OPERATE_UI:
/* /*
if (temperature_change_frequency == 1) { if (temps_update_flag) {
temperature_change_frequency = 0; temps_update_flag = false;
disp_temp_operate(); disp_temp_operate();
} }
@ -986,16 +1008,16 @@ void GUI_RefreshPage() {
case PAUSE_UI: case PAUSE_UI:
/* /*
if (temperature_change_frequency == 1) { if (temps_update_flag) {
temperature_change_frequency = 0; temps_update_flag = false;
disp_temp_pause(); disp_temp_pause();
} }
*/ */
break; break;
case FAN_UI: case FAN_UI:
if (temperature_change_frequency == 1) { if (temps_update_flag) {
temperature_change_frequency = 0; temps_update_flag = false;
disp_fan_value(); disp_fan_value();
} }
break; break;
@ -1003,14 +1025,12 @@ void GUI_RefreshPage() {
case MOVE_MOTOR_UI: case MOVE_MOTOR_UI:
/* /*
if (mksReprint.mks_printer_state == MKS_IDLE) { if (mksReprint.mks_printer_state == MKS_IDLE) {
if ((z_high_count==1)&&(temper_error_flg != 1)) { if (z_high_count == 1 && temper_error_flg != 1) {
z_high_count = 0; z_high_count = 0;
{ memset((char *)gCfgItems.move_z_coordinate, ' ', sizeof(gCfgItems.move_z_coordinate));
memset((char *)gCfgItems.move_z_coordinate, ' ', sizeof(gCfgItems.move_z_coordinate)); GUI_DispStringAt((const char *)gCfgItems.move_z_coordinate, 380, TITLE_YPOS);
GUI_DispStringAt((const char *)gCfgItems.move_z_coordinate, 380, TITLE_YPOS); sprintf_P((char *)gCfgItems.move_z_coordinate, PSTR("Z: %.3f"), current_position[Z_AXIS]);
sprintf_P((char *)gCfgItems.move_z_coordinate, PSTR("Z: %.3f"), current_position[Z_AXIS]); GUI_DispStringAt((const char *)gCfgItems.move_z_coordinate, 380, TITLE_YPOS);
GUI_DispStringAt((const char *)gCfgItems.move_z_coordinate, 380, TITLE_YPOS);
}
} }
} }
*/ */
@ -1018,9 +1038,9 @@ void GUI_RefreshPage() {
#if ENABLED(USE_WIFI_FUNCTION) #if ENABLED(USE_WIFI_FUNCTION)
case WIFI_UI: case WIFI_UI:
if (temperature_change_frequency == 1) { if (temps_update_flag) {
disp_wifi_state(); disp_wifi_state();
temperature_change_frequency = 0; temps_update_flag = false;
} }
break; break;
#endif #endif
@ -1030,8 +1050,8 @@ void GUI_RefreshPage() {
break; break;
case FILAMENTCHANGE_UI: case FILAMENTCHANGE_UI:
if (temperature_change_frequency) { if (temps_update_flag) {
temperature_change_frequency = 0; temps_update_flag = false;
disp_filament_temp(); disp_filament_temp();
} }
break; break;
@ -1046,9 +1066,9 @@ void GUI_RefreshPage() {
break; break;
case WIFI_LIST_UI: case WIFI_LIST_UI:
#if ENABLED(USE_WIFI_FUNCTION) #if ENABLED(USE_WIFI_FUNCTION)
if (printing_rate_update_flag == 1) { if (printing_rate_update_flag) {
disp_wifi_list(); disp_wifi_list();
printing_rate_update_flag = 0; printing_rate_update_flag = false;
} }
#endif #endif
break; break;
@ -1103,8 +1123,8 @@ void GUI_RefreshPage() {
#endif #endif
case BABY_STEP_UI: case BABY_STEP_UI:
if (temperature_change_frequency == 1) { if (temps_update_flag) {
temperature_change_frequency = 0; temps_update_flag = false;
disp_z_offset_value(); disp_z_offset_value();
} }
break; break;
@ -1589,21 +1609,36 @@ void lv_imgbtn_use_label_style(lv_obj_t *imgbtn) {
lv_imgbtn_set_style(imgbtn, LV_BTN_STATE_PR, &tft_style_label_pre); lv_imgbtn_set_style(imgbtn, LV_BTN_STATE_PR, &tft_style_label_pre);
} }
// Use label style for the image button // Use label style for the button
void lv_btn_use_label_style(lv_obj_t *btn) { void lv_btn_use_label_style(lv_obj_t *btn) {
lv_btn_set_style(btn, LV_BTN_STYLE_REL, &tft_style_label_rel); lv_btn_set_style(btn, LV_BTN_STYLE_REL, &tft_style_label_rel);
lv_btn_set_style(btn, LV_BTN_STYLE_PR, &tft_style_label_pre); lv_btn_set_style(btn, LV_BTN_STYLE_PR, &tft_style_label_pre);
} }
// Use button style for the button
void lv_btn_use_button_style(lv_obj_t *btn) {
lv_btn_set_style(btn, LV_BTN_STYLE_REL, &style_btn_rel);
lv_btn_set_style(btn, LV_BTN_STYLE_PR, &style_btn_pr);
}
// Use a single style for both Released and Pressed // Use a single style for both Released and Pressed
void lv_btn_set_style_both(lv_obj_t *btn, lv_style_t *style) { void lv_btn_set_style_both(lv_obj_t *btn, lv_style_t *style) {
lv_btn_set_style(btn, LV_BTN_STYLE_REL, style); lv_btn_set_style(btn, LV_BTN_STYLE_REL, style);
lv_btn_set_style(btn, LV_BTN_STYLE_PR, style); lv_btn_set_style(btn, LV_BTN_STYLE_PR, style);
} }
// Create a screen
lv_obj_t* lv_screen_create() {
lv_obj_t *scr = lv_obj_create(nullptr, nullptr);
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
return scr;
}
// Create an empty label // Create an empty label
lv_obj_t* lv_label_create_empty(lv_obj_t *par) { lv_obj_t* lv_label_create_empty(lv_obj_t *par) {
return lv_label_create(par, (lv_obj_t*)NULL); return lv_label_create(par, (lv_obj_t*)nullptr);
} }
// Create a label with style and text // Create a label with style and text
@ -1621,35 +1656,66 @@ lv_obj_t* lv_label_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, const char
} }
// Create a button with callback, ID, and Style. // Create a button with callback, ID, and Style.
lv_obj_t* lv_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id, lv_style_t *style) { lv_obj_t* lv_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id/*=0*/, lv_style_t *style/*=&style_para_value*/) {
lv_obj_t *btn = lv_btn_create(par, NULL); lv_obj_t *btn = lv_btn_create(par, nullptr);
if (id) if (id)
lv_obj_set_event_cb_mks(btn, cb, id, NULL, 0); lv_obj_set_event_cb_mks(btn, cb, id, nullptr, 0);
else else
lv_obj_set_event_cb(btn, cb); lv_obj_set_event_cb(btn, cb);
lv_btn_set_style_both(btn, style); lv_btn_set_style_both(btn, style);
return btn; return btn;
} }
// Create a button with callback and ID. Style set to style_para_value. // Create a button with callback and ID, with label style.
lv_obj_t* lv_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id) { lv_obj_t* lv_label_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id/*=0*/) {
return lv_btn_create(par, cb, id, &style_para_value); lv_obj_t *btn = lv_btn_create(par, cb, id, nullptr);
lv_btn_use_label_style(btn);
return btn;
}
// Create a button with callback and ID, with button style.
lv_obj_t* lv_button_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id/*=0*/) {
lv_obj_t *btn = lv_btn_create(par, cb, id, nullptr);
lv_btn_use_button_style(btn);
return btn;
}
// Create a button with position, size, callback, ID, and style.
lv_obj_t* lv_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id, lv_style_t *style) {
lv_obj_t *btn = lv_btn_create(par, cb, id, style);
lv_obj_set_pos(btn, x, y);
lv_obj_set_size(btn, w, h);
return btn;
} }
// Create a button with position, size, callback, and ID. Style set to style_para_value. // Create a button with position, size, callback, and ID. Style set to style_para_value.
lv_obj_t* lv_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id) { lv_obj_t* lv_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id/*=0*/) {
lv_obj_t *btn = lv_btn_create(par, cb, id); lv_obj_t *btn = lv_btn_create(par, x, y, w, h, cb, id, &style_para_value);
return btn;
}
// Create a button with position, size, callback, and ID, with label style.
lv_obj_t* lv_label_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id/*=0*/) {
lv_obj_t *btn = lv_label_btn_create(par, cb, id);
lv_obj_set_pos(btn, x, y);
lv_obj_set_size(btn, w, h);
return btn;
}
// Create a button with position, size, callback, and ID, with label style.
lv_obj_t* lv_button_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id/*=0*/) {
lv_obj_t *btn = lv_button_btn_create(par, cb, id);
lv_obj_set_pos(btn, x, y); lv_obj_set_pos(btn, x, y);
lv_obj_set_size(btn, w, h); lv_obj_set_size(btn, w, h);
return btn; return btn;
} }
// Create a button with callback and ID. Style set to style_para_back. // Create a button with callback and ID. Style set to style_para_back.
lv_obj_t* lv_btn_create_back(lv_obj_t *par, lv_event_cb_t cb, const int id) { lv_obj_t* lv_btn_create_back(lv_obj_t *par, lv_event_cb_t cb, const int id/*=0*/) {
return lv_btn_create(par, cb, id, &style_para_back); return lv_btn_create(par, cb, id, &style_para_back);
} }
// Create a button with position, size, callback, and ID. Style set to style_para_back. // Create a button with position, size, callback, and ID. Style set to style_para_back.
lv_obj_t* lv_btn_create_back(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id) { lv_obj_t* lv_btn_create_back(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id/*=0*/) {
lv_obj_t *btn = lv_btn_create_back(par, cb, id); lv_obj_t *btn = lv_btn_create_back(par, cb, id);
lv_obj_set_pos(btn, x, y); lv_obj_set_pos(btn, x, y);
lv_obj_set_size(btn, w, h); lv_obj_set_size(btn, w, h);
@ -1657,11 +1723,11 @@ lv_obj_t* lv_btn_create_back(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord
} }
// Create an image button with image, callback, and ID. Use label style. // Create an image button with image, callback, and ID. Use label style.
lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_event_cb_t cb, const int id) { lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_event_cb_t cb, const int id/*=0*/) {
lv_obj_t *btn = lv_imgbtn_create(par, NULL); lv_obj_t *btn = lv_imgbtn_create(par, nullptr);
if (img) lv_imgbtn_set_src_both(btn, img); if (img) lv_imgbtn_set_src_both(btn, img);
if (id) if (id)
lv_obj_set_event_cb_mks(btn, cb, id, NULL, 0); lv_obj_set_event_cb_mks(btn, cb, id, nullptr, 0);
else else
lv_obj_set_event_cb(btn, cb); lv_obj_set_event_cb(btn, cb);
lv_imgbtn_use_label_style(btn); lv_imgbtn_use_label_style(btn);
@ -1670,12 +1736,96 @@ lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_event_cb_t cb, con
} }
// Create an image button with image, position, callback, and ID. Use label style. // Create an image button with image, position, callback, and ID. Use label style.
lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id) { lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id/*=0*/) {
lv_obj_t *btn = lv_imgbtn_create(par, img, cb, id); lv_obj_t *btn = lv_imgbtn_create(par, img, cb, id);
lv_obj_set_pos(btn, x, y); lv_obj_set_pos(btn, x, y);
return btn; return btn;
} }
lv_obj_t* lv_big_button_create(lv_obj_t *par, const char *img, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, bool centerLabel) {
lv_obj_t *btn = lv_imgbtn_create(par, img, cb, id);
lv_obj_set_pos(btn, x, y);
lv_obj_t *label = lv_label_create_empty(btn);
if (gCfgItems.multiple_language) {
lv_label_set_text(label, text);
if (centerLabel)
lv_obj_align(label, btn, LV_ALIGN_CENTER, 0, 0);
else
lv_obj_align(label, btn, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
}
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable == true)
lv_group_add_obj(g, btn);
#endif
return btn;
}
lv_obj_t* lv_screen_menu_item(lv_obj_t *par, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, const int index, bool drawArrow) {
lv_obj_t *btn = lv_btn_create(par, nullptr); /*Add a button the current screen*/
lv_obj_set_pos(btn, x, y); /*Set its position*/
lv_obj_set_size(btn, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
if (id > -1) lv_obj_set_event_cb_mks(btn, cb, id, nullptr, 0);
lv_btn_use_label_style(btn);
lv_btn_set_layout(btn, LV_LAYOUT_OFF);
lv_obj_t *label = lv_label_create_empty(btn); /*Add a label to the button*/
if (gCfgItems.multiple_language) {
lv_label_set_text(label, text);
lv_obj_align(label, btn, LV_ALIGN_IN_LEFT_MID, 0, 0);
}
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable == true) {
lv_group_add_obj(g, btn);
}
#endif
if (drawArrow) (void)lv_imgbtn_create(par, "F:/bmp_arrow.bin", x + PARA_UI_SIZE_X, y + PARA_UI_ARROW_V, cb, id);
lv_obj_t *line1 = lv_line_create(par, nullptr);
lv_ex_line(line1, line_points[index]);
return btn;
}
lv_obj_t* lv_screen_menu_item_1_edit(lv_obj_t *par, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, const int index, const char *editValue) {
lv_obj_t* btn = lv_screen_menu_item(par, text, x, y, cb, -1, index, false);
lv_obj_t* btnValue = lv_btn_create(par, PARA_UI_VALUE_POS_X, y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, cb, id);
lv_obj_t* labelValue = lv_label_create_empty(btnValue);
lv_label_set_text(labelValue, editValue);
lv_obj_align(labelValue, btnValue, LV_ALIGN_CENTER, 0, 0);
return btn;
}
lv_obj_t* lv_screen_menu_item_2_edit(lv_obj_t *par, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, const int index, const char *editValue, const int idEdit2, const char *editValue2) {
lv_obj_t* btn = lv_screen_menu_item(par, text, x, y, cb, -1, index, false);
lv_obj_t* btnValue = lv_btn_create(par, PARA_UI_VALUE_POS_X_2, y + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, cb, idEdit2);
lv_obj_t* labelValue = lv_label_create_empty(btnValue);
lv_label_set_text(labelValue, editValue2);
lv_obj_align(labelValue, btnValue, LV_ALIGN_CENTER, 0, 0);
btnValue = lv_btn_create(par, PARA_UI_VALUE_POS_X, y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, cb, id);
labelValue = lv_label_create_empty(btnValue);
lv_label_set_text(labelValue, editValue);
lv_obj_align(labelValue, btnValue, LV_ALIGN_CENTER, 0, 0);
return btn;
}
lv_obj_t* lv_screen_menu_item_onoff(lv_obj_t *par, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, const int index, const bool curValue) {
lv_screen_menu_item(par, text, x, y, cb, -1, index, false);
lv_obj_t* btnValue = lv_imgbtn_create(par, curValue ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin", PARA_UI_STATE_POS_X, y + PARA_UI_STATE_V, cb, id);
lv_obj_t* labelValue = lv_label_create_empty(btnValue);
lv_label_set_text(labelValue, curValue ? machine_menu.enable : machine_menu.disable);
lv_obj_align(labelValue, btnValue, LV_ALIGN_CENTER, 0, 0);
return btnValue;
}
void lv_screen_menu_item_onoff_update(lv_obj_t *btn, const bool curValue) {
lv_imgbtn_set_src_both(btn, curValue ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin");
lv_label_set_text((lv_obj_t*)btn->child_ll.head, curValue ? machine_menu.enable : machine_menu.disable);
}
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
void sd_detection() { void sd_detection() {
@ -1689,11 +1839,11 @@ lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_coord_t x, lv_coor
#endif #endif
void lv_ex_line(lv_obj_t * line, lv_point_t *points) { void lv_ex_line(lv_obj_t *line, lv_point_t *points) {
// Copy the previous line and apply the new style // Copy the previous line and apply the new style
lv_line_set_points(line, points, 2); // Set the points lv_line_set_points(line, points, 2); // Set the points
lv_line_set_style(line, LV_LINE_STYLE_MAIN, &style_line); lv_line_set_style(line, LV_LINE_STYLE_MAIN, &style_line);
lv_obj_align(line, NULL, LV_ALIGN_IN_TOP_MID, 0, 0); lv_obj_align(line, nullptr, LV_ALIGN_IN_TOP_MID, 0, 0);
} }
extern volatile uint32_t systick_uptime_millis; extern volatile uint32_t systick_uptime_millis;

View file

@ -164,48 +164,6 @@
#endif // ifdef TFT35 #endif // ifdef TFT35
// Set the same image for both Released and Pressed
void lv_imgbtn_set_src_both(lv_obj_t *imgbtn, const void *src);
// Set label styles for Released and Pressed
void lv_imgbtn_use_label_style(lv_obj_t *imgbtn);
// Set label styles for Released and Pressed
void lv_btn_use_label_style(lv_obj_t *btn);
// Set the same style for both Released and Pressed
void lv_btn_set_style_both(lv_obj_t *btn, lv_style_t *style);
// Create an empty label
lv_obj_t* lv_label_create_empty(lv_obj_t *par);
// Create a label with style and text
lv_obj_t* lv_label_create(lv_obj_t *par, const char *text);
// Create a label with style, position, and text
lv_obj_t* lv_label_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, const char *text);
// Create a button with callback, ID, and Style.
lv_obj_t* lv_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id, lv_style_t *style);
// Create a button with callback and ID. Style set to style_para_value.
lv_obj_t* lv_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id);
// Create a button with position, size, callback, and ID. Style set to style_para_value.
lv_obj_t* lv_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id);
// Create a button with callback and ID. Style set to style_para_back.
lv_obj_t* lv_btn_create_back(lv_obj_t *par, lv_event_cb_t cb, const int id);
// Create a button with position, size, callback, and ID. Style set to style_para_back.
lv_obj_t* lv_btn_create_back(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id);
// Create an image button with image, callback, and ID. Use label style.
lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_event_cb_t cb, const int id);
// Create an image button with image, position, callback, and ID. Use label style.
lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id);
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { /* C-declarations for C++ */ extern "C" { /* C-declarations for C++ */
#endif #endif
@ -240,10 +198,10 @@ typedef struct {
} CFG_ITMES; } CFG_ITMES;
typedef struct { typedef struct {
uint8_t curTempType : 1, uint8_t curTempType:1,
curSprayerChoose : 3, curSprayerChoose:3,
stepHeat : 4; stepHeat:4;
uint8_t leveling_first_time : 1, uint8_t leveling_first_time:1,
para_ui_page:1, para_ui_page:1,
configWifi:1, configWifi:1,
command_send:1, command_send:1,
@ -467,6 +425,8 @@ extern lv_style_t style_sel_text;
extern lv_style_t style_para_value; extern lv_style_t style_para_value;
extern lv_style_t style_para_back; extern lv_style_t style_para_back;
extern lv_style_t lv_bar_style_indic; extern lv_style_t lv_bar_style_indic;
extern lv_style_t style_btn_pr;
extern lv_style_t style_btn_rel;
extern lv_point_t line_points[4][2]; extern lv_point_t line_points[4][2];
@ -489,8 +449,78 @@ extern void gCfg_to_spiFlah();
extern void print_time_count(); extern void print_time_count();
extern void LV_TASK_HANDLER(); extern void LV_TASK_HANDLER();
extern void lv_ex_line(lv_obj_t * line, lv_point_t *points); extern void lv_ex_line(lv_obj_t *line, lv_point_t *points);
#ifdef __cplusplus #ifdef __cplusplus
} /* C-declarations for C++ */ } /* C-declarations for C++ */
#endif #endif
// Set the same image for both Released and Pressed
void lv_imgbtn_set_src_both(lv_obj_t *imgbtn, const void *src);
// Set label styles for Released and Pressed
void lv_imgbtn_use_label_style(lv_obj_t *imgbtn);
// Set label styles for Released and Pressed
void lv_btn_use_label_style(lv_obj_t *btn);
// Set the same style for both Released and Pressed
void lv_btn_set_style_both(lv_obj_t *btn, lv_style_t *style);
// Create a screen
lv_obj_t* lv_screen_create();
// Create an empty label
lv_obj_t* lv_label_create_empty(lv_obj_t *par);
// Create a label with style and text
lv_obj_t* lv_label_create(lv_obj_t *par, const char *text);
// Create a label with style, position, and text
lv_obj_t* lv_label_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, const char *text);
// Create a button with callback, ID, and Style.
lv_obj_t* lv_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id, lv_style_t *style=&style_para_value);
// Create a button with callback and ID, with label style.
lv_obj_t* lv_label_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id=0);
// Create a button with callback and ID, with button style.
lv_obj_t* lv_button_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id=0);
// Create a button with position, size, callback, ID, and style.
lv_obj_t* lv_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id, lv_style_t *style);
// Create a button with position, size, callback, and ID. Style set to style_para_value.
lv_obj_t* lv_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id=0);
// Create a button with position, size, callback, and ID, with label style.
lv_obj_t* lv_label_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id=0);
// Create a button with position, size, callback, and ID, with button style.
lv_obj_t* lv_button_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id=0);
// Create a button with callback and ID. Style set to style_para_back.
lv_obj_t* lv_btn_create_back(lv_obj_t *par, lv_event_cb_t cb, const int id=0);
// Create a button with position, size, callback, and ID. Style set to style_para_back.
lv_obj_t* lv_btn_create_back(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id=0);
// Create an image button with image, callback, and ID. Use label style.
lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_event_cb_t cb, const int id=0);
// Create an image button with image, position, callback, and ID. Use label style.
lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id=0);
// Create a big image button with a label, follow the LVGL UI standard.
lv_obj_t* lv_big_button_create(lv_obj_t *par, const char *img, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, bool centerLabel = false);
// Create a menu item, follow the LVGL UI standard.
lv_obj_t* lv_screen_menu_item(lv_obj_t *par, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, const int index, bool drawArrow = true);
lv_obj_t* lv_screen_menu_item_1_edit(lv_obj_t *par, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, const int index, const char *editValue);
lv_obj_t* lv_screen_menu_item_2_edit(lv_obj_t *par, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, const int index, const char *editValue, const int idEdit2, const char *editValue2);
lv_obj_t* lv_screen_menu_item_onoff(lv_obj_t *par, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, const int index, const bool curValue);
void lv_screen_menu_item_onoff_update(lv_obj_t *btn, const bool curValue);
#define _DIA_1(T) (uiCfg.dialogType == DIALOG_##T)
#define DIALOG_IS(V...) DO(DIA,||,V)

View file

@ -30,80 +30,60 @@
#include "draw_ui.h" #include "draw_ui.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t *scr, *wifi_name_text, *wifi_key_text, *wifi_state_text, *wifi_ip_text; static lv_obj_t *scr, *wifi_name_text, *wifi_key_text, *wifi_state_text, *wifi_ip_text;
#define ID_W_RETURN 1 enum {
#define ID_W_CLOUD 2 ID_W_RETURN = 1,
#define ID_W_RECONNECT 3 ID_W_CLOUD,
ID_W_RECONNECT
};
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_W_RETURN: case ID_W_RETURN:
if (event == LV_EVENT_CLICKED) { clear_cur_ui();
lv_draw_set();
} break;
else if (event == LV_EVENT_RELEASED) {
clear_cur_ui();
lv_draw_set();
}
break;
case ID_W_CLOUD: case ID_W_CLOUD:
if (event == LV_EVENT_CLICKED) { //clear_cur_ui();
//draw_return_ui();
} break;
else if (event == LV_EVENT_RELEASED) {
//clear_cur_ui();
//draw_return_ui();
}
break;
case ID_W_RECONNECT: case ID_W_RECONNECT:
if (event == LV_EVENT_CLICKED) { clear_cur_ui();
lv_draw_wifi_list();
} break;
else if (event == LV_EVENT_RELEASED) {
clear_cur_ui();
lv_draw_wifi_list();
}
break;
} }
} }
void lv_draw_wifi(void) { 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) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_UI;
} }
disp_state = WIFI_UI; disp_state = WIFI_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
// Create an Image button // Create an Image button
buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_W_RETURN); lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_W_RETURN);
#if HAS_ROTARY_ENCODER #if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack); if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif #endif
lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.wifi_mode_sel == STA_MODEL) { lv_obj_t *buttonReconnect = nullptr, *label_Reconnect = nullptr;
//buttonCloud = lv_imgbtn_create(scr, NULL);
buttonReconnect = lv_imgbtn_create(scr, NULL);
}
if (gCfgItems.wifi_mode_sel == STA_MODEL) { if (gCfgItems.wifi_mode_sel == STA_MODEL) {
lv_obj_set_event_cb_mks(buttonReconnect, event_handler,ID_W_RECONNECT, NULL, 0); buttonReconnect = lv_imgbtn_create(scr, nullptr);
lv_obj_set_event_cb_mks(buttonReconnect, event_handler, ID_W_RECONNECT, nullptr, 0);
lv_imgbtn_set_src_both(buttonReconnect, "F:/bmp_wifi.bin"); lv_imgbtn_set_src_both(buttonReconnect, "F:/bmp_wifi.bin");
lv_imgbtn_use_label_style(buttonReconnect); lv_imgbtn_use_label_style(buttonReconnect);
@ -113,12 +93,7 @@ void lv_draw_wifi(void) {
lv_obj_set_pos(buttonReconnect, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight); 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); lv_btn_set_layout(buttonReconnect, LV_LAYOUT_OFF);
}
label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.wifi_mode_sel == STA_MODEL) {
//label_Cloud = lv_label_create_empty(buttonCloud);
label_Reconnect = lv_label_create_empty(buttonReconnect); label_Reconnect = lv_label_create_empty(buttonReconnect);
} }
@ -127,9 +102,6 @@ void lv_draw_wifi(void) {
lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
if (gCfgItems.wifi_mode_sel == STA_MODEL) { 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_label_set_text(label_Reconnect, wifi_menu.reconnect);
lv_obj_align(label_Reconnect, buttonReconnect, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); lv_obj_align(label_Reconnect, buttonReconnect, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
} }
@ -148,38 +120,33 @@ void lv_draw_wifi(void) {
} }
void disp_wifi_state() { void disp_wifi_state() {
memset(public_buf_m, 0, sizeof(public_buf_m)); strcpy(public_buf_m, wifi_menu.ip);
strcpy(public_buf_m,wifi_menu.ip); strcat(public_buf_m, ipPara.ip_addr);
strcat(public_buf_m,ipPara.ip_addr);
lv_label_set_text(wifi_ip_text, public_buf_m); lv_label_set_text(wifi_ip_text, public_buf_m);
lv_obj_align(wifi_ip_text, NULL, LV_ALIGN_CENTER, 0, -100); lv_obj_align(wifi_ip_text, nullptr, LV_ALIGN_CENTER, 0, -100);
memset(public_buf_m, 0, sizeof(public_buf_m)); strcpy(public_buf_m, wifi_menu.wifi);
strcpy(public_buf_m,wifi_menu.wifi); strcat(public_buf_m, wifiPara.ap_name);
strcat(public_buf_m,wifiPara.ap_name);
lv_label_set_text(wifi_name_text, public_buf_m); lv_label_set_text(wifi_name_text, public_buf_m);
lv_obj_align(wifi_name_text, NULL, LV_ALIGN_CENTER, 0, -70); lv_obj_align(wifi_name_text, nullptr, LV_ALIGN_CENTER, 0, -70);
if (wifiPara.mode == AP_MODEL) { if (wifiPara.mode == AP_MODEL) {
memset(public_buf_m, 0, sizeof(public_buf_m)); strcpy(public_buf_m, wifi_menu.key);
strcpy(public_buf_m,wifi_menu.key); strcat(public_buf_m, wifiPara.keyCode);
strcat(public_buf_m,wifiPara.keyCode);
lv_label_set_text(wifi_key_text, public_buf_m); lv_label_set_text(wifi_key_text, public_buf_m);
lv_obj_align(wifi_key_text, NULL, LV_ALIGN_CENTER, 0, -40); lv_obj_align(wifi_key_text, nullptr, LV_ALIGN_CENTER, 0, -40);
memset(public_buf_m, 0, sizeof(public_buf_m)); strcpy(public_buf_m, wifi_menu.state_ap);
strcpy(public_buf_m,wifi_menu.state_ap);
if (wifi_link_state == WIFI_CONNECTED) if (wifi_link_state == WIFI_CONNECTED)
strcat(public_buf_m,wifi_menu.connected); strcat(public_buf_m, wifi_menu.connected);
else if (wifi_link_state == WIFI_NOT_CONFIG) else if (wifi_link_state == WIFI_NOT_CONFIG)
strcat(public_buf_m,wifi_menu.disconnected); strcat(public_buf_m, wifi_menu.disconnected);
else else
strcat(public_buf_m,wifi_menu.exception); strcat(public_buf_m, wifi_menu.exception);
lv_label_set_text(wifi_state_text, public_buf_m); lv_label_set_text(wifi_state_text, public_buf_m);
lv_obj_align(wifi_state_text, NULL, LV_ALIGN_CENTER, 0, -10); lv_obj_align(wifi_state_text, nullptr, LV_ALIGN_CENTER, 0, -10);
} }
else { else {
ZERO(public_buf_m);
strcpy(public_buf_m, wifi_menu.state_sta); strcpy(public_buf_m, wifi_menu.state_sta);
if (wifi_link_state == WIFI_CONNECTED) if (wifi_link_state == WIFI_CONNECTED)
strcat(public_buf_m, wifi_menu.connected); strcat(public_buf_m, wifi_menu.connected);
@ -188,10 +155,10 @@ void disp_wifi_state() {
else else
strcat(public_buf_m, wifi_menu.exception); strcat(public_buf_m, wifi_menu.exception);
lv_label_set_text(wifi_state_text, public_buf_m); lv_label_set_text(wifi_state_text, public_buf_m);
lv_obj_align(wifi_state_text, NULL, LV_ALIGN_CENTER, 0, -40); lv_obj_align(wifi_state_text, nullptr, LV_ALIGN_CENTER, 0, -40);
lv_label_set_text(wifi_key_text, ""); lv_label_set_text(wifi_key_text, "");
lv_obj_align(wifi_key_text, NULL, LV_ALIGN_CENTER, 0, -10); lv_obj_align(wifi_key_text, nullptr, LV_ALIGN_CENTER, 0, -10);
} }
} }

View file

@ -39,61 +39,48 @@
WIFI_LIST wifi_list; WIFI_LIST wifi_list;
list_menu_def list_menu; list_menu_def list_menu;
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t * scr; static lv_obj_t *scr;
static lv_obj_t *buttonWifiN[NUMBER_OF_PAGE]; static lv_obj_t *buttonWifiN[NUMBER_OF_PAGE];
static lv_obj_t *labelWifiText[NUMBER_OF_PAGE]; static lv_obj_t *labelWifiText[NUMBER_OF_PAGE];
static lv_obj_t *labelPageText; static lv_obj_t *labelPageText;
#define ID_WL_RETURN 11 #define ID_WL_RETURN 11
#define ID_WL_DOWN 12 #define ID_WL_DOWN 12
static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
static void event_handler(lv_obj_t * obj, lv_event_t event) {
if (obj->mks_obj_id == ID_WL_RETURN) { if (obj->mks_obj_id == ID_WL_RETURN) {
if (event == LV_EVENT_CLICKED) { clear_cur_ui();
lv_draw_set();
}
else if (event == LV_EVENT_RELEASED) {
clear_cur_ui();
lv_draw_set();
}
} }
else if (obj->mks_obj_id == ID_WL_DOWN) { else if (obj->mks_obj_id == ID_WL_DOWN) {
if (event == LV_EVENT_CLICKED) { if (wifi_list.getNameNum > 0) {
if ((wifi_list.nameIndex + NUMBER_OF_PAGE) >= wifi_list.getNameNum) {
} wifi_list.nameIndex = 0;
else if (event == LV_EVENT_RELEASED) { wifi_list.currentWifipage = 1;
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 {
wifi_list.nameIndex += NUMBER_OF_PAGE;
wifi_list.currentWifipage++;
}
disp_wifi_list();
} }
} }
else { else {
for (uint8_t i = 0; i < NUMBER_OF_PAGE; i++) { for (uint8_t i = 0; i < NUMBER_OF_PAGE; i++) {
if (obj->mks_obj_id == i + 1) { if (obj->mks_obj_id == i + 1) {
if (event == LV_EVENT_CLICKED) { 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;
else if (event == LV_EVENT_RELEASED) { last_disp_state = WIFI_LIST_UI;
if (wifi_list.getNameNum != 0) { lv_clear_wifi_list();
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; if (do_wifi)
wifi_list.nameIndex += i; lv_draw_wifi();
last_disp_state = WIFI_LIST_UI; else {
lv_clear_wifi_list(); keyboard_value = wifiConfig;
if (do_wifi) lv_draw_keyboard();
lv_draw_wifi();
else {
keyboard_value = wifiConfig;
lv_draw_keyboard();
}
} }
} }
} }
@ -102,34 +89,23 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
} }
void lv_draw_wifi_list(void) { 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) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_LIST_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_LIST_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_LIST_UI;
} }
disp_state = WIFI_LIST_UI; disp_state = WIFI_LIST_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text()); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
buttonDown = lv_imgbtn_create(scr, "F:/bmp_pageDown.bin", OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight + OTHER_BTN_YPIEL + INTERVAL_H, event_handler, ID_WL_DOWN); lv_obj_t *buttonDown = lv_imgbtn_create(scr, "F:/bmp_pageDown.bin", OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight + OTHER_BTN_YPIEL + INTERVAL_H, event_handler, ID_WL_DOWN);
buttonBack = lv_imgbtn_create(scr, "F:/bmp_back.bin", OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight + (OTHER_BTN_YPIEL + INTERVAL_H) * 2, event_handler, ID_WL_RETURN); lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_back.bin", OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight + (OTHER_BTN_YPIEL + INTERVAL_H) * 2, event_handler, ID_WL_RETURN);
for (uint8_t i = 0; i < NUMBER_OF_PAGE; i++) { for (uint8_t i = 0; i < NUMBER_OF_PAGE; i++) {
buttonWifiN[i] = lv_btn_create(scr, NULL); /*Add a button the current screen*/ buttonWifiN[i] = lv_label_btn_create(scr, 0, NAME_BTN_Y * i + 10 + titleHeight, NAME_BTN_X, NAME_BTN_Y, event_handler, i + 1);
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_use_label_style(buttonWifiN[i]);
lv_btn_set_layout(buttonWifiN[i], LV_LAYOUT_OFF);
labelWifiText[i] = lv_label_create_empty(buttonWifiN[i]); labelWifiText[i] = lv_label_create_empty(buttonWifiN[i]);
#if HAS_ROTARY_ENCODER #if HAS_ROTARY_ENCODER
uint8_t j = 0; uint8_t j = 0;
@ -147,9 +123,10 @@ void lv_draw_wifi_list(void) {
wifi_list.currentWifipage = 1; wifi_list.currentWifipage = 1;
if (wifi_link_state == WIFI_CONNECTED && wifiPara.mode == STA_MODEL) { if (wifi_link_state == WIFI_CONNECTED && wifiPara.mode == STA_MODEL) {
memset(wifi_list.wifiConnectedName, 0, sizeof(&wifi_list.wifiConnectedName)); ZERO(wifi_list.wifiConnectedName);
memcpy(wifi_list.wifiConnectedName, wifiPara.ap_name, sizeof(wifi_list.wifiConnectedName)); memcpy(wifi_list.wifiConnectedName, wifiPara.ap_name, sizeof(wifi_list.wifiConnectedName));
} }
#if HAS_ROTARY_ENCODER #if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) { if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonDown); lv_group_add_obj(g, buttonDown);
@ -166,10 +143,10 @@ void disp_wifi_list(void) {
sprintf((char *)tmpStr, list_menu.file_pages, wifi_list.currentWifipage, wifi_list.getPage); sprintf((char *)tmpStr, list_menu.file_pages, wifi_list.currentWifipage, wifi_list.getPage);
lv_label_set_text(labelPageText, (const char *)tmpStr); lv_label_set_text(labelPageText, (const char *)tmpStr);
lv_obj_align(labelPageText, NULL, LV_ALIGN_CENTER, 50, -100); lv_obj_align(labelPageText, nullptr, LV_ALIGN_CENTER, 50, -100);
for (i = 0; i < NUMBER_OF_PAGE; i++) { for (i = 0; i < NUMBER_OF_PAGE; i++) {
memset(tmpStr, 0, sizeof(tmpStr)); ZERO(tmpStr);
j = wifi_list.nameIndex + i; j = wifi_list.nameIndex + i;
if (j >= wifi_list.getNameNum) { if (j >= wifi_list.getNameNum) {
@ -187,7 +164,7 @@ void disp_wifi_list(void) {
} }
void wifi_scan_handle() { void wifi_scan_handle() {
if (uiCfg.dialogType != WIFI_ENABLE_TIPS || uiCfg.command_send != 1) return; if (!DIALOG_IS(WIFI_ENABLE_TIPS) || uiCfg.command_send != 1) return;
last_disp_state = DIALOG_UI; last_disp_state = DIALOG_UI;
lv_clear_dialog(); lv_clear_dialog();
if (wifi_link_state == WIFI_CONNECTED && wifiPara.mode != AP_MODEL) if (wifi_link_state == WIFI_CONNECTED && wifiPara.mode != AP_MODEL)

View file

@ -30,161 +30,117 @@
#include "draw_ui.h" #include "draw_ui.h"
extern lv_group_t * g; extern lv_group_t *g;
static lv_obj_t *scr, *labelModelValue = NULL, *buttonModelValue = NULL, *labelCloudValue = NULL; static lv_obj_t *scr, *labelModelValue = nullptr, *buttonModelValue = nullptr, *labelCloudValue = nullptr;
#define ID_WIFI_RETURN 1 enum {
#define ID_WIFI_MODEL 2 ID_WIFI_RETURN = 1,
#define ID_WIFI_NAME 3 ID_WIFI_MODEL,
#define ID_WIFI_PASSWORD 4 ID_WIFI_NAME,
#define ID_WIFI_CLOUD 5 ID_WIFI_PASSWORD,
#define ID_WIFI_CONFIG 6 ID_WIFI_CLOUD,
ID_WIFI_CONFIG
};
static void event_handler(lv_obj_t * obj, lv_event_t event) { static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
switch (obj->mks_obj_id) { switch (obj->mks_obj_id) {
case ID_WIFI_RETURN: case ID_WIFI_RETURN:
if (event == LV_EVENT_CLICKED) { lv_clear_wifi_settings();
draw_return_ui();
} break;
else if (event == LV_EVENT_RELEASED) {
lv_clear_wifi_settings();
draw_return_ui();
}
break;
case ID_WIFI_MODEL: case ID_WIFI_MODEL:
if (event == LV_EVENT_CLICKED) { if (gCfgItems.wifi_mode_sel == AP_MODEL) {
gCfgItems.wifi_mode_sel = STA_MODEL;
} lv_label_set_text(labelModelValue, WIFI_STA_TEXT);
else if (event == LV_EVENT_RELEASED) { lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER, 0, 0);
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);
}
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(); update_spi_flash();
} }
break; 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:
keyboard_value = wifiName;
lv_clear_wifi_settings();
lv_draw_keyboard();
break;
case ID_WIFI_PASSWORD:
keyboard_value = wifiPassWord;
lv_clear_wifi_settings();
lv_draw_keyboard();
break;
case ID_WIFI_CLOUD:
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);
}
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: case ID_WIFI_CONFIG:
if (event == LV_EVENT_CLICKED) { lv_clear_wifi_settings();
lv_draw_dialog(DIALOG_WIFI_CONFIG_TIPS);
} break;
else if (event == LV_EVENT_RELEASED) {
lv_clear_wifi_settings();
lv_draw_dialog(DIALOG_WIFI_CONFIG_TIPS);
}
break;
} }
} }
void lv_draw_wifi_settings(void) { 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) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_SETTINGS_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_SETTINGS_UI; disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_SETTINGS_UI;
} }
disp_state = WIFI_SETTINGS_UI; disp_state = WIFI_SETTINGS_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.WifiConfTitle); (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.WifiConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
labelModelText = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.wifiMode); lv_obj_t *labelModelText = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.wifiMode);
buttonModelValue = lv_imgbtn_create(scr, NULL); lv_obj_t *buttonModelValue = lv_imgbtn_create(scr, "F:/bmp_blank_sel.bin", PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, event_handler, ID_WIFI_MODEL);
lv_imgbtn_set_src_both(buttonModelValue, "F:/bmp_blank_sel.bin");
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_btn_set_style_both(buttonModelValue, &style_para_value_pre); lv_btn_set_style_both(buttonModelValue, &style_para_value_pre);
lv_btn_set_layout(buttonModelValue, LV_LAYOUT_OFF);
labelModelValue = lv_label_create_empty(buttonModelValue); labelModelValue = lv_label_create_empty(buttonModelValue);
line1 = lv_line_create(scr, NULL); lv_obj_t *line1 = lv_line_create(scr, nullptr);
lv_ex_line(line1,line_points[0]); lv_ex_line(line1, line_points[0]);
labelNameText = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, NULL); lv_obj_t *labelNameText = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, nullptr);
lv_obj_t *buttonNameValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_WIFI_NAME);
lv_obj_t *labelNameValue = lv_label_create_empty(buttonNameValue);
buttonNameValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_WIFI_NAME); lv_obj_t *line2 = lv_line_create(scr, nullptr);
labelNameValue = lv_label_create_empty(buttonNameValue); lv_ex_line(line2, line_points[1]);
line2 = lv_line_create(scr, NULL); lv_obj_t *labelPassWordText = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, nullptr);
lv_ex_line(line2,line_points[1]); lv_obj_t *buttonPassWordValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_WIFI_PASSWORD);
lv_obj_t *labelPassWordValue = lv_label_create_empty(buttonPassWordValue);
labelPassWordText = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, NULL); lv_obj_t *line3 = lv_line_create(scr, nullptr);
lv_ex_line(line3, line_points[2]);
buttonPassWordValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_WIFI_PASSWORD); lv_obj_t *labelCloudText = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, machine_menu.wifiCloud);
labelPassWordValue = lv_label_create_empty(buttonPassWordValue); lv_obj_t *buttonCloudValue = lv_imgbtn_create(scr, gCfgItems.cloud_enable ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin", PARA_UI_STATE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_STATE_V, event_handler, ID_WIFI_CLOUD);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3,line_points[2]);
labelCloudText = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, machine_menu.wifiCloud);
buttonCloudValue = lv_imgbtn_create(scr, gCfgItems.cloud_enable ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin", PARA_UI_STATE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_STATE_V, event_handler, ID_WIFI_CLOUD);
labelCloudValue = lv_label_create_empty(buttonCloudValue); labelCloudValue = lv_label_create_empty(buttonCloudValue);
line4 = lv_line_create(scr, NULL); lv_obj_t *line4 = lv_line_create(scr, nullptr);
lv_ex_line(line4,line_points[3]); lv_ex_line(line4, line_points[3]);
buttonConfig = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_WIFI_CONFIG); lv_obj_t *buttonConfig = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_WIFI_CONFIG);
labelConfig = lv_label_create_empty(buttonConfig); lv_obj_t *labelConfig = lv_label_create_empty(buttonConfig);
buttonBack = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_WIFI_RETURN); lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_WIFI_RETURN);
label_Back = lv_label_create_empty(buttonBack); lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
if (gCfgItems.multiple_language) { if (gCfgItems.multiple_language) {
if (gCfgItems.wifi_mode_sel == AP_MODEL) { if (gCfgItems.wifi_mode_sel == AP_MODEL) {
@ -195,26 +151,24 @@ void lv_draw_wifi_settings(void) {
lv_label_set_text(labelModelValue, WIFI_STA_TEXT); lv_label_set_text(labelModelValue, WIFI_STA_TEXT);
lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER, 0, 0); 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,machine_menu.wifiName); strcat(public_buf_m, (const char *)uiCfg.wifi_name);
strcat(public_buf_m,(const char *)uiCfg.wifi_name); lv_label_set_text(labelNameText, public_buf_m);
lv_label_set_text(labelNameText,public_buf_m);
lv_label_set_text(labelNameValue,machine_menu.wifiEdit); lv_label_set_text(labelNameValue, machine_menu.wifiEdit);
lv_obj_align(labelNameValue, buttonNameValue, LV_ALIGN_CENTER, 0, 0); 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,machine_menu.wifiPassWord); strcat(public_buf_m, (const char *)uiCfg.wifi_key);
strcat(public_buf_m,(const char *)uiCfg.wifi_key); lv_label_set_text(labelPassWordText, public_buf_m);
lv_label_set_text(labelPassWordText,public_buf_m);
lv_label_set_text(labelPassWordValue,machine_menu.wifiEdit); lv_label_set_text(labelPassWordValue, machine_menu.wifiEdit);
lv_obj_align(labelPassWordValue, buttonPassWordValue, LV_ALIGN_CENTER, 0, 0); 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_label_set_text(labelCloudValue, gCfgItems.cloud_enable ? machine_menu.enable : machine_menu.disable);
lv_obj_align(labelCloudValue, buttonCloudValue, LV_ALIGN_CENTER, 0, 0); lv_obj_align(labelCloudValue, buttonCloudValue, LV_ALIGN_CENTER, 0, 0);
lv_label_set_text(labelConfig,machine_menu.wifiConfig); lv_label_set_text(labelConfig, machine_menu.wifiConfig);
lv_obj_align(labelConfig, buttonConfig, LV_ALIGN_CENTER, 0, 0); lv_obj_align(labelConfig, buttonConfig, LV_ALIGN_CENTER, 0, 0);
lv_label_set_text(label_Back, common_menu.text_back); lv_label_set_text(label_Back, common_menu.text_back);

View file

@ -30,14 +30,14 @@
#include "draw_ui.h" #include "draw_ui.h"
static lv_obj_t * scr; static lv_obj_t *scr;
TIPS_TYPE wifi_tips_type; TIPS_TYPE wifi_tips_type;
TIPS_DISP tips_disp; TIPS_DISP tips_disp;
tips_menu_def tips_menu; tips_menu_def tips_menu;
void lv_draw_wifi_tips(void) { void lv_draw_wifi_tips(void) {
static lv_obj_t * text_tips,*wifi_name; static lv_obj_t *text_tips,*wifi_name;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_TIPS_UI) { if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_TIPS_UI) {
disp_state_stack._disp_index++; disp_state_stack._disp_index++;
@ -45,28 +45,24 @@ void lv_draw_wifi_tips(void) {
} }
disp_state = WIFI_TIPS_UI; disp_state = WIFI_TIPS_UI;
scr = lv_obj_create(NULL, NULL); scr = lv_screen_create();
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
lv_refr_now(lv_refr_get_disp_refreshing()); lv_refr_now(lv_refr_get_disp_refreshing());
wifi_name = lv_label_create(scr, (const char *)wifi_list.wifiName[wifi_list.nameIndex]); wifi_name = lv_label_create(scr, (const char *)wifi_list.wifiName[wifi_list.nameIndex]);
lv_obj_align(wifi_name, NULL, LV_ALIGN_CENTER, 0, -20); lv_obj_align(wifi_name, nullptr, LV_ALIGN_CENTER, 0, -20);
text_tips = lv_label_create_empty(scr); text_tips = lv_label_create_empty(scr);
if (wifi_tips_type == TIPS_TYPE_JOINING) { if (wifi_tips_type == TIPS_TYPE_JOINING) {
lv_label_set_text(text_tips, tips_menu.joining); lv_label_set_text(text_tips, tips_menu.joining);
lv_obj_align(text_tips, NULL, LV_ALIGN_CENTER, 0, -60); lv_obj_align(text_tips, nullptr, LV_ALIGN_CENTER, 0, -60);
} }
else if (wifi_tips_type == TIPS_TYPE_TAILED_JOIN) { else if (wifi_tips_type == TIPS_TYPE_TAILED_JOIN) {
lv_label_set_text(text_tips, tips_menu.failedJoin); lv_label_set_text(text_tips, tips_menu.failedJoin);
lv_obj_align(text_tips, NULL, LV_ALIGN_CENTER, 0, -60); lv_obj_align(text_tips, nullptr, LV_ALIGN_CENTER, 0, -60);
} }
else if (wifi_tips_type == TIPS_TYPE_WIFI_CONECTED) { else if (wifi_tips_type == TIPS_TYPE_WIFI_CONECTED) {
lv_label_set_text(text_tips, tips_menu.wifiConected); lv_label_set_text(text_tips, tips_menu.wifiConected);
lv_obj_align(text_tips, NULL, LV_ALIGN_CENTER, 0, -60); lv_obj_align(text_tips, nullptr, LV_ALIGN_CENTER, 0, -60);
} }
tips_disp.timer = TIPS_TIMER_START; tips_disp.timer = TIPS_TIMER_START;

View file

@ -62,7 +62,7 @@ static const uint8_t * __user_font_get_bitmap(const lv_font_t * font, uint32_t u
memcpy(&__g_xbf_hd, p, sizeof(x_header_t)); memcpy(&__g_xbf_hd, p, sizeof(x_header_t));
} }
if (unicode_letter > __g_xbf_hd.max || unicode_letter < __g_xbf_hd.min) if (unicode_letter > __g_xbf_hd.max || unicode_letter < __g_xbf_hd.min)
return NULL; return nullptr;
uint32_t unicode_offset = sizeof(x_header_t) + (unicode_letter - __g_xbf_hd.min) * 4; uint32_t unicode_offset = sizeof(x_header_t) + (unicode_letter - __g_xbf_hd.min) * 4;
uint32_t *p_pos = (uint32_t *)__user_font_getdata(unicode_offset, 4); uint32_t *p_pos = (uint32_t *)__user_font_getdata(unicode_offset, 4);
if (p_pos[0] != 0) { if (p_pos[0] != 0) {
@ -72,7 +72,7 @@ static const uint8_t * __user_font_get_bitmap(const lv_font_t * font, uint32_t u
//return __user_font_getdata(pos+2, gdsc->box_w*__g_xbf_hd.bpp/8); //return __user_font_getdata(pos+2, gdsc->box_w*__g_xbf_hd.bpp/8);
return __user_font_getdata(pos + 2, sizeof(__g_font_buf)); return __user_font_getdata(pos + 2, sizeof(__g_font_buf));
} }
return NULL; return nullptr;
} }
static bool __user_font_get_glyph_dsc(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) { static bool __user_font_get_glyph_dsc(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) {
@ -81,7 +81,7 @@ static bool __user_font_get_glyph_dsc(const lv_font_t * font, lv_font_glyph_dsc_
memcpy(&__g_xbf_hd, p, sizeof(x_header_t)); memcpy(&__g_xbf_hd, p, sizeof(x_header_t));
} }
if (unicode_letter > __g_xbf_hd.max || unicode_letter < __g_xbf_hd.min) if (unicode_letter > __g_xbf_hd.max || unicode_letter < __g_xbf_hd.min)
return NULL; return false;
uint32_t unicode_offset = sizeof(x_header_t) + (unicode_letter - __g_xbf_hd.min) * 4; uint32_t unicode_offset = sizeof(x_header_t) + (unicode_letter - __g_xbf_hd.min) * 4;
uint32_t *p_pos = (uint32_t *)__user_font_getdata(unicode_offset, 4); uint32_t *p_pos = (uint32_t *)__user_font_getdata(unicode_offset, 4);
if (p_pos[0] != 0) { if (p_pos[0] != 0) {

View file

@ -637,7 +637,7 @@ void disp_string(uint16_t x, uint16_t y, const char * string, uint16_t charColor
} }
} }
//static lv_obj_t * scr_test; //static lv_obj_t *scr_test;
void disp_assets_update() { void disp_assets_update() {
SPI_TFT.LCD_clear(0x0000); SPI_TFT.LCD_clear(0x0000);
disp_string(100, 140, "Assets Updating...", 0xFFFF, 0x0000); disp_string(100, 140, "Assets Updating...", 0xFFFF, 0x0000);

View file

@ -58,13 +58,11 @@ void printer_state_polling() {
if (gCfgItems.pausePosZ != (float)-1) { if (gCfgItems.pausePosZ != (float)-1) {
gcode.process_subcommands_now_P(PSTR("G91")); gcode.process_subcommands_now_P(PSTR("G91"));
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("G1 Z%.1f"), gCfgItems.pausePosZ); sprintf_P(public_buf_l, PSTR("G1 Z%.1f"), gCfgItems.pausePosZ);
gcode.process_subcommands_now(public_buf_l); gcode.process_subcommands_now(public_buf_l);
gcode.process_subcommands_now_P(PSTR("G90")); gcode.process_subcommands_now_P(PSTR("G90"));
} }
if (gCfgItems.pausePosX != (float)-1 && gCfgItems.pausePosY != (float)-1) { if (gCfgItems.pausePosX != (float)-1 && gCfgItems.pausePosY != (float)-1) {
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("G1 X%.1f Y%.1f"), gCfgItems.pausePosX, gCfgItems.pausePosY); sprintf_P(public_buf_l, PSTR("G1 X%.1f Y%.1f"), gCfgItems.pausePosX, gCfgItems.pausePosY);
gcode.process_subcommands_now(public_buf_l); gcode.process_subcommands_now(public_buf_l);
} }
@ -88,13 +86,11 @@ void printer_state_polling() {
if (uiCfg.print_state == RESUMING) { if (uiCfg.print_state == RESUMING) {
if (IS_SD_PAUSED()) { if (IS_SD_PAUSED()) {
if (gCfgItems.pausePosX != (float)-1 && gCfgItems.pausePosY != (float)-1) { if (gCfgItems.pausePosX != (float)-1 && gCfgItems.pausePosY != (float)-1) {
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("G1 X%.1f Y%.1f"), uiCfg.current_x_position_bak, uiCfg.current_y_position_bak); sprintf_P(public_buf_m, PSTR("G1 X%.1f Y%.1f"), uiCfg.current_x_position_bak, uiCfg.current_y_position_bak);
gcode.process_subcommands_now(public_buf_m); gcode.process_subcommands_now(public_buf_m);
} }
if (gCfgItems.pausePosZ != (float)-1) { if (gCfgItems.pausePosZ != (float)-1) {
gcode.process_subcommands_now_P(PSTR("G91")); gcode.process_subcommands_now_P(PSTR("G91"));
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("G1 Z-%.1f"), gCfgItems.pausePosZ); sprintf_P(public_buf_l, PSTR("G1 Z-%.1f"), gCfgItems.pausePosZ);
gcode.process_subcommands_now(public_buf_l); gcode.process_subcommands_now(public_buf_l);
gcode.process_subcommands_now_P(PSTR("G90")); gcode.process_subcommands_now_P(PSTR("G90"));
@ -109,7 +105,6 @@ void printer_state_polling() {
} }
#if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(POWER_LOSS_RECOVERY)
if (uiCfg.print_state == REPRINTED) { if (uiCfg.print_state == REPRINTED) {
ZERO(public_buf_m);
#if HAS_HOTEND #if HAS_HOTEND
HOTEND_LOOP() { HOTEND_LOOP() {
const int16_t et = recovery.info.target_temperature[e]; const int16_t et = recovery.info.target_temperature[e];
@ -128,7 +123,6 @@ void printer_state_polling() {
#if 0 #if 0
// Move back to the saved XY // Move back to the saved XY
char str_1[16], str_2[16]; char str_1[16], str_2[16];
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("G1 X%s Y%s F2000"), sprintf_P(public_buf_m, PSTR("G1 X%s Y%s F2000"),
dtostrf(recovery.info.current_position.x, 1, 3, str_1), dtostrf(recovery.info.current_position.x, 1, 3, str_1),
dtostrf(recovery.info.current_position.y, 1, 3, str_2) dtostrf(recovery.info.current_position.y, 1, 3, str_2)
@ -137,7 +131,6 @@ void printer_state_polling() {
if (gCfgItems.pause_reprint && gCfgItems.pausePosZ != -1.0f) { if (gCfgItems.pause_reprint && gCfgItems.pausePosZ != -1.0f) {
gcode.process_subcommands_now_P(PSTR("G91")); gcode.process_subcommands_now_P(PSTR("G91"));
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("G1 Z-%.1f"), gCfgItems.pausePosZ); sprintf_P(public_buf_l, PSTR("G1 Z-%.1f"), gCfgItems.pausePosZ);
gcode.process_subcommands_now(public_buf_l); gcode.process_subcommands_now(public_buf_l);
gcode.process_subcommands_now_P(PSTR("G90")); gcode.process_subcommands_now_P(PSTR("G90"));

View file

@ -99,7 +99,7 @@ void SysTick_Callback() {
uiCfg.filament_unloading_time_cnt = 0; uiCfg.filament_unloading_time_cnt = 0;
uiCfg.filament_unloading_time_flg = 0; uiCfg.filament_unloading_time_flg = 0;
uiCfg.filament_unloading_completed = 1; uiCfg.filament_unloading_completed = 1;
uiCfg.filament_rate = 100; uiCfg.filament_rate = 100;
} }
} }
} }
@ -133,7 +133,7 @@ void tft_lvgl_init() {
lv_init(); lv_init();
lv_disp_buf_init(&disp_buf, bmp_public_buf, NULL, LV_HOR_RES_MAX * 18); /*Initialize the display buffer*/ lv_disp_buf_init(&disp_buf, bmp_public_buf, nullptr, LV_HOR_RES_MAX * 18); /*Initialize the display buffer*/
lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/ lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
lv_disp_drv_init(&disp_drv); /*Basic initialization*/ lv_disp_drv_init(&disp_drv); /*Basic initialization*/
@ -199,7 +199,6 @@ void tft_lvgl_init() {
uiCfg.print_state = REPRINTING; uiCfg.print_state = REPRINTING;
ZERO(public_buf_m);
strncpy(public_buf_m, recovery.info.sd_filename, sizeof(public_buf_m)); strncpy(public_buf_m, recovery.info.sd_filename, sizeof(public_buf_m));
card.printLongPath(public_buf_m); card.printLongPath(public_buf_m);
@ -216,15 +215,14 @@ void tft_lvgl_init() {
} }
void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p) { void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p) {
uint16_t i, width, height; uint16_t width = area->x2 - area->x1 + 1,
height = area->y2 - area->y1 + 1;
width = area->x2 - area->x1 + 1;
height = area->y2 - area->y1 + 1;
SPI_TFT.setWindow((uint16_t)area->x1, (uint16_t)area->y1, width, height); SPI_TFT.setWindow((uint16_t)area->x1, (uint16_t)area->y1, width, height);
for (i = 0; i < height; i++) {
for (uint16_t i = 0; i < height; i++)
SPI_TFT.tftio.WriteSequence((uint16_t*)(color_p + width * i), width); SPI_TFT.tftio.WriteSequence((uint16_t*)(color_p + width * i), width);
}
lv_disp_flush_ready(disp); /* Indicate you are ready with the flushing*/ lv_disp_flush_ready(disp); /* Indicate you are ready with the flushing*/
W25QXX.init(SPI_QUARTER_SPEED); W25QXX.init(SPI_QUARTER_SPEED);
@ -310,10 +308,9 @@ extern uint8_t currentFlashPage;
uint32_t pic_read_base_addr = 0, pic_read_addr_offset = 0; uint32_t pic_read_base_addr = 0, pic_read_addr_offset = 0;
lv_fs_res_t spi_flash_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode) { lv_fs_res_t spi_flash_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode) {
static char last_path_name[30]; static char last_path_name[30];
if (strcasecmp(last_path_name,path) != 0) { if (strcasecmp(last_path_name, path) != 0) {
pic_read_base_addr = lv_get_pic_addr((uint8_t *)path); pic_read_base_addr = lv_get_pic_addr((uint8_t *)path);
ZERO(last_path_name); strcpy(last_path_name, path);
strcpy(last_path_name,path);
} }
else { else {
W25QXX.init(SPI_QUARTER_SPEED); W25QXX.init(SPI_QUARTER_SPEED);
@ -362,11 +359,10 @@ uint32_t sd_read_base_addr = 0,sd_read_addr_offset = 0;
lv_fs_res_t sd_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode) { lv_fs_res_t sd_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode) {
//cur_namefff = strrchr(path, '/'); //cur_namefff = strrchr(path, '/');
char name_buf[100]; char name_buf[100];
ZERO(name_buf); *name_buf = '/';
strcat(name_buf,"/"); strcpy(name_buf + 1, path);
strcat(name_buf,path); char *temp = strstr(name_buf, ".bin");
char *temp = strstr(name_buf,".bin"); if (temp) strcpy(temp, ".GCO");
if (temp) { strcpy(temp,".GCO"); }
sd_read_base_addr = lv_open_gcode_file((char *)name_buf); sd_read_base_addr = lv_open_gcode_file((char *)name_buf);
sd_read_addr_offset = sd_read_base_addr; sd_read_addr_offset = sd_read_base_addr;
if (sd_read_addr_offset == 0) return LV_FS_RES_NOT_EX; if (sd_read_addr_offset == 0) return LV_FS_RES_NOT_EX;

View file

@ -260,7 +260,7 @@ void WriteByteSlip(uint8_t b) {
// Wait for a data packet to be returned. If the body of the packet is // Wait for a data packet to be returned. If the body of the packet is
// non-zero length, return an allocated buffer indirectly containing the // non-zero length, return an allocated buffer indirectly containing the
// data and return the data length. Note that if the pointer for returning // 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. // the data buffer is nullptr, the response is expected to be two bytes of zero.
// //
// If an error occurs, return a negative value. Otherwise, return the number // 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"). // of bytes in the response (or zero if the response was not the standard "two bytes of zero").
@ -533,7 +533,7 @@ EspUploadResult flashFinish(signed char reboot) {
// Compute the checksum of a block of data // Compute the checksum of a block of data
uint16_t checksum(const uint8_t *data, uint16_t dataLen, uint16_t cksum) { uint16_t checksum(const uint8_t *data, uint16_t dataLen, uint16_t cksum) {
if (data != NULL) { if (data != nullptr) {
while (dataLen--) { while (dataLen--) {
cksum ^= (uint16_t)*data++; cksum ^= (uint16_t)*data++;
} }

View file

@ -53,5 +53,17 @@ opt_disable TFT_INTERFACE_FSMC TFT_RES_320x240
opt_enable TFT_INTERFACE_SPI TFT_RES_480x320 opt_enable TFT_INTERFACE_SPI TFT_RES_480x320
exec_test $1 $2 "MKS Robin v2 nano New Color UI 480x320 SPI" exec_test $1 $2 "MKS Robin v2 nano New Color UI 480x320 SPI"
#
# MKS Robin v2 nano LVGL SPI + TMC
# (Robin v2 nano has no FSMC interface)
#
use_example_configs Mks/Robin
opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V2
opt_disable TFT_INTERFACE_FSMC TFT_COLOR_UI TOUCH_SCREEN TFT_RES_320x240
opt_enable TFT_INTERFACE_SPI TFT_LVGL_UI TFT_RES_480x320
opt_set X_DRIVER_TYPE TMC2209
opt_set Y_DRIVER_TYPE TMC2209
exec_test $1 $2 "MKS Robin v2 nano LVGL SPI + TMC"
# cleanup # cleanup
restore_configs restore_configs