Browse Source

Add MKS Robin E3P, improve LVGL UI (#19442)

vanilla_fb_2.0.x
makerbase 4 years ago
committed by Scott Lahteine
parent
commit
33788c8405
  1. 2
      Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp
  2. 11
      Marlin/src/MarlinCore.cpp
  3. 73
      Marlin/src/core/boards.h
  4. 2
      Marlin/src/lcd/extui/lib/mks_ui/SPIFlashStorage.cpp
  5. 5
      Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.cpp
  6. 41
      Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp
  7. 322
      Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.cpp
  8. 234
      Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.cpp
  9. 203
      Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.cpp
  10. 33
      Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.h
  11. 352
      Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.cpp
  12. 36
      Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.h
  13. 83
      Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp
  14. 455
      Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp
  15. 5
      Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h
  16. 139
      Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.cpp
  17. 172
      Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.cpp
  18. 33
      Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.h
  19. 97
      Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp
  20. 56
      Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp
  21. 270
      Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp
  22. 36
      Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.h
  23. 329
      Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp
  24. 33
      Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.h
  25. 137
      Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp
  26. 262
      Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.cpp
  27. 33
      Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.h
  28. 150
      Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.cpp
  29. 286
      Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp
  30. 33
      Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.h
  31. 136
      Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp
  32. 261
      Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.cpp
  33. 33
      Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.h
  34. 114
      Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.cpp
  35. 81
      Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.cpp
  36. 69
      Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp
  37. 459
      Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.cpp
  38. 33
      Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.h
  39. 212
      Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.cpp
  40. 160
      Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.cpp
  41. 87
      Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp
  42. 291
      Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp
  43. 261
      Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp
  44. 120
      Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.cpp
  45. 97
      Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp
  46. 103
      Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp
  47. 3
      Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h
  48. 195
      Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp
  49. 122
      Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp
  50. 249
      Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp
  51. 216
      Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.cpp
  52. 389
      Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.cpp
  53. 456
      Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.cpp
  54. 171
      Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp
  55. 495
      Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp
  56. 168
      Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h
  57. 222
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp
  58. 38
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.h
  59. 235
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.cpp
  60. 76
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.h
  61. 299
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.cpp
  62. 36
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.h
  63. 85
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.cpp
  64. 51
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.h
  65. 69
      Marlin/src/lcd/extui/lib/mks_ui/irq_overrid.cpp
  66. 100
      Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp
  67. 174
      Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp
  68. 13
      Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h
  69. 44
      Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp
  70. 54
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_en.h
  71. 5
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_fr.h
  72. 5
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_it.h
  73. 5
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_ru.h
  74. 52
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_s_cn.h
  75. 5
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_sp.h
  76. 51
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_t_cn.h
  77. 880
      Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp
  78. 51
      Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h
  79. 291
      Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.cpp
  80. 75
      Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.h
  81. 120
      Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.cpp
  82. 102
      Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.h
  83. 1927
      Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp
  84. 202
      Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h
  85. 847
      Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp
  86. 74
      Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.h
  87. 14
      Marlin/src/module/stepper.h
  88. 2
      Marlin/src/pins/pins.h
  89. 377
      Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h
  90. 38
      Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h
  91. 48
      Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h
  92. 14
      buildroot/share/PlatformIO/ldscripts/mks_robin_e3p.ld
  93. 40
      buildroot/share/PlatformIO/scripts/mks_robin_e3p.py
  94. 18
      platformio.ini

2
Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp

@ -201,6 +201,8 @@ uint32_t TFT_FSMC::GetID() {
id = ReadID(LCD_READ_ID);
if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF)
id = ReadID(LCD_READ_ID4);
if ((id & 0xFF00) == 0 && (id & 0xFF) != 0)
id = ReadID(LCD_READ_ID4);
return id;
}

11
Marlin/src/MarlinCore.cpp

@ -796,6 +796,10 @@ void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr
UNUSED(lcd_component);
#endif
#if HAS_TFT_LVGL_UI
lv_draw_error_message(lcd_error);
#endif
#ifdef ACTION_ON_KILL
host_action_kill();
#endif
@ -920,6 +924,13 @@ void setup() {
SERIAL_ECHO_MSG("start");
#endif
#if BOTH(HAS_TFT_LVGL_UI, USE_WIFI_FUNCTION)
mks_esp_wifi_init();
WIFISERIAL.begin(WIFI_BAUDRATE);
serial_connect_timeout = millis() + 1000UL;
while (/*!WIFISERIAL && */PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
#endif
SETUP_RUN(HAL_init());
#if HAS_L64XX

73
Marlin/src/core/boards.h

@ -282,42 +282,43 @@
// STM32 ARM Cortex-M3
//
#define BOARD_STM32F103RE 4000 // STM32F103RE Libmaple-based STM32F1 controller
#define BOARD_MALYAN_M200 4001 // STM32C8T6 Libmaple-based STM32F1 controller
#define BOARD_MALYAN_M200_V2 4002 // STM32F070CB STM32F0 controller
#define BOARD_STM3R_MINI 4003 // STM32F103RE Libmaple-based STM32F1 controller
#define BOARD_GTM32_PRO_VB 4004 // STM32F103VET6 controller
#define BOARD_MORPHEUS 4005 // STM32F103C8 / STM32F103CB Libmaple-based STM32F1 controller
#define BOARD_CHITU3D 4006 // Chitu3D (STM32F103RET6)
#define BOARD_MKS_ROBIN 4007 // MKS Robin (STM32F103ZET6)
#define BOARD_MKS_ROBIN_MINI 4008 // MKS Robin Mini (STM32F103VET6)
#define BOARD_MKS_ROBIN_NANO 4009 // MKS Robin Nano (STM32F103VET6)
#define BOARD_MKS_ROBIN_NANO_V2 4010 // MKS Robin Nano V2 (STM32F103VET6)
#define BOARD_MKS_ROBIN_LITE 4011 // MKS Robin Lite/Lite2 (STM32F103RCT6)
#define BOARD_MKS_ROBIN_LITE3 4012 // MKS Robin Lite3 (STM32F103RCT6)
#define BOARD_MKS_ROBIN_PRO 4013 // MKS Robin Pro (STM32F103ZET6)
#define BOARD_BTT_SKR_MINI_V1_1 4014 // BigTreeTech SKR Mini v1.1 (STM32F103RC)
#define BOARD_BTT_SKR_MINI_E3_V1_0 4015 // BigTreeTech SKR Mini E3 (STM32F103RC)
#define BOARD_BTT_SKR_MINI_E3_V1_2 4016 // BigTreeTech SKR Mini E3 V1.2 (STM32F103RC)
#define BOARD_BTT_SKR_MINI_E3_V2_0 4017 // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC)
#define BOARD_BTT_SKR_E3_DIP 4018 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE)
#define BOARD_JGAURORA_A5S_A1 4019 // JGAurora A5S A1 (STM32F103ZET6)
#define BOARD_FYSETC_AIO_II 4020 // FYSETC AIO_II
#define BOARD_FYSETC_CHEETAH 4021 // FYSETC Cheetah
#define BOARD_FYSETC_CHEETAH_V12 4022 // FYSETC Cheetah V1.2
#define BOARD_LONGER3D_LK 4023 // Alfawise U20/U20+/U30 (Longer3D LK1/2) / STM32F103VET6
#define BOARD_GTM32_MINI 4024 // STM32F103VET6 controller
#define BOARD_GTM32_MINI_A30 4025 // STM32F103VET6 controller
#define BOARD_GTM32_REV_B 4026 // STM32F103VET6 controller
#define BOARD_MKS_ROBIN_E3D 4027 // MKS Robin E3D (STM32F103RCT6)
#define BOARD_MKS_ROBIN_E3 4028 // MKS Robin E3 (STM32F103RCT6)
#define BOARD_MALYAN_M300 4029 // STM32F070-based delta
#define BOARD_CCROBOT_MEEB_3DP 4030 // ccrobot-online.com MEEB_3DP (STM32F103RC)
#define BOARD_CHITU3D_V5 4031 // Chitu3D TronXY X5SA V5 Board
#define BOARD_CHITU3D_V6 4032 // Chitu3D TronXY X5SA V5 Board
#define BOARD_CREALITY_V4 4033 // Creality v4.x (STM32F103RE)
#define BOARD_CREALITY_V427 4034 // Creality v4.2.7 (STM32F103RE)
#define BOARD_TRIGORILLA_PRO 4035 // Trigorilla Pro (STM32F103ZET6)
#define BOARD_MALYAN_M200_V2 4000 // STM32F070CB STM32F0 controller
#define BOARD_MALYAN_M300 4001 // STM32F070-based delta
#define BOARD_STM32F103RE 4002 // STM32F103RE Libmaple-based STM32F1 controller
#define BOARD_MALYAN_M200 4003 // STM32C8T6 Libmaple-based STM32F1 controller
#define BOARD_STM3R_MINI 4004 // STM32F103RE Libmaple-based STM32F1 controller
#define BOARD_GTM32_PRO_VB 4005 // STM32F103VET6 controller
#define BOARD_GTM32_MINI 4006 // STM32F103VET6 controller
#define BOARD_GTM32_MINI_A30 4007 // STM32F103VET6 controller
#define BOARD_GTM32_REV_B 4008 // STM32F103VET6 controller
#define BOARD_MORPHEUS 4009 // STM32F103C8 / STM32F103CB Libmaple-based STM32F1 controller
#define BOARD_CHITU3D 4010 // Chitu3D (STM32F103RET6)
#define BOARD_MKS_ROBIN 4011 // MKS Robin (STM32F103ZET6)
#define BOARD_MKS_ROBIN_MINI 4012 // MKS Robin Mini (STM32F103VET6)
#define BOARD_MKS_ROBIN_NANO 4013 // MKS Robin Nano (STM32F103VET6)
#define BOARD_MKS_ROBIN_NANO_V2 4014 // MKS Robin Nano V2 (STM32F103VET6)
#define BOARD_MKS_ROBIN_LITE 4015 // MKS Robin Lite/Lite2 (STM32F103RCT6)
#define BOARD_MKS_ROBIN_LITE3 4016 // MKS Robin Lite3 (STM32F103RCT6)
#define BOARD_MKS_ROBIN_PRO 4017 // MKS Robin Pro (STM32F103ZET6)
#define BOARD_MKS_ROBIN_E3 4018 // MKS Robin E3 (STM32F103RCT6)
#define BOARD_MKS_ROBIN_E3D 4019 // MKS Robin E3D (STM32F103RCT6)
#define BOARD_MKS_ROBIN_E3P 4020 // MKS Robin E3p (STM32F103VET6)
#define BOARD_BTT_SKR_MINI_V1_1 4021 // BigTreeTech SKR Mini v1.1 (STM32F103RC)
#define BOARD_BTT_SKR_MINI_E3_V1_0 4022 // BigTreeTech SKR Mini E3 (STM32F103RC)
#define BOARD_BTT_SKR_MINI_E3_V1_2 4023 // BigTreeTech SKR Mini E3 V1.2 (STM32F103RC)
#define BOARD_BTT_SKR_MINI_E3_V2_0 4024 // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC)
#define BOARD_BTT_SKR_E3_DIP 4025 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE)
#define BOARD_JGAURORA_A5S_A1 4026 // JGAurora A5S A1 (STM32F103ZET6)
#define BOARD_FYSETC_AIO_II 4027 // FYSETC AIO_II
#define BOARD_FYSETC_CHEETAH 4028 // FYSETC Cheetah
#define BOARD_FYSETC_CHEETAH_V12 4029 // FYSETC Cheetah V1.2
#define BOARD_LONGER3D_LK 4030 // Alfawise U20/U20+/U30 (Longer3D LK1/2) / STM32F103VET6
#define BOARD_CCROBOT_MEEB_3DP 4031 // ccrobot-online.com MEEB_3DP (STM32F103RC)
#define BOARD_CHITU3D_V5 4032 // Chitu3D TronXY X5SA V5 Board
#define BOARD_CHITU3D_V6 4033 // Chitu3D TronXY X5SA V5 Board
#define BOARD_CREALITY_V4 4034 // Creality v4.x (STM32F103RE)
#define BOARD_CREALITY_V427 4035 // Creality v4.2.7 (STM32F103RE)
#define BOARD_TRIGORILLA_PRO 4036 // Trigorilla Pro (STM32F103ZET6)
//
// ARM Cortex-M4F

2
Marlin/src/lcd/extui/lib/mks_ui/SPIFlashStorage.cpp

@ -27,6 +27,8 @@
#include "../../../../inc/MarlinConfig.h"
#include "SPIFlashStorage.h"
extern W25QXXFlash W25QXX;
uint8_t SPIFlashStorage::m_pageData[SPI_FLASH_PageSize];
uint32_t SPIFlashStorage::m_currentPage;
uint16_t SPIFlashStorage::m_pageDataUsed;

5
Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.cpp

@ -26,6 +26,7 @@
#include "SPI_TFT.h"
#include "pic_manager.h"
#include "tft_lvgl_configuration.h"
#include "../../../../inc/MarlinConfig.h"
@ -74,6 +75,7 @@ void TFT::SetWindows(uint16_t x, uint16_t y, uint16_t with, uint16_t height) {
}
void TFT::LCD_init() {
TFT_BLK_L;
TFT_RST_H;
delay(150);
TFT_RST_L;
@ -92,8 +94,7 @@ void TFT::LCD_init() {
LCD_WR_DATA(0x96);
LCD_WR_REG(0x36);
LCD_WR_DATA(0x28);
LCD_WR_DATA(0x28 + TERN0(GRAPHICAL_TFT_ROTATE_180, 0x80));
LCD_WR_REG(0x3A);
LCD_WR_DATA(0x55);

41
Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp

@ -33,8 +33,9 @@
#include "../../../../MarlinCore.h"
#include "../../../../module/temperature.h"
extern lv_group_t * g;
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
@ -73,17 +74,18 @@ void lv_draw_about(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_pic);
// Create an Image button
buttonBack = lv_imgbtn_create(scr, NULL);
#if 1
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_A_RETURN, "bmp_return.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_A_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif
#endif
lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
@ -97,30 +99,27 @@ void lv_draw_about(void) {
lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
}
fw_version = lv_label_create(scr, NULL);
lv_obj_set_style(fw_version, &tft_style_label_rel);
lv_label_set_text(fw_version, SHORT_BUILD_VERSION);
lv_obj_align(fw_version, NULL, LV_ALIGN_CENTER, 0, -60);
//fw_version = lv_label_create(scr, NULL);
//lv_obj_set_style(fw_version, &tft_style_label_rel);
//lv_label_set_text(fw_version, SHORT_BUILD_VERSION);
//lv_obj_align(fw_version, NULL, LV_ALIGN_CENTER, 0, -60);
fw_type = lv_label_create(scr, NULL);
lv_obj_set_style(fw_type, &tft_style_label_rel);
lv_label_set_text(fw_type,
#if MB(MKS_ROBIN_PRO)
"Firmware: Robin_Pro35"
#elif MB(MKS_ROBIN_NANO, MKS_ROBIN_NANO_V2)
"Firmware: Robin_Nano35"
#else
CUSTOM_MACHINE_NAME
#endif
);
lv_label_set_text(fw_type, "Firmware: Marlin " SHORT_BUILD_VERSION);
lv_obj_align(fw_type, NULL, LV_ALIGN_CENTER, 0, -20);
board = lv_label_create(scr, NULL);
lv_obj_set_style(board, &tft_style_label_rel);
lv_label_set_text(board, "Board: " BOARD_INFO_NAME);
lv_obj_align(board, NULL, LV_ALIGN_CENTER, 0, 20);
lv_obj_align(board, NULL, LV_ALIGN_CENTER, 0, -60);
}
void lv_clear_about() { lv_obj_del(scr); }
void lv_clear_about() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

322
Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.cpp

@ -29,6 +29,7 @@
#include "../../../../MarlinCore.h"
#include "../../../../module/planner.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_ACCE_RETURN 1
@ -160,14 +161,14 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
void lv_draw_acceleration_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL;
lv_obj_t *buttonPrintText = NULL, *labelPrintText = NULL, *buttonPrintValue = NULL, *labelPrintValue = NULL;
lv_obj_t *buttonRetraText = NULL, *labelRetraText = NULL, *buttonRetraValue = NULL, *labelRetraValue = NULL;
lv_obj_t *buttonTravelText = NULL, *labelTravelText = NULL, *buttonTravelValue = NULL, *labelTravelValue = NULL;
lv_obj_t *buttonXText = NULL, *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *buttonYText = NULL, *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *buttonZText = NULL, *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t *buttonE0Text = NULL, *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL;
lv_obj_t *buttonE1Text = NULL, *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL;
lv_obj_t *labelPrintText = NULL, *buttonPrintValue = NULL, *labelPrintValue = NULL;
lv_obj_t *labelRetraText = NULL, *buttonRetraValue = NULL, *labelRetraValue = NULL;
lv_obj_t *labelTravelText = NULL, *buttonTravelValue = NULL, *labelTravelValue = NULL;
lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL;
lv_obj_t *labelE1Text = NULL, *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) {
disp_state_stack._disp_index++;
@ -188,231 +189,202 @@ void lv_draw_acceleration_settings(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_para_back);
// LV_IMG_DECLARE(bmp_para_arrow);
LV_IMG_DECLARE(bmp_para_bank);
if (uiCfg.para_ui_page != 1) {
buttonPrintText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonPrintText, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
lv_obj_set_size(buttonPrintText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonPrintText, event_handler);
lv_btn_set_style(buttonPrintText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonPrintText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonPrintText, LV_LAYOUT_OFF);
labelPrintText = lv_label_create(buttonPrintText, NULL); /*Add a label to the button*/
buttonPrintValue = lv_imgbtn_create(scr, NULL);
labelPrintText = lv_label_create(scr, NULL);
lv_obj_set_style(labelPrintText, &tft_style_label_rel);
lv_obj_set_pos(labelPrintText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
lv_label_set_text(labelPrintText, machine_menu.PrintAcceleration);
buttonPrintValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonPrintValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonPrintValue, event_handler, ID_ACCE_PRINT, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonPrintValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonPrintValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonPrintValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonPrintValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonPrintValue, LV_LAYOUT_OFF);
lv_obj_set_size(buttonPrintValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonPrintValue, event_handler, ID_ACCE_PRINT, NULL, 0);
lv_btn_set_style(buttonPrintValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonPrintValue, LV_BTN_STYLE_PR, &style_para_value);
labelPrintValue = lv_label_create(buttonPrintValue, NULL);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonRetraText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonRetraText, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/
lv_obj_set_size(buttonRetraText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonRetraText, event_handler);
lv_btn_set_style(buttonRetraText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonRetraText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonRetraText, LV_LAYOUT_OFF);
labelRetraText = lv_label_create(buttonRetraText, NULL); /*Add a label to the button*/
labelRetraText = lv_label_create(scr, NULL);
lv_obj_set_style(labelRetraText, &tft_style_label_rel);
lv_obj_set_pos(labelRetraText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
lv_label_set_text(labelRetraText, machine_menu.RetractAcceleration);
buttonRetraValue = lv_imgbtn_create(scr, NULL);
buttonRetraValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonRetraValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonRetraValue, event_handler, ID_ACCE_RETRA, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonRetraValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonRetraValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonRetraValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonRetraValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonRetraValue, LV_LAYOUT_OFF);
lv_obj_set_size(buttonRetraValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonRetraValue, event_handler, ID_ACCE_RETRA, NULL, 0);
lv_btn_set_style(buttonRetraValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonRetraValue, LV_BTN_STYLE_PR, &style_para_value);
labelRetraValue = lv_label_create(buttonRetraValue, NULL);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
buttonTravelText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonTravelText, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/
lv_obj_set_size(buttonTravelText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonTravelText, event_handler);
lv_btn_set_style(buttonTravelText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonTravelText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonTravelText, LV_LAYOUT_OFF);
labelTravelText = lv_label_create(buttonTravelText, NULL); /*Add a label to the button*/
labelTravelText = lv_label_create(scr, NULL);
lv_obj_set_style(labelTravelText, &tft_style_label_rel);
lv_obj_set_pos(labelTravelText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
lv_label_set_text(labelTravelText, machine_menu.TravelAcceleration);
buttonTravelValue = lv_imgbtn_create(scr, NULL);
buttonTravelValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonTravelValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonTravelValue, event_handler, ID_ACCE_TRAVEL, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonTravelValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonTravelValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonTravelValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonTravelValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonTravelValue, LV_LAYOUT_OFF);
lv_obj_set_size(buttonTravelValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonTravelValue, event_handler, ID_ACCE_TRAVEL, NULL, 0);
lv_btn_set_style(buttonTravelValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonTravelValue, LV_BTN_STYLE_PR, &style_para_value);
labelTravelValue = lv_label_create(buttonTravelValue, NULL);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
buttonXText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y * 4); /*Set its position*/
lv_obj_set_size(buttonXText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonXText, event_handler);
lv_btn_set_style(buttonXText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonXText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonXText, LV_LAYOUT_OFF);
labelXText = lv_label_create(buttonXText, NULL); /*Add a label to the button*/
labelXText = lv_label_create(scr, NULL);
lv_obj_set_style(labelXText, &tft_style_label_rel);
lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
lv_label_set_text(labelXText, machine_menu.X_Acceleration);
buttonXValue = lv_imgbtn_create(scr, NULL);
buttonXValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_ACCE_X, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF);
lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_ACCE_X, NULL, 0);
lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value);
labelXValue = lv_label_create(buttonXValue, NULL);
line4 = lv_line_create(scr, NULL);
lv_ex_line(line4, line_points[3]);
buttonTurnPage = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_ACCE_DOWN, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back);
lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
buttonTurnPage = lv_btn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_ACCE_DOWN, NULL, 0);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, 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 {
buttonYText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonYText, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
lv_obj_set_size(buttonYText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonYText, event_handler);
lv_btn_set_style(buttonYText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonYText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonYText, LV_LAYOUT_OFF);
labelYText = lv_label_create(buttonYText, NULL); /*Add a label to the button*/
buttonYValue = lv_imgbtn_create(scr, NULL);
labelYText = lv_label_create(scr, NULL);
lv_obj_set_style(labelYText, &tft_style_label_rel);
lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
lv_label_set_text(labelYText, machine_menu.Y_Acceleration);
buttonYValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_ACCE_Y, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF);
lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_ACCE_Y, NULL, 0);
lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value);
labelYValue = lv_label_create(buttonYValue, NULL);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonZText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonZText, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/
lv_obj_set_size(buttonZText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonZText, event_handler);
lv_btn_set_style(buttonZText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonZText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonZText, LV_LAYOUT_OFF);
labelZText = lv_label_create(buttonZText, NULL); /*Add a label to the button*/
labelZText = lv_label_create(scr, NULL);
lv_obj_set_style(labelZText, &tft_style_label_rel);
lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
lv_label_set_text(labelZText, machine_menu.Z_Acceleration);
buttonZValue = lv_imgbtn_create(scr, NULL);
buttonZValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_ACCE_Z, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF);
lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_ACCE_Y, NULL, 0);
lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_ACCE_Z, NULL, 0);
lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value);
labelZValue = lv_label_create(buttonZValue, NULL);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
buttonE0Text = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/
lv_obj_set_size(buttonE0Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonE0Text, event_handler);
lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonE0Text, LV_LAYOUT_OFF);
labelE0Text = lv_label_create(buttonE0Text, NULL); /*Add a label to the button*/
labelE0Text = lv_label_create(scr, NULL);
lv_obj_set_style(labelE0Text, &tft_style_label_rel);
lv_obj_set_pos(labelE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
lv_label_set_text(labelE0Text, machine_menu.E0_Acceleration);
buttonE0Value = lv_imgbtn_create(scr, NULL);
buttonE0Value = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonE0Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_ACCE_E0, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonE0Value, LV_LAYOUT_OFF);
lv_obj_set_size(buttonE0Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_ACCE_Y, NULL, 0);
lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_ACCE_E0, NULL, 0);
lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_PR, &style_para_value);
labelE0Value = lv_label_create(buttonE0Value, NULL);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
buttonE1Text = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonE1Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4); /*Set its position*/
lv_obj_set_size(buttonE1Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonE1Text, event_handler);
lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonE1Text, LV_LAYOUT_OFF);
labelE1Text = lv_label_create(buttonE1Text, NULL); /*Add a label to the button*/
labelE1Text = lv_label_create(scr, NULL);
lv_obj_set_style(labelE1Text, &tft_style_label_rel);
lv_obj_set_pos(labelE1Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
lv_label_set_text(labelE1Text, machine_menu.E1_Acceleration);
buttonE1Value = lv_imgbtn_create(scr, NULL);
buttonE1Value = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonE1Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_ACCE_E1, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonE1Value, LV_LAYOUT_OFF);
lv_obj_set_size(buttonE1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE); lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_ACCE_Y, NULL, 0);
lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_ACCE_E1, NULL, 0);
lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_PR, &style_para_value);
labelE1Value = lv_label_create(buttonE1Value, NULL);
line4 = lv_line_create(scr, NULL);
lv_ex_line(line4, line_points[3]);
buttonTurnPage = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_ACCE_UP, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back);
lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
buttonTurnPage = lv_btn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_ACCE_UP, NULL, 0);
//lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
//lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
//lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
//lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, 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_btn_set_layout(buttonTurnPage, LV_LAYOUT_OFF);
//labelTurnPage = lv_label_create(buttonTurnPage, NULL);
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);
lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
labelTurnPage = lv_label_create(buttonTurnPage, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_ACCE_RETURN, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
buttonBack = lv_btn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_ACCE_RETURN, NULL, 0);
//lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
//lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
//lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
//lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
label_Back = lv_label_create(buttonBack, NULL);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif
//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 != 0) {
if (uiCfg.para_ui_page != 1) {
lv_label_set_text(labelPrintText, machine_menu.PrintAcceleration);
lv_obj_align(labelPrintText, buttonPrintText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelRetraText, machine_menu.RetractAcceleration);
lv_obj_align(labelRetraText, buttonRetraText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelTravelText, machine_menu.TravelAcceleration);
lv_obj_align(labelTravelText, buttonTravelText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelXText, machine_menu.X_Acceleration);
lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelTurnPage, machine_menu.next);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
@ -438,17 +410,6 @@ void lv_draw_acceleration_settings(void) {
lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
}
else {
lv_label_set_text(labelYText, machine_menu.Y_Acceleration);
lv_obj_align(labelYText, buttonYText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelZText, machine_menu.Z_Acceleration);
lv_obj_align(labelZText, buttonZText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelE0Text, machine_menu.E0_Acceleration);
lv_obj_align(labelE0Text, buttonE0Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelE1Text, machine_menu.E1_Acceleration);
lv_obj_align(labelE1Text, buttonE1Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelTurnPage, machine_menu.previous);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
@ -478,6 +439,11 @@ void lv_draw_acceleration_settings(void) {
}
}
void lv_clear_acceleration_settings() { lv_obj_del(scr); }
void lv_clear_acceleration_settings() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

234
Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.cpp

@ -28,11 +28,18 @@
#include "../../../../MarlinCore.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_ADVANCE_RETURN 1
#define ID_PAUSE_POS 2
#define ID_PAUSE_POS_ARROW 3
#define ID_ADVANCE_RETURN 1
#define ID_PAUSE_POS 2
#define ID_PAUSE_POS_ARROW 3
#define ID_WIFI_PARA 4
#define ID_WIFI_PARA_ARROW 5
#define ID_FILAMENT_SETTINGS 6
#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) {
switch (obj->mks_obj_id) {
@ -63,13 +70,79 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
lv_draw_pause_position();
}
break;
case ID_FILAMENT_SETTINGS:
if (event == LV_EVENT_CLICKED) {
}
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;
#if ENABLED(USE_WIFI_FUNCTION)
case ID_WIFI_PARA:
if (event == LV_EVENT_CLICKED) {
}
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;
#endif
#if HAS_ROTARY_ENCODER
case ID_ENCODER_SETTINGS:
if (event == LV_EVENT_CLICKED) {
}
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;
#endif
}
}
void lv_draw_advance_settings(void) {
lv_obj_t *buttonBack, *label_Back;
lv_obj_t *buttonPausePos, *labelPausePos, *buttonPausePosNarrow;
lv_obj_t * line1;
lv_obj_t *buttonFilamentSettings, *labelFilamentSettings, *buttonFilamentSettingsNarrow;
lv_obj_t * line1,* line2;
#if ENABLED(USE_WIFI_FUNCTION)
lv_obj_t *buttonWifiSet,*labelWifiSet,*buttonWifiSetNarrow;
#endif
#if HAS_ROTARY_ENCODER
lv_obj_t *buttonEcoder,*labelEcoder,*buttonEcoderNarrow;
#endif
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ADVANCED_UI) {
disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = ADVANCED_UI;
@ -89,24 +162,24 @@ void lv_draw_advance_settings(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_para_back);
LV_IMG_DECLARE(bmp_para_arrow);
buttonPausePos = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonPausePos, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
lv_obj_set_size(buttonPausePos, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
buttonPausePos = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonPausePos, PARA_UI_POS_X, PARA_UI_POS_Y);
lv_obj_set_size(buttonPausePos, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);
//lv_obj_set_event_cb(buttonMachine, event_handler);
lv_obj_set_event_cb_mks(buttonPausePos, event_handler, ID_PAUSE_POS, NULL, 0);
lv_btn_set_style(buttonPausePos, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonPausePos, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_style(buttonPausePos, LV_BTN_STYLE_REL, &tft_style_label_rel);
lv_btn_set_style(buttonPausePos, LV_BTN_STYLE_PR, &tft_style_label_pre);
lv_btn_set_layout(buttonPausePos, LV_LAYOUT_OFF);
labelPausePos = lv_label_create(buttonPausePos, NULL); /*Add a label to the button*/
labelPausePos = lv_label_create(buttonPausePos, NULL);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonPausePos);
#endif
buttonPausePosNarrow = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonPausePosNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonPausePosNarrow, event_handler, ID_PAUSE_POS_ARROW, "bmp_arrow.bin", 0);
lv_imgbtn_set_src(buttonPausePosNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
lv_imgbtn_set_src(buttonPausePosNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
lv_obj_set_event_cb_mks(buttonPausePosNarrow, event_handler, ID_PAUSE_POS_ARROW, NULL, 0);
lv_imgbtn_set_src(buttonPausePosNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonPausePosNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonPausePosNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonPausePosNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonPausePosNarrow, LV_LAYOUT_OFF);
@ -114,13 +187,117 @@ void lv_draw_advance_settings(void) {
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_set_style(buttonFilamentSettings, LV_BTN_STYLE_REL, &tft_style_label_rel);
lv_btn_set_style(buttonFilamentSettings, LV_BTN_STYLE_PR, &tft_style_label_pre);
lv_btn_set_layout(buttonFilamentSettings, LV_LAYOUT_OFF);
labelFilamentSettings = lv_label_create(buttonFilamentSettings, NULL);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonFilamentSettings);
#endif
buttonFilamentSettingsNarrow = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonFilamentSettingsNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y*2 + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonFilamentSettingsNarrow, event_handler, ID_FILAMENT_SETTINGS_ARROW, NULL, 0);
lv_imgbtn_set_src(buttonFilamentSettingsNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonFilamentSettingsNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonFilamentSettingsNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonFilamentSettingsNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonFilamentSettingsNarrow, LV_LAYOUT_OFF);
line2 = lv_line_create(lv_scr_act(), NULL);
lv_ex_line(line2, line_points[1]);
#if ENABLED(USE_WIFI_FUNCTION)
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_set_style(buttonWifiSet, LV_BTN_STYLE_REL, &tft_style_label_rel);
lv_btn_set_style(buttonWifiSet, LV_BTN_STYLE_PR, &tft_style_label_pre);
lv_btn_set_layout(buttonWifiSet, LV_LAYOUT_OFF);
labelWifiSet = lv_label_create(buttonWifiSet, NULL);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonWifiSet);
#endif
buttonWifiSetNarrow = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonWifiSetNarrow,PARA_UI_POS_X+PARA_UI_SIZE_X,PARA_UI_POS_Y*3+PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonWifiSetNarrow, event_handler,ID_WIFI_PARA_ARROW, NULL,0);
lv_imgbtn_set_src(buttonWifiSetNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonWifiSetNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonWifiSetNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonWifiSetNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonWifiSetNarrow, LV_LAYOUT_OFF);
lv_obj_t * line3 = lv_line_create(scr, NULL);
lv_ex_line(line3,line_points[2]);
#if HAS_ROTARY_ENCODER
buttonEcoder = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonEcoder, PARA_UI_POS_X,PARA_UI_POS_Y*4);
lv_obj_set_size(buttonEcoder, PARA_UI_SIZE_X,PARA_UI_SIZE_Y);
lv_obj_set_event_cb_mks(buttonEcoder, event_handler,ID_ENCODER_SETTINGS,NULL,0);
lv_btn_set_style(buttonEcoder, LV_BTN_STYLE_REL, &tft_style_label_rel);
lv_btn_set_style(buttonEcoder, LV_BTN_STYLE_PR, &tft_style_label_pre);
lv_btn_set_layout(buttonEcoder, LV_LAYOUT_OFF);
labelEcoder = lv_label_create(buttonEcoder, NULL);
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonEcoder);
buttonEcoderNarrow = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonEcoderNarrow,PARA_UI_POS_X+PARA_UI_SIZE_X,PARA_UI_POS_Y*4+PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonEcoderNarrow, event_handler,ID_ENCODER_SETTINGS_ARROW, NULL,0);
lv_imgbtn_set_src(buttonEcoderNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonEcoderNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonEcoderNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonEcoderNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonEcoderNarrow, LV_LAYOUT_OFF);
lv_obj_t * line4 = lv_line_create(scr, NULL);
lv_ex_line(line4,line_points[3]);
#endif
#elif HAS_ROTARY_ENCODER
buttonEcoder = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonEcoder, PARA_UI_POS_X,PARA_UI_POS_Y*3);
lv_obj_set_size(buttonEcoder, PARA_UI_SIZE_X,PARA_UI_SIZE_Y);
lv_obj_set_event_cb_mks(buttonEcoder, event_handler,ID_ENCODER_SETTINGS,NULL,0);
lv_btn_set_style(buttonEcoder, LV_BTN_STYLE_REL, &tft_style_label_rel);
lv_btn_set_style(buttonEcoder, LV_BTN_STYLE_PR, &tft_style_label_pre);
lv_btn_set_layout(buttonEcoder, LV_LAYOUT_OFF);
labelEcoder = lv_label_create(buttonEcoder, NULL);
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonEcoder);
buttonEcoderNarrow = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonEcoderNarrow,PARA_UI_POS_X+PARA_UI_SIZE_X,PARA_UI_POS_Y*3+PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonEcoderNarrow, event_handler,ID_ENCODER_SETTINGS_ARROW, NULL,0);
lv_imgbtn_set_src(buttonEcoderNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonEcoderNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonEcoderNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonEcoderNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonEcoderNarrow, LV_LAYOUT_OFF);
lv_obj_t * line3 = lv_line_create(scr, NULL);
lv_ex_line(line3,line_points[2]);
#endif
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_ADVANCE_RETURN, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_ADVANCE_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
label_Back = lv_label_create(buttonBack, NULL);
@ -131,10 +308,27 @@ void lv_draw_advance_settings(void) {
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(labelEcoder, machine_menu.EncoderSettings);
lv_obj_align(labelEcoder, buttonEcoder, LV_ALIGN_IN_LEFT_MID,0, 0);
#endif
}
}
void lv_clear_advance_settings() { lv_obj_del(scr); }
void lv_clear_advance_settings() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

203
Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.cpp

@ -0,0 +1,203 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if BOTH(HAS_TFT_LVGL_UI, HAS_BED_PROBE)
#include "lv_conf.h"
#include "draw_ui.h"
#include "../../../../MarlinCore.h"
#include "../../../../module/planner.h"
#include "../../../../module/probe.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_OFFSET_RETURN 1
#define ID_OFFSET_X 2
#define ID_OFFSET_Y 3
#define ID_OFFSET_Z 4
static void event_handler(lv_obj_t * obj, lv_event_t event) {
switch (obj->mks_obj_id) {
case ID_OFFSET_RETURN:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_auto_level_offset_settings();
draw_return_ui();
}
break;
case ID_OFFSET_X:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = x_offset;
lv_clear_auto_level_offset_settings();
lv_draw_number_key();
}
break;
case ID_OFFSET_Y:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = y_offset;
lv_clear_auto_level_offset_settings();
lv_draw_number_key();
}
break;
case ID_OFFSET_Z:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = z_offset;
lv_clear_auto_level_offset_settings();
lv_draw_number_key();
}
break;
}
}
void lv_draw_auto_level_offset_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL;
lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != NOZZLE_PROBE_OFFSET_UI) {
disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = NOZZLE_PROBE_OFFSET_UI;
}
disp_state = NOZZLE_PROBE_OFFSET_UI;
scr = lv_obj_create(NULL, NULL);
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
lv_obj_t * title = lv_label_create(scr, NULL);
lv_obj_set_style(title, &tft_style_label_rel);
lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
lv_label_set_text(title, machine_menu.OffsetConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing());
labelXText = lv_label_create(scr, NULL);
lv_obj_set_style(labelXText, &tft_style_label_rel);
lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
lv_label_set_text(labelXText, machine_menu.Xoffset);
buttonXValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_OFFSET_X, NULL, 0);
lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value);
labelXValue = lv_label_create(buttonXValue, NULL);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
labelYText = lv_label_create(scr, NULL);
lv_obj_set_style(labelYText, &tft_style_label_rel);
lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
lv_label_set_text(labelYText, machine_menu.Yoffset);
buttonYValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_OFFSET_Y, NULL, 0);
lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value);
labelYValue = lv_label_create(buttonYValue, NULL);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
labelZText = lv_label_create(scr, NULL);
lv_obj_set_style(labelZText, &tft_style_label_rel);
lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
lv_label_set_text(labelZText, machine_menu.Zoffset);
buttonZValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_OFFSET_Z, NULL, 0);
lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value);
labelZValue = lv_label_create(buttonZValue, NULL);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
buttonBack = lv_btn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_OFFSET_RETURN, NULL, 0);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
label_Back = lv_label_create(buttonBack, NULL);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonXValue);
lv_group_add_obj(g, buttonYValue);
lv_group_add_obj(g, buttonZValue);
lv_group_add_obj(g, buttonBack);
}
#endif
if (gCfgItems.multiple_language != 0) {
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.1f"), TERN(HAS_PROBE_XY_OFFSET, probe.offset.x, 0));
lv_label_set_text(labelXValue, public_buf_l);
lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.1f"), TERN(HAS_PROBE_XY_OFFSET, probe.offset.y, 0));
lv_label_set_text(labelYValue, public_buf_l);
lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.1f"), probe.offset.z);
lv_label_set_text(labelZValue, public_buf_l);
lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
lv_label_set_text(label_Back, common_menu.text_back);
lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
}
}
void lv_clear_auto_level_offset_settings() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI && HAS_BED_PROBE

33
Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.h

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

352
Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.cpp

@ -0,0 +1,352 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI
#include "lv_conf.h"
#include "draw_ui.h"
#include "../../../../MarlinCore.h"
#include "../../../../gcode/queue.h"
#include "../../../../gcode/gcode.h"
#if HAS_BED_PROBE
#include "../../../../module/probe.h"
#endif
extern lv_group_t * g;
static lv_obj_t * scr;
static lv_obj_t *labelV, *buttonV, * zOffsetText;
#define ID_BABY_STEP_X_P 1
#define ID_BABY_STEP_X_N 2
#define ID_BABY_STEP_Y_P 3
#define ID_BABY_STEP_Y_N 4
#define ID_BABY_STEP_Z_P 5
#define ID_BABY_STEP_Z_N 6
#define ID_BABY_STEP_DIST 7
#define ID_BABY_STEP_RETURN 8
static float babystep_dist=0.01;
static uint8_t has_adjust_z = 0;
static void event_handler(lv_obj_t * obj, lv_event_t event) {
char baby_buf[30]={0};
switch (obj->mks_obj_id) {
case ID_BABY_STEP_X_P:
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
ZERO(baby_buf);
sprintf_P(baby_buf, PSTR("M290 X%.3f"),babystep_dist);
gcode.process_subcommands_now_P(PSTR(baby_buf));
has_adjust_z = 1;
}
break;
case ID_BABY_STEP_X_N:
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
ZERO(baby_buf);
sprintf_P(baby_buf, PSTR("M290 X%.3f"),((float)0 - babystep_dist));
gcode.process_subcommands_now_P(PSTR(baby_buf));
has_adjust_z = 1;
}
break;
case ID_BABY_STEP_Y_P:
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
ZERO(baby_buf);
sprintf_P(baby_buf, PSTR("M290 Y%.3f"), babystep_dist);
gcode.process_subcommands_now_P(PSTR(baby_buf));
has_adjust_z = 1;
}
break;
case ID_BABY_STEP_Y_N:
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
ZERO(baby_buf);
sprintf_P(baby_buf, PSTR("M290 Y%.3f"),((float)0 - babystep_dist));
gcode.process_subcommands_now_P(PSTR(baby_buf));
has_adjust_z = 1;
}
break;
case ID_BABY_STEP_Z_P:
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
ZERO(baby_buf);
sprintf_P(baby_buf, PSTR("M290 Z%.3f"), babystep_dist);
gcode.process_subcommands_now_P(PSTR(baby_buf));
has_adjust_z = 1;
}
break;
case ID_BABY_STEP_Z_N:
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
ZERO(baby_buf);
sprintf_P(baby_buf, PSTR("M290 Z%.3f"),((float)0 - babystep_dist));
gcode.process_subcommands_now_P(PSTR(baby_buf));
has_adjust_z = 1;
}
break;
case ID_BABY_STEP_DIST:
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
if (abs((int)(100 * babystep_dist)) == 1)
babystep_dist = 0.05;
else if (abs((int)(100 * babystep_dist)) == 5)
babystep_dist = 0.1;
else
babystep_dist = 0.01;
disp_baby_step_dist();
}
break;
case ID_BABY_STEP_RETURN:
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
if (has_adjust_z == 1) {
gcode.process_subcommands_now_P(PSTR("M500"));
has_adjust_z = 0;
}
clear_cur_ui();
draw_return_ui();
}
break;
}
}
void lv_draw_baby_stepping(void) {
lv_obj_t *buttonXI, *buttonXD, *buttonYI, *buttonYD, *buttonZI, *buttonZD, *buttonBack;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != BABY_STEP_UI) {
disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = BABY_STEP_UI;
}
disp_state = BABY_STEP_UI;
scr = lv_obj_create(NULL, NULL);
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
lv_obj_t * title = lv_label_create(scr, NULL);
lv_obj_set_style(title, &tft_style_label_rel);
lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
lv_label_set_text(title, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing());
// Create an Image button
buttonXI = lv_imgbtn_create(scr, NULL);
buttonXD = lv_imgbtn_create(scr, NULL);
buttonYI = lv_imgbtn_create(scr, NULL);
buttonYD = lv_imgbtn_create(scr, NULL);
buttonZI = lv_imgbtn_create(scr, NULL);
buttonZD = lv_imgbtn_create(scr, NULL);
buttonV = lv_imgbtn_create(scr, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonXI, event_handler, ID_BABY_STEP_X_P, NULL, 0);
lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_REL, "F:/bmp_xAdd.bin");
lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_PR, "F:/bmp_xAdd.bin");
lv_imgbtn_set_style(buttonXI, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonXI, LV_BTN_STATE_REL, &tft_style_label_rel);
#if 1
lv_obj_set_event_cb_mks(buttonXD, event_handler, ID_BABY_STEP_X_N, NULL, 0);
lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_REL, "F:/bmp_xDec.bin");
lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_PR, "F:/bmp_xDec.bin");
lv_imgbtn_set_style(buttonXD, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonXD, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonYI, event_handler, ID_BABY_STEP_Y_P, NULL, 0);
lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_REL, "F:/bmp_yAdd.bin");
lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_PR, "F:/bmp_yAdd.bin");
lv_imgbtn_set_style(buttonYI, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonYI, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonYD, event_handler, ID_BABY_STEP_Y_N, NULL, 0);
lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_REL, "F:/bmp_yDec.bin");
lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_PR, "F:/bmp_yDec.bin");
lv_imgbtn_set_style(buttonYD, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonYD, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonZI, event_handler, ID_BABY_STEP_Z_P, NULL, 0);
lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_REL, "F:/bmp_zAdd.bin");
lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_PR, "F:/bmp_zAdd.bin");
lv_imgbtn_set_style(buttonZI, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonZI, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonZD, event_handler, ID_BABY_STEP_Z_N, NULL, 0);
lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_REL, "F:/bmp_zDec.bin");
lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_PR, "F:/bmp_zDec.bin");
lv_imgbtn_set_style(buttonZD, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonZD, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonV, event_handler, ID_BABY_STEP_DIST, NULL, 0);
lv_imgbtn_set_style(buttonV, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonV, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_BABY_STEP_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif // if 1
lv_obj_set_pos(buttonXI, INTERVAL_V, titleHeight);
lv_obj_set_pos(buttonYI, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight);
lv_obj_set_pos(buttonZI, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight);
lv_obj_set_pos(buttonV, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight);
lv_obj_set_pos(buttonXD, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
lv_obj_set_pos(buttonYD, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
lv_obj_set_pos(buttonZD, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
// Create labels on the image buttons
lv_btn_set_layout(buttonXI, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonXD, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonYI, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonYD, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonZI, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonZD, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonV, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
lv_obj_t *labelXI = lv_label_create(buttonXI, NULL);
lv_obj_t *labelXD = lv_label_create(buttonXD, NULL);
lv_obj_t *labelYI = lv_label_create(buttonYI, NULL);
lv_obj_t *labelYD = lv_label_create(buttonYD, NULL);
lv_obj_t *labelZI = lv_label_create(buttonZI, NULL);
lv_obj_t *labelZD = lv_label_create(buttonZD, NULL);
labelV = lv_label_create(buttonV, NULL);
lv_obj_t *label_Back = lv_label_create(buttonBack, NULL);
if (gCfgItems.multiple_language != 0) {
lv_label_set_text(labelXI, move_menu.x_add);
lv_obj_align(labelXI, buttonXI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(labelXD, move_menu.x_dec);
lv_obj_align(labelXD, buttonXD, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(labelYI, move_menu.y_add);
lv_obj_align(labelYI, buttonYI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(labelYD, move_menu.y_dec);
lv_obj_align(labelYD, buttonYD, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(labelZI, move_menu.z_add);
lv_obj_align(labelZI, buttonZI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(labelZD, move_menu.z_dec);
lv_obj_align(labelZD, buttonZD, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_Back, common_menu.text_back);
lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
}
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonXI);
lv_group_add_obj(g, buttonXD);
lv_group_add_obj(g, buttonYI);
lv_group_add_obj(g, buttonYD);
lv_group_add_obj(g, buttonZI);
lv_group_add_obj(g, buttonZD);
lv_group_add_obj(g, buttonV);
lv_group_add_obj(g, buttonBack);
}
#endif
disp_baby_step_dist();
zOffsetText = lv_label_create(scr, NULL);
lv_obj_set_style(zOffsetText, &tft_style_label_rel);
lv_obj_set_pos(zOffsetText, 290, TITLE_YPOS);
disp_z_offset_value();
}
void disp_baby_step_dist() {
// char buf[30] = {0};
if ((int)(100 * babystep_dist) == 1) {
lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_baby_move0_01.bin");
lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_baby_move0_01.bin");
}
else if ((int)(100 * babystep_dist) == 5) {
lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_baby_move0_05.bin");
lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_baby_move0_05.bin");
}
else if ((int)(100 * babystep_dist) == 10) {
lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_baby_move0_1.bin");
lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_baby_move0_1.bin");
}
if (gCfgItems.multiple_language != 0) {
if ((int)(100 * babystep_dist) == 1) {
lv_label_set_text(labelV, move_menu.step_001mm);
lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
}
else if ((int)(100 * babystep_dist) == 5) {
lv_label_set_text(labelV, move_menu.step_005mm);
lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
}
else if ((int)(100 * babystep_dist) == 10) {
lv_label_set_text(labelV, move_menu.step_01mm);
lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
}
}
}
void disp_z_offset_value() {
char buf[20];
ZERO(buf);
sprintf_P(buf, PSTR("offset Z: %.3f"), (double)TERN(HAS_BED_PROBE, probe.offset.z, 0));
lv_label_set_text(zOffsetText, buf);
}
void lv_clear_baby_stepping() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

36
Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.h

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

83
Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp

@ -34,9 +34,10 @@
#include "../../../../module/temperature.h"
#include "../../../../module/planner.h"
extern lv_group_t * g;
static lv_obj_t * scr;
static lv_obj_t * labelStep, *buttonStep, *buttonMov, *buttonExt;
static lv_obj_t * labelMov, *labelExt;
static lv_obj_t *labelStep, *buttonStep, *buttonMov, *buttonExt;
static lv_obj_t *labelMov, *labelExt;
static lv_obj_t * printSpeedText;
#define ID_C_ADD 1
@ -175,7 +176,6 @@ void lv_draw_change_speed(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_pic);
// Create an Image button
buttonAdd = lv_imgbtn_create(scr, NULL);
@ -185,38 +185,34 @@ void lv_draw_change_speed(void) {
buttonStep = lv_imgbtn_create(scr, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_C_ADD, "bmp_Add.bin", 0);
lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_C_ADD, NULL, 0);
lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, "F:/bmp_Add.bin");
lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, "F:/bmp_Add.bin");
lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW);
#if 1
lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_C_DEC, "bmp_Dec.bin", 0);
lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_C_DEC, NULL, 0);
lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, "F:/bmp_Dec.bin");
lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, "F:/bmp_Dec.bin");
lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_imgbtn_set_src(buttonMov, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonMov, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonMov, event_handler, ID_C_MOVE, NULL, 0);
lv_imgbtn_set_style(buttonMov, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonMov, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_imgbtn_set_src(buttonExt, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonExt, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonExt, event_handler, ID_C_EXT, NULL, 0);
lv_imgbtn_set_style(buttonExt, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonExt, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_C_STEP, NULL, 0);
lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_C_RETURN, "bmp_return.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_C_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif
@ -253,6 +249,17 @@ void lv_draw_change_speed(void) {
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, buttonMov);
lv_group_add_obj(g, buttonExt);
lv_group_add_obj(g, buttonStep);
lv_group_add_obj(g, buttonBack);
}
#endif
disp_speed_type();
disp_speed_step();
@ -262,13 +269,18 @@ void lv_draw_change_speed(void) {
}
void disp_speed_step() {
if (uiCfg.stepPrintSpeed == 1)
lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_C_STEP, "bmp_step1_percent.bin", 0);
else if (uiCfg.stepPrintSpeed == 5)
lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_C_STEP, "bmp_step5_percent.bin", 0);
else if (uiCfg.stepPrintSpeed == 10)
lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_C_STEP, "bmp_step10_percent.bin", 0);
if (uiCfg.stepPrintSpeed == 1) {
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step1_percent.bin");
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step1_percent.bin");
}
else if (uiCfg.stepPrintSpeed == 5) {
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step5_percent.bin");
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step5_percent.bin");
}
else if (uiCfg.stepPrintSpeed == 10) {
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step10_percent.bin");
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step10_percent.bin");
}
if (gCfgItems.multiple_language != 0) {
if (uiCfg.stepPrintSpeed == 1) {
lv_label_set_text(labelStep, speed_menu.step_1percent);
@ -309,13 +321,17 @@ void disp_print_speed() {
void disp_speed_type() {
switch (speedType) {
case 1:
lv_obj_set_event_cb_mks(buttonExt, event_handler, ID_C_EXT, "bmp_extruct_sel.bin", 0);
lv_obj_set_event_cb_mks(buttonMov, event_handler, ID_C_MOVE, "bmp_mov_changeSpeed.bin", 0);
lv_imgbtn_set_src(buttonMov, LV_BTN_STATE_REL, "F:/bmp_mov_changeSpeed.bin");
lv_imgbtn_set_src(buttonMov, LV_BTN_STATE_PR, "F:/bmp_mov_changeSpeed.bin");
lv_imgbtn_set_src(buttonExt, LV_BTN_STATE_REL, "F:/bmp_extruct_sel.bin");
lv_imgbtn_set_src(buttonExt, LV_BTN_STATE_PR, "F:/bmp_extruct_sel.bin");
break;
default:
lv_obj_set_event_cb_mks(buttonExt, event_handler, ID_C_EXT, "bmp_speed_extruct.bin", 0);
lv_obj_set_event_cb_mks(buttonMov, event_handler, ID_C_MOVE, "bmp_mov_sel.bin", 0);
lv_imgbtn_set_src(buttonMov, LV_BTN_STATE_REL, "F:/bmp_mov_sel.bin");
lv_imgbtn_set_src(buttonMov, LV_BTN_STATE_PR, "F:/bmp_mov_sel.bin");
lv_imgbtn_set_src(buttonExt, LV_BTN_STATE_REL, "F:/bmp_speed_extruct.bin");
lv_imgbtn_set_src(buttonExt, LV_BTN_STATE_PR, "F:/bmp_speed_extruct.bin");
break;
}
lv_obj_refresh_ext_draw_pad(buttonExt);
@ -330,6 +346,11 @@ void disp_speed_type() {
}
}
void lv_clear_change_speed() { lv_obj_del(scr); }
void lv_clear_change_speed() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

455
Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp

@ -41,6 +41,7 @@
#include "../../../../gcode/queue.h"
#include "../../../../module/temperature.h"
#include "../../../../module/planner.h"
#include "../../../../gcode/gcode.h"
#if ENABLED(POWER_LOSS_RECOVERY)
#include "../../../../feature/powerloss.h"
@ -51,20 +52,25 @@
#endif
#include "../../../../gcode/gcode.h"
#include "pic_manager.h"
extern lv_group_t * g;
static lv_obj_t * scr;
static lv_obj_t * tempText1;
static lv_obj_t * filament_bar;
extern uint8_t sel_id;
extern uint8_t once_flag;
extern uint8_t gcode_preview_over;
uint8_t DialogType;
extern int upload_result ;
extern uint32_t upload_time;
extern uint32_t upload_size;
extern uint8_t temperature_change_frequency;
static void btn_ok_event_cb(lv_obj_t * btn, lv_event_t event) {
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
if (DialogType == DIALOG_TYPE_PRINT_FILE) {
if (uiCfg.dialogType == DIALOG_TYPE_PRINT_FILE) {
#if HAS_GCODE_PREVIEW
preview_gcode_prehandle(list_file.file_name[sel_id]);
#endif
@ -108,7 +114,8 @@ static void btn_ok_event_cb(lv_obj_t * btn, lv_event_t event) {
}
#endif
}
else if (DialogType == DIALOG_TYPE_STOP) {
else if (uiCfg.dialogType == DIALOG_TYPE_STOP) {
wait_for_heatup = false;
stop_print_time();
lv_clear_dialog();
lv_draw_ready_print();
@ -130,40 +137,57 @@ static void btn_ok_event_cb(lv_obj_t * btn, lv_event_t event) {
//queue.inject_P(PSTR("G91\nG1 Z10\nG90\nG28 X0 Y0\nM84\nM107"));
#endif
}
else if (DialogType == DIALOG_TYPE_FINISH_PRINT) {
else if (uiCfg.dialogType == DIALOG_TYPE_FINISH_PRINT) {
clear_cur_ui();
lv_draw_ready_print();
}
#if ENABLED(ADVANCED_PAUSE_FEATURE)
else if (DialogType == DIALOG_PAUSE_MESSAGE_WAITING
|| DialogType == DIALOG_PAUSE_MESSAGE_INSERT
|| DialogType == DIALOG_PAUSE_MESSAGE_HEAT
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 (DialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE;
}
else if (DialogType == DIALOG_PAUSE_MESSAGE_RESUME) {
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_RESUME) {
clear_cur_ui();
draw_return_ui();
}
#endif
else if (DialogType == DIALOG_STORE_EEPROM_TIPS) {
else if (uiCfg.dialogType == DIALOG_STORE_EEPROM_TIPS) {
gcode.process_subcommands_now_P(PSTR("M500"));
clear_cur_ui();
draw_return_ui();
}
else if (DialogType == DIALOG_READ_EEPROM_TIPS) {
else if (uiCfg.dialogType == DIALOG_READ_EEPROM_TIPS) {
gcode.process_subcommands_now_P(PSTR("M501"));
clear_cur_ui();
draw_return_ui();
}
else if (DialogType == DIALOG_REVERT_EEPROM_TIPS) {
else if (uiCfg.dialogType == DIALOG_REVERT_EEPROM_TIPS) {
gcode.process_subcommands_now_P(PSTR("M502"));
clear_cur_ui();
draw_return_ui();
}
else if (uiCfg.dialogType == DIALOG_WIFI_CONFIG_TIPS) {
uiCfg.configWifi = 1;
clear_cur_ui();
draw_return_ui();
}
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED) {
uiCfg.filament_heat_completed_load = 1;
}
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED) {
uiCfg.filament_heat_completed_unload = 1;
}
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_COMPLETED
|| uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED
) {
clear_cur_ui();
draw_return_ui();
}
}
}
@ -172,11 +196,35 @@ static void btn_cancel_event_cb(lv_obj_t * btn, lv_event_t event) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
if (DialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
#if ENABLED(ADVANCED_PAUSE_FEATURE)
pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT;
#endif
}
else if ((uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_HEAT)
|| (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_HEAT)
|| (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED)
|| (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED)
) {
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target= uiCfg.desireSprayerTempBak;
clear_cur_ui();
draw_return_ui();
}
else if ((uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOADING)
|| (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOADING)
) {
queue.enqueue_one_P(PSTR("M410"));
uiCfg.filament_rate = 0;
uiCfg.filament_loading_completed = 0;
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();
@ -186,13 +234,15 @@ static void btn_cancel_event_cb(lv_obj_t * btn, lv_event_t event) {
void lv_draw_dialog(uint8_t type) {
lv_obj_t * btnOk = NULL;
lv_obj_t * btnCancel = NULL;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != DIALOG_UI) {
disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = DIALOG_UI;
}
disp_state = DIALOG_UI;
DialogType = type;
uiCfg.dialogType = type;
scr = lv_obj_create(NULL, NULL);
@ -208,7 +258,6 @@ void lv_draw_dialog(uint8_t type) {
lv_refr_now(lv_refr_get_disp_refreshing());
//LV_IMG_DECLARE(bmp_pic);
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
@ -231,60 +280,151 @@ void lv_draw_dialog(uint8_t type) {
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_obj_t * labelDialog = lv_label_create(scr, NULL);
lv_obj_t *labelDialog = lv_label_create(scr, NULL);
lv_obj_set_style(labelDialog, &tft_style_label_rel);
if (DialogType == DIALOG_TYPE_FINISH_PRINT || DialogType == DIALOG_PAUSE_MESSAGE_RESUME) {
lv_obj_t * 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_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel); // Set the button's released style
lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr); // Set the button's pressed style
lv_obj_t * labelOk = lv_label_create(btnOk, NULL); // Add a label to the button
lv_label_set_text(labelOk, print_file_dialog_menu.confirm); // Set the labels text
if (uiCfg.dialogType == DIALOG_TYPE_FINISH_PRINT || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_RESUME) {
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_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel); // Set the button's released style
lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr); // Set the button's pressed style
lv_obj_t *labelOk = lv_label_create(btnOk, NULL); // Add a label to the button
lv_label_set_text(labelOk, print_file_dialog_menu.confirm); // Set the labels text
}
else if (DialogType == DIALOG_PAUSE_MESSAGE_WAITING
|| DialogType == DIALOG_PAUSE_MESSAGE_INSERT
|| DialogType == DIALOG_PAUSE_MESSAGE_HEAT
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_WAITING
|| uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_INSERT
|| uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEAT
) {
lv_obj_t * btnOk = lv_btn_create(scr, NULL); // Add a button the current screen
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_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel); // Set the button's released style
lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr); // Set the button's pressed style
lv_obj_t * labelOk = lv_label_create(btnOk, NULL); // Add a label to the button
lv_obj_t *labelOk = lv_label_create(btnOk, NULL); // Add a label to the button
lv_label_set_text(labelOk, print_file_dialog_menu.confirm); // Set the labels text
}
else if (DialogType == DIALOG_PAUSE_MESSAGE_PAUSING
|| DialogType == DIALOG_PAUSE_MESSAGE_CHANGING
|| DialogType == DIALOG_PAUSE_MESSAGE_UNLOAD
|| DialogType == DIALOG_PAUSE_MESSAGE_LOAD
|| DialogType == DIALOG_PAUSE_MESSAGE_PURGE
|| DialogType == DIALOG_PAUSE_MESSAGE_RESUME
|| DialogType == DIALOG_PAUSE_MESSAGE_HEATING
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_PAUSING
|| 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
}
else if (uiCfg.dialogType == WIFI_ENABLE_TIPS) {
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_set_style(btnCancel, LV_BTN_STYLE_REL, &style_btn_rel);
lv_btn_set_style(btnCancel, LV_BTN_STYLE_PR, &style_btn_pr);
lv_obj_t *labelCancel = lv_label_create(btnCancel, NULL);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
}
else if (uiCfg.dialogType == DIALOG_TRANSFER_NO_DEVICE) {
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_set_style(btnCancel, LV_BTN_STYLE_REL, &style_btn_rel);
lv_btn_set_style(btnCancel, LV_BTN_STYLE_PR, &style_btn_pr);
lv_obj_t *labelCancel = lv_label_create(btnCancel, NULL);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
}
#if ENABLED(USE_WIFI_FUNCTION)
else if (uiCfg.dialogType == DIALOG_TYPE_UPLOAD_FILE) {
if (upload_result == 2) {
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_set_style(btnCancel, LV_BTN_STYLE_REL, &style_btn_rel);
lv_btn_set_style(btnCancel, LV_BTN_STYLE_PR, &style_btn_pr);
lv_obj_t *labelCancel = lv_label_create(btnCancel, NULL);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
}
else if (upload_result == 3) {
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_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel);
lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr);
lv_obj_t *labelOk = lv_label_create(btnOk, NULL);
lv_label_set_text(labelOk, print_file_dialog_menu.confirm);
}
}
#endif //USE_WIFI_FUNCTION
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_HEAT
|| uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_HEAT
) {
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_set_style(btnCancel, LV_BTN_STYLE_REL, &style_btn_rel);
lv_btn_set_style(btnCancel, LV_BTN_STYLE_PR, &style_btn_pr);
lv_obj_t *labelCancel = lv_label_create(btnCancel, NULL);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
tempText1 = lv_label_create(scr, NULL);
lv_obj_set_style(tempText1, &tft_style_label_rel);
filament_sprayer_temp();
}
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_COMPLETED
|| uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED
) {
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_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel);
lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr);
lv_obj_t *labelOk = lv_label_create(btnOk, NULL);
lv_label_set_text(labelOk, print_file_dialog_menu.confirm);
}
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOADING
|| uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOADING
) {
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_set_style(btnCancel, LV_BTN_STYLE_REL, &style_btn_rel);
lv_btn_set_style(btnCancel, LV_BTN_STYLE_PR, &style_btn_pr);
lv_obj_t *labelCancel = lv_label_create(btnCancel, NULL);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
filament_bar = lv_bar_create(scr, NULL);
lv_obj_set_pos(filament_bar, (TFT_WIDTH-400)/2, ((TFT_HEIGHT - titleHeight)-40)/2);
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_anim_time(filament_bar, 1000);
lv_bar_set_value(filament_bar, 0, LV_ANIM_ON);
}
else {
lv_obj_t * btnOk = lv_btn_create(scr, NULL); // Add a button the current screen
btnOk = lv_btn_create(scr, NULL); // Add a button the current screen
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_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel); // Set the button's released style
lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr); // Set the button's pressed style
lv_obj_t * labelOk = lv_label_create(btnOk, NULL); // Add a label to the button
lv_obj_t *labelOk = lv_label_create(btnOk, NULL); // Add a label to the button
lv_obj_t * btnCancel = lv_btn_create(scr, NULL); // Add a button the current screen
btnCancel = lv_btn_create(scr, NULL); // Add a button the current screen
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_set_style(btnCancel, LV_BTN_STYLE_REL, &style_btn_rel); // Set the button's released style
lv_btn_set_style(btnCancel, LV_BTN_STYLE_PR, &style_btn_pr); // Set the button's pressed style
lv_obj_t * labelCancel = lv_label_create(btnCancel, NULL); // Add a label to the button
lv_obj_t *labelCancel = lv_label_create(btnCancel, NULL); // Add a label to the button
if (DialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
lv_label_set_text(labelOk, pause_msg_menu.purgeMore); // Set the labels text
lv_label_set_text(labelCancel, pause_msg_menu.continuePrint);
}
@ -293,82 +433,271 @@ void lv_draw_dialog(uint8_t type) {
lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
}
}
if (DialogType == DIALOG_TYPE_PRINT_FILE) {
if (uiCfg.dialogType == DIALOG_TYPE_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_t * labelFile = lv_label_create(scr, NULL);
lv_obj_t *labelFile = lv_label_create(scr, NULL);
lv_obj_set_style(labelFile, &tft_style_label_rel);
lv_label_set_text(labelFile, list_file.long_name[sel_id]);
lv_obj_align(labelFile, NULL, LV_ALIGN_CENTER, 0, -60);
}
else if (DialogType == DIALOG_TYPE_STOP) {
else if (uiCfg.dialogType == DIALOG_TYPE_STOP) {
lv_label_set_text(labelDialog, print_file_dialog_menu.cancle_print);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (DialogType == DIALOG_TYPE_FINISH_PRINT) {
else if (uiCfg.dialogType == DIALOG_TYPE_FINISH_PRINT) {
lv_label_set_text(labelDialog, print_file_dialog_menu.print_finish);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (DialogType == DIALOG_PAUSE_MESSAGE_PAUSING) {
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_PAUSING) {
lv_label_set_text(labelDialog, pause_msg_menu.pausing);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (DialogType == DIALOG_PAUSE_MESSAGE_CHANGING) {
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_CHANGING) {
lv_label_set_text(labelDialog, pause_msg_menu.changing);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (DialogType == DIALOG_PAUSE_MESSAGE_UNLOAD) {
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_UNLOAD) {
lv_label_set_text(labelDialog, pause_msg_menu.unload);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (DialogType == DIALOG_PAUSE_MESSAGE_WAITING) {
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_WAITING) {
lv_label_set_text(labelDialog, pause_msg_menu.waiting);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (DialogType == DIALOG_PAUSE_MESSAGE_INSERT) {
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_INSERT) {
lv_label_set_text(labelDialog, pause_msg_menu.insert);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (DialogType == DIALOG_PAUSE_MESSAGE_LOAD) {
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_LOAD) {
lv_label_set_text(labelDialog, pause_msg_menu.load);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (DialogType == DIALOG_PAUSE_MESSAGE_PURGE) {
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_PURGE) {
lv_label_set_text(labelDialog, pause_msg_menu.purge);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (DialogType == DIALOG_PAUSE_MESSAGE_RESUME) {
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_RESUME) {
lv_label_set_text(labelDialog, pause_msg_menu.resume);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (DialogType == DIALOG_PAUSE_MESSAGE_HEAT) {
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEAT) {
lv_label_set_text(labelDialog, pause_msg_menu.heat);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (DialogType == DIALOG_PAUSE_MESSAGE_HEATING) {
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEATING) {
lv_label_set_text(labelDialog, pause_msg_menu.heating);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (DialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
lv_label_set_text(labelDialog, pause_msg_menu.option);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (DialogType == DIALOG_STORE_EEPROM_TIPS) {
else if (uiCfg.dialogType == DIALOG_STORE_EEPROM_TIPS) {
lv_label_set_text(labelDialog, eeprom_menu.storeTips);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (DialogType == DIALOG_READ_EEPROM_TIPS) {
else if (uiCfg.dialogType == DIALOG_READ_EEPROM_TIPS) {
lv_label_set_text(labelDialog, eeprom_menu.readTips);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (DialogType == DIALOG_REVERT_EEPROM_TIPS) {
else if (uiCfg.dialogType == DIALOG_REVERT_EEPROM_TIPS) {
lv_label_set_text(labelDialog, eeprom_menu.revertTips);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (uiCfg.dialogType == DIALOG_WIFI_CONFIG_TIPS) {
lv_label_set_text(labelDialog, machine_menu.wifiConfigTips);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (uiCfg.dialogType == 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);
}
else if (uiCfg.dialogType == DIALOG_TRANSFER_NO_DEVICE) {
lv_label_set_text(labelDialog, DIALOG_UPDATE_NO_DEVICE_EN);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
#if ENABLED(USE_WIFI_FUNCTION)
else if (uiCfg.dialogType == DIALOG_TYPE_UPLOAD_FILE) {
if (upload_result == 1) {
lv_label_set_text(labelDialog, DIALOG_UPLOAD_ING_EN);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (upload_result == 2) {
lv_label_set_text(labelDialog, DIALOG_UPLOAD_ERROR_EN);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (upload_result == 3) {
char buf[200];
int _index = 0;
ZERO(buf);
strcpy(buf, DIALOG_UPLOAD_FINISH_EN);
_index = strlen(buf);
buf[_index] = '\n';
_index++;
strcat(buf, DIALOG_UPLOAD_SIZE_EN);
_index = strlen(buf);
buf[_index] = ':';
_index++;
sprintf(&buf[_index], " %d KBytes\n", (int)(upload_size / 1024));
strcat(buf, DIALOG_UPLOAD_TIME_EN);
_index = strlen(buf);
buf[_index] = ':';
_index++;
sprintf(&buf[_index], " %d s\n", (int)upload_time);
strcat(buf, DIALOG_UPLOAD_SPEED_EN);
_index = strlen(buf);
buf[_index] = ':';
_index++;
sprintf(&buf[_index], " %d KBytes/s\n", (int)(upload_size / upload_time / 1024));
lv_label_set_text(labelDialog, buf);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
}
#endif //USE_WIFI_FUNCTION
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_HEAT) {
lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_heat);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED) {
lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_heat_confirm);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_HEAT) {
lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_heat);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED) {
lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_heat_confirm);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_COMPLETED) {
lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_completed);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED) {
lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_completed);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
}
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOADING) {
lv_label_set_text(labelDialog, filament_menu.filament_dialog_loading);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -70);
}
else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOADING) {
lv_label_set_text(labelDialog, filament_menu.filament_dialog_unloading);
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -70);
}
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
if (btnOk) lv_group_add_obj(g, btnOk);
if (btnCancel) lv_group_add_obj(g, btnCancel);
}
#endif
}
void filament_sprayer_temp() {
char buf[20] = {0};
public_buf_l[0] = '\0';
if (uiCfg.curSprayerChoose < 1)
strcat(public_buf_l, preheat_menu.ext1);
else
strcat(public_buf_l, preheat_menu.ext2);
sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target);
strcat_P(public_buf_l, PSTR(": "));
strcat(public_buf_l, buf);
lv_label_set_text(tempText1, public_buf_l);
lv_obj_align(tempText1, NULL, LV_ALIGN_CENTER, 0, -50);
}
void filament_dialog_handle() {
if ((temperature_change_frequency == 1)
&& ((uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_HEAT)
|| (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_HEAT))
) {
filament_sprayer_temp();
temperature_change_frequency = 0;
}
if (uiCfg.filament_heat_completed_load == 1) {
uiCfg.filament_heat_completed_load = 0;
lv_clear_dialog();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOADING);
planner.synchronize();
uiCfg.filament_loading_time_flg = 1;
uiCfg.filament_loading_time_cnt = 0;
ZERO(public_buf_m);
sprintf_P(public_buf_m,PSTR("T%d\nG91\nG1 E%d F%d\nG90"),uiCfg.curSprayerChoose,gCfgItems.filamentchange_load_length,gCfgItems.filamentchange_load_speed);
queue.inject_P(PSTR(public_buf_m));
//gcode.process_subcommands_now_P(PSTR(public_buf_m));
}
if (uiCfg.filament_heat_completed_unload == 1) {
uiCfg.filament_heat_completed_unload = 0;
lv_clear_dialog();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOADING);
planner.synchronize();
uiCfg.filament_unloading_time_flg = 1;
uiCfg.filament_unloading_time_cnt = 0;
ZERO(public_buf_m);
sprintf_P(public_buf_m,PSTR("T%d\nG91\nG1 E-%d F%d\nG90"),uiCfg.curSprayerChoose,gCfgItems.filamentchange_unload_length,gCfgItems.filamentchange_unload_speed);
queue.inject_P(PSTR(public_buf_m));
}
if (((abs((int)((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius - gCfgItems.filament_limit_temper)) <= 1)
|| ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius > gCfgItems.filament_limit_temper))
&& (uiCfg.filament_load_heat_flg == 1)
) {
uiCfg.filament_load_heat_flg = 0;
lv_clear_dialog();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED);
}
if (uiCfg.filament_loading_completed == 1) {
uiCfg.filament_rate = 0;
uiCfg.filament_loading_completed = 0;
lv_clear_dialog();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_COMPLETED);
}
if (((abs((int)((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius - gCfgItems.filament_limit_temper)) <= 1)
|| ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius > gCfgItems.filament_limit_temper))
&& (uiCfg.filament_unload_heat_flg == 1)
) {
uiCfg.filament_unload_heat_flg = 0;
lv_clear_dialog();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED);
}
if (uiCfg.filament_unloading_completed == 1) {
uiCfg.filament_rate = 0;
uiCfg.filament_unloading_completed = 0;
lv_clear_dialog();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED);
}
if ( uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOADING
|| uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOADING
) lv_filament_setbar();
}
void lv_clear_dialog() { lv_obj_del(scr); }
void lv_filament_setbar() {
lv_bar_set_value(filament_bar, uiCfg.filament_rate, LV_ANIM_ON);
}
void lv_clear_dialog() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

5
Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h

@ -69,6 +69,8 @@
#define DIALOG_READ_EEPROM_TIPS 33
#define DIALOG_REVERT_EEPROM_TIPS 34
#define DIALOG_WIFI_CONFIG_TIPS 35
#define DIALOG_TRANSFER_NO_DEVICE 36
#define BTN_OK_X 100
#define BTN_OK_Y 180
#define BTN_CANCEL_X 280
@ -76,6 +78,9 @@
extern void lv_draw_dialog(uint8_t type);
extern void lv_clear_dialog();
extern void filament_sprayer_temp();
extern void filament_dialog_handle();
extern void lv_filament_setbar();
//extern void disp_temp_ready_print();
#ifdef __cplusplus

139
Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.cpp

@ -28,6 +28,7 @@
#include "../../../../MarlinCore.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_EEPROM_RETURN 1
@ -48,26 +49,25 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
draw_return_ui();
}
break;
case ID_EEPROM_STORE:
if (event == LV_EVENT_CLICKED) {
#if 0
case ID_EEPROM_STORE:
if (event == LV_EVENT_CLICKED) {
}
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;
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;
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_eeprom_settings();
lv_draw_dialog(DIALOG_STORE_EEPROM_TIPS);
}
break;
#if 0
case ID_EEPROM_READ:
if (event == LV_EVENT_CLICKED) {
@ -111,10 +111,10 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
void lv_draw_eeprom_settings(void) {
lv_obj_t *buttonBack, *label_Back;
//lv_obj_t *buttonStore,*labelStore,*buttonStoreNarrow;
lv_obj_t *buttonStore,*labelStore,*buttonStoreNarrow;
//lv_obj_t *buttonRead,*labelRead,*buttonReadNarrow;
lv_obj_t *buttonRevert, *labelRevert, *buttonRevertNarrow;
lv_obj_t * line1; // * line2,* line3;
lv_obj_t * line1, * line2; //* line3;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != EEPROM_SETTINGS_UI) {
disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = EEPROM_SETTINGS_UI;
@ -134,53 +134,6 @@ void lv_draw_eeprom_settings(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_para_back);
LV_IMG_DECLARE(bmp_para_arrow);
#if 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); /*Set its position*/
lv_obj_set_size(buttonStore, 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(buttonStore, event_handler, ID_EEPROM_STORE, NULL, 0);
lv_btn_set_style(buttonStore, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonStore, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonStore, LV_LAYOUT_OFF);
labelStore = lv_label_create(buttonStore, NULL); /*Add a label to the button*/
buttonStoreNarrow = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonStoreNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonStoreNarrow, event_handler, ID_EEPROM_STORE_ARROW, "bmp_arrow.bin", 0);
lv_imgbtn_set_src(buttonStoreNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
lv_imgbtn_set_src(buttonStoreNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
lv_imgbtn_set_style(buttonStoreNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonStoreNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonStoreNarrow, LV_LAYOUT_OFF);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonRead = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonRead, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/
lv_obj_set_size(buttonRead, 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(buttonRead, event_handler, ID_EEPROM_READ, NULL, 0);
lv_btn_set_style(buttonRead, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonRead, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonRead, LV_LAYOUT_OFF);
labelRead = lv_label_create(buttonRead, NULL); /*Add a label to the button*/
buttonReadNarrow = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonReadNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonReadNarrow, event_handler, ID_EEPROM_READ_ARROW, "bmp_arrow.bin", 0);
lv_imgbtn_set_src(buttonReadNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
lv_imgbtn_set_src(buttonReadNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
lv_imgbtn_set_style(buttonReadNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonReadNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonReadNarrow, LV_LAYOUT_OFF);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
#endif // if 0
buttonRevert = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonRevert, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
lv_obj_set_size(buttonRevert, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
@ -193,9 +146,9 @@ void lv_draw_eeprom_settings(void) {
buttonRevertNarrow = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonRevertNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonRevertNarrow, event_handler, ID_EEPROM_REVERT_ARROW, "bmp_arrow.bin", 0);
lv_imgbtn_set_src(buttonRevertNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
lv_imgbtn_set_src(buttonRevertNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
lv_obj_set_event_cb_mks(buttonRevertNarrow, event_handler, ID_EEPROM_REVERT_ARROW, NULL, 0);
lv_imgbtn_set_src(buttonRevertNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonRevertNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonRevertNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonRevertNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonRevertNarrow, LV_LAYOUT_OFF);
@ -205,10 +158,32 @@ void lv_draw_eeprom_settings(void) {
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_set_style(buttonStore, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonStore, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonStore, LV_LAYOUT_OFF);
labelStore = lv_label_create(buttonStore, NULL); /*Add a label to the button*/
buttonStoreNarrow = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonStoreNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonStoreNarrow, event_handler, ID_EEPROM_STORE_ARROW, NULL, 0);
lv_imgbtn_set_src(buttonStoreNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonStoreNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonStoreNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonStoreNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonStoreNarrow, LV_LAYOUT_OFF);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_EEPROM_RETURN, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_EEPROM_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
@ -220,8 +195,8 @@ void lv_draw_eeprom_settings(void) {
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(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);
@ -229,9 +204,21 @@ void lv_draw_eeprom_settings(void) {
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() { lv_obj_del(scr); }
void lv_clear_eeprom_settings() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

172
Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.cpp

@ -0,0 +1,172 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI
#include "lv_conf.h"
#include "draw_ui.h"
#include "../../../../MarlinCore.h"
#include "../../../../module/planner.h"
#include "../../../../module/stepper/indirection.h"
#include "../../../../feature/tmc_util.h"
#include "../../../../gcode/gcode.h"
#include "../../../../module/planner.h"
#if BUTTONS_EXIST(EN1, EN2)
extern lv_group_t * g;
static lv_obj_t * scr;
static lv_obj_t * buttonEncoderState = NULL;
static lv_obj_t *labelEncoderState = NULL;
#define ID_ENCODER_RETURN 1
#define ID_ENCODER_STATE 2
static void event_handler(lv_obj_t * obj, lv_event_t event) {
switch (obj->mks_obj_id) {
case ID_ENCODER_RETURN:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_encoder_settings();
draw_return_ui();
}
break;
case ID_ENCODER_STATE:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
if (gCfgItems.encoder_enable) {
gCfgItems.encoder_enable = false;
lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
lv_label_set_text(labelEncoderState, machine_menu.disable);
update_spi_flash();
}
else {
gCfgItems.encoder_enable = true;
lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
lv_label_set_text(labelEncoderState, machine_menu.enable);
update_spi_flash();
}
}
break;
}
}
void lv_draw_encoder_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL;
lv_obj_t *labelEncoderTips = NULL;
lv_obj_t * line1 = NULL;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ENCODER_SETTINGS_UI) {
disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = ENCODER_SETTINGS_UI;
}
disp_state = ENCODER_SETTINGS_UI;
scr = lv_obj_create(NULL, NULL);
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
lv_obj_t * title = lv_label_create(scr, NULL);
lv_obj_set_style(title, &tft_style_label_rel);
lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
lv_label_set_text(title, machine_menu.EncoderConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing());
labelEncoderTips = lv_label_create(scr, NULL);
lv_obj_set_style(labelEncoderTips, &tft_style_label_rel);
lv_obj_set_pos(labelEncoderTips, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
lv_label_set_text(labelEncoderTips, machine_menu.EncoderConfText);
buttonEncoderState = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonEncoderState, PARA_UI_STATE_POS_X, PARA_UI_POS_Y + PARA_UI_STATE_V);
if (gCfgItems.encoder_enable) {
lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
}
else {
lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
}
lv_obj_set_event_cb_mks(buttonEncoderState, event_handler, ID_ENCODER_STATE, NULL, 0);
lv_imgbtn_set_style(buttonEncoderState, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonEncoderState, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonEncoderState, LV_LAYOUT_OFF);
labelEncoderState = lv_label_create(buttonEncoderState, NULL);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_ENCODER_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
label_Back = lv_label_create(buttonBack, NULL);
if (gCfgItems.encoder_enable) {
lv_label_set_text(labelEncoderState, machine_menu.enable);
lv_obj_align(labelEncoderState, buttonEncoderState, LV_ALIGN_CENTER, 0, 0);
}
else {
lv_label_set_text(labelEncoderState, machine_menu.disable);
lv_obj_align(labelEncoderState, buttonEncoderState, LV_ALIGN_CENTER, 0, 0);
}
lv_label_set_text(label_Back, common_menu.text_back);
lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonEncoderState);
lv_group_add_obj(g, buttonBack);
}
#endif
}
void lv_clear_encoder_settings() {
#if HAS_ROTARY_ENCODER
lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // BUTTONS_EXIST(EN1, EN2)
#endif // HAS_TFT_LVGL_UI

33
Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.h

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

97
Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp

@ -35,10 +35,11 @@
#include "../../../../gcode/queue.h"
static lv_obj_t * scr;
extern lv_group_t* g;
static lv_obj_t * buttoType, *buttonStep, *buttonSpeed;
static lv_obj_t * labelType;
static lv_obj_t * labelStep;
static lv_obj_t * labelSpeed;
static lv_obj_t *labelType;
static lv_obj_t *labelStep;
static lv_obj_t *labelSpeed;
static lv_obj_t * tempText;
static lv_obj_t * ExtruText;
@ -171,8 +172,6 @@ void lv_draw_extrusion(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_pic);
// Create image buttons
buttonAdd = lv_imgbtn_create(scr, NULL);
buttonDec = lv_imgbtn_create(scr, NULL);
@ -181,37 +180,35 @@ void lv_draw_extrusion(void) {
buttonSpeed = lv_imgbtn_create(scr, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_E_ADD, "bmp_in.bin", 0);
lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_E_ADD, NULL, 0);
lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, "F:/bmp_in.bin");
lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, "F:/bmp_in.bin");
lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW);
#if 1
lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_E_DEC, "bmp_out.bin", 0);
lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_E_DEC, NULL, 0);
lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, "F:/bmp_out.bin");
lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, "F:/bmp_out.bin");
lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttoType, event_handler, ID_E_TYPE, NULL, 0);
lv_imgbtn_set_style(buttoType, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttoType, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_E_STEP, NULL, 0);
lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_E_SPEED, NULL, 0);
lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_E_RETURN, "bmp_return.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_E_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif
@ -249,6 +246,17 @@ void lv_draw_extrusion(void) {
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, buttoType);
lv_group_add_obj(g, buttonStep);
lv_group_add_obj(g, buttonSpeed);
lv_group_add_obj(g, buttonBack);
}
#endif
disp_ext_type();
disp_ext_step();
disp_ext_speed();
@ -264,14 +272,16 @@ void lv_draw_extrusion(void) {
void disp_ext_type() {
if (uiCfg.curSprayerChoose == 1) {
lv_obj_set_event_cb_mks(buttoType, event_handler, ID_E_TYPE, "bmp_extru2.bin", 0);
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru2.bin");
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru2.bin");
if (gCfgItems.multiple_language != 0) {
lv_label_set_text(labelType, extrude_menu.ext2);
lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
}
}
else {
lv_obj_set_event_cb_mks(buttoType, event_handler, ID_E_TYPE, "bmp_extru1.bin", 0);
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru1.bin");
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru1.bin");
if (gCfgItems.multiple_language != 0) {
lv_label_set_text(labelType, extrude_menu.ext1);
lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
@ -280,12 +290,18 @@ void disp_ext_type() {
}
void disp_ext_speed() {
if (uiCfg.extruSpeed == 20)
lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_E_SPEED, "bmp_speed_high.bin", 0);
else if (uiCfg.extruSpeed == 1)
lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_E_SPEED, "bmp_speed_slow.bin", 0);
else
lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_E_SPEED, "bmp_speed_normal.bin", 0);
if (uiCfg.extruSpeed == 20) {
lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_REL, "F:/bmp_speed_high.bin");
lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, "F:/bmp_speed_high.bin");
}
else if (uiCfg.extruSpeed == 1) {
lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_REL, "F:/bmp_speed_slow.bin");
lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, "F:/bmp_speed_slow.bin");
}
else {
lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_REL, "F:/bmp_speed_normal.bin");
lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, "F:/bmp_speed_normal.bin");
}
if (gCfgItems.multiple_language != 0) {
if (uiCfg.extruSpeed == 20) {
@ -348,12 +364,18 @@ void disp_extru_amount() {
}
void disp_ext_step() {
if (uiCfg.extruStep == 1)
lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_E_STEP, "bmp_step1_mm.bin", 0);
else if (uiCfg.extruStep == 5)
lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_E_STEP, "bmp_step5_mm.bin", 0);
else if (uiCfg.extruStep == 10)
lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_E_STEP, "bmp_step10_mm.bin", 0);
if (uiCfg.extruStep == 1) {
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step1_mm.bin");
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step1_mm.bin");
}
else if (uiCfg.extruStep == 5) {
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step5_mm.bin");
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step5_mm.bin");
}
else if (uiCfg.extruStep == 10) {
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step10_mm.bin");
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step10_mm.bin");
}
if (gCfgItems.multiple_language != 0) {
if (uiCfg.extruStep == 1) {
@ -371,6 +393,11 @@ void disp_ext_step() {
}
}
void lv_clear_extrusion() { lv_obj_del(scr); }
void lv_clear_extrusion() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

56
Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp

@ -35,6 +35,7 @@
#include "../../../../gcode/queue.h"
#include "../../../../gcode/gcode.h"
extern lv_group_t * g;
static lv_obj_t * scr;
static lv_obj_t * fanText;
@ -138,8 +139,6 @@ void lv_draw_fan(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_pic);
// Create an Image button
buttonAdd = lv_imgbtn_create(scr, NULL);
buttonDec = lv_imgbtn_create(scr, NULL);
@ -148,41 +147,41 @@ void lv_draw_fan(void) {
buttonOff = lv_imgbtn_create(scr, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_F_ADD, "bmp_Add.bin", 0);
lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_F_ADD, NULL, 0);
lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, "F:/bmp_Add.bin");
lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, "F:/bmp_Add.bin");
lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW);
#if 1
lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_F_DEC, "bmp_Dec.bin", 0);
lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_F_DEC, NULL, 0);
lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, "F:/bmp_Dec.bin");
lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, "F:/bmp_Dec.bin");
lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonHigh, event_handler,ID_F_HIGH,"bmp_speed255.bin",0);
lv_imgbtn_set_src(buttonHigh, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonHigh, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonHigh, event_handler,ID_F_HIGH, NULL,0);
lv_imgbtn_set_src(buttonHigh, LV_BTN_STATE_REL, "F:/bmp_speed255.bin");
lv_imgbtn_set_src(buttonHigh, LV_BTN_STATE_PR, "F:/bmp_speed255.bin");
lv_imgbtn_set_style(buttonHigh, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonHigh, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonMid, event_handler,ID_F_MID,"bmp_speed127.bin",0);
lv_imgbtn_set_src(buttonMid, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonMid, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonMid, event_handler,ID_F_MID, NULL,0);
lv_imgbtn_set_src(buttonMid, LV_BTN_STATE_REL, "F:/bmp_speed127.bin");
lv_imgbtn_set_src(buttonMid, LV_BTN_STATE_PR, "F:/bmp_speed127.bin");
lv_imgbtn_set_style(buttonMid, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonMid, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonOff, event_handler,ID_F_OFF,"bmp_speed0.bin",0);
lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonOff, event_handler,ID_F_OFF, NULL,0);
lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_REL, "F:/bmp_speed0.bin");
lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_PR, "F:/bmp_speed0.bin");
lv_imgbtn_set_style(buttonOff, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonOff, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonBack, event_handler,ID_F_RETURN,"bmp_return.bin",0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonBack, event_handler,ID_F_RETURN, NULL,0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
@ -229,6 +228,16 @@ void lv_draw_fan(void) {
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(scr, NULL);
lv_obj_set_style(fanText, &tft_style_label_rel);
@ -246,6 +255,11 @@ void disp_fan_value() {
lv_obj_align(fanText, NULL, LV_ALIGN_CENTER, 0, -65);
}
void lv_clear_fan() { lv_obj_del(scr); }
void lv_clear_fan() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

270
Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp

@ -0,0 +1,270 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI
#include "lv_conf.h"
#include "draw_ui.h"
#include "../../../../MarlinCore.h"
#include "../../../../module/temperature.h"
#include "../../../../gcode/queue.h"
#include "../../../../gcode/gcode.h"
#include "../../../../module/motion.h"
#include "../../../../module/planner.h"
extern lv_group_t * g;
static lv_obj_t * scr;
static lv_obj_t *buttoType;
static lv_obj_t *labelType;
static lv_obj_t * tempText1;
#define ID_FILAMNT_IN 1
#define ID_FILAMNT_OUT 2
#define ID_FILAMNT_TYPE 3
#define ID_FILAMNT_RETURN 4
extern feedRate_t feedrate_mm_s;
static void event_handler(lv_obj_t * obj, lv_event_t event) {
switch (obj->mks_obj_id) {
case ID_FILAMNT_IN:
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
uiCfg.filament_load_heat_flg = 1;
if ((abs(thermalManager.temp_hotend[uiCfg.curSprayerChoose].target - thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius) <= 1)
|| (gCfgItems.filament_limit_temper <= thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius)) {
lv_clear_filament_change();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED);
}
else {
lv_clear_filament_change();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_HEAT);
if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].target < gCfgItems.filament_limit_temper) {
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = gCfgItems.filament_limit_temper;
thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
}
}
}
break;
case ID_FILAMNT_OUT:
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
uiCfg.filament_unload_heat_flg=1;
if ((thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > 0)
&& ((abs((int)((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target - thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius)) <= 1)
|| ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= gCfgItems.filament_limit_temper))
) {
lv_clear_filament_change();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED);
}
else {
lv_clear_filament_change();
lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_HEAT);
if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].target < gCfgItems.filament_limit_temper) {
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = gCfgItems.filament_limit_temper;
thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
}
filament_sprayer_temp();
}
}
break;
case ID_FILAMNT_TYPE:
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
#if HAS_MULTI_EXTRUDER
if (uiCfg.curSprayerChoose == 0)
uiCfg.curSprayerChoose = 1;
else if (uiCfg.curSprayerChoose == 1)
uiCfg.curSprayerChoose = 0;
#endif
disp_filament_type();
}
break;
case ID_FILAMNT_RETURN:
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
#if HAS_MULTI_EXTRUDER
if (uiCfg.print_state != IDLE && uiCfg.print_state != REPRINTED)
gcode.process_subcommands_now_P(uiCfg.curSprayerChoose_bak == 1 ? PSTR("T1") : PSTR("T0"));
#endif
feedrate_mm_s = (float)uiCfg.moveSpeed_bak;
if (uiCfg.print_state == PAUSED)
planner.set_e_position_mm((destination.e = current_position.e = uiCfg.current_e_position_bak));
//current_position.e = destination.e = uiCfg.current_e_position_bak;
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = uiCfg.desireSprayerTempBak;
clear_cur_ui();
draw_return_ui();
}
break;
}
}
void lv_draw_filament_change(void) {
lv_obj_t *buttonIn, *buttonOut;
lv_obj_t *buttonBack;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != FILAMENTCHANGE_UI) {
disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = FILAMENTCHANGE_UI;
}
disp_state = FILAMENTCHANGE_UI;
scr = lv_obj_create(NULL, NULL);
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
lv_obj_t * title = lv_label_create(scr, NULL);
lv_obj_set_style(title, &tft_style_label_rel);
lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
lv_label_set_text(title, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing());
// Create an Image button
buttonIn = lv_imgbtn_create(scr, NULL);
buttonOut = lv_imgbtn_create(scr, NULL);
buttoType = lv_imgbtn_create(scr, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonIn, event_handler, ID_FILAMNT_IN, NULL, 0);
lv_imgbtn_set_src(buttonIn, LV_BTN_STATE_REL, "F:/bmp_in.bin");
lv_imgbtn_set_src(buttonIn, LV_BTN_STATE_PR, "F:/bmp_in.bin");
lv_imgbtn_set_style(buttonIn, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonIn, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_clear_protect(buttonIn, LV_PROTECT_FOLLOW);
lv_obj_set_event_cb_mks(buttonOut, event_handler, ID_FILAMNT_OUT, NULL, 0);
lv_imgbtn_set_src(buttonOut, LV_BTN_STATE_REL, "F:/bmp_out.bin");
lv_imgbtn_set_src(buttonOut, LV_BTN_STATE_PR, "F:/bmp_out.bin");
lv_imgbtn_set_style(buttonOut, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonOut, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttoType, event_handler, ID_FILAMNT_TYPE, NULL, 0);
lv_imgbtn_set_style(buttoType, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttoType, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_FILAMNT_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_pos(buttonIn, INTERVAL_V, titleHeight);
lv_obj_set_pos(buttonOut, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight);
lv_obj_set_pos(buttoType, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
// Create labels on the image buttons
lv_btn_set_layout(buttonIn, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonOut, LV_LAYOUT_OFF);
lv_btn_set_layout(buttoType, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
lv_obj_t *labelIn = lv_label_create(buttonIn, NULL);
lv_obj_t *labelOut = lv_label_create(buttonOut, NULL);
labelType = lv_label_create(buttoType, NULL);
lv_obj_t *label_Back = lv_label_create(buttonBack, NULL);
if (gCfgItems.multiple_language != 0) {
lv_label_set_text(labelIn, filament_menu.in);
lv_obj_align(labelIn, buttonIn, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(labelOut, filament_menu.out);
lv_obj_align(labelOut, buttonOut, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_Back, common_menu.text_back);
lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
}
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonIn);
lv_group_add_obj(g, buttonOut);
lv_group_add_obj(g, buttoType);
lv_group_add_obj(g, buttonBack);
}
#endif
disp_filament_type();
tempText1 = lv_label_create(scr, NULL);
lv_obj_set_style(tempText1, &tft_style_label_rel);
disp_filament_temp();
}
void disp_filament_type() {
if (uiCfg.curSprayerChoose == 1) {
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru2.bin");
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru2.bin");
if (gCfgItems.multiple_language != 0) {
lv_label_set_text(labelType, preheat_menu.ext2);
lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
}
}
else {
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru1.bin");
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru1.bin");
if (gCfgItems.multiple_language != 0) {
lv_label_set_text(labelType, preheat_menu.ext1);
lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
}
}
}
void disp_filament_temp() {
char buf[20] = {0};
public_buf_l[0] = '\0';
if (uiCfg.curSprayerChoose < 1)
strcat(public_buf_l, preheat_menu.ext1);
else
strcat(public_buf_l, preheat_menu.ext2);
sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target);
strcat_P(public_buf_l, PSTR(": "));
strcat(public_buf_l, buf);
lv_label_set_text(tempText1, public_buf_l);
lv_obj_align(tempText1, NULL, LV_ALIGN_CENTER, 0, -50);
}
void lv_clear_filament_change() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

36
Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.h

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

329
Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp

@ -0,0 +1,329 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI
#include "lv_conf.h"
#include "draw_ui.h"
#include "../../../../MarlinCore.h"
#include "../../../../module/planner.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_FILAMENT_SET_RETURN 1
#define ID_FILAMENT_SET_IN_LENGTH 2
#define ID_FILAMENT_SET_IN_SPEED 3
#define ID_FILAMENT_SET_OUT_LENGTH 4
#define ID_FILAMENT_SET_OUT_SPEED 5
#define ID_FILAMENT_SET_TEMP 6
#define ID_FILAMENT_SET_DOWN 12
#define ID_FILAMENT_SET_UP 13
static void event_handler(lv_obj_t * obj, lv_event_t event) {
switch (obj->mks_obj_id) {
case ID_FILAMENT_SET_RETURN:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 0;
lv_clear_filament_settings();
draw_return_ui();
}
break;
case ID_FILAMENT_SET_IN_LENGTH:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = load_length;
lv_clear_filament_settings();
lv_draw_number_key();
}
break;
case ID_FILAMENT_SET_IN_SPEED:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = load_speed;
lv_clear_filament_settings();
lv_draw_number_key();
}
break;
case ID_FILAMENT_SET_OUT_LENGTH:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = unload_length;
lv_clear_filament_settings();
lv_draw_number_key();
}
break;
case ID_FILAMENT_SET_OUT_SPEED:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = unload_speed;
lv_clear_filament_settings();
lv_draw_number_key();
}
break;
case ID_FILAMENT_SET_TEMP:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = filament_temp;
lv_clear_filament_settings();
lv_draw_number_key();
}
break;
case ID_FILAMENT_SET_UP:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 0;
lv_clear_filament_settings();
lv_draw_filament_settings();
}
break;
case ID_FILAMENT_SET_DOWN:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 1;
lv_clear_filament_settings();
lv_draw_filament_settings();
}
break;
}
}
void lv_draw_filament_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL;
lv_obj_t *labelInLengthText = NULL, *buttonInLengthValue = NULL, *labelInLengthValue = NULL;
lv_obj_t *labelInSpeedText = NULL, *buttonInSpeedValue = NULL, *labelInSpeedValue = NULL;
lv_obj_t *labelOutLengthText = NULL, *buttonOutLengthValue = NULL, *labelOutLengthValue = NULL;
lv_obj_t *labelOutSpeedText = NULL, *buttonOutSpeedValue = NULL, *labelOutSpeedValue = NULL;
lv_obj_t *labelTemperText = NULL, *buttonTemperValue = NULL, *labelTemperValue = NULL;
lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != FILAMENT_SETTINGS_UI) {
disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = FILAMENT_SETTINGS_UI;
}
disp_state = FILAMENT_SETTINGS_UI;
scr = lv_obj_create(NULL, NULL);
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
lv_obj_t * title = lv_label_create(scr, NULL);
lv_obj_set_style(title, &tft_style_label_rel);
lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
lv_label_set_text(title, machine_menu.FilamentConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing());
if (uiCfg.para_ui_page != 1) {
labelInLengthText = lv_label_create(scr, NULL);
lv_obj_set_style(labelInLengthText, &tft_style_label_rel);
lv_obj_set_pos(labelInLengthText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
lv_label_set_text(labelInLengthText, machine_menu.InLength);
buttonInLengthValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonInLengthValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonInLengthValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonInLengthValue, event_handler, ID_FILAMENT_SET_IN_LENGTH, NULL, 0);
lv_btn_set_style(buttonInLengthValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonInLengthValue, LV_BTN_STYLE_PR, &style_para_value);
labelInLengthValue = lv_label_create(buttonInLengthValue, NULL);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
labelInSpeedText = lv_label_create(scr, NULL);
lv_obj_set_style(labelInSpeedText, &tft_style_label_rel);
lv_obj_set_pos(labelInSpeedText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
lv_label_set_text(labelInSpeedText, machine_menu.InSpeed);
buttonInSpeedValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonInSpeedValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonInSpeedValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonInSpeedValue, event_handler, ID_FILAMENT_SET_IN_SPEED, NULL, 0);
lv_btn_set_style(buttonInSpeedValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonInSpeedValue, LV_BTN_STYLE_PR, &style_para_value);
labelInSpeedValue = lv_label_create(buttonInSpeedValue, NULL);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
labelOutLengthText = lv_label_create(scr, NULL);
lv_obj_set_style(labelOutLengthText, &tft_style_label_rel);
lv_obj_set_pos(labelOutLengthText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 6);
lv_label_set_text(labelOutLengthText, machine_menu.OutLength);
buttonOutLengthValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonOutLengthValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonOutLengthValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonOutLengthValue, event_handler, ID_FILAMENT_SET_OUT_LENGTH, NULL, 0);
lv_btn_set_style(buttonOutLengthValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonOutLengthValue, LV_BTN_STYLE_PR, &style_para_value);
labelOutLengthValue = lv_label_create(buttonOutLengthValue, NULL);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
labelOutSpeedText = lv_label_create(scr, NULL);
lv_obj_set_style(labelOutSpeedText, &tft_style_label_rel);
lv_obj_set_pos(labelOutSpeedText, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
lv_label_set_text(labelOutSpeedText, machine_menu.OutSpeed);
buttonOutSpeedValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonOutSpeedValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonOutSpeedValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonOutSpeedValue, event_handler, ID_FILAMENT_SET_OUT_SPEED, NULL, 0);
lv_btn_set_style(buttonOutSpeedValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonOutSpeedValue, LV_BTN_STYLE_PR, &style_para_value);
labelOutSpeedValue = lv_label_create(buttonOutSpeedValue, NULL);
line4 = lv_line_create(scr, NULL);
lv_ex_line(line4, line_points[3]);
buttonTurnPage = lv_btn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FILAMENT_SET_DOWN, NULL, 0);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonInLengthValue);
lv_group_add_obj(g, buttonInSpeedValue);
lv_group_add_obj(g, buttonOutLengthValue);
lv_group_add_obj(g, buttonOutSpeedValue);
lv_group_add_obj(g, buttonTurnPage);
}
#endif
}
else {
labelTemperText = lv_label_create(scr, NULL);
lv_obj_set_style(labelTemperText, &tft_style_label_rel);
lv_obj_set_pos(labelTemperText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
lv_label_set_text(labelTemperText, machine_menu.FilamentTemperature);
buttonTemperValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonTemperValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonTemperValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonTemperValue, event_handler, ID_FILAMENT_SET_TEMP, NULL, 0);
lv_btn_set_style(buttonTemperValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonTemperValue, LV_BTN_STYLE_PR, &style_para_value);
labelTemperValue = lv_label_create(buttonTemperValue, NULL);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonTurnPage = lv_btn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FILAMENT_SET_UP, NULL, 0);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonTemperValue);
lv_group_add_obj(g, buttonTurnPage);
}
#endif
}
lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
labelTurnPage = lv_label_create(buttonTurnPage, NULL);
buttonBack = lv_btn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_FILAMENT_SET_RETURN, NULL, 0);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
label_Back = lv_label_create(buttonBack, NULL);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif
if (gCfgItems.multiple_language != 0) {
if (uiCfg.para_ui_page != 1) {
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_load_length);
lv_label_set_text(labelInLengthValue, public_buf_l);
lv_obj_align(labelInLengthValue, buttonInLengthValue, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_load_speed);
lv_label_set_text(labelInSpeedValue, public_buf_l);
lv_obj_align(labelInSpeedValue, buttonInSpeedValue, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_unload_length);
lv_label_set_text(labelOutLengthValue, public_buf_l);
lv_obj_align(labelOutLengthValue, buttonOutLengthValue, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_unload_speed);
lv_label_set_text(labelOutSpeedValue, public_buf_l);
lv_obj_align(labelOutSpeedValue, buttonOutSpeedValue, LV_ALIGN_CENTER, 0, 0);
lv_label_set_text(labelTurnPage, machine_menu.next);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
}
else {
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filament_limit_temper);
lv_label_set_text(labelTemperValue, public_buf_l);
lv_obj_align(labelTemperValue, buttonTemperValue, LV_ALIGN_CENTER, 0, 0);
lv_label_set_text(labelTurnPage, machine_menu.previous);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
}
lv_label_set_text(label_Back, common_menu.text_back);
lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
}
}
void lv_clear_filament_settings() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

33
Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.h

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

137
Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp

@ -34,6 +34,7 @@
#include "draw_ui.h"
#include "../../../../gcode/queue.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_H_ALL 1
@ -92,7 +93,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_obj_del(scr);
lv_clear_home();
lv_draw_tool();
}
break;
@ -125,128 +126,93 @@ void lv_draw_home(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_pic);
/*Create an Image button*/
//buttonWifi = lv_imgbtn_create(scr, NULL);
buttonHomeAll = lv_imgbtn_create(scr, NULL);
buttonHomeX = lv_imgbtn_create(scr, NULL);
// Create image buttons
//buttonWifi = lv_imgbtn_create(scr, NULL);
buttonHomeAll = lv_imgbtn_create(scr, NULL);
buttonHomeX = lv_imgbtn_create(scr, NULL);
//buttonContinue = lv_imgbtn_create(scr, NULL);
buttonHomeY = lv_imgbtn_create(scr, NULL);
buttonHomeZ = lv_imgbtn_create(scr, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
buttonOffAll = lv_imgbtn_create(scr, NULL);
buttonOffXY = lv_imgbtn_create(scr, NULL);
//lv_obj_set_event_cb_mks(buttonWifi, event_handler,ID_S_WIFI,"bmp_Wifi.bin",0);
//lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_REL, &bmp_pic);
//lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_PR, &bmp_pic);
//lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_PR, &tft_style_label_pre);
//lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_REL, &tft_style_label_rel);
//lv_obj_clear_protect(buttonWifi, LV_PROTECT_FOLLOW);
buttonHomeY = lv_imgbtn_create(scr, NULL);
buttonHomeZ = lv_imgbtn_create(scr, NULL);
buttonOffAll = lv_imgbtn_create(scr, NULL);
buttonOffXY = lv_imgbtn_create(scr, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
#if 1
lv_obj_set_event_cb_mks(buttonHomeAll, event_handler,ID_H_ALL,"bmp_zero.bin",0);
lv_imgbtn_set_src(buttonHomeAll, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonHomeAll, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonHomeAll, event_handler,ID_H_ALL, NULL,0);
lv_imgbtn_set_src(buttonHomeAll, LV_BTN_STATE_REL, "F:/bmp_zeroAll.bin");
lv_imgbtn_set_src(buttonHomeAll, LV_BTN_STATE_PR, "F:/bmp_zeroAll.bin");
lv_imgbtn_set_style(buttonHomeAll, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonHomeAll, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonHomeX, event_handler, ID_H_X, "bmp_zeroX.bin", 0);
lv_imgbtn_set_src(buttonHomeX, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonHomeX, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonHomeX, event_handler, ID_H_X, NULL, 0);
lv_imgbtn_set_src(buttonHomeX, LV_BTN_STATE_REL, "F:/bmp_zeroX.bin");
lv_imgbtn_set_src(buttonHomeX, LV_BTN_STATE_PR, "F:/bmp_zeroX.bin");
lv_imgbtn_set_style(buttonHomeX, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonHomeX, LV_BTN_STATE_REL, &tft_style_label_rel);
//lv_obj_set_event_cb_mks(buttonContinue, event_handler,ID_S_CONTINUE,"bmp_Breakpoint.bin",0);
//lv_imgbtn_set_src(buttonContinue, LV_BTN_STATE_REL, &bmp_pic);
//lv_imgbtn_set_src(buttonContinue, LV_BTN_STATE_PR, &bmp_pic);
//lv_imgbtn_set_style(buttonContinue, LV_BTN_STATE_PR, &tft_style_label_pre);
//lv_imgbtn_set_style(buttonContinue, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonHomeY, event_handler, ID_H_Y, "bmp_zeroY.bin", 0);
lv_imgbtn_set_src(buttonHomeY, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonHomeY, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonHomeY, event_handler, ID_H_Y, NULL, 0);
lv_imgbtn_set_src(buttonHomeY, LV_BTN_STATE_REL, "F:/bmp_zeroY.bin");
lv_imgbtn_set_src(buttonHomeY, LV_BTN_STATE_PR, "F:/bmp_zeroY.bin");
lv_imgbtn_set_style(buttonHomeY, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonHomeY, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonHomeZ, event_handler, ID_H_Z, "bmp_zeroZ.bin", 0);
lv_imgbtn_set_src(buttonHomeZ, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonHomeZ, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonHomeZ, event_handler, ID_H_Z, NULL, 0);
lv_imgbtn_set_src(buttonHomeZ, LV_BTN_STATE_REL, "F:/bmp_zeroZ.bin");
lv_imgbtn_set_src(buttonHomeZ, LV_BTN_STATE_PR, "F:/bmp_zeroZ.bin");
lv_imgbtn_set_style(buttonHomeZ, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonHomeZ, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonOffAll, event_handler,ID_H_OFF_ALL,"bmp_function1.bin",0);
lv_imgbtn_set_src(buttonOffAll, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonOffAll, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonOffAll, event_handler,ID_H_OFF_ALL, NULL,0);
lv_imgbtn_set_src(buttonOffAll, LV_BTN_STATE_REL, "F:/bmp_function1.bin");
lv_imgbtn_set_src(buttonOffAll, LV_BTN_STATE_PR, "F:/bmp_function1.bin");
lv_imgbtn_set_style(buttonOffAll, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonOffAll, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonOffXY, event_handler,ID_H_OFF_XY,"bmp_function1.bin",0);
lv_imgbtn_set_src(buttonOffXY, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonOffXY, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonOffXY, event_handler,ID_H_OFF_XY, NULL,0);
lv_imgbtn_set_src(buttonOffXY, LV_BTN_STATE_REL, "F:/bmp_function1.bin");
lv_imgbtn_set_src(buttonOffXY, LV_BTN_STATE_PR, "F:/bmp_function1.bin");
lv_imgbtn_set_style(buttonOffXY, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonOffXY, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonBack, event_handler,ID_H_RETURN,"bmp_return.bin",0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonBack, event_handler,ID_H_RETURN, NULL,0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif
/*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(buttonHomeAll, INTERVAL_V, titleHeight);
lv_obj_set_pos(buttonHomeX, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight);
lv_obj_set_pos(buttonHomeY, 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(buttonHomeZ, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight);
lv_obj_set_pos(buttonHomeAll, INTERVAL_V, titleHeight);
lv_obj_set_pos(buttonOffAll, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
lv_obj_set_pos(buttonOffXY, 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);
/*Create a label on the Image button*/
//lv_btn_set_layout(buttonWifi, LV_LAYOUT_OFF);
// Create labels on the image buttons
lv_btn_set_layout(buttonHomeAll, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonHomeX, LV_LAYOUT_OFF);
//lv_btn_set_layout(buttonContinue, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonHomeY, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonHomeZ, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonOffAll, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonOffXY, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
//lv_obj_t * labelWifi= lv_label_create(buttonWifi, NULL);
lv_obj_t * labelHomeAll = lv_label_create(buttonHomeAll, NULL);
lv_obj_t * labelHomeX = lv_label_create(buttonHomeX, NULL);
//lv_obj_t * label_Continue = lv_label_create(buttonContinue, NULL);
lv_obj_t * labelHomeY = lv_label_create(buttonHomeY, NULL);
lv_obj_t * labelHomeZ = lv_label_create(buttonHomeZ, NULL);
lv_obj_t * labelOffAll = lv_label_create(buttonOffAll, NULL);
lv_obj_t * labelOffXY = lv_label_create(buttonOffXY, NULL);
lv_obj_t * label_Back = lv_label_create(buttonBack, NULL);
lv_obj_t *labelHomeAll = lv_label_create(buttonHomeAll, NULL);
lv_obj_t *labelHomeX = lv_label_create(buttonHomeX, NULL);
lv_obj_t *labelHomeY = lv_label_create(buttonHomeY, NULL);
lv_obj_t *labelHomeZ = lv_label_create(buttonHomeZ, NULL);
lv_obj_t *labelOffAll = lv_label_create(buttonOffAll, NULL);
lv_obj_t *labelOffXY = lv_label_create(buttonOffXY, NULL);
lv_obj_t *label_Back = lv_label_create(buttonBack, NULL);
if (gCfgItems.multiple_language != 0) {
//lv_label_set_text(labelWifi, set_menu.wifi);
//lv_obj_align(labelWifi, buttonWifi, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
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(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(labelHomeY, home_menu.home_y);
lv_obj_align(labelHomeY, buttonHomeY, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
@ -262,8 +228,25 @@ void lv_draw_home(void) {
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() { lv_obj_del(scr); }
void lv_clear_home() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

262
Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.cpp

@ -0,0 +1,262 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI
#include "lv_conf.h"
#include "draw_ui.h"
#include "../../../../MarlinCore.h"
#include "../../../../module/planner.h"
#include "../../../../module/probe.h"
#if USE_SENSORLESS
#include "../../../../module/stepper/indirection.h"
#include "../../../../feature/tmc_util.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_SENSITIVITY_RETURN 1
#define ID_SENSITIVITY_X 2
#define ID_SENSITIVITY_Y 3
#define ID_SENSITIVITY_Z 4
#define ID_SENSITIVITY_Z2 5
static void event_handler(lv_obj_t * obj, lv_event_t event) {
switch (obj->mks_obj_id) {
case ID_SENSITIVITY_RETURN:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_homing_sensitivity_settings();
draw_return_ui();
}
break;
case ID_SENSITIVITY_X:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = x_sensitivity;
lv_clear_homing_sensitivity_settings();
lv_draw_number_key();
}
break;
case ID_SENSITIVITY_Y:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = y_sensitivity;
lv_clear_homing_sensitivity_settings();
lv_draw_number_key();
}
break;
case ID_SENSITIVITY_Z:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = z_sensitivity;
lv_clear_homing_sensitivity_settings();
lv_draw_number_key();
}
break;
#if Z2_SENSORLESS
case ID_SENSITIVITY_Z2:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = z2_sensitivity;
lv_clear_homing_sensitivity_settings();
lv_draw_number_key();
}
break;
#endif
}
}
void lv_draw_homing_sensitivity_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL;
lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL;
#if Z2_SENSORLESS
lv_obj_t *labelZ2Text = NULL, *buttonZ2Value = NULL, *labelZ2Value = NULL;
lv_obj_t * line4 = NULL;
#endif
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != HOMING_SENSITIVITY_UI) {
disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = HOMING_SENSITIVITY_UI;
}
disp_state = HOMING_SENSITIVITY_UI;
scr = lv_obj_create(NULL, NULL);
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
lv_obj_t * title = lv_label_create(scr, NULL);
lv_obj_set_style(title, &tft_style_label_rel);
lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
lv_label_set_text(title, machine_menu.HomingSensitivityConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing());
labelXText = lv_label_create(scr, NULL);
lv_obj_set_style(labelXText, &tft_style_label_rel);
lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
lv_label_set_text(labelXText, machine_menu.X_Sensitivity);
buttonXValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_SENSITIVITY_X, NULL, 0);
lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value);
labelXValue = lv_label_create(buttonXValue, NULL);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonXValue);
#endif
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
labelYText = lv_label_create(scr, NULL);
lv_obj_set_style(labelYText, &tft_style_label_rel);
lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
lv_label_set_text(labelYText, machine_menu.Y_Sensitivity);
buttonYValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_SENSITIVITY_Y, NULL, 0);
lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value);
labelYValue = lv_label_create(buttonYValue, NULL);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonYValue);
#endif
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
labelZText = lv_label_create(scr, NULL);
lv_obj_set_style(labelZText, &tft_style_label_rel);
lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
lv_label_set_text(labelZText, machine_menu.Z_Sensitivity);
buttonZValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_SENSITIVITY_Z, NULL, 0);
lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value);
labelZValue = lv_label_create(buttonZValue, NULL);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable == true) lv_group_add_obj(g, buttonZValue);
#endif
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
#if Z2_SENSORLESS
labelZ2Text = lv_label_create(scr, NULL);
lv_obj_set_style(labelZ2Text, &tft_style_label_rel);
lv_obj_set_pos(labelZ2Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
lv_label_set_text(labelZ2Text, machine_menu.Z2_Sensitivity);
buttonZ2Value = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonZ2Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonZ2Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonZ2Value, event_handler, ID_SENSITIVITY_Z2, NULL, 0);
lv_btn_set_style(buttonZ2Value, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonZ2Value, LV_BTN_STYLE_PR, &style_para_value);
labelZ2Value = lv_label_create(buttonZ2Value, NULL);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonZ2Value);
#endif
line4 = lv_line_create(scr, NULL);
lv_ex_line(line4, line_points[3]);
#endif
buttonBack = lv_btn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_SENSITIVITY_RETURN, NULL, 0);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
label_Back = lv_label_create(buttonBack, NULL);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif
if (gCfgItems.multiple_language != 0) {
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), TERN(X_SENSORLESS, stepperX.homing_threshold(), 0));
lv_label_set_text(labelXValue, public_buf_l);
lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), TERN(Y_SENSORLESS, stepperY.homing_threshold(), 0));
lv_label_set_text(labelYValue, public_buf_l);
lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), TERN(Z_SENSORLESS, stepperZ.homing_threshold(), 0));
lv_label_set_text(labelZValue, public_buf_l);
lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
#if Z2_SENSORLESS
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), TERN(Z2_SENSORLESS, stepperZ2.homing_threshold(), 0));
lv_label_set_text(labelZ2Value, public_buf_l);
lv_obj_align(labelZ2Value, buttonZ2Value, LV_ALIGN_CENTER, 0, 0);
#endif
lv_label_set_text(label_Back, common_menu.text_back);
lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
}
}
void lv_clear_homing_sensitivity_settings() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // USE_SENSORLESS
#endif // HAS_TFT_LVGL_UI && USE_SENSORLESS

33
Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.h

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

150
Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.cpp

@ -29,6 +29,7 @@
#include "../../../../MarlinCore.h"
#include "../../../../module/planner.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_JERK_RETURN 1
@ -93,10 +94,10 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
void lv_draw_jerk_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL;
lv_obj_t *buttonXText = NULL, *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *buttonYText = NULL, *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *buttonZText = NULL, *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t *buttonEText = NULL, *labelEText = NULL, *buttonEValue = NULL, *labelEValue = NULL;
lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t *labelEText = NULL, *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) {
disp_state_stack._disp_index++;
@ -117,109 +118,89 @@ void lv_draw_jerk_settings(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_para_back);
// LV_IMG_DECLARE(bmp_para_arrow);
LV_IMG_DECLARE(bmp_para_bank);
labelXText = lv_label_create(scr, NULL);
lv_obj_set_style(labelXText, &tft_style_label_rel);
lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
lv_label_set_text(labelXText, machine_menu.X_Jerk);
buttonXText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
lv_obj_set_size(buttonXText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonXText, event_handler);
lv_btn_set_style(buttonXText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonXText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonXText, LV_LAYOUT_OFF);
labelXText = lv_label_create(buttonXText, NULL); /*Add a label to the button*/
buttonXValue = lv_imgbtn_create(scr, NULL);
buttonXValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_JERK_X, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF);
lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_JERK_X, NULL, 0);
lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value);
labelXValue = lv_label_create(buttonXValue, NULL);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonYText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/
lv_obj_set_size(buttonYText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonYText, event_handler);
lv_btn_set_style(buttonYText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonYText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonYText, LV_LAYOUT_OFF);
labelYText = lv_label_create(buttonYText, NULL); /*Add a label to the button*/
labelYText = lv_label_create(scr, NULL);
lv_obj_set_style(labelYText, &tft_style_label_rel);
lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
lv_label_set_text(labelYText, machine_menu.Y_Jerk);
buttonYValue = lv_imgbtn_create(scr, NULL);
buttonYValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_JERK_Y, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF);
lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_JERK_Y, NULL, 0);
lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value);
labelYValue = lv_label_create(buttonYValue, NULL);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
buttonZText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/
lv_obj_set_size(buttonZText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonZText, event_handler);
lv_btn_set_style(buttonZText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonZText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonZText, LV_LAYOUT_OFF);
labelZText = lv_label_create(buttonZText, NULL); /*Add a label to the button*/
labelZText = lv_label_create(scr, NULL);
lv_obj_set_style(labelZText, &tft_style_label_rel);
lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
lv_label_set_text(labelZText, machine_menu.Z_Jerk);
buttonZValue = lv_imgbtn_create(scr, NULL);
buttonZValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_JERK_Z, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF);
lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_JERK_Z, NULL, 0);
lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value);
labelZValue = lv_label_create(buttonZValue, NULL);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
buttonEText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonEText, PARA_UI_POS_X, PARA_UI_POS_Y * 4); /*Set its position*/
lv_obj_set_size(buttonEText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonEText, event_handler);
lv_btn_set_style(buttonEText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonEText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonEText, LV_LAYOUT_OFF);
labelEText = lv_label_create(buttonEText, NULL); /*Add a label to the button*/
labelEText = lv_label_create(scr, NULL);
lv_obj_set_style(labelEText, &tft_style_label_rel);
lv_obj_set_pos(labelEText, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
lv_label_set_text(labelEText, machine_menu.E_Jerk);
buttonEValue = lv_imgbtn_create(scr, NULL);
buttonEValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonEValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonEValue, event_handler, ID_JERK_E, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonEValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonEValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonEValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonEValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonEValue, LV_LAYOUT_OFF);
lv_obj_set_size(buttonEValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonEValue, event_handler, ID_JERK_E, NULL, 0);
lv_btn_set_style(buttonEValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonEValue, LV_BTN_STYLE_PR, &style_para_value);
labelEValue = lv_label_create(buttonEValue, NULL);
line4 = lv_line_create(scr, NULL);
lv_ex_line(line4, line_points[3]);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_JERK_RETURN, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
buttonBack = lv_btn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_JERK_RETURN, NULL, 0);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
label_Back = lv_label_create(buttonBack, NULL);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable == 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 != 0) {
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[X_AXIS]);
@ -241,23 +222,16 @@ void lv_draw_jerk_settings(void) {
lv_label_set_text(labelEValue, public_buf_l);
lv_obj_align(labelEValue, buttonEValue, LV_ALIGN_CENTER, 0, 0);
lv_label_set_text(labelXText, machine_menu.X_Jerk);
lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelYText, machine_menu.Y_Jerk);
lv_obj_align(labelYText, buttonYText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelZText, machine_menu.Z_Jerk);
lv_obj_align(labelZText, buttonZText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelEText, machine_menu.E_Jerk);
lv_obj_align(labelEText, buttonEText, LV_ALIGN_IN_LEFT_MID, 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() { lv_obj_del(scr); }
void lv_clear_jerk_settings() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI && HAS_CLASSIC_JERK

286
Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp

@ -0,0 +1,286 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI
#include "lv_conf.h"
#include "draw_ui.h"
#include "../../../../../Configuration.h"
#include "../../../../MarlinCore.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define LV_KB_CTRL_BTN_FLAGS (LV_BTNM_CTRL_NO_REPEAT | LV_BTNM_CTRL_CLICK_TRIG)
static const char * kb_map_lc[] = {"1#", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", LV_SYMBOL_BACKSPACE, "\n",
"ABC", "a", "s", "d", "f", "g", "h", "j", "k", "l", LV_SYMBOL_NEW_LINE, "\n",
"_", "-", "z", "x", "c", "v", "b", "n", "m", ".", ",", ":", "\n",
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
static const lv_btnm_ctrl_t kb_ctrl_lc_map[] = {
LV_KB_CTRL_BTN_FLAGS | 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7,
LV_KB_CTRL_BTN_FLAGS | 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2};
static const char * kb_map_uc[] = {"1#", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", LV_SYMBOL_BACKSPACE, "\n",
"abc", "A", "S", "D", "F", "G", "H", "J", "K", "L", LV_SYMBOL_NEW_LINE, "\n",
"_", "-", "Z", "X", "C", "V", "B", "N", "M", ".", ",", ":", "\n",
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
static const lv_btnm_ctrl_t kb_ctrl_uc_map[] = {
LV_KB_CTRL_BTN_FLAGS | 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7,
LV_KB_CTRL_BTN_FLAGS | 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2};
static const char * kb_map_spec[] = {"0", "1", "2", "3", "4" ,"5", "6", "7", "8", "9", LV_SYMBOL_BACKSPACE, "\n",
"abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n",
"\\", "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n",
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
static const lv_btnm_ctrl_t kb_ctrl_spec_map[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2,
LV_KB_CTRL_BTN_FLAGS | 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2};
static const lv_btnm_ctrl_t kb_ctrl_num_map[] = {
1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2,
1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2,
1, 1, 1, 2,
1, 1, 1, 1, 1};
static void lv_kb_event_cb(lv_obj_t * kb, lv_event_t event) {
//LV_ASSERT_OBJ(kb, LV_OBJX_NAME);
if (event != LV_EVENT_VALUE_CHANGED) return;
lv_kb_ext_t * ext = (lv_kb_ext_t * )lv_obj_get_ext_attr(kb);
const uint16_t btn_id = lv_btnm_get_active_btn(kb);
if (btn_id == LV_BTNM_BTN_NONE) return;
if (lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_HIDDEN | LV_BTNM_CTRL_INACTIVE)) return;
if (lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_NO_REPEAT) && event == LV_EVENT_LONG_PRESSED_REPEAT) return;
const char * txt = lv_btnm_get_active_btn_text(kb);
if (txt == NULL) return;
// Do the corresponding action according to the text of the button
if (strcmp(txt, "abc") == 0) {
lv_btnm_set_map(kb, kb_map_lc);
lv_btnm_set_ctrl_map(kb, kb_ctrl_lc_map);
return;
}
else if (strcmp(txt, "ABC") == 0) {
lv_btnm_set_map(kb, kb_map_uc);
lv_btnm_set_ctrl_map(kb, kb_ctrl_uc_map);
return;
}
else if (strcmp(txt, "1#") == 0) {
lv_btnm_set_map(kb, kb_map_spec);
lv_btnm_set_ctrl_map(kb, kb_ctrl_spec_map);
return;
}
else if (strcmp(txt, LV_SYMBOL_CLOSE) == 0) {
if (kb->event_cb != lv_kb_def_event_cb) {
//lv_res_t res = lv_event_send(kb, LV_EVENT_CANCEL, NULL);
//if (res != LV_RES_OK) return;
lv_clear_keyboard();
draw_return_ui();
}
else {
lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/
lv_obj_del(kb);
return;
}
return;
}
else if (strcmp(txt, LV_SYMBOL_OK) == 0) {
if (kb->event_cb != lv_kb_def_event_cb) {
//lv_res_t res = lv_event_send(kb, LV_EVENT_APPLY, NULL);
//if (res != LV_RES_OK) return;
const char * ret_ta_txt = lv_ta_get_text(ext->ta);
switch (keyboard_value) {
#if ENABLED(USE_WIFI_FUNCTION)
case wifiName:
memcpy(uiCfg.wifi_name,ret_ta_txt,sizeof(uiCfg.wifi_name));
lv_clear_keyboard();
draw_return_ui();
break;
case wifiPassWord:
memcpy(uiCfg.wifi_key,ret_ta_txt,sizeof(uiCfg.wifi_name));
lv_clear_keyboard();
draw_return_ui();
break;
case wifiConfig:
memset((void *)uiCfg.wifi_name, 0, sizeof(uiCfg.wifi_name));
memcpy((void *)uiCfg.wifi_name, wifi_list.wifiName[wifi_list.nameIndex], 32);
memset((void *)uiCfg.wifi_key, 0, sizeof(uiCfg.wifi_key));
memcpy((void *)uiCfg.wifi_key, ret_ta_txt, sizeof(uiCfg.wifi_key));
gCfgItems.wifi_mode_sel = STA_MODEL;
package_to_wifi(WIFI_PARA_SET, (char *)0, 0);
memset(public_buf_l,0,sizeof(public_buf_l));
public_buf_l[0] = 0xA5;
public_buf_l[1] = 0x09;
public_buf_l[2] = 0x01;
public_buf_l[3] = 0x00;
public_buf_l[4] = 0x01;
public_buf_l[5] = 0xFC;
public_buf_l[6] = 0x00;
raw_send_to_wifi(public_buf_l, 6);
last_disp_state = KEY_BOARD_UI;
lv_clear_keyboard();
wifi_tips_type = TIPS_TYPE_JOINING;
lv_draw_wifi_tips();
break;
#endif // USE_WIFI_FUNCTION
case gcodeCommand:
uint8_t buf[100];
strncpy((char *)buf,ret_ta_txt,sizeof(buf));
update_gcode_command(AUTO_LEVELING_COMMAND_ADDR,buf);
lv_clear_keyboard();
draw_return_ui();
break;
default: break;
}
}
else {
lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/
}
return;
}
/*Add the characters to the text area if set*/
if (ext->ta == NULL) return;
if (strcmp(txt, "Enter") == 0 || strcmp(txt, LV_SYMBOL_NEW_LINE) == 0)
lv_ta_add_char(ext->ta, '\n');
else if (strcmp(txt, LV_SYMBOL_LEFT) == 0)
lv_ta_cursor_left(ext->ta);
else if (strcmp(txt, LV_SYMBOL_RIGHT) == 0)
lv_ta_cursor_right(ext->ta);
else if (strcmp(txt, LV_SYMBOL_BACKSPACE) == 0)
lv_ta_del_char(ext->ta);
else if (strcmp(txt, "+/-") == 0) {
uint16_t cur = lv_ta_get_cursor_pos(ext->ta);
const char * ta_txt = lv_ta_get_text(ext->ta);
if (ta_txt[0] == '-') {
lv_ta_set_cursor_pos(ext->ta, 1);
lv_ta_del_char(ext->ta);
lv_ta_add_char(ext->ta, '+');
lv_ta_set_cursor_pos(ext->ta, cur);
}
else if (ta_txt[0] == '+') {
lv_ta_set_cursor_pos(ext->ta, 1);
lv_ta_del_char(ext->ta);
lv_ta_add_char(ext->ta, '-');
lv_ta_set_cursor_pos(ext->ta, cur);
}
else {
lv_ta_set_cursor_pos(ext->ta, 0);
lv_ta_add_char(ext->ta, '-');
lv_ta_set_cursor_pos(ext->ta, cur + 1);
}
}
else {
lv_ta_add_text(ext->ta, txt);
}
}
void lv_draw_keyboard() {
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != KEY_BOARD_UI) {
disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = KEY_BOARD_UI;
}
disp_state = KEY_BOARD_UI;
scr = lv_obj_create(NULL, NULL);
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
lv_refr_now(lv_refr_get_disp_refreshing());
/*Create styles for the keyboard*/
static lv_style_t rel_style, pr_style;
lv_style_copy(&rel_style, &lv_style_btn_rel);
rel_style.body.radius = 0;
rel_style.body.border.width = 1;
rel_style.body.main_color = lv_color_make(0xa9, 0x62, 0x1d);
rel_style.body.grad_color = lv_color_make(0xa7, 0x59, 0x0e);
lv_style_copy(&pr_style, &lv_style_btn_pr);
pr_style.body.radius = 0;
pr_style.body.border.width = 1;
pr_style.body.main_color = lv_color_make(0x72, 0x42, 0x15);
pr_style.body.grad_color = lv_color_make(0x6a, 0x3a, 0x0c);
/*Create a keyboard and apply the styles*/
lv_obj_t *kb = lv_kb_create(scr, NULL);
lv_obj_set_event_cb(kb, lv_kb_event_cb);
lv_kb_set_cursor_manage(kb, true);
lv_kb_set_style(kb, LV_KB_STYLE_BG, &lv_style_transp_tight);
lv_kb_set_style(kb, LV_KB_STYLE_BTN_REL, &rel_style);
lv_kb_set_style(kb, LV_KB_STYLE_BTN_PR, &pr_style);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
//lv_group_add_obj(g, kb);
//lv_group_set_editing(g, true);
}
#endif
/*Create a text area. The keyboard will write here*/
lv_obj_t *ta = lv_ta_create(scr, NULL);
lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
if (keyboard_value == gcodeCommand) {
get_gcode_command(AUTO_LEVELING_COMMAND_ADDR,(uint8_t *)public_buf_m);
public_buf_m[sizeof(public_buf_m)-1] = 0;
lv_ta_set_text(ta, public_buf_m);
}
else {
lv_ta_set_text(ta, "");
}
/*Assign the text area to the keyboard*/
lv_kb_set_ta(kb, ta);
}
void lv_clear_keyboard() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) { /* lv_group_remove_all_objs(g); */ }
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

33
Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.h

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

136
Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp

@ -49,6 +49,7 @@
static void disp_language(uint8_t language, uint8_t state);
extern lv_group_t * g;
static lv_obj_t * scr;
static lv_obj_t *buttonCN, *buttonT_CN, *buttonEN, *buttonRU;
static lv_obj_t *buttonES, *buttonFR, *buttonIT, *buttonBack;
@ -61,9 +62,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
}
else if (event == LV_EVENT_RELEASED) {
disp_language(gCfgItems.language, UNSELECTED);
lv_obj_set_event_cb_mks(buttonCN, event_handler, ID_CN, "bmp_simplified_cn_sel.bin", 0);
lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_REL, "F:/bmp_simplified_cn_sel.bin");
lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_PR, "F:/bmp_simplified_cn_sel.bin");
lv_obj_refresh_ext_draw_pad(buttonCN);
gCfgItems.language = LANG_SIMPLE_CHINESE;
gCfg_to_spiFlah();
update_spi_flash();
disp_language_init();
}
break;
@ -73,9 +76,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
}
else if (event == LV_EVENT_RELEASED) {
disp_language(gCfgItems.language, UNSELECTED);
lv_obj_set_event_cb_mks(buttonT_CN, event_handler, ID_T_CN, "bmp_traditional_cn_sel.bin", 0);
lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_REL, "F:/bmp_traditional_cn_sel.bin");
lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_PR, "F:/bmp_traditional_cn_sel.bin");
lv_obj_refresh_ext_draw_pad(buttonT_CN);
gCfgItems.language = LANG_COMPLEX_CHINESE;
gCfg_to_spiFlah();
update_spi_flash();
disp_language_init();
}
break;
@ -85,9 +90,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
}
else if (event == LV_EVENT_RELEASED) {
disp_language(gCfgItems.language, UNSELECTED);
lv_obj_set_event_cb_mks(buttonEN, event_handler, ID_EN, "bmp_english_sel.bin", 0);
lv_imgbtn_set_src(buttonEN, LV_BTN_STATE_REL, "F:/bmp_english_sel.bin");
lv_imgbtn_set_src(buttonEN, LV_BTN_STATE_PR, "F:/bmp_english_sel.bin");
lv_obj_refresh_ext_draw_pad(buttonEN);
gCfgItems.language = LANG_ENGLISH;
gCfg_to_spiFlah();
update_spi_flash();
disp_language_init();
}
break;
@ -97,9 +104,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
}
else if (event == LV_EVENT_RELEASED) {
disp_language(gCfgItems.language, UNSELECTED);
lv_obj_set_event_cb_mks(buttonRU, event_handler, ID_RU, "bmp_russian_sel.bin", 0);
lv_imgbtn_set_src(buttonRU, LV_BTN_STATE_REL, "F:/bmp_russian_sel.bin");
lv_imgbtn_set_src(buttonRU, LV_BTN_STATE_PR, "F:/bmp_russian_sel.bin");
lv_obj_refresh_ext_draw_pad(buttonRU);
gCfgItems.language = LANG_RUSSIAN;
gCfg_to_spiFlah();
update_spi_flash();
disp_language_init();
}
break;
@ -109,9 +118,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
}
else if (event == LV_EVENT_RELEASED) {
disp_language(gCfgItems.language, UNSELECTED);
lv_obj_set_event_cb_mks(buttonES, event_handler, ID_ES, "bmp_spanish_sel.bin", 0);
lv_imgbtn_set_src(buttonES, LV_BTN_STATE_REL, "F:/bmp_spanish_sel.bin");
lv_imgbtn_set_src(buttonES, LV_BTN_STATE_PR, "F:/bmp_spanish_sel.bin");
lv_obj_refresh_ext_draw_pad(buttonES);
gCfgItems.language = LANG_SPANISH;
gCfg_to_spiFlah();
update_spi_flash();
disp_language_init();
}
break;
@ -121,9 +132,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
}
else if (event == LV_EVENT_RELEASED) {
disp_language(gCfgItems.language, UNSELECTED);
lv_obj_set_event_cb_mks(buttonFR, event_handler, ID_FR, "bmp_french_sel.bin", 0);
lv_imgbtn_set_src(buttonFR, LV_BTN_STATE_REL, "F:/bmp_french_sel.bin");
lv_imgbtn_set_src(buttonFR, LV_BTN_STATE_PR, "F:/bmp_french_sel.bin");
lv_obj_refresh_ext_draw_pad(buttonFR);
gCfgItems.language = LANG_FRENCH;
gCfg_to_spiFlah();
update_spi_flash();
disp_language_init();
}
break;
@ -133,9 +146,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
}
else if (event == LV_EVENT_RELEASED) {
disp_language(gCfgItems.language, UNSELECTED);
lv_obj_set_event_cb_mks(buttonIT, event_handler, ID_FR, "bmp_italy_sel.bin", 0);
lv_imgbtn_set_src(buttonIT, LV_BTN_STATE_REL, "F:/bmp_italy_sel.bin");
lv_imgbtn_set_src(buttonIT, LV_BTN_STATE_PR, "F:/bmp_italy_sel.bin");
lv_obj_refresh_ext_draw_pad(buttonIT);
gCfgItems.language = LANG_ITALY;
gCfg_to_spiFlah();
update_spi_flash();
disp_language_init();
}
break;
@ -154,8 +169,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
buttonFR = NULL;
buttonIT = NULL;
buttonBack = NULL;
lv_obj_del(scr);
lv_clear_language();
lv_draw_set();
}
break;
@ -172,42 +186,42 @@ static void disp_language(uint8_t language, uint8_t state) {
switch (language) {
case LANG_SIMPLE_CHINESE:
id = ID_CN;
strcpy_P(public_buf_l, PSTR("bmp_simplified_cn"));
strcpy_P(public_buf_l, PSTR("F:/bmp_simplified_cn"));
obj = buttonCN;
break;
case LANG_COMPLEX_CHINESE:
id = ID_T_CN;
strcpy_P(public_buf_l, PSTR("bmp_traditional_cn"));
strcpy_P(public_buf_l, PSTR("F:/bmp_traditional_cn"));
obj = buttonT_CN;
break;
case LANG_ENGLISH:
id = ID_EN;
strcpy_P(public_buf_l, PSTR("bmp_english"));
strcpy_P(public_buf_l, PSTR("F:/bmp_english"));
obj = buttonEN;
break;
case LANG_RUSSIAN:
id = ID_RU;
strcpy_P(public_buf_l, PSTR("bmp_russian"));
strcpy_P(public_buf_l, PSTR("F:/bmp_russian"));
obj = buttonRU;
break;
case LANG_SPANISH:
id = ID_ES;
strcpy_P(public_buf_l, PSTR("bmp_spanish"));
strcpy_P(public_buf_l, PSTR("F:/bmp_spanish"));
obj = buttonES;
break;
case LANG_FRENCH:
id = ID_FR;
strcpy_P(public_buf_l, PSTR("bmp_french"));
strcpy_P(public_buf_l, PSTR("F:/bmp_french"));
obj = buttonFR;
break;
case LANG_ITALY:
id = ID_IT;
strcpy_P(public_buf_l, PSTR("bmp_italy"));
strcpy_P(public_buf_l, PSTR("F:/bmp_italy"));
obj = buttonIT;
break;
default:
id = ID_CN;
strcpy_P(public_buf_l, PSTR("bmp_simplified_cn"));
strcpy_P(public_buf_l, PSTR("F:/bmp_simplified_cn"));
obj = buttonCN;
break;
}
@ -216,7 +230,9 @@ static void disp_language(uint8_t language, uint8_t state) {
strcat_P(public_buf_l, PSTR(".bin"));
lv_obj_set_event_cb_mks(obj, event_handler, id, public_buf_l, 0);
lv_obj_set_event_cb_mks(obj, event_handler, id, NULL, 0);
lv_imgbtn_set_src(obj, LV_BTN_STATE_REL, public_buf_l);
lv_imgbtn_set_src(obj, LV_BTN_STATE_PR, public_buf_l);
if (state == UNSELECTED) lv_obj_refresh_ext_draw_pad(obj);
}
@ -244,8 +260,6 @@ void lv_draw_language(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_pic);
// Create image buttons
buttonCN = lv_imgbtn_create(scr, NULL);
buttonT_CN = lv_imgbtn_create(scr, NULL);
@ -256,52 +270,53 @@ void lv_draw_language(void) {
buttonIT = lv_imgbtn_create(scr, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonCN, event_handler, ID_CN, "bmp_simplified_cn.bin", 0);
lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonCN, event_handler, ID_CN, NULL, 0);
lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_REL, "F:/bmp_simplified_cn.bin");
lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_PR, "F:/bmp_simplified_cn.bin");
lv_imgbtn_set_style(buttonCN, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonCN, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_clear_protect(buttonCN, LV_PROTECT_FOLLOW);
#if 1
lv_obj_set_event_cb_mks(buttonT_CN, event_handler, ID_T_CN, "bmp_traditional_cn.bin", 0);
lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonT_CN, event_handler, ID_T_CN, NULL, 0);
lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_REL, "F:/bmp_traditional_cn.bin");
lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_PR, "F:/bmp_traditional_cn.bin");
lv_imgbtn_set_style(buttonT_CN, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonT_CN, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonEN, event_handler, ID_EN, "bmp_english.bin", 0);
lv_imgbtn_set_src(buttonEN, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonEN, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonEN, event_handler, ID_EN, NULL, 0);
lv_imgbtn_set_src(buttonEN, LV_BTN_STATE_REL, "F:/bmp_english.bin");
lv_imgbtn_set_src(buttonEN, LV_BTN_STATE_PR, "F:/bmp_english.bin");
lv_imgbtn_set_style(buttonEN, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonEN, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonRU, event_handler, ID_RU, "bmp_russian.bin", 0);
lv_imgbtn_set_src(buttonRU, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonRU, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonRU, event_handler, ID_RU, NULL, 0);
lv_imgbtn_set_src(buttonRU, LV_BTN_STATE_REL, "F:/bmp_russian.bin");
lv_imgbtn_set_src(buttonRU, LV_BTN_STATE_PR, "F:/bmp_russian.bin");
lv_imgbtn_set_style(buttonRU, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonRU, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonES, event_handler, ID_ES, "bmp_spanish.bin", 0);
lv_imgbtn_set_src(buttonES, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonES, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonES, event_handler, ID_ES, NULL, 0);
lv_imgbtn_set_src(buttonES, LV_BTN_STATE_REL, "F:/bmp_spanish.bin");
lv_imgbtn_set_src(buttonES, LV_BTN_STATE_PR, "F:/bmp_spanish.bin");
lv_imgbtn_set_style(buttonES, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonES, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonFR, event_handler, ID_FR, "bmp_french.bin", 0);
lv_imgbtn_set_src(buttonFR, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonFR, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonFR, event_handler, ID_FR, NULL, 0);
lv_imgbtn_set_src(buttonFR, LV_BTN_STATE_REL, "F:/bmp_french.bin");
lv_imgbtn_set_src(buttonFR, LV_BTN_STATE_PR, "F:/bmp_french.bin");
lv_imgbtn_set_style(buttonFR, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonFR, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonIT, event_handler, ID_IT, "bmp_italy.bin", 0);
lv_imgbtn_set_src(buttonIT, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonIT, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonIT, event_handler, ID_IT, NULL, 0);
lv_imgbtn_set_src(buttonIT, LV_BTN_STATE_REL, "F:/bmp_italy.bin");
lv_imgbtn_set_src(buttonIT, LV_BTN_STATE_PR, "F:/bmp_italy.bin");
lv_imgbtn_set_style(buttonIT, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonIT, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_L_RETURN, "bmp_return.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_L_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
@ -362,8 +377,25 @@ void lv_draw_language(void) {
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() { lv_obj_del(scr); }
void lv_clear_language() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

261
Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.cpp

@ -0,0 +1,261 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI
#include "lv_conf.h"
#include "draw_ui.h"
#include "../../../../MarlinCore.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_LEVEL_RETURN 1
#define ID_LEVEL_POSITION 2
#define ID_LEVEL_POSITION_ARROW 3
#define ID_LEVEL_COMMAND 4
#define ID_LEVEL_COMMAND_ARROW 5
#define ID_LEVEL_ZOFFSET 6
#define ID_LEVEL_ZOFFSET_ARROW 7
static void event_handler(lv_obj_t * obj, lv_event_t event) {
switch (obj->mks_obj_id) {
case ID_LEVEL_RETURN:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_level_settings();
draw_return_ui();
}
break;
case ID_LEVEL_POSITION:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_level_settings();
lv_draw_manual_level_pos_settings();
}
break;
case ID_LEVEL_POSITION_ARROW:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_level_settings();
lv_draw_manual_level_pos_settings();
}
break;
case ID_LEVEL_COMMAND:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
keyboard_value = gcodeCommand;
lv_clear_level_settings();
lv_draw_keyboard();
}
break;
case ID_LEVEL_COMMAND_ARROW:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
keyboard_value = gcodeCommand;
lv_clear_level_settings();
lv_draw_keyboard();
}
break;
#if HAS_BED_PROBE
case ID_LEVEL_ZOFFSET:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_level_settings();
lv_draw_auto_level_offset_settings();
}
break;
case ID_LEVEL_ZOFFSET_ARROW:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_level_settings();
lv_draw_auto_level_offset_settings();
}
break;
#endif
}
}
void lv_draw_level_settings(void) {
lv_obj_t *buttonBack, *label_Back;
lv_obj_t *buttonPosition, *labelPosition, *buttonPositionNarrow;
lv_obj_t *buttonCommand, *labelCommand, *buttonCommandNarrow;
#if HAS_BED_PROBE
lv_obj_t *buttonZoffset, *labelZoffset, *buttonZoffsetNarrow;
lv_obj_t * line3;
#endif
lv_obj_t * line1, * line2;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != LEVELING_PARA_UI) {
disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = LEVELING_PARA_UI;
}
disp_state = LEVELING_PARA_UI;
scr = lv_obj_create(NULL, NULL);
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
lv_obj_t * title = lv_label_create(scr, NULL);
lv_obj_set_style(title, &tft_style_label_rel);
lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
lv_label_set_text(title, machine_menu.LevelingParaConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing());
buttonPosition = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonPosition, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
lv_obj_set_size(buttonPosition, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb_mks(buttonPosition, event_handler, ID_LEVEL_POSITION, NULL, 0);
lv_btn_set_style(buttonPosition, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonPosition, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonPosition, LV_LAYOUT_OFF);
labelPosition = lv_label_create(buttonPosition, NULL); /*Add a label to the button*/
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonPosition);
#endif
buttonPositionNarrow = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonPositionNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonPositionNarrow, event_handler, ID_LEVEL_POSITION_ARROW, NULL, 0);
lv_imgbtn_set_src(buttonPositionNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonPositionNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonPositionNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonPositionNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonPositionNarrow, LV_LAYOUT_OFF);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonCommand = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonCommand, PARA_UI_POS_X, PARA_UI_POS_Y * 2);
lv_obj_set_size(buttonCommand, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);
lv_obj_set_event_cb_mks(buttonCommand, event_handler, ID_LEVEL_COMMAND, NULL, 0);
lv_btn_set_style(buttonCommand, LV_BTN_STYLE_REL, &tft_style_label_rel);
lv_btn_set_style(buttonCommand, LV_BTN_STYLE_PR, &tft_style_label_pre);
lv_btn_set_layout(buttonCommand, LV_LAYOUT_OFF);
labelCommand = lv_label_create(buttonCommand, NULL);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonCommand);
#endif
buttonCommandNarrow = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonCommandNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonCommandNarrow, event_handler, ID_LEVEL_COMMAND_ARROW, NULL, 0);
lv_imgbtn_set_src(buttonCommandNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonCommandNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonCommandNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonCommandNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonCommandNarrow, LV_LAYOUT_OFF);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
#if HAS_BED_PROBE
buttonZoffset = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonZoffset, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/
lv_obj_set_size(buttonZoffset, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb_mks(buttonZoffset, event_handler, ID_LEVEL_ZOFFSET, NULL, 0);
lv_btn_set_style(buttonZoffset, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonZoffset, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonZoffset, LV_LAYOUT_OFF);
labelZoffset = lv_label_create(buttonZoffset, NULL); /*Add a label to the button*/
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonZoffset);
#endif
buttonZoffsetNarrow = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonZoffsetNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonZoffsetNarrow, event_handler, ID_LEVEL_ZOFFSET_ARROW, NULL, 0);
lv_imgbtn_set_src(buttonZoffsetNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonZoffsetNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonZoffsetNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonZoffsetNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonZoffsetNarrow, LV_LAYOUT_OFF);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
#endif // HAS_BED_PROBE
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_LEVEL_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
label_Back = lv_label_create(buttonBack, NULL);
if (gCfgItems.multiple_language != 0) {
lv_label_set_text(label_Back, common_menu.text_back);
lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
lv_label_set_text(labelPosition, machine_menu.LevelingManuPosConf);
lv_obj_align(labelPosition, buttonPosition, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelCommand, machine_menu.LevelingAutoCommandConf);
lv_obj_align(labelCommand, buttonCommand, LV_ALIGN_IN_LEFT_MID, 0, 0);
#if HAS_BED_PROBE
lv_label_set_text(labelZoffset, machine_menu.LevelingAutoZoffsetConf);
lv_obj_align(labelZoffset, buttonZoffset, LV_ALIGN_IN_LEFT_MID, 0, 0);
#endif
}
}
void lv_clear_level_settings() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

33
Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.h

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

114
Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.cpp

@ -28,6 +28,7 @@
#include "../../../../MarlinCore.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_PARA_RETURN 1
@ -35,8 +36,10 @@ static lv_obj_t * scr;
#define ID_PARA_MACHINE_ARROW 3
#define ID_PARA_MOTOR 4
#define ID_PARA_MOTOR_ARROW 5
#define ID_PARA_ADVANCE 6
#define ID_PARA_ADVANCE_ARROW 7
#define ID_PARA_LEVEL 6
#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) {
switch (obj->mks_obj_id) {
@ -85,6 +88,24 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
lv_draw_motor_settings();
}
break;
case ID_PARA_LEVEL:
if (event == LV_EVENT_CLICKED) {
}
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;
case ID_PARA_ADVANCE:
if (event == LV_EVENT_CLICKED) {
@ -110,8 +131,9 @@ 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;
lv_obj_t * line1, * line2, * line3, * line4;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MACHINE_PARA_UI) {
disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = MACHINE_PARA_UI;
@ -131,9 +153,6 @@ void lv_draw_machine_para(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_para_back);
LV_IMG_DECLARE(bmp_para_arrow);
buttonMachine = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonMachine, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
lv_obj_set_size(buttonMachine, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
@ -146,9 +165,9 @@ void lv_draw_machine_para(void) {
buttonMachineNarrow = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonMachineNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonMachineNarrow, event_handler, ID_PARA_MACHINE_ARROW, "bmp_arrow.bin", 0);
lv_imgbtn_set_src(buttonMachineNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
lv_imgbtn_set_src(buttonMachineNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
lv_obj_set_event_cb_mks(buttonMachineNarrow, event_handler, ID_PARA_MACHINE_ARROW, NULL, 0);
lv_imgbtn_set_src(buttonMachineNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonMachineNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonMachineNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonMachineNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonMachineNarrow, LV_LAYOUT_OFF);
@ -168,9 +187,9 @@ void lv_draw_machine_para(void) {
buttonMotorNarrow = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonMotorNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonMotorNarrow, event_handler, ID_PARA_MOTOR_ARROW, "bmp_arrow.bin", 0);
lv_imgbtn_set_src(buttonMotorNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
lv_imgbtn_set_src(buttonMotorNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
lv_obj_set_event_cb_mks(buttonMotorNarrow, event_handler, ID_PARA_MOTOR_ARROW, NULL, 0);
lv_imgbtn_set_src(buttonMotorNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonMotorNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonMotorNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonMotorNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonMotorNarrow, LV_LAYOUT_OFF);
@ -178,8 +197,30 @@ void lv_draw_machine_para(void) {
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
buttonLevel = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonLevel, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/
lv_obj_set_size(buttonLevel, 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(buttonLevel, event_handler, ID_PARA_LEVEL, NULL, 0);
lv_btn_set_style(buttonLevel, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonLevel, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonLevel, LV_LAYOUT_OFF);
labelLevel = lv_label_create(buttonLevel, NULL); /*Add a label to the button*/
buttonLevelNarrow = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonLevelNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonLevelNarrow, event_handler, ID_PARA_LEVEL_ARROW, NULL, 0);
lv_imgbtn_set_src(buttonLevelNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonLevelNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonLevelNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonLevelNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonLevelNarrow, LV_LAYOUT_OFF);
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 * 3); /*Set its position*/
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);
@ -189,44 +230,61 @@ void lv_draw_machine_para(void) {
labelAdvance = lv_label_create(buttonAdvance, NULL); /*Add a label to the button*/
buttonAdvanceNarrow = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonAdvanceNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonAdvanceNarrow, event_handler, ID_PARA_ADVANCE_ARROW, "bmp_arrow.bin", 0);
lv_imgbtn_set_src(buttonAdvanceNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
lv_imgbtn_set_src(buttonAdvanceNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
lv_obj_set_pos(buttonAdvanceNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 4 + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonAdvanceNarrow, event_handler, ID_PARA_ADVANCE_ARROW, NULL, 0);
lv_imgbtn_set_src(buttonAdvanceNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonAdvanceNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonAdvanceNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonAdvanceNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonAdvanceNarrow, LV_LAYOUT_OFF);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
line4 = lv_line_create(scr, NULL);
lv_ex_line(line4, line_points[3]);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_PARA_RETURN, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_PARA_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y);
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
label_Back = lv_label_create(buttonBack, NULL);
if (gCfgItems.multiple_language != 0) {
lv_label_set_text(label_Back, common_menu.text_back);
lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
lv_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, 0);
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, 0);
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, 0);
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() { lv_obj_del(scr); }
void lv_clear_machine_para() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

81
Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.cpp

@ -28,6 +28,7 @@
#include "../../../../MarlinCore.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_MACHINE_RETURN 1
@ -138,24 +139,21 @@ void lv_draw_machine_settings(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_para_back);
LV_IMG_DECLARE(bmp_para_arrow);
buttonAcceleration = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonAcceleration, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
lv_obj_set_size(buttonAcceleration, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
buttonAcceleration = lv_btn_create(scr, NULL); // Add a button the current screen
lv_obj_set_pos(buttonAcceleration, PARA_UI_POS_X, PARA_UI_POS_Y); // Set its position
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_set_style(buttonAcceleration, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonAcceleration, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_style(buttonAcceleration, LV_BTN_STYLE_REL, &tft_style_label_rel); // Set the button's released style
lv_btn_set_style(buttonAcceleration, LV_BTN_STYLE_PR, &tft_style_label_pre); // Set the button's pressed style
lv_btn_set_layout(buttonAcceleration, LV_LAYOUT_OFF);
labelAcceleration = lv_label_create(buttonAcceleration, NULL); /*Add a label to the button*/
labelAcceleration = lv_label_create(buttonAcceleration, NULL); // Add a label to the button
buttonAccelerationNarrow = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonAccelerationNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonAccelerationNarrow, event_handler, ID_MACHINE_ACCELERATION_ARROW, "bmp_arrow.bin", 0);
lv_imgbtn_set_src(buttonAccelerationNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
lv_imgbtn_set_src(buttonAccelerationNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
lv_obj_set_event_cb_mks(buttonAccelerationNarrow, event_handler, ID_MACHINE_ACCELERATION_ARROW, NULL, 0);
lv_imgbtn_set_src(buttonAccelerationNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonAccelerationNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonAccelerationNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonAccelerationNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonAccelerationNarrow, LV_LAYOUT_OFF);
@ -163,21 +161,21 @@ void lv_draw_machine_settings(void) {
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*/
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_set_style(buttonMaxFeedrate, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonMaxFeedrate, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_style(buttonMaxFeedrate, LV_BTN_STYLE_REL, &tft_style_label_rel); // Set the button's released style
lv_btn_set_style(buttonMaxFeedrate, LV_BTN_STYLE_PR, &tft_style_label_pre); // Set the button's pressed style
lv_btn_set_layout(buttonMaxFeedrate, LV_LAYOUT_OFF);
labelMaxFeedrate = lv_label_create(buttonMaxFeedrate, NULL); /*Add a label to the button*/
labelMaxFeedrate = lv_label_create(buttonMaxFeedrate, NULL); // Add a label to the button
buttonMaxFeedrateNarrow = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonMaxFeedrateNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonMaxFeedrateNarrow, event_handler, ID_MACHINE_FEEDRATE_ARROW, "bmp_arrow.bin", 0);
lv_imgbtn_set_src(buttonMaxFeedrateNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
lv_imgbtn_set_src(buttonMaxFeedrateNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
lv_obj_set_event_cb_mks(buttonMaxFeedrateNarrow, event_handler, ID_MACHINE_FEEDRATE_ARROW, NULL, 0);
lv_imgbtn_set_src(buttonMaxFeedrateNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonMaxFeedrateNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonMaxFeedrateNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonMaxFeedrateNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonMaxFeedrateNarrow, LV_LAYOUT_OFF);
@ -186,21 +184,21 @@ void lv_draw_machine_settings(void) {
lv_ex_line(line2, line_points[1]);
#if HAS_CLASSIC_JERK
buttonJerk = lv_btn_create(scr, NULL); /*Add a button the current screen*/
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*/
buttonJerk = lv_btn_create(scr, NULL); // Add a button the current screen
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_set_style(buttonJerk, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonJerk, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_style(buttonJerk, LV_BTN_STYLE_REL, &tft_style_label_rel); // Set the button's released style
lv_btn_set_style(buttonJerk, LV_BTN_STYLE_PR, &tft_style_label_pre); // Set the button's pressed style
lv_btn_set_layout(buttonJerk, LV_LAYOUT_OFF);
labelJerk = lv_label_create(buttonJerk, NULL); /*Add a label to the button*/
labelJerk = lv_label_create(buttonJerk, NULL); // Add a label to the button
buttonJerkNarrow = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonJerkNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonJerkNarrow, event_handler, ID_MACHINE_JERK_ARROW, "bmp_arrow.bin", 0);
lv_imgbtn_set_src(buttonJerkNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
lv_imgbtn_set_src(buttonJerkNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
lv_obj_set_event_cb_mks(buttonJerkNarrow, event_handler, ID_MACHINE_JERK_ARROW, NULL, 0);
lv_imgbtn_set_src(buttonJerkNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonJerkNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonJerkNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonJerkNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonJerkNarrow, LV_LAYOUT_OFF);
@ -210,9 +208,9 @@ void lv_draw_machine_settings(void) {
#endif
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MACHINE_RETURN, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MACHINE_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
@ -234,8 +232,23 @@ void lv_draw_machine_settings(void) {
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
}
void lv_clear_machine_settings() { lv_obj_del(scr); }
void lv_clear_machine_settings() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

69
Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp

@ -32,7 +32,7 @@
#include "draw_ui.h"
#include "../../../../gcode/queue.h"
//static lv_obj_t *buttonMoveZ,*buttonTest,*buttonZ0,*buttonStop,*buttonReturn;
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_M_POINT1 1
@ -59,7 +59,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
queue.enqueue_now_P(PSTR("G1 Z10"));
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), X_MIN_POS + 30, Y_MIN_POS + 30);
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"));
}
@ -79,7 +79,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
queue.enqueue_now_P(PSTR("G1 Z10"));
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), X_MAX_POS - 30, Y_MIN_POS + 30);
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"));
}
@ -99,7 +99,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
queue.enqueue_now_P(PSTR("G1 Z10"));
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), X_MAX_POS - 30, Y_MAX_POS - 30);
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"));
}
@ -120,7 +120,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
queue.enqueue_now_P(PSTR("G1 Z10"));
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), X_MIN_POS + 30, Y_MAX_POS - 30);
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"));
}
@ -140,7 +140,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
queue.enqueue_now_P(PSTR("G1 Z10"));
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), X_BED_SIZE / 2, Y_BED_SIZE / 2);
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"));
}
@ -159,7 +159,6 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
}
}
void lv_draw_manualLevel(void) {
lv_obj_t *buttonPoint1, *buttonPoint2, *buttonPoint3, *buttonPoint4, *buttonPoint5;
lv_obj_t *buttonBack;
@ -185,8 +184,6 @@ void lv_draw_manualLevel(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_pic);
// Create an Image button
buttonPoint1 = lv_imgbtn_create(scr, NULL);
buttonPoint2 = lv_imgbtn_create(scr, NULL);
@ -195,40 +192,41 @@ void lv_draw_manualLevel(void) {
buttonPoint5 = lv_imgbtn_create(scr, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonPoint1, event_handler, ID_M_POINT1, "bmp_leveling1.bin", 0);
lv_imgbtn_set_src(buttonPoint1, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonPoint1, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonPoint1, event_handler, ID_M_POINT1, NULL, 0);
lv_imgbtn_set_src(buttonPoint1, LV_BTN_STATE_REL, "F:/bmp_leveling1.bin");
lv_imgbtn_set_src(buttonPoint1, LV_BTN_STATE_PR, "F:/bmp_leveling1.bin");
lv_imgbtn_set_style(buttonPoint1, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonPoint1, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_clear_protect(buttonPoint1, LV_PROTECT_FOLLOW);
#if 1
lv_obj_set_event_cb_mks(buttonPoint2, event_handler, ID_M_POINT2, "bmp_leveling2.bin", 0);
lv_imgbtn_set_src(buttonPoint2, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonPoint2, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonPoint2, event_handler, ID_M_POINT2, NULL, 0);
lv_imgbtn_set_src(buttonPoint2, LV_BTN_STATE_REL, "F:/bmp_leveling2.bin");
lv_imgbtn_set_src(buttonPoint2, LV_BTN_STATE_PR, "F:/bmp_leveling2.bin");
lv_imgbtn_set_style(buttonPoint2, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonPoint2, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonPoint3, event_handler, ID_M_POINT3, "bmp_leveling3.bin", 0);
lv_imgbtn_set_src(buttonPoint3, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonPoint3, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonPoint3, event_handler, ID_M_POINT3, NULL, 0);
lv_imgbtn_set_src(buttonPoint3, LV_BTN_STATE_REL, "F:/bmp_leveling3.bin");
lv_imgbtn_set_src(buttonPoint3, LV_BTN_STATE_PR, "F:/bmp_leveling3.bin");
lv_imgbtn_set_style(buttonPoint3, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonPoint3, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonPoint4, event_handler, ID_M_POINT4, "bmp_leveling4.bin", 0);
lv_imgbtn_set_src(buttonPoint4, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonPoint4, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonPoint4, event_handler, ID_M_POINT4, NULL, 0);
lv_imgbtn_set_src(buttonPoint4, LV_BTN_STATE_REL, "F:/bmp_leveling4.bin");
lv_imgbtn_set_src(buttonPoint4, LV_BTN_STATE_PR, "F:/bmp_leveling4.bin");
lv_imgbtn_set_style(buttonPoint4, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonPoint4, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonPoint5, event_handler, ID_M_POINT5, "bmp_leveling5.bin", 0);
lv_imgbtn_set_src(buttonPoint5, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonPoint5, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonPoint5, event_handler, ID_M_POINT5, NULL, 0);
lv_imgbtn_set_src(buttonPoint5, LV_BTN_STATE_REL, "F:/bmp_leveling5.bin");
lv_imgbtn_set_src(buttonPoint5, LV_BTN_STATE_PR, "F:/bmp_leveling5.bin");
lv_imgbtn_set_style(buttonPoint5, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonPoint5, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MANUAL_RETURN, "bmp_return.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MANUAL_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif
@ -274,8 +272,23 @@ void lv_draw_manualLevel(void) {
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() { lv_obj_del(scr); }
void lv_clear_manualLevel() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

459
Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.cpp

@ -0,0 +1,459 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI
#include "lv_conf.h"
#include "draw_ui.h"
#include "../../../../MarlinCore.h"
#include "../../../../module/planner.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_MANUAL_POS_RETURN 1
#define ID_MANUAL_POS_X1 2
#define ID_MANUAL_POS_Y1 3
#define ID_MANUAL_POS_X2 4
#define ID_MANUAL_POS_Y2 5
#define ID_MANUAL_POS_X3 6
#define ID_MANUAL_POS_Y3 7
#define ID_MANUAL_POS_X4 8
#define ID_MANUAL_POS_Y4 9
#define ID_MANUAL_POS_X5 10
#define ID_MANUAL_POS_Y5 11
#define ID_MANUAL_POS_DOWN 12
#define ID_MANUAL_POS_UP 13
static void event_handler(lv_obj_t * obj, lv_event_t event) {
switch (obj->mks_obj_id) {
case ID_MANUAL_POS_RETURN:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 0;
lv_clear_manual_level_pos_settings();
draw_return_ui();
}
break;
case ID_MANUAL_POS_X1:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = level_pos_x1;
lv_clear_manual_level_pos_settings();
lv_draw_number_key();
}
break;
case ID_MANUAL_POS_Y1:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = level_pos_y1;
lv_clear_manual_level_pos_settings();
lv_draw_number_key();
}
break;
case ID_MANUAL_POS_X2:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = level_pos_x2;
lv_clear_manual_level_pos_settings();
lv_draw_number_key();
}
break;
case ID_MANUAL_POS_Y2:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = level_pos_y2;
lv_clear_manual_level_pos_settings();
lv_draw_number_key();
}
break;
case ID_MANUAL_POS_X3:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = level_pos_x3;
lv_clear_manual_level_pos_settings();
lv_draw_number_key();
}
break;
case ID_MANUAL_POS_Y3:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = level_pos_y3;
lv_clear_manual_level_pos_settings();
lv_draw_number_key();
}
break;
case ID_MANUAL_POS_X4:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = level_pos_x4;
lv_clear_manual_level_pos_settings();
lv_draw_number_key();
}
break;
case ID_MANUAL_POS_Y4:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = level_pos_y4;
lv_clear_manual_level_pos_settings();
lv_draw_number_key();
}
break;
case ID_MANUAL_POS_X5:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = level_pos_y5;
lv_clear_manual_level_pos_settings();
lv_draw_number_key();
}
break;
case ID_MANUAL_POS_Y5:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = level_pos_y5;
lv_clear_manual_level_pos_settings();
lv_draw_number_key();
}
break;
case ID_MANUAL_POS_UP:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 0;
lv_clear_manual_level_pos_settings();
lv_draw_manual_level_pos_settings();
}
break;
case ID_MANUAL_POS_DOWN:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 1;
lv_clear_manual_level_pos_settings();
lv_draw_manual_level_pos_settings();
}
break;
}
}
void lv_draw_manual_level_pos_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL;
lv_obj_t *labelPoint1Text = NULL, *buttonX1Value = NULL, *labelX1Value = NULL;
lv_obj_t *buttonY1Value = NULL, *labelY1Value = NULL;
lv_obj_t *labelPoint2Text = NULL, *buttonX2Value = NULL, *labelX2Value = NULL;
lv_obj_t *buttonY2Value = NULL, *labelY2Value = NULL;
lv_obj_t *labelPoint3Text = NULL, *buttonX3Value = NULL, *labelX3Value = NULL;
lv_obj_t *buttonY3Value = NULL, *labelY3Value = NULL;
lv_obj_t *labelPoint4Text = NULL, *buttonX4Value = NULL, *labelX4Value = NULL;
lv_obj_t *buttonY4Value = NULL, *labelY4Value = NULL;
lv_obj_t *labelPoint5Text = NULL, *buttonX5Value = NULL, *labelX5Value = NULL;
lv_obj_t *buttonY5Value = NULL, *labelY5Value = NULL;
lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MANUAL_LEVELING_POSIGION_UI) {
disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = MANUAL_LEVELING_POSIGION_UI;
}
disp_state = MANUAL_LEVELING_POSIGION_UI;
scr = lv_obj_create(NULL, NULL);
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
lv_obj_t * title = lv_label_create(scr, NULL);
lv_obj_set_style(title, &tft_style_label_rel);
lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
lv_label_set_text(title, machine_menu.LevelingParaConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing());
if (uiCfg.para_ui_page != 1) {
labelPoint1Text = lv_label_create(scr, NULL);
lv_obj_set_style(labelPoint1Text, &tft_style_label_rel);
lv_obj_set_pos(labelPoint1Text, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
lv_label_set_text(labelPoint1Text, leveling_menu.position1);
buttonX1Value = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonX1Value, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonX1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonX1Value, event_handler, ID_MANUAL_POS_X1, NULL, 0);
lv_btn_set_style(buttonX1Value, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonX1Value, LV_BTN_STYLE_PR, &style_para_value);
labelX1Value = lv_label_create(buttonX1Value, NULL);
buttonY1Value = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonY1Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonY1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonY1Value, event_handler, ID_MANUAL_POS_Y1, NULL, 0);
lv_btn_set_style(buttonY1Value, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonY1Value, LV_BTN_STYLE_PR, &style_para_value);
labelY1Value = lv_label_create(buttonY1Value, NULL);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
labelPoint2Text = lv_label_create(scr, NULL);
lv_obj_set_style(labelPoint2Text, &tft_style_label_rel);
lv_obj_set_pos(labelPoint2Text, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
lv_label_set_text(labelPoint2Text, leveling_menu.position2);
buttonX2Value = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonX2Value, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonX2Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonX2Value, event_handler, ID_MANUAL_POS_X2, NULL, 0);
lv_btn_set_style(buttonX2Value, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonX2Value, LV_BTN_STYLE_PR, &style_para_value);
labelX2Value = lv_label_create(buttonX2Value, NULL);
buttonY2Value = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonY2Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonY2Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonY2Value, event_handler, ID_MANUAL_POS_Y2, NULL, 0);
lv_btn_set_style(buttonY2Value, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonY2Value, LV_BTN_STYLE_PR, &style_para_value);
labelY2Value = lv_label_create(buttonY2Value, NULL);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
labelPoint3Text = lv_label_create(scr, NULL);
lv_obj_set_style(labelPoint3Text, &tft_style_label_rel);
lv_obj_set_pos(labelPoint3Text, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
lv_label_set_text(labelPoint3Text, leveling_menu.position3);
buttonX3Value = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonX3Value, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonX3Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonX3Value, event_handler, ID_MANUAL_POS_X3, NULL, 0);
lv_btn_set_style(buttonX3Value, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonX3Value, LV_BTN_STYLE_PR, &style_para_value);
labelX3Value = lv_label_create(buttonX3Value, NULL);
buttonY3Value = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonY3Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonY3Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonY3Value, event_handler, ID_MANUAL_POS_Y3, NULL, 0);
lv_btn_set_style(buttonY3Value, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonY3Value, LV_BTN_STYLE_PR, &style_para_value);
labelY3Value = lv_label_create(buttonY3Value, NULL);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
labelPoint4Text = lv_label_create(scr, NULL);
lv_obj_set_style(labelPoint4Text, &tft_style_label_rel);
lv_obj_set_pos(labelPoint4Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
lv_label_set_text(labelPoint4Text, leveling_menu.position4);
buttonX4Value = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonX4Value, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonX4Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonX4Value, event_handler, ID_MANUAL_POS_X4, NULL, 0);
lv_btn_set_style(buttonX4Value, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonX4Value, LV_BTN_STYLE_PR, &style_para_value);
labelX4Value = lv_label_create(buttonX4Value, NULL);
buttonY4Value = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonY4Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonY4Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonY4Value, event_handler, ID_MANUAL_POS_Y4, NULL, 0);
lv_btn_set_style(buttonY4Value, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonY4Value, LV_BTN_STYLE_PR, &style_para_value);
labelY4Value = lv_label_create(buttonY4Value, NULL);
line4 = lv_line_create(scr, NULL);
lv_ex_line(line4, line_points[3]);
buttonTurnPage = lv_btn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_MANUAL_POS_DOWN, NULL, 0);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonX1Value);
lv_group_add_obj(g, buttonY1Value);
lv_group_add_obj(g, buttonX2Value);
lv_group_add_obj(g, buttonY2Value);
lv_group_add_obj(g, buttonX3Value);
lv_group_add_obj(g, buttonY3Value);
lv_group_add_obj(g, buttonX4Value);
lv_group_add_obj(g, buttonY4Value);
lv_group_add_obj(g, buttonTurnPage);
}
#endif
}
else {
labelPoint5Text = lv_label_create(scr, NULL);
lv_obj_set_style(labelPoint5Text, &tft_style_label_rel);
lv_obj_set_pos(labelPoint5Text, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
lv_label_set_text(labelPoint5Text, leveling_menu.position5);
buttonX5Value = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonX5Value, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonX5Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonX5Value, event_handler, ID_MANUAL_POS_X5, NULL, 0);
lv_btn_set_style(buttonX5Value, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonX5Value, LV_BTN_STYLE_PR, &style_para_value);
labelX5Value = lv_label_create(buttonX5Value, NULL);
buttonY5Value = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonY5Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2);
lv_obj_set_size(buttonY5Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonY5Value, event_handler, ID_MANUAL_POS_Y5, NULL, 0);
lv_btn_set_style(buttonY5Value, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonY5Value, LV_BTN_STYLE_PR, &style_para_value);
labelY5Value = lv_label_create(buttonY5Value, NULL);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonTurnPage = lv_btn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_MANUAL_POS_UP, NULL, 0);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonX5Value);
lv_group_add_obj(g, buttonY5Value);
lv_group_add_obj(g, buttonTurnPage);
}
#endif
}
lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
labelTurnPage = lv_label_create(buttonTurnPage, NULL);
buttonBack = lv_btn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MANUAL_POS_RETURN, NULL, 0);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
label_Back = lv_label_create(buttonBack, NULL);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif
if (gCfgItems.multiple_language != 0) {
if (uiCfg.para_ui_page != 1) {
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[0][0]);
lv_label_set_text(labelX1Value, public_buf_l);
lv_obj_align(labelX1Value, buttonX1Value, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[0][1]);
lv_label_set_text(labelY1Value, public_buf_l);
lv_obj_align(labelY1Value, buttonY1Value, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[1][0]);
lv_label_set_text(labelX2Value, public_buf_l);
lv_obj_align(labelX2Value, buttonX2Value, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[1][1]);
lv_label_set_text(labelY2Value, public_buf_l);
lv_obj_align(labelY2Value, buttonY2Value, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[2][0]);
lv_label_set_text(labelX3Value, public_buf_l);
lv_obj_align(labelX3Value, buttonX3Value, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[2][1]);
lv_label_set_text(labelY3Value, public_buf_l);
lv_obj_align(labelY3Value, buttonY3Value, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[3][0]);
lv_label_set_text(labelX4Value, public_buf_l);
lv_obj_align(labelX4Value, buttonX4Value, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[3][1]);
lv_label_set_text(labelY4Value, public_buf_l);
lv_obj_align(labelY4Value, buttonY4Value, LV_ALIGN_CENTER, 0, 0);
lv_label_set_text(labelTurnPage, machine_menu.next);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
}
else {
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[4][0]);
lv_label_set_text(labelX5Value, public_buf_l);
lv_obj_align(labelX5Value, buttonX5Value, LV_ALIGN_CENTER, 0, 0);
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[4][1]);
lv_label_set_text(labelY5Value, public_buf_l);
lv_obj_align(labelY5Value, buttonY5Value, LV_ALIGN_CENTER, 0, 0);
lv_label_set_text(labelTurnPage, machine_menu.previous);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
}
lv_label_set_text(label_Back, common_menu.text_back);
lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
}
}
void lv_clear_manual_level_pos_settings() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

33
Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.h

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

212
Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.cpp

@ -29,6 +29,7 @@
#include "../../../../MarlinCore.h"
#include "../../../../module/planner.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_FEED_RETURN 1
@ -127,11 +128,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
void lv_draw_max_feedrate_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL;
lv_obj_t *buttonXText = NULL, *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *buttonYText = NULL, *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *buttonZText = NULL, *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t *buttonE0Text = NULL, *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL;
lv_obj_t *buttonE1Text = NULL, *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL;
lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL;
lv_obj_t *labelE1Text = NULL, *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) {
disp_state_stack._disp_index++;
@ -152,166 +153,139 @@ void lv_draw_max_feedrate_settings(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_para_back);
// LV_IMG_DECLARE(bmp_para_arrow);
LV_IMG_DECLARE(bmp_para_bank);
if (uiCfg.para_ui_page != 1) {
buttonXText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
lv_obj_set_size(buttonXText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonXText, event_handler);
lv_btn_set_style(buttonXText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonXText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonXText, LV_LAYOUT_OFF);
labelXText = lv_label_create(buttonXText, NULL); /*Add a label to the button*/
buttonXValue = lv_imgbtn_create(scr, NULL);
labelXText = lv_label_create(scr, NULL);
lv_obj_set_style(labelXText, &tft_style_label_rel);
lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
lv_label_set_text(labelXText, machine_menu.XMaxFeedRate);
buttonXValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_FEED_X, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_FEED_X, NULL, 0);
lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value);
lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF);
labelXValue = lv_label_create(buttonXValue, NULL);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonYText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/
lv_obj_set_size(buttonYText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonYText, event_handler);
lv_btn_set_style(buttonYText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonYText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonYText, LV_LAYOUT_OFF);
labelYText = lv_label_create(buttonYText, NULL); /*Add a label to the button*/
labelYText = lv_label_create(scr, NULL);
lv_obj_set_style(labelYText, &tft_style_label_rel);
lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
lv_label_set_text(labelYText, machine_menu.YMaxFeedRate);
buttonYValue = lv_imgbtn_create(scr, NULL);
buttonYValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_FEED_Y, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_FEED_Y, NULL, 0);
lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value);
lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF);
labelYValue = lv_label_create(buttonYValue, NULL);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
buttonZText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/
lv_obj_set_size(buttonZText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonZText, event_handler);
lv_btn_set_style(buttonZText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonZText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonZText, LV_LAYOUT_OFF);
labelZText = lv_label_create(buttonZText, NULL); /*Add a label to the button*/
labelZText = lv_label_create(scr, NULL);
lv_obj_set_style(labelZText, &tft_style_label_rel);
lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
lv_label_set_text(labelZText, machine_menu.ZMaxFeedRate);
buttonZValue = lv_imgbtn_create(scr, NULL);
buttonZValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_FEED_Z, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_FEED_Z, NULL, 0);
lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value);
lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF);
labelZValue = lv_label_create(buttonZValue, NULL);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
buttonE0Text = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4); /*Set its position*/
lv_obj_set_size(buttonE0Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonE0Text, event_handler);
lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonE0Text, LV_LAYOUT_OFF);
labelE0Text = lv_label_create(buttonE0Text, NULL); /*Add a label to the button*/
labelE0Text = lv_label_create(scr, NULL);
lv_obj_set_style(labelE0Text, &tft_style_label_rel);
lv_obj_set_pos(labelE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
lv_label_set_text(labelE0Text, machine_menu.E0MaxFeedRate);
buttonE0Value = lv_imgbtn_create(scr, NULL);
buttonE0Value = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonE0Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_FEED_E0, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_REL, &style_para_value_rel);
lv_obj_set_size(buttonE0Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_FEED_E0, NULL, 0);
lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_PR, &style_para_value);
lv_btn_set_layout(buttonE0Value, LV_LAYOUT_OFF);
labelE0Value = lv_label_create(buttonE0Value, NULL);
line4 = lv_line_create(scr, NULL);
lv_ex_line(line4, line_points[3]);
buttonTurnPage = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FEED_DOWN, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back);
lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
buttonTurnPage = lv_btn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FEED_DOWN, NULL, 0);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, 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 {
buttonE1Text = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonE1Text, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
lv_obj_set_size(buttonE1Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonE1Text, event_handler);
lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonE1Text, LV_LAYOUT_OFF);
labelE1Text = lv_label_create(buttonE1Text, NULL); /*Add a label to the button*/
buttonE1Value = lv_imgbtn_create(scr, NULL);
labelE1Text = lv_label_create(scr, NULL);
lv_obj_set_style(labelE1Text, &tft_style_label_rel);
lv_obj_set_pos(labelE1Text, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
lv_label_set_text(labelE1Text, machine_menu.E1MaxFeedRate);
buttonE1Value = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonE1Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_FEED_E1, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_REL, &style_para_value_rel);
lv_obj_set_size(buttonE1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_FEED_E1, NULL, 0);
lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_PR, &style_para_value);
lv_btn_set_layout(buttonE1Value, LV_LAYOUT_OFF);
labelE1Value = lv_label_create(buttonE1Value, NULL);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonTurnPage = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FEED_UP, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back);
lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
buttonTurnPage = lv_btn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FEED_UP, NULL, 0);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, 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_btn_set_layout(buttonTurnPage, LV_LAYOUT_OFF);
lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
labelTurnPage = lv_label_create(buttonTurnPage, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_FEED_RETURN, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
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_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
label_Back = lv_label_create(buttonBack, NULL);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif
if (gCfgItems.multiple_language != 0) {
if (uiCfg.para_ui_page != 1) {
lv_label_set_text(labelXText, machine_menu.XMaxFeedRate);
lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelYText, machine_menu.YMaxFeedRate);
lv_obj_align(labelYText, buttonYText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelZText, machine_menu.ZMaxFeedRate);
lv_obj_align(labelZText, buttonZText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelE0Text, machine_menu.E0MaxFeedRate);
lv_obj_align(labelE0Text, buttonE0Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelTurnPage, machine_menu.next);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
@ -337,9 +311,6 @@ void lv_draw_max_feedrate_settings(void) {
lv_obj_align(labelE0Value, buttonE0Value, LV_ALIGN_CENTER, 0, 0);
}
else {
lv_label_set_text(labelE1Text, machine_menu.E1MaxFeedRate);
lv_obj_align(labelE1Text, buttonE1Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelTurnPage, machine_menu.previous);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
@ -354,6 +325,11 @@ void lv_draw_max_feedrate_settings(void) {
}
}
void lv_clear_max_feedrate_settings() { lv_obj_del(scr); }
void lv_clear_max_feedrate_settings() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

160
Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.cpp

@ -28,6 +28,7 @@
#include "../../../../MarlinCore.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_MOTOR_RETURN 1
@ -37,6 +38,8 @@ static lv_obj_t * scr;
#define ID_MOTOR_TMC_CURRENT_ARROW 5
#define ID_MOTOR_STEP_MODE 6
#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) {
switch (obj->mks_obj_id) {
@ -67,6 +70,26 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
lv_draw_step_settings();
}
break;
#if USE_SENSORLESS
case ID_HOME_SENSE:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_motor_settings();
lv_draw_homing_sensitivity_settings();
}
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
#if HAS_TRINAMIC_CONFIG
case ID_MOTOR_TMC_CURRENT:
if (event == LV_EVENT_CLICKED) {
@ -113,15 +136,27 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
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;
lv_obj_t * line2;
#if HAS_STEALTHCHOP
#if USE_SENSORLESS
lv_obj_t * line4;
#else
lv_obj_t * line3;
#endif
lv_obj_t *buttonStepMode, *labelStepMode, *buttonStepModeNarrow;
lv_obj_t * line3;
#endif
#endif
lv_obj_t * line1;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MOTOR_SETTINGS_UI) {
disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = MOTOR_SETTINGS_UI;
@ -141,9 +176,6 @@ void lv_draw_motor_settings(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_para_back);
LV_IMG_DECLARE(bmp_para_arrow);
buttonSteps = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonSteps, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
lv_obj_set_size(buttonSteps, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
@ -154,20 +186,54 @@ void lv_draw_motor_settings(void) {
lv_btn_set_layout(buttonSteps, LV_LAYOUT_OFF);
labelSteps = lv_label_create(buttonSteps, NULL); /*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, NULL);
lv_obj_set_pos(buttonStepsNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonStepsNarrow, event_handler, ID_MOTOR_STEPS_ARROW, "bmp_arrow.bin", 0);
lv_imgbtn_set_src(buttonStepsNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
lv_imgbtn_set_src(buttonStepsNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
lv_obj_set_event_cb_mks(buttonStepsNarrow, event_handler, ID_MOTOR_STEPS_ARROW, NULL, 0);
lv_imgbtn_set_src(buttonStepsNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonStepsNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonStepsNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonStepsNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonStepsNarrow, LV_LAYOUT_OFF);
line1 = lv_line_create(lv_scr_act(), NULL);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
#if USE_SENSORLESS
buttonSensitivity = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonSensitivity, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/
lv_obj_set_size(buttonSensitivity, 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(buttonSensitivity, event_handler, ID_HOME_SENSE, NULL, 0);
lv_btn_set_style(buttonSensitivity, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonSensitivity, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonSensitivity, LV_LAYOUT_OFF);
labelSensitivity = lv_label_create(buttonSensitivity, NULL); /*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, NULL);
lv_obj_set_pos(buttonSensitivityNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonSensitivityNarrow, event_handler, ID_HOME_SENSE_ARROW, NULL, 0);
lv_imgbtn_set_src(buttonSensitivityNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonSensitivityNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonSensitivityNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonSensitivityNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonSensitivityNarrow, LV_LAYOUT_OFF);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
#endif
#if HAS_TRINAMIC_CONFIG
buttonTMCcurrent = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonTMCcurrent, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/
lv_obj_set_pos(buttonTMCcurrent, PARA_UI_POS_X, TERN(USE_SENSORLESS, PARA_UI_POS_Y * 3, PARA_UI_POS_Y * 2));
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);
@ -175,61 +241,86 @@ void lv_draw_motor_settings(void) {
lv_btn_set_style(buttonTMCcurrent, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonTMCcurrent, LV_LAYOUT_OFF);
labelTMCcurrent = lv_label_create(buttonTMCcurrent, NULL); /*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, NULL);
lv_obj_set_pos(buttonTMCcurrentNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonTMCcurrentNarrow, event_handler, ID_MOTOR_TMC_CURRENT_ARROW, "bmp_arrow.bin", 0);
lv_imgbtn_set_src(buttonTMCcurrentNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
lv_imgbtn_set_src(buttonTMCcurrentNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
lv_obj_set_pos(buttonTMCcurrentNarrow, 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);
lv_obj_set_event_cb_mks(buttonTMCcurrentNarrow, event_handler, ID_MOTOR_TMC_CURRENT_ARROW, NULL, 0);
lv_imgbtn_set_src(buttonTMCcurrentNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonTMCcurrentNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonTMCcurrentNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonTMCcurrentNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonTMCcurrentNarrow, LV_LAYOUT_OFF);
line2 = lv_line_create(lv_scr_act(), NULL);
lv_ex_line(line2, line_points[1]);
#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
buttonStepMode = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonStepMode, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/
lv_obj_set_pos(buttonStepMode, PARA_UI_POS_X, TERN(USE_SENSORLESS, PARA_UI_POS_Y * 4, PARA_UI_POS_Y * 3));
lv_obj_set_size(buttonStepMode, 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(buttonStepMode, event_handler, ID_MOTOR_STEP_MODE, NULL, 0);
lv_btn_set_style(buttonStepMode, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonStepMode, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonStepMode, LV_LAYOUT_OFF);
labelStepMode = lv_label_create(buttonStepMode, NULL); /*Add a label to the button*/
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonStepMode);
#endif
buttonStepModeNarrow = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonStepModeNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V);
lv_obj_set_event_cb_mks(buttonStepModeNarrow, event_handler, ID_MOTOR_STEP_MODE_ARROW, "bmp_arrow.bin", 0);
lv_imgbtn_set_src(buttonStepModeNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
lv_imgbtn_set_src(buttonStepModeNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
lv_obj_set_pos(buttonStepModeNarrow, 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);
lv_obj_set_event_cb_mks(buttonStepModeNarrow, event_handler, ID_MOTOR_STEP_MODE_ARROW, NULL, 0);
lv_imgbtn_set_src(buttonStepModeNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
lv_imgbtn_set_src(buttonStepModeNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
lv_imgbtn_set_style(buttonStepModeNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonStepModeNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonStepModeNarrow, LV_LAYOUT_OFF);
line3 = lv_line_create(lv_scr_act(), NULL);
lv_ex_line(line3, line_points[2]);
#endif
#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, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MOTOR_RETURN, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MOTOR_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
label_Back = lv_label_create(buttonBack, NULL);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif
if (gCfgItems.multiple_language != 0) {
lv_label_set_text(label_Back, common_menu.text_back);
lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
lv_label_set_text(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);
@ -242,6 +333,11 @@ void lv_draw_motor_settings(void) {
}
void lv_clear_motor_settings() { lv_obj_del(scr); }
void lv_clear_motor_settings() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

87
Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp

@ -32,6 +32,7 @@
#include "draw_ui.h"
#include "../../../../gcode/queue.h"
extern lv_group_t * g;
static lv_obj_t * scr;
static lv_obj_t *labelV, *buttonV;
@ -179,8 +180,6 @@ void lv_draw_move_motor(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_pic);
// Create an Image button
buttonXI = lv_imgbtn_create(scr, NULL);
buttonXD = lv_imgbtn_create(scr, NULL);
@ -191,55 +190,56 @@ void lv_draw_move_motor(void) {
buttonV = lv_imgbtn_create(scr, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonXI, event_handler, ID_M_X_P, "bmp_xAdd.bin", 0);
lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonXI, event_handler, ID_M_X_P, NULL, 0);
lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_REL, "F:/bmp_xAdd.bin");
lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_PR, "F:/bmp_xAdd.bin");
lv_imgbtn_set_style(buttonXI, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonXI, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_clear_protect(buttonXI, LV_PROTECT_FOLLOW);
#if 1
lv_obj_set_event_cb_mks(buttonXD, event_handler, ID_M_X_N, "bmp_xDec.bin", 0);
lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonXD, event_handler, ID_M_X_N, NULL, 0);
lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_REL, "F:/bmp_xDec.bin");
lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_PR, "F:/bmp_xDec.bin");
lv_imgbtn_set_style(buttonXD, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonXD, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonYI, event_handler, ID_M_Y_P, "bmp_yAdd.bin", 0);
lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonYI, event_handler, ID_M_Y_P, NULL, 0);
lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_REL, "F:/bmp_yAdd.bin");
lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_PR, "F:/bmp_yAdd.bin");
lv_imgbtn_set_style(buttonYI, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonYI, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonYD, event_handler, ID_M_Y_N, "bmp_yDec.bin", 0);
lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonYD, event_handler, ID_M_Y_N, NULL, 0);
lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_REL, "F:/bmp_yDec.bin");
lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_PR, "F:/bmp_yDec.bin");
lv_imgbtn_set_style(buttonYD, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonYD, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonZI, event_handler, ID_M_Z_P, "bmp_zAdd.bin", 0);
lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonZI, event_handler, ID_M_Z_P, NULL, 0);
lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_REL, "F:/bmp_zAdd.bin");
lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_PR, "F:/bmp_zAdd.bin");
lv_imgbtn_set_style(buttonZI, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonZI, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonZD, event_handler, ID_M_Z_N, "bmp_zDec.bin", 0);
lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonZD, event_handler, ID_M_Z_N, NULL, 0);
lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_REL, "F:/bmp_zDec.bin");
lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_PR, "F:/bmp_zDec.bin");
lv_imgbtn_set_style(buttonZD, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonZD, LV_BTN_STATE_REL, &tft_style_label_rel);
//lv_obj_set_event_cb_mks(buttonV, event_handler,ID_T_MORE,"bmp_More.bin",0);
lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonV, event_handler, ID_M_STEP, NULL, 0);
lv_imgbtn_set_style(buttonV, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonV, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_M_RETURN, "bmp_return.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_M_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif // if 1
lv_obj_set_pos(buttonXI, INTERVAL_V, titleHeight);
lv_obj_set_pos(buttonYI, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight);
lv_obj_set_pos(buttonZI, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight);
@ -290,6 +290,18 @@ void lv_draw_move_motor(void) {
lv_label_set_text(label_Back, common_menu.text_back);
lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
}
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonXI);
lv_group_add_obj(g, buttonXD);
lv_group_add_obj(g, buttonYI);
lv_group_add_obj(g, buttonYD);
lv_group_add_obj(g, buttonZI);
lv_group_add_obj(g, buttonZD);
lv_group_add_obj(g, buttonV);
lv_group_add_obj(g, buttonBack);
}
#endif
disp_move_dist();
}
@ -297,12 +309,18 @@ void lv_draw_move_motor(void) {
void disp_move_dist() {
// char buf[30] = {0};
if ((int)(10 * uiCfg.move_dist) == 1)
lv_obj_set_event_cb_mks(buttonV, event_handler, ID_M_STEP, "bmp_step_move0_1.bin", 0);
else if ((int)(10 * uiCfg.move_dist) == 10)
lv_obj_set_event_cb_mks(buttonV, event_handler, ID_M_STEP, "bmp_step_move1.bin", 0);
else if ((int)(10 * uiCfg.move_dist) == 100)
lv_obj_set_event_cb_mks(buttonV, event_handler, ID_M_STEP, "bmp_step_move10.bin", 0);
if ((int)(10 * uiCfg.move_dist) == 1) {
lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_step_move0_1.bin");
lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_step_move0_1.bin");
}
else if ((int)(10 * uiCfg.move_dist) == 10) {
lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_step_move1.bin");
lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_step_move1.bin");
}
else if ((int)(10 * uiCfg.move_dist) == 100) {
lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_step_move10.bin");
lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_step_move10.bin");
}
if (gCfgItems.multiple_language != 0) {
if ((int)(10 * uiCfg.move_dist) == 1) {
lv_label_set_text(labelV, move_menu.step_01mm);
@ -319,6 +337,11 @@ void disp_move_dist() {
}
}
void lv_clear_move_motor() { lv_obj_del(scr); }
void lv_clear_move_motor() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

291
Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp

@ -47,6 +47,11 @@
#include "../../../../feature/tmc_util.h"
#endif
#if HAS_BED_PROBE
#include "../../../../module/probe.h"
#endif
extern lv_group_t * g;
static lv_obj_t * scr;
static lv_obj_t *buttonValue = NULL;
static lv_obj_t *labelValue = NULL;
@ -77,113 +82,92 @@ static void disp_key_value() {
float milliamps;
#endif
ZERO(public_buf_m);
switch (value) {
case PrintAcceleration:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.acceleration);
break;
case RetractAcceleration:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.retract_acceleration);
break;
case TravelAcceleration:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.travel_acceleration);
break;
case XAcceleration:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[X_AXIS]);
break;
case YAcceleration:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[Y_AXIS]);
break;
case ZAcceleration:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[Z_AXIS]);
break;
case E0Acceleration:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[E_AXIS]);
break;
case E1Acceleration:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)]);
break;
case XMaxFeedRate:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[X_AXIS]);
break;
case YMaxFeedRate:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[Y_AXIS]);
break;
case ZMaxFeedRate:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[Z_AXIS]);
break;
case E0MaxFeedRate:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS]);
break;
case E1MaxFeedRate:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS_N(1)]);
break;
case XJerk:
#if HAS_CLASSIC_JERK
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%.1f"), planner.max_jerk[X_AXIS]);
#endif
break;
case YJerk:
#if HAS_CLASSIC_JERK
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%.1f"), planner.max_jerk[Y_AXIS]);
#endif
break;
case ZJerk:
#if HAS_CLASSIC_JERK
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%.1f"), planner.max_jerk[Z_AXIS]);
#endif
break;
case EJerk:
#if HAS_CLASSIC_JERK
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%.1f"), planner.max_jerk[E_AXIS]);
#endif
break;
case Xstep:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.axis_steps_per_mm[X_AXIS]);
break;
case Ystep:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.axis_steps_per_mm[Y_AXIS]);
break;
case Zstep:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.axis_steps_per_mm[Z_AXIS]);
break;
case E0step:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.axis_steps_per_mm[E_AXIS]);
break;
case E1step:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.axis_steps_per_mm[E_AXIS_N(1)]);
break;
case Xcurrent:
#if AXIS_IS_TMC(X)
ZERO(public_buf_m);
milliamps = stepperX.getMilliamps();
sprintf_P(public_buf_m, PSTR("%.1f"), milliamps);
#endif
@ -191,7 +175,6 @@ static void disp_key_value() {
case Ycurrent:
#if AXIS_IS_TMC(Y)
ZERO(public_buf_m);
milliamps = stepperY.getMilliamps();
sprintf_P(public_buf_m, PSTR("%.1f"), milliamps);
#endif
@ -199,7 +182,6 @@ static void disp_key_value() {
case Zcurrent:
#if AXIS_IS_TMC(Z)
ZERO(public_buf_m);
milliamps = stepperZ.getMilliamps();
sprintf_P(public_buf_m, PSTR("%.1f"), milliamps);
#endif
@ -207,7 +189,6 @@ static void disp_key_value() {
case E0current:
#if AXIS_IS_TMC(E0)
ZERO(public_buf_m);
milliamps = stepperE0.getMilliamps();
sprintf_P(public_buf_m, PSTR("%.1f"), milliamps);
#endif
@ -215,24 +196,100 @@ static void disp_key_value() {
case E1current:
#if AXIS_IS_TMC(E1)
ZERO(public_buf_m);
milliamps = stepperE1.getMilliamps();
sprintf_P(public_buf_m, PSTR("%.1f"), milliamps);
#endif
break;
case pause_pos_x:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%.1f"), gCfgItems.pausePosX);
break;
case pause_pos_y:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%.1f"), gCfgItems.pausePosY);
break;
case pause_pos_z:
ZERO(public_buf_m);
sprintf_P(public_buf_m, PSTR("%.1f"), gCfgItems.pausePosZ);
break;
case level_pos_x1:
sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[0][0]);
break;
case level_pos_y1:
sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[0][1]);
break;
case level_pos_x2:
sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[1][0]);
break;
case level_pos_y2:
sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[1][1]);
break;
case level_pos_x3:
sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[2][0]);
break;
case level_pos_y3:
sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[2][1]);
break;
case level_pos_x4:
sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[3][0]);
break;
case level_pos_y4:
sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[3][1]);
break;
case level_pos_x5:
sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[4][0]);
break;
case level_pos_y5:
sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[4][1]);
break;
#if HAS_BED_PROBE
case x_offset:
#if HAS_PROBE_XY_OFFSET
sprintf_P(public_buf_m, PSTR("%.1f"), probe.offset.x);
#endif
break;
case y_offset:
#if HAS_PROBE_XY_OFFSET
sprintf_P(public_buf_m, PSTR("%.1f"), probe.offset.y);
#endif
break;
case z_offset:
sprintf_P(public_buf_m, PSTR("%.1f"), probe.offset.z);
break;
#endif
case load_length:
sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filamentchange_load_length);
break;
case load_speed:
sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filamentchange_load_speed);
break;
case unload_length:
sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filamentchange_unload_length);
break;
case unload_speed:
sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filamentchange_unload_speed);
break;
case filament_temp:
sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filament_limit_temper);
break;
case x_sensitivity:
#if X_SENSORLESS
sprintf_P(public_buf_m, PSTR("%d"), TERN(X_SENSORLESS, stepperX.homing_threshold(), 0));
#endif
break;
case y_sensitivity:
#if Y_SENSORLESS
sprintf_P(public_buf_m, PSTR("%d"), TERN(Y_SENSORLESS, stepperY.homing_threshold(), 0));
#endif
break;
case z_sensitivity:
#if Z_SENSORLESS
sprintf_P(public_buf_m, PSTR("%d"), TERN(Z_SENSORLESS, stepperZ.homing_threshold(), 0));
#endif
break;
case z2_sensitivity:
#if Z2_SENSORLESS
sprintf_P(public_buf_m, PSTR("%d"), TERN(Z2_SENSORLESS, stepperZ2.homing_threshold(), 0));
#endif
break;
}
ZERO(key_value);
strcpy(key_value, public_buf_m);
@ -313,18 +370,23 @@ static void set_value_confirm() {
break;
case Xstep:
planner.settings.axis_steps_per_mm[X_AXIS] = atof(key_value);
planner.refresh_positioning();
break;
case Ystep:
planner.settings.axis_steps_per_mm[Y_AXIS] = atof(key_value);
planner.refresh_positioning();
break;
case Zstep:
planner.settings.axis_steps_per_mm[Z_AXIS] = atof(key_value);
planner.refresh_positioning();
break;
case E0step:
planner.settings.axis_steps_per_mm[E_AXIS] = atof(key_value);
planner.refresh_positioning();
break;
case E1step:
planner.settings.axis_steps_per_mm[E_AXIS_N(1)] = atof(key_value);
planner.refresh_positioning();
break;
case Xcurrent:
#if AXIS_IS_TMC(X)
@ -368,6 +430,114 @@ static void set_value_confirm() {
gCfgItems.pausePosZ = atof(key_value);
update_spi_flash();
break;
case level_pos_x1:
gCfgItems.levelingPos[0][0] = atoi(key_value);
update_spi_flash();
break;
case level_pos_y1:
gCfgItems.levelingPos[0][1] = atoi(key_value);
update_spi_flash();
break;
case level_pos_x2:
gCfgItems.levelingPos[1][0] = atoi(key_value);
update_spi_flash();
break;
case level_pos_y2:
gCfgItems.levelingPos[1][1] = atoi(key_value);
update_spi_flash();
break;
case level_pos_x3:
gCfgItems.levelingPos[2][0] = atoi(key_value);
update_spi_flash();
break;
case level_pos_y3:
gCfgItems.levelingPos[2][1] = atoi(key_value);
update_spi_flash();
break;
case level_pos_x4:
gCfgItems.levelingPos[3][0] = atoi(key_value);
update_spi_flash();
break;
case level_pos_y4:
gCfgItems.levelingPos[3][1] = atoi(key_value);
update_spi_flash();
break;
case level_pos_x5:
gCfgItems.levelingPos[4][0] = atoi(key_value);
update_spi_flash();
break;
case level_pos_y5:
gCfgItems.levelingPos[4][1] = atoi(key_value);
update_spi_flash();
break;
#if HAS_BED_PROBE
case x_offset:
#if HAS_PROBE_XY_OFFSET
float x;
x = atof(key_value);
if (WITHIN(x, -(X_BED_SIZE), X_BED_SIZE))
probe.offset.x = x;
#endif
break;
case y_offset:
#if HAS_PROBE_XY_OFFSET
float y;
y = atof(key_value);
if (WITHIN(y, -(Y_BED_SIZE), Y_BED_SIZE))
probe.offset.y = y;
#endif
break;
case z_offset:
float z;
z = atof(key_value);
if (WITHIN(z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX))
probe.offset.z = z;
break;
#endif
case load_length:
gCfgItems.filamentchange_load_length = atoi(key_value);
uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length*60.0/gCfgItems.filamentchange_load_speed)+0.5);
update_spi_flash();
break;
case load_speed:
gCfgItems.filamentchange_load_speed = atoi(key_value);
uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length*60.0/gCfgItems.filamentchange_load_speed)+0.5);
update_spi_flash();
break;
case unload_length:
gCfgItems.filamentchange_unload_length = atoi(key_value);
uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length*60.0/gCfgItems.filamentchange_unload_speed)+0.5);
update_spi_flash();
break;
case unload_speed:
gCfgItems.filamentchange_unload_speed = atoi(key_value);
uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length*60.0/gCfgItems.filamentchange_unload_speed)+0.5);
update_spi_flash();
break;
case filament_temp:
gCfgItems.filament_limit_temper = atoi(key_value);
update_spi_flash();
break;
case x_sensitivity:
#if X_SENSORLESS
stepperX.homing_threshold(atoi(key_value));
#endif
break;
case y_sensitivity:
#if Y_SENSORLESS
stepperY.homing_threshold(atoi(key_value));
#endif
break;
case z_sensitivity:
#if Z_SENSORLESS
stepperZ.homing_threshold(atoi(key_value));
#endif
break;
case z2_sensitivity:
#if Z2_SENSORLESS
stepperZ2.homing_threshold(atoi(key_value));
#endif
break;
}
gcode.process_subcommands_now_P(PSTR("M500"));
}
@ -604,15 +774,13 @@ void lv_draw_number_key(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
//LV_IMG_DECLARE(bmp_pic);
buttonValue = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonValue, 92, 40); /*Set its position*/
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);
//lv_btn_set_layout(buttonValue, LV_LAYOUT_OFF);
labelValue = lv_label_create(buttonValue, NULL); /*Add a label to the button*/
NumberKey_1 = lv_btn_create(scr, NULL); /*Add a button the current screen*/
@ -621,7 +789,7 @@ void lv_draw_number_key(void) {
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);
//lv_btn_set_layout(NumberKey_1, LV_LAYOUT_OFF);
labelKey_1 = lv_label_create(NumberKey_1, NULL); /*Add a label to the button*/
lv_label_set_text(labelKey_1, machine_menu.key_1);
lv_obj_align(labelKey_1, NumberKey_1, LV_ALIGN_CENTER, 0, 0);
@ -632,7 +800,7 @@ void lv_draw_number_key(void) {
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);
//lv_btn_set_layout(NumberKey_2, LV_LAYOUT_OFF);
labelKey_2 = lv_label_create(NumberKey_2, NULL); /*Add a label to the button*/
lv_label_set_text(labelKey_2, machine_menu.key_2);
lv_obj_align(labelKey_2, NumberKey_2, LV_ALIGN_CENTER, 0, 0);
@ -643,7 +811,7 @@ void lv_draw_number_key(void) {
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);
//lv_btn_set_layout(NumberKey_3, LV_LAYOUT_OFF);
labelKey_3 = lv_label_create(NumberKey_3, NULL); /*Add a label to the button*/
lv_label_set_text(labelKey_3, machine_menu.key_3);
lv_obj_align(labelKey_3, NumberKey_3, LV_ALIGN_CENTER, 0, 0);
@ -654,7 +822,7 @@ void lv_draw_number_key(void) {
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);
//lv_btn_set_layout(NumberKey_4, LV_LAYOUT_OFF);
labelKey_4 = lv_label_create(NumberKey_4, NULL); /*Add a label to the button*/
lv_label_set_text(labelKey_4, machine_menu.key_4);
lv_obj_align(labelKey_4, NumberKey_4, LV_ALIGN_CENTER, 0, 0);
@ -665,7 +833,7 @@ void lv_draw_number_key(void) {
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);
//lv_btn_set_layout(NumberKey_5, LV_LAYOUT_OFF);
labelKey_5 = lv_label_create(NumberKey_5, NULL); /*Add a label to the button*/
lv_label_set_text(labelKey_5, machine_menu.key_5);
lv_obj_align(labelKey_5, NumberKey_5, LV_ALIGN_CENTER, 0, 0);
@ -676,7 +844,7 @@ void lv_draw_number_key(void) {
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);
//lv_btn_set_layout(NumberKey_6, LV_LAYOUT_OFF);
labelKey_6 = lv_label_create(NumberKey_6, NULL); /*Add a label to the button*/
lv_label_set_text(labelKey_6, machine_menu.key_6);
lv_obj_align(labelKey_6, NumberKey_6, LV_ALIGN_CENTER, 0, 0);
@ -687,7 +855,7 @@ void lv_draw_number_key(void) {
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);
//lv_btn_set_layout(NumberKey_7, LV_LAYOUT_OFF);
labelKey_7 = lv_label_create(NumberKey_7, NULL); /*Add a label to the button*/
lv_label_set_text(labelKey_7, machine_menu.key_7);
lv_obj_align(labelKey_7, NumberKey_7, LV_ALIGN_CENTER, 0, 0);
@ -698,7 +866,7 @@ void lv_draw_number_key(void) {
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);
//lv_btn_set_layout(NumberKey_8, LV_LAYOUT_OFF);
labelKey_8 = lv_label_create(NumberKey_8, NULL); /*Add a label to the button*/
lv_label_set_text(labelKey_8, machine_menu.key_8);
lv_obj_align(labelKey_8, NumberKey_8, LV_ALIGN_CENTER, 0, 0);
@ -709,7 +877,7 @@ void lv_draw_number_key(void) {
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);
//lv_btn_set_layout(NumberKey_9, LV_LAYOUT_OFF);
labelKey_9 = lv_label_create(NumberKey_9, NULL); /*Add a label to the button*/
lv_label_set_text(labelKey_9, machine_menu.key_9);
lv_obj_align(labelKey_9, NumberKey_9, LV_ALIGN_CENTER, 0, 0);
@ -720,7 +888,7 @@ void lv_draw_number_key(void) {
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);
//lv_btn_set_layout(NumberKey_0, LV_LAYOUT_OFF);
labelKey_0 = lv_label_create(NumberKey_0, NULL); /*Add a label to the button*/
lv_label_set_text(labelKey_0, machine_menu.key_0);
lv_obj_align(labelKey_0, NumberKey_0, LV_ALIGN_CENTER, 0, 0);
@ -731,7 +899,7 @@ void lv_draw_number_key(void) {
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);
//lv_btn_set_layout(KeyBack, LV_LAYOUT_OFF);
labelKeyBack = lv_label_create(KeyBack, NULL); /*Add a label to the button*/
lv_label_set_text(labelKeyBack, machine_menu.key_back);
lv_obj_align(labelKeyBack, KeyBack, LV_ALIGN_CENTER, 0, 0);
@ -742,7 +910,7 @@ void lv_draw_number_key(void) {
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);
//lv_btn_set_layout(KeyReset, LV_LAYOUT_OFF);
labelKeyReset = lv_label_create(KeyReset, NULL); /*Add a label to the button*/
lv_label_set_text(labelKeyReset, machine_menu.key_reset);
lv_obj_align(labelKeyReset, KeyReset, LV_ALIGN_CENTER, 0, 0);
@ -753,7 +921,7 @@ void lv_draw_number_key(void) {
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);
//lv_btn_set_layout(KeyConfirm, LV_LAYOUT_OFF);
labelKeyConfirm = lv_label_create(KeyConfirm, NULL); /*Add a label to the button*/
lv_label_set_text(labelKeyConfirm, machine_menu.key_confirm);
lv_obj_align(labelKeyConfirm, KeyConfirm, LV_ALIGN_CENTER, 0, 0);
@ -764,7 +932,7 @@ void lv_draw_number_key(void) {
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);
//lv_btn_set_layout(KeyPoint, LV_LAYOUT_OFF);
labelKeyPoint = lv_label_create(KeyPoint, NULL); /*Add a label to the button*/
lv_label_set_text(labelKeyPoint, machine_menu.key_point);
lv_obj_align(labelKeyPoint, KeyPoint, LV_ALIGN_CENTER, 0, 0);
@ -775,14 +943,39 @@ void lv_draw_number_key(void) {
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);
//lv_btn_set_layout(Minus, LV_LAYOUT_OFF);
labelMinus = lv_label_create(Minus, NULL); /*Add a label to the button*/
lv_label_set_text(labelMinus, machine_menu.negative);
lv_obj_align(labelMinus, Minus, LV_ALIGN_CENTER, 0, 0);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, NumberKey_1);
lv_group_add_obj(g, NumberKey_2);
lv_group_add_obj(g, NumberKey_3);
lv_group_add_obj(g, KeyBack);
lv_group_add_obj(g, NumberKey_4);
lv_group_add_obj(g, NumberKey_5);
lv_group_add_obj(g, NumberKey_6);
lv_group_add_obj(g, KeyReset);
lv_group_add_obj(g, NumberKey_7);
lv_group_add_obj(g, NumberKey_8);
lv_group_add_obj(g, NumberKey_9);
lv_group_add_obj(g, NumberKey_0);
lv_group_add_obj(g, Minus);
lv_group_add_obj(g, KeyPoint);
lv_group_add_obj(g, KeyConfirm);
}
#endif
disp_key_value();
}
void lv_clear_number_key() { lv_obj_del(scr); }
void lv_clear_number_key() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

261
Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp

@ -31,7 +31,11 @@
//#include "../lvgl/src/lv_core/lv_refr.h"
#include "../../../../MarlinCore.h"
#include "../../../../module/temperature.h"
#include "../../../../module/motion.h"
#include "../../../../sd/cardreader.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_O_PRE_HEAT 1
@ -42,10 +46,13 @@ static lv_obj_t * scr;
#define ID_O_RETURN 6
#define ID_O_FAN 7
#define ID_O_POWER_OFF 8
#define ID_O_BABY_STEP 9
static lv_obj_t *label_PowerOff;
static lv_obj_t *buttonPowerOff;
extern feedRate_t feedrate_mm_s;
static void event_handler(lv_obj_t * obj, lv_event_t event) {
switch (obj->mks_obj_id) {
case ID_O_PRE_HEAT:
@ -80,6 +87,20 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
#if HAS_MULTI_EXTRUDER
uiCfg.curSprayerChoose_bak = active_extruder;
#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();
}
break;
case ID_O_FAN:
@ -116,7 +137,8 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
else if (event == LV_EVENT_RELEASED) {
if (gCfgItems.finish_power_off == 1) {
gCfgItems.finish_power_off = 0;
lv_obj_set_event_cb_mks(obj, event_handler, ID_O_POWER_OFF, "bmp_manual_off.bin", 0); // didn't find bmp_Mamual...
lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_REL, "F:/bmp_manual_off.bin");
lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_PR, "F:/bmp_manual_off.bin");
lv_label_set_text(label_PowerOff, printing_more_menu.manual);
lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_obj_refresh_ext_draw_pad(label_PowerOff);
@ -124,7 +146,8 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
}
else {
gCfgItems.finish_power_off = 1;
lv_obj_set_event_cb_mks(obj, event_handler, ID_O_POWER_OFF, "bmp_auto_off.bin", 0);
lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_REL, "F:/bmp_auto_off.bin");
lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_PR, "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);
@ -132,16 +155,26 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
}
}
break;
case ID_O_BABY_STEP:
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_operation();
lv_draw_baby_stepping();
}
break;
}
}
void lv_draw_operation(void) {
lv_obj_t *buttonPreHeat, *buttonExtrusion, *buttonSpeed;
lv_obj_t *buttonBack, *buttonFan;
lv_obj_t *labelPreHeat, *labelExtrusion;
lv_obj_t *label_Back, *label_Speed, *label_Fan;
lv_obj_t *buttonPreHeat = NULL, *buttonExtrusion = NULL, *buttonSpeed = NULL;
lv_obj_t *buttonBack = NULL, *buttonFan = NULL;
lv_obj_t *labelPreHeat = NULL, *labelExtrusion = NULL;
lv_obj_t *label_Back = NULL, *label_Speed = NULL, *label_Fan = NULL;
lv_obj_t *buttonMove = NULL, *label_Move = NULL;
lv_obj_t *buttonBabyStep = NULL, *label_BabyStep = NULL;
lv_obj_t *buttonFilament = NULL, *label_Filament = NULL;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != OPERATE_UI) {
disp_state_stack._disp_index++;
@ -162,143 +195,188 @@ void lv_draw_operation(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_pic);
/*Create an Image button*/
buttonPreHeat = lv_imgbtn_create(scr, NULL);
buttonExtrusion = lv_imgbtn_create(scr, NULL);
buttonFan = lv_imgbtn_create(scr, NULL);
buttonSpeed = lv_imgbtn_create(scr, NULL);
// Create image buttons
buttonPreHeat = lv_imgbtn_create(scr, NULL);
buttonFilament = lv_imgbtn_create(scr, NULL);
buttonFan = lv_imgbtn_create(scr, NULL);
buttonPowerOff = lv_imgbtn_create(scr, NULL);
if (uiCfg.print_state != WORKING) {
//buttonFilament = lv_imgbtn_create(scr, NULL);
//} else {
buttonMove = lv_imgbtn_create(scr, NULL);
buttonExtrusion = lv_imgbtn_create(scr, NULL);
buttonMove = lv_imgbtn_create(scr, NULL);
}
else {
buttonSpeed = lv_imgbtn_create(scr, NULL);
buttonBabyStep = lv_imgbtn_create(scr, NULL);
}
buttonBack = lv_imgbtn_create(scr, NULL);
buttonPowerOff = lv_imgbtn_create(scr, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonPreHeat, event_handler, ID_O_PRE_HEAT, "bmp_temp.bin", 0);
lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonPreHeat, event_handler, ID_O_PRE_HEAT, NULL, 0);
lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_REL, "F:/bmp_temp.bin");
lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_PR, "F:/bmp_temp.bin");
lv_imgbtn_set_style(buttonPreHeat, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonPreHeat, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_clear_protect(buttonPreHeat, LV_PROTECT_FOLLOW);
lv_obj_set_event_cb_mks(buttonFilament, event_handler, ID_O_FILAMENT, NULL, 0);
lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_REL, "F:/bmp_filamentchange.bin");
lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_PR, "F:/bmp_filamentchange.bin");
lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_REL, &tft_style_label_rel);
#if 1
lv_obj_set_event_cb_mks(buttonExtrusion, event_handler, ID_O_EXTRUCT, "bmp_extrude_opr.bin", 0);
lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_PR, &bmp_pic);
lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonFan, event_handler, ID_O_FAN, "bmp_fan.bin", 0);
lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonFan, event_handler, ID_O_FAN, NULL, 0);
lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_REL, "F:/bmp_fan.bin");
lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_PR, "F:/bmp_fan.bin");
lv_imgbtn_set_style(buttonFan, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonFan, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_O_SPEED, "bmp_speed.bin", 0);
lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, &bmp_pic);
lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_REL, &tft_style_label_rel);
if (gCfgItems.finish_power_off == 1) {
lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_REL, "F:/bmp_auto_off.bin");
lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_PR, "F:/bmp_auto_off.bin");
}
else {
lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_REL, "F:/bmp_manual_off.bin");
lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_PR, "F:/bmp_manual_off.bin");
}
lv_obj_set_event_cb_mks(buttonPowerOff, event_handler, ID_O_POWER_OFF, NULL, 0);
lv_imgbtn_set_style(buttonPowerOff, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonPowerOff, LV_BTN_STATE_REL, &tft_style_label_rel);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonPreHeat);
lv_group_add_obj(g, buttonFilament);
lv_group_add_obj(g, buttonFan);
lv_group_add_obj(g, buttonPowerOff);
}
#endif
if (uiCfg.print_state != WORKING) {
/*
lv_obj_set_event_cb_mks(buttonFilament, event_handler,ID_O_FILAMENT,"bmp_Filamentchange.bin",0);
lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_PR, &bmp_pic);
lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_REL, &tft_style_label_rel);
} else {
*/
lv_obj_set_event_cb_mks(buttonMove, event_handler, ID_O_MOV, "bmp_move_opr.bin", 0);
lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonExtrusion, event_handler, ID_O_EXTRUCT, NULL, 0);
lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_REL, "F:/bmp_extrude_opr.bin");
lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_PR, "F:/bmp_extrude_opr.bin");
lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonMove, event_handler, ID_O_MOV, NULL, 0);
lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_REL, "F:/bmp_move_opr.bin");
lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_PR, "F:/bmp_move_opr.bin");
lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_REL, &tft_style_label_rel);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonExtrusion);
lv_group_add_obj(g, buttonMove);
}
#endif
}
else {
lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_O_SPEED, NULL, 0);
lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_REL, "F:/bmp_speed.bin");
lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, "F:/bmp_speed.bin");
lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonBabyStep, event_handler, ID_O_BABY_STEP, NULL, 0);
lv_imgbtn_set_src(buttonBabyStep, LV_BTN_STATE_REL, "F:/bmp_mov.bin");
lv_imgbtn_set_src(buttonBabyStep, LV_BTN_STATE_PR, "F:/bmp_mov.bin");
lv_imgbtn_set_style(buttonBabyStep, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBabyStep, LV_BTN_STATE_REL, &tft_style_label_rel);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonSpeed);
lv_group_add_obj(g, buttonBabyStep);
}
#endif
}
if (gCfgItems.finish_power_off == 1)
lv_obj_set_event_cb_mks(buttonPowerOff, event_handler, ID_O_POWER_OFF, "bmp_auto_off.bin", 0);
else
lv_obj_set_event_cb_mks(buttonPowerOff, event_handler, ID_O_POWER_OFF, "bmp_manual_off.bin", 0);
lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_PR, &bmp_pic);
lv_imgbtn_set_style(buttonPowerOff, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonPowerOff, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_O_RETURN, "bmp_return.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_O_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif // if 1
lv_obj_set_pos(buttonPreHeat, INTERVAL_V, titleHeight);
lv_obj_set_pos(buttonExtrusion, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif
lv_obj_set_pos(buttonPreHeat, INTERVAL_V, titleHeight);
lv_obj_set_pos(buttonFilament, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight);
lv_obj_set_pos(buttonFan, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight);
lv_obj_set_pos(buttonSpeed, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight);
lv_obj_set_pos(buttonPowerOff, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight);
if (uiCfg.print_state != WORKING) {
/*
lv_obj_set_pos(buttonFilament,INTERVAL_V,BTN_Y_PIXEL+INTERVAL_H+titleHeight);
} else {
*/
lv_obj_set_pos(buttonMove, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
lv_obj_set_pos(buttonPowerOff, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
lv_obj_set_pos(buttonExtrusion, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
lv_obj_set_pos(buttonMove, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
}
else {
lv_obj_set_pos(buttonPowerOff, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
lv_obj_set_pos(buttonSpeed, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
lv_obj_set_pos(buttonBabyStep, 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);
/*Create a label on the Image button*/
// Create labels on the image buttons
lv_btn_set_layout(buttonPreHeat, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonExtrusion, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonFilament, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonFan, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonSpeed, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonPowerOff, LV_LAYOUT_OFF);
if (uiCfg.print_state != WORKING) {
/*
lv_btn_set_layout(buttonFilament, LV_LAYOUT_OFF);
} else {
*/
lv_btn_set_layout(buttonExtrusion, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonMove, LV_LAYOUT_OFF);
}
lv_btn_set_layout(buttonPowerOff, LV_LAYOUT_OFF);
else {
lv_btn_set_layout(buttonSpeed, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonBabyStep, LV_LAYOUT_OFF);
}
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
labelPreHeat = lv_label_create(buttonPreHeat, NULL);
labelExtrusion = lv_label_create(buttonExtrusion, NULL);
label_Filament = lv_label_create(buttonFilament, NULL);
label_Fan = lv_label_create(buttonFan, NULL);
label_Speed = lv_label_create(buttonSpeed, NULL);
label_PowerOff = lv_label_create(buttonPowerOff, NULL);
if (uiCfg.print_state != WORKING) {
/*
label_Filament = lv_label_create(buttonFilament, NULL);
} else {
*/
label_Move = lv_label_create(buttonMove, NULL);
labelExtrusion = lv_label_create(buttonExtrusion, NULL);
label_Move = lv_label_create(buttonMove, NULL);
}
else {
label_Speed = lv_label_create(buttonSpeed, NULL);
label_BabyStep = lv_label_create(buttonBabyStep, NULL);
}
label_PowerOff = lv_label_create(buttonPowerOff, NULL);
label_Back = lv_label_create(buttonBack, NULL);
if (gCfgItems.multiple_language != 0) {
lv_label_set_text(labelPreHeat, operation_menu.temp);
lv_obj_align(labelPreHeat, buttonPreHeat, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(labelExtrusion, operation_menu.extr);
lv_obj_align(labelExtrusion, buttonExtrusion, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_Filament, operation_menu.filament);
lv_obj_align(label_Filament, buttonFilament, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_Fan, operation_menu.fan);
lv_obj_align(label_Fan, buttonFan, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_Speed, operation_menu.speed);
lv_obj_align(label_Speed, buttonSpeed, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
if (gCfgItems.finish_power_off == 1)
lv_label_set_text(label_PowerOff, printing_more_menu.auto_close);
else
lv_label_set_text(label_PowerOff, printing_more_menu.manual);
lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
if (uiCfg.print_state != WORKING) {
/*
@ -306,21 +384,30 @@ void lv_draw_operation(void) {
lv_obj_align(label_Filament, buttonFilament, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
} else {
*/
lv_label_set_text(labelExtrusion, operation_menu.extr);
lv_obj_align(labelExtrusion, buttonExtrusion, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_Move, operation_menu.move);
lv_obj_align(label_Move, buttonMove, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
}
else {
lv_label_set_text(label_Speed, operation_menu.speed);
lv_obj_align(label_Speed, buttonSpeed, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
if (gCfgItems.finish_power_off == 1)
lv_label_set_text(label_PowerOff, printing_more_menu.auto_close);
else
lv_label_set_text(label_PowerOff, printing_more_menu.manual);
lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_BabyStep, operation_menu.babystep);
lv_obj_align(label_BabyStep, buttonBabyStep, 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);
}
}
void lv_clear_operation() { lv_obj_del(scr); }
void lv_clear_operation() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

120
Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.cpp

@ -29,6 +29,7 @@
#include "../../../../MarlinCore.h"
#include "../../../../module/planner.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_PAUSE_RETURN 1
@ -82,9 +83,9 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
void lv_draw_pause_position(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL;
lv_obj_t *buttonXText = NULL, *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *buttonYText = NULL, *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *buttonZText = NULL, *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != PAUSE_POS_UI) {
@ -106,85 +107,60 @@ void lv_draw_pause_position(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_para_back);
// LV_IMG_DECLARE(bmp_para_arrow);
LV_IMG_DECLARE(bmp_para_bank);
labelXText = lv_label_create(scr, NULL);
lv_obj_set_style(labelXText, &tft_style_label_rel);
lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
lv_label_set_text(labelXText, machine_menu.xPos);
buttonXText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
lv_obj_set_size(buttonXText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonXText, event_handler);
lv_btn_set_style(buttonXText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonXText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonXText, LV_LAYOUT_OFF);
labelXText = lv_label_create(buttonXText, NULL); /*Add a label to the button*/
buttonXValue = lv_imgbtn_create(scr, NULL);
buttonXValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_PAUSE_X, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF);
lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value);
lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_PAUSE_X, NULL, 0);
labelXValue = lv_label_create(buttonXValue, NULL);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonYText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/
lv_obj_set_size(buttonYText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonYText, event_handler);
lv_btn_set_style(buttonYText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonYText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonYText, LV_LAYOUT_OFF);
labelYText = lv_label_create(buttonYText, NULL); /*Add a label to the button*/
labelYText = lv_label_create(scr, NULL);
lv_obj_set_style(labelYText, &tft_style_label_rel);
lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
lv_label_set_text(labelYText, machine_menu.yPos);
buttonYValue = lv_imgbtn_create(scr, NULL);
buttonYValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_PAUSE_Y, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF);
lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_PAUSE_Y, NULL, 0);
lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value);
labelYValue = lv_label_create(buttonYValue, NULL);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
buttonZText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/
lv_obj_set_size(buttonZText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonZText, event_handler);
lv_btn_set_style(buttonZText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonZText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonZText, LV_LAYOUT_OFF);
labelZText = lv_label_create(buttonZText, NULL); /*Add a label to the button*/
labelZText = lv_label_create(scr, NULL);
lv_obj_set_style(labelZText, &tft_style_label_rel);
lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
lv_label_set_text(labelZText, machine_menu.zPos);
buttonZValue = lv_imgbtn_create(scr, NULL);
buttonZValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_PAUSE_Z, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF);
lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_PAUSE_Z, NULL, 0);
lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value);
labelZValue = lv_label_create(buttonZValue, NULL);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_PAUSE_RETURN, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
buttonBack = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
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_PAUSE_RETURN, NULL, 0);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
label_Back = lv_label_create(buttonBack, NULL);
if (gCfgItems.multiple_language != 0) {
@ -203,20 +179,24 @@ void lv_draw_pause_position(void) {
lv_label_set_text(labelZValue, public_buf_l);
lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
lv_label_set_text(labelXText, machine_menu.xPos);
lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelYText, machine_menu.yPos);
lv_obj_align(labelYText, buttonYText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelZText, machine_menu.zPos);
lv_obj_align(labelZText, buttonZText, LV_ALIGN_IN_LEFT_MID, 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() { lv_obj_del(scr); }
void lv_clear_pause_position() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

97
Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp

@ -34,9 +34,10 @@
#include "../../../../module/temperature.h"
static lv_obj_t * scr;
extern lv_group_t* g;
static lv_obj_t *buttoType, *buttonStep;
static lv_obj_t * labelType;
static lv_obj_t * labelStep;
static lv_obj_t *labelType;
static lv_obj_t *labelStep;
static lv_obj_t * tempText1;
#define ID_P_ADD 1
@ -58,23 +59,22 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
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);
thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
}
}
#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);
thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
}
#endif
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();
}
thermalManager.start_watching_bed();
}
#endif
disp_desire_temp();
@ -88,23 +88,21 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
if (uiCfg.curTempType == 0) {
if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > uiCfg.stepHeat) {
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target -= uiCfg.stepHeat;
thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
}
else {
thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)0;
thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
}
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;
thermalManager.start_watching_bed();
}
else {
thermalManager.temp_bed.target = (float)0;
thermalManager.start_watching_bed();
}
thermalManager.start_watching_bed();
}
#endif
disp_desire_temp();
@ -212,9 +210,7 @@ void lv_draw_preHeat(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_pic);
/*Create an Image button*/
// Create image buttons
buttonAdd = lv_imgbtn_create(scr, NULL);
buttonDec = lv_imgbtn_create(scr, NULL);
buttoType = lv_imgbtn_create(scr, NULL);
@ -222,40 +218,37 @@ void lv_draw_preHeat(void) {
buttonOff = lv_imgbtn_create(scr, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_P_ADD, "bmp_Add.bin", 0);
lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_P_ADD, NULL, 0);
lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, "F:/bmp_Add.bin");
lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, "F:/bmp_Add.bin");
lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW);
#if 1
lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_P_DEC, "bmp_Dec.bin", 0);
lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_P_DEC, NULL, 0);
lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, "F:/bmp_Dec.bin");
lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, "F:/bmp_Dec.bin");
lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttoType, event_handler, ID_P_TYPE, NULL, 0);
lv_imgbtn_set_style(buttoType, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttoType, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_P_STEP, NULL, 0);
lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonOff, event_handler, ID_P_OFF, "bmp_speed0.bin", 0);
lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonOff, event_handler, ID_P_OFF, NULL, 0);
lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_REL, "F:/bmp_speed0.bin");
lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_PR, "F:/bmp_speed0.bin");
lv_imgbtn_set_style(buttonOff, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonOff, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_P_RETURN, "bmp_return.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_P_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif
@ -295,6 +288,16 @@ void lv_draw_preHeat(void) {
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, buttoType);
lv_group_add_obj(g, buttonStep);
lv_group_add_obj(g, buttonOff);
lv_group_add_obj(g, buttonBack);
}
#endif
disp_temp_type();
disp_step_heat();
@ -307,14 +310,16 @@ void lv_draw_preHeat(void) {
void disp_temp_type() {
if (uiCfg.curTempType == 0) {
if (uiCfg.curSprayerChoose == 1) {
lv_obj_set_event_cb_mks(buttoType, event_handler, ID_P_TYPE, "bmp_extru2.bin", 0);
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru2.bin");
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru2.bin");
if (gCfgItems.multiple_language != 0) {
lv_label_set_text(labelType, preheat_menu.ext2);
lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
}
}
else {
lv_obj_set_event_cb_mks(buttoType, event_handler, ID_P_TYPE, "bmp_extru1.bin", 0);
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru1.bin");
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru1.bin");
if (gCfgItems.multiple_language != 0) {
lv_label_set_text(labelType, preheat_menu.ext1);
lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
@ -323,7 +328,8 @@ void disp_temp_type() {
}
else {
lv_obj_set_event_cb_mks(buttoType, event_handler, ID_P_TYPE, "bmp_bed.bin", 0);
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_bed.bin");
lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_bed.bin");
if (gCfgItems.multiple_language != 0) {
lv_label_set_text(labelType, preheat_menu.hotbed);
lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
@ -356,12 +362,18 @@ void disp_desire_temp() {
}
void disp_step_heat() {
if (uiCfg.stepHeat == 1)
lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_P_STEP, "bmp_step1_degree.bin", 0);
else if (uiCfg.stepHeat == 5)
lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_P_STEP, "bmp_step5_degree.bin", 0);
else if (uiCfg.stepHeat == 10)
lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_P_STEP, "bmp_step10_degree.bin", 0);
if (uiCfg.stepHeat == 1) {
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step1_degree.bin");
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step1_degree.bin");
}
else if (uiCfg.stepHeat == 5) {
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step5_degree.bin");
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step5_degree.bin");
}
else if (uiCfg.stepHeat == 10) {
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step10_degree.bin");
lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step10_degree.bin");
}
if (gCfgItems.multiple_language != 0) {
if (uiCfg.stepHeat == 1) {
@ -379,6 +391,11 @@ void disp_step_heat() {
}
}
void lv_clear_preHeat() { lv_obj_del(scr); }
void lv_clear_preHeat() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

103
Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp

@ -33,6 +33,7 @@
#include "../../../../sd/cardreader.h"
static lv_obj_t * scr;
extern lv_group_t* g;
static lv_obj_t *buttonPageUp, *buttonPageDown, *buttonBack,
*buttonGcode[FILE_BTN_CNT], *labelPageUp[FILE_BTN_CNT], *buttonText[FILE_BTN_CNT];
@ -132,11 +133,6 @@ uint8_t have_pre_pic(char *path) {
return 0;
}
LV_IMG_DECLARE(bmp_pic_117x92);
LV_IMG_DECLARE(bmp_pic_100x100);
LV_IMG_DECLARE(bmp_pic);
LV_IMG_DECLARE(bmp_pic_100x40);
static void event_handler(lv_obj_t * obj, lv_event_t event) {
uint8_t i, file_count = 0;
//switch (obj->mks_obj_id)
@ -157,7 +153,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
#endif
if (file_count != 0) {
dir_offset[curDirLever].curPage--;
lv_obj_del(scr);
lv_clear_print_file();
disp_gcode_icon(file_count);
}
}
@ -175,7 +171,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
#endif
if (file_count != 0) {
dir_offset[curDirLever].curPage++;
lv_obj_del(scr);
lv_clear_print_file();
disp_gcode_icon(file_count);
}
if (file_count < FILE_NUM)
@ -202,12 +198,12 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
#if ENABLED(SDSUPPORT)
file_count = search_file();
#endif
lv_obj_del(scr);
lv_clear_print_file();
disp_gcode_icon(file_count);
}
}
else {
lv_obj_del(scr);
lv_clear_print_file();
lv_draw_ready_print();
}
}
@ -227,12 +223,12 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
#if ENABLED(SDSUPPORT)
file_count = search_file();
#endif
lv_obj_del(scr);
lv_clear_print_file();
disp_gcode_icon(file_count);
}
else {
sel_id = i;
lv_obj_del(scr);
lv_clear_print_file();
lv_draw_dialog(DIALOG_TYPE_PRINT_FILE);
}
break;
@ -269,9 +265,9 @@ void lv_draw_print_file(void) {
#endif
disp_gcode_icon(file_count);
//lv_obj_t * labelPageUp = lv_label_create(buttonPageUp, NULL);
//lv_obj_t * labelPageDown = lv_label_create(buttonPageDown, NULL);
//lv_obj_t * label_Back = lv_label_create(buttonBack, NULL);
//lv_obj_t *labelPageUp = lv_label_create(buttonPageUp, NULL);
//lv_obj_t *labelPageDown = lv_label_create(buttonPageDown, NULL);
//lv_obj_t *label_Back = lv_label_create(buttonBack, NULL);
/*
if (gCfgItems.multiple_language != 0) {
@ -286,7 +282,7 @@ void lv_draw_print_file(void) {
}
*/
}
static char test_public_buf_l[40];
void disp_gcode_icon(uint8_t file_num) {
uint8_t i;
@ -310,23 +306,22 @@ void disp_gcode_icon(uint8_t file_num) {
buttonPageDown = lv_imgbtn_create(scr, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonPageUp, event_handler, ID_P_UP, "bmp_pageUp.bin", 0);
lv_imgbtn_set_src(buttonPageUp, LV_BTN_STATE_REL, &bmp_pic_117x92);
lv_imgbtn_set_src(buttonPageUp, LV_BTN_STATE_PR, &bmp_pic_117x92);
lv_obj_set_event_cb_mks(buttonPageUp, event_handler, ID_P_UP, NULL, 0);
lv_imgbtn_set_src(buttonPageUp, LV_BTN_STATE_REL, "F:/bmp_pageUp.bin");
lv_imgbtn_set_src(buttonPageUp, LV_BTN_STATE_PR, "F:/bmp_pageUp.bin");
lv_imgbtn_set_style(buttonPageUp, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonPageUp, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_clear_protect(buttonPageUp, LV_PROTECT_FOLLOW);
#if 1
lv_obj_set_event_cb_mks(buttonPageDown, event_handler, ID_P_DOWN, "bmp_pageDown.bin", 0);
lv_imgbtn_set_src(buttonPageDown, LV_BTN_STATE_REL, &bmp_pic_117x92);
lv_imgbtn_set_src(buttonPageDown, LV_BTN_STATE_PR, &bmp_pic_117x92);
lv_obj_set_event_cb_mks(buttonPageDown, event_handler, ID_P_DOWN, NULL, 0);
lv_imgbtn_set_src(buttonPageDown, LV_BTN_STATE_REL, "F:/bmp_pageDown.bin");
lv_imgbtn_set_src(buttonPageDown, LV_BTN_STATE_PR, "F:/bmp_pageDown.bin");
lv_imgbtn_set_style(buttonPageDown, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonPageDown, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_P_RETURN, "bmp_back.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic_117x92);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic_117x92);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_P_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif
@ -365,9 +360,9 @@ void disp_gcode_icon(uint8_t file_num) {
cutFileName((char *)list_file.long_name[i], 16, 8, (char *)public_buf_m);
if (list_file.IsFolder[i] == 1) {
lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), "bmp_dir.bin", 0);
lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), NULL, 0);
lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, "F:/bmp_dir.bin");
lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, "F:/bmp_dir.bin");
if (i < 3)
lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight);
else
@ -380,9 +375,17 @@ void disp_gcode_icon(uint8_t file_num) {
}
else {
if (have_pre_pic((char *)list_file.file_name[i])) {
lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), list_file.file_name[i], 1);
lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, &bmp_pic_100x100);
lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, &bmp_pic_100x100);
//lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), list_file.file_name[i], 1);
ZERO(test_public_buf_l);
strcat(test_public_buf_l,"S:");
strcat(test_public_buf_l,list_file.file_name[i]);
char *temp = strstr(test_public_buf_l,".GCO");
if (temp) { strcpy(temp,".bin"); }
lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), NULL, 0);
lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, test_public_buf_l);
lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, test_public_buf_l);
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);
buttonText[i] = lv_btn_create(scr, NULL);
@ -395,8 +398,6 @@ void disp_gcode_icon(uint8_t file_num) {
lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW);
lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF);
//lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),NULL,0);
//lv_imgbtn_set_src(buttonText[i], LV_BTN_STATE_REL, &bmp_pic_100x40);
//lv_imgbtn_set_src(buttonText[i], LV_BTN_STATE_PR, &bmp_pic_100x40);
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);
}
@ -412,8 +413,6 @@ void disp_gcode_icon(uint8_t file_num) {
lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW);
lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF);
//lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),NULL,0);
//lv_imgbtn_set_src(buttonText[i], LV_BTN_STATE_REL, &bmp_pic_100x40);
//lv_imgbtn_set_src(buttonText[i], LV_BTN_STATE_PR, &bmp_pic_100x40);
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);
}
@ -423,9 +422,9 @@ void disp_gcode_icon(uint8_t file_num) {
lv_obj_align(labelPageUp[i], buttonText[i], LV_ALIGN_IN_BOTTOM_MID, 0, 0);
}
else {
lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), "bmp_file.bin", 0);
lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), NULL, 0);
lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, "F:/bmp_file.bin");
lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, "F:/bmp_file.bin");
if (i < 3)
lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight);
else
@ -437,15 +436,26 @@ void disp_gcode_icon(uint8_t file_num) {
lv_obj_align(labelPageUp[i], buttonGcode[i], LV_ALIGN_IN_BOTTOM_MID, 0, -5);
}
}
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonGcode[i]);
#endif
#else // !TFT35
#endif // !TFT35
}
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonPageUp);
lv_group_add_obj(g, buttonPageDown);
lv_group_add_obj(g, buttonBack);
}
#endif
}
void lv_open_gcode_file(char *path) {
uint32_t lv_open_gcode_file(char *path) {
#if ENABLED(SDSUPPORT)
uint32_t *ps4;
int pre_sread_cnt;
uint32_t pre_sread_cnt = 0;
char *cur_name;
cur_name = strrchr(path, '/');
@ -458,10 +468,10 @@ void lv_open_gcode_file(char *path) {
pre_sread_cnt = (uint32_t)ps4 - (uint32_t)((uint32_t *)(&public_buf[0]));
card.setIndex(pre_sread_cnt);
}
return pre_sread_cnt;
#endif // SDSUPPORT
}
int ascii2dec_test(char *ascii) {
int result = 0;
if (ascii == 0) return 0;
@ -534,6 +544,10 @@ void lv_gcode_file_read(uint8_t *data_buf) {
void lv_close_gcode_file() {TERN_(SDSUPPORT, card.closefile());}
void lv_gcode_file_seek(uint32_t pos) {
card.setIndex(pos);
}
void cutFileName(char *path, int len, int bytePerLine, char *outStr) {
#if _LFN_UNICODE
TCHAR *tmpFile;
@ -616,6 +630,11 @@ void cutFileName(char *path, int len, int bytePerLine, char *outStr) {
#endif
}
void lv_clear_print_file() { lv_obj_del(scr); }
void lv_clear_print_file() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

3
Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h

@ -52,12 +52,13 @@ extern LIST_FILE list_file;
extern void disp_gcode_icon(uint8_t file_num);
extern void lv_draw_print_file(void);
extern void 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_close_gcode_file();
extern void cutFileName(char *path, int len, int bytePerLine, char *outStr);
extern int ascii2dec_test(char *ascii);
extern void lv_clear_print_file();
extern void lv_gcode_file_seek(uint32_t pos);
//extern void disp_temp_ready_print();
#ifdef __cplusplus

195
Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp

@ -35,6 +35,7 @@
#include "../../../../module/motion.h"
#include "../../../../sd/cardreader.h"
#include "../../../../gcode/queue.h"
#include "../../../../gcode/gcode.h"
#if ENABLED(POWER_LOSS_RECOVERY)
#include "../../../../feature/powerloss.h"
@ -43,10 +44,11 @@
#include "../../../ultralcd.h"
#endif
extern lv_group_t * g;
static lv_obj_t * scr;
static lv_obj_t * labelExt1, * labelExt2, * labelFan, * labelZpos, * labelTime;
static lv_obj_t * labelPause, * labelStop, * labelOperat;
static lv_obj_t * bar1;
static lv_obj_t *labelExt1, * labelExt2, * labelFan, * labelZpos, * labelTime;
static lv_obj_t *labelPause, * labelStop, * labelOperat;
static lv_obj_t * bar1, *bar1ValueText;
static lv_obj_t * buttonPause, *buttonOperat, *buttonStop;
#if HAS_HEATED_BED
@ -57,8 +59,6 @@ static lv_obj_t * buttonPause, *buttonOperat, *buttonStop;
#define ID_STOP 2
#define ID_OPTION 3
lv_style_t lv_bar_style_indic;
uint8_t once_flag = 0;
extern uint32_t To_pre_view;
extern uint8_t flash_preview_begin;
@ -82,21 +82,23 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
stop_print_time();
uiCfg.print_state = PAUSING;
#endif
lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_resume.bin", 0);
lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_REL, "F:/bmp_resume.bin");
lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_PR, "F:/bmp_resume.bin");
lv_label_set_text(labelPause, printing_menu.resume);
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
}
else if (uiCfg.print_state == PAUSED) {
uiCfg.print_state = RESUMING;
// if (IS_SD_PAUSED())queue.inject_P(PSTR("M24"));// queue.inject_P(M24_STR);
lv_obj_set_event_cb_mks(obj, event_handler, ID_PAUSE, "bmp_pause.bin", 0);
lv_imgbtn_set_src(obj, LV_BTN_STATE_REL, "F:/bmp_pause.bin");
lv_imgbtn_set_src(obj, LV_BTN_STATE_PR, "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_obj_set_event_cb_mks(obj, event_handler, ID_PAUSE, "bmp_pause.bin", 0);
lv_imgbtn_set_src(obj, LV_BTN_STATE_REL, "F:/bmp_pause.bin");
lv_imgbtn_set_src(obj, LV_BTN_STATE_PR, "F:/bmp_pause.bin");
lv_label_set_text(labelPause, printing_menu.pause);
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
// recovery.resume();
@ -115,7 +117,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
}
else if (event == LV_EVENT_RELEASED) {
if (gcode_preview_over != 1) {
lv_obj_del(scr);
lv_clear_printing();
lv_draw_dialog(DIALOG_TYPE_STOP);
}
}
@ -126,7 +128,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
}
else if (event == LV_EVENT_RELEASED) {
if (gcode_preview_over != 1) {
lv_obj_del(scr);
lv_clear_printing();
lv_draw_operation();
}
}
@ -159,88 +161,71 @@ void lv_draw_printing(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_pic_150x80);
LV_IMG_DECLARE(bmp_pic_45x45);
/*Create an Image button*/
buttonExt1 = lv_imgbtn_create(scr, NULL);
if (EXTRUDERS == 2)
buttonExt2 = lv_imgbtn_create(scr, NULL);
// Create image buttons
buttonExt1 = lv_img_create(scr, NULL);
#if HAS_MULTI_EXTRUDER
buttonExt2 = lv_img_create(scr, NULL);
#endif
#if HAS_HEATED_BED
buttonBedstate = lv_imgbtn_create(scr, NULL);
buttonBedstate = lv_img_create(scr, NULL);
#endif
buttonFanstate = lv_imgbtn_create(scr, NULL);
buttonZpos = lv_imgbtn_create(scr, NULL);
buttonFanstate = lv_img_create(scr, NULL);
buttonTime = lv_img_create(scr, NULL);
buttonZpos = lv_img_create(scr, NULL);
buttonPause = lv_imgbtn_create(scr, NULL);
buttonStop = lv_imgbtn_create(scr, NULL);
buttonOperat = lv_imgbtn_create(scr, NULL);
buttonTime = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonExt1, event_handler, 0, "bmp_ext1_state.bin", 0);
lv_imgbtn_set_src(buttonExt1, LV_BTN_STATE_REL, &bmp_pic_45x45);
lv_imgbtn_set_src(buttonExt1, LV_BTN_STATE_PR, &bmp_pic_45x45);
lv_imgbtn_set_style(buttonExt1, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonExt1, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_clear_protect(buttonExt1, LV_PROTECT_FOLLOW);
lv_img_set_src(buttonExt1, "F:/bmp_ext1_state.bin");
#if 1
if (EXTRUDERS == 2) {
lv_obj_set_event_cb_mks(buttonExt2, event_handler, 0, "bmp_ext2_state.bin", 0);
lv_imgbtn_set_src(buttonExt2, LV_BTN_STATE_REL, &bmp_pic_45x45);
lv_imgbtn_set_src(buttonExt2, LV_BTN_STATE_PR, &bmp_pic_45x45);
lv_imgbtn_set_style(buttonExt2, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonExt2, LV_BTN_STATE_REL, &tft_style_label_rel);
}
#if HAS_MULTI_EXTRUDER
lv_img_set_src(buttonExt2, "F:/bmp_ext2_state.bin");
#endif
#if HAS_HEATED_BED
lv_obj_set_event_cb_mks(buttonBedstate, event_handler, 0, "bmp_bed_state.bin", 0);
lv_imgbtn_set_src(buttonBedstate, LV_BTN_STATE_REL, &bmp_pic_45x45);
lv_imgbtn_set_src(buttonBedstate, LV_BTN_STATE_PR, &bmp_pic_45x45);
lv_imgbtn_set_style(buttonBedstate, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBedstate, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_img_set_src(buttonBedstate, "F:/bmp_bed_state.bin");
#endif
lv_obj_set_event_cb_mks(buttonFanstate, event_handler, 0, "bmp_fan_state.bin", 0);
lv_imgbtn_set_src(buttonFanstate, LV_BTN_STATE_REL, &bmp_pic_45x45);
lv_imgbtn_set_src(buttonFanstate, LV_BTN_STATE_PR, &bmp_pic_45x45);
lv_imgbtn_set_style(buttonFanstate, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonFanstate, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonTime, event_handler, 0, "bmp_time_state.bin", 0);
lv_imgbtn_set_src(buttonTime, LV_BTN_STATE_REL, &bmp_pic_45x45);
lv_imgbtn_set_src(buttonTime, LV_BTN_STATE_PR, &bmp_pic_45x45);
lv_imgbtn_set_style(buttonTime, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonTime, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonZpos, event_handler, 0, "bmp_zpos_state.bin", 0);
lv_imgbtn_set_src(buttonZpos, LV_BTN_STATE_REL, &bmp_pic_45x45);
lv_imgbtn_set_src(buttonZpos, LV_BTN_STATE_PR, &bmp_pic_45x45);
lv_imgbtn_set_style(buttonZpos, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonZpos, LV_BTN_STATE_REL, &tft_style_label_rel);
if (uiCfg.print_state == WORKING)
lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_pause.bin", 0);
else
lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_resume.bin", 0);
lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_REL, &bmp_pic_150x80);
lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_PR, &bmp_pic_150x80);
lv_img_set_src(buttonFanstate, "F:/bmp_fan_state.bin");
lv_img_set_src(buttonTime, "F:/bmp_time_state.bin");
lv_img_set_src(buttonZpos, "F:/bmp_zpos_state.bin");
if (uiCfg.print_state == WORKING) {
lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_REL, "F:/bmp_pause.bin");
lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_PR, "F:/bmp_pause.bin");
}
else {
lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_REL, "F:/bmp_resume.bin");
lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_PR, "F:/bmp_resume.bin");
}
lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, NULL, 0);
lv_imgbtn_set_style(buttonPause, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonPause, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonStop, event_handler, ID_STOP, "bmp_stop.bin", 0);
lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_REL, &bmp_pic_150x80);
lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_PR, &bmp_pic_150x80);
lv_obj_set_event_cb_mks(buttonStop, event_handler, ID_STOP, NULL, 0);
lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_REL, "F:/bmp_stop.bin");
lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_PR, "F:/bmp_stop.bin");
lv_imgbtn_set_style(buttonStop, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonStop, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonOperat, event_handler, ID_OPTION, "bmp_operate.bin", 0);
lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_REL, &bmp_pic_150x80);
lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_PR, &bmp_pic_150x80);
lv_obj_set_event_cb_mks(buttonOperat, event_handler, ID_OPTION, NULL, 0);
lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_REL, "F:/bmp_operate.bin");
lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_PR, "F:/bmp_operate.bin");
lv_imgbtn_set_style(buttonOperat, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonOperat, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif // if 1
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonPause);
lv_group_add_obj(g, buttonStop);
lv_group_add_obj(g, buttonOperat);
}
#endif
lv_obj_set_pos(buttonExt1, 205, 136);
#if HAS_MULTI_EXTRUDER
@ -258,17 +243,19 @@ void lv_draw_printing(void) {
lv_obj_set_pos(buttonStop, 165, 240);
lv_obj_set_pos(buttonOperat, 325, 240);
/*Create a label on the Image button*/
lv_btn_set_layout(buttonExt1, LV_LAYOUT_OFF);
if (EXTRUDERS == 2)
lv_btn_set_layout(buttonExt2, LV_LAYOUT_OFF);
// Create labels on the image buttons
//lv_btn_set_layout(buttonExt1, LV_LAYOUT_OFF);
//#if HAS_MULTI_EXTRUDER
//lv_btn_set_layout(buttonExt2, LV_LAYOUT_OFF);
//#endif
#if HAS_HEATED_BED
lv_btn_set_layout(buttonBedstate, LV_LAYOUT_OFF);
#endif
//#if HAS_HEATED_BED
//lv_btn_set_layout(buttonBedstate, LV_LAYOUT_OFF);
//#endif
lv_btn_set_layout(buttonFanstate, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonZpos, LV_LAYOUT_OFF);
//lv_btn_set_layout(buttonFanstate, LV_LAYOUT_OFF);
//lv_btn_set_layout(buttonTime, LV_LAYOUT_OFF);
//lv_btn_set_layout(buttonZpos, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonPause, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonStop, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonOperat, LV_LAYOUT_OFF);
@ -293,23 +280,20 @@ void lv_draw_printing(void) {
lv_obj_set_style(labelFan, &tft_style_label_rel);
lv_obj_set_pos(labelFan, 395, 196);
labelZpos = lv_label_create(scr, NULL);
lv_obj_set_style(labelZpos, &tft_style_label_rel);
lv_obj_set_pos(labelZpos, 395, 96);
labelTime = lv_label_create(scr, NULL);
lv_obj_set_style(labelTime, &tft_style_label_rel);
lv_obj_set_pos(labelTime, 250, 96);
labelZpos = lv_label_create(scr, NULL);
lv_obj_set_style(labelZpos, &tft_style_label_rel);
lv_obj_set_pos(labelZpos, 395, 96);
labelPause = lv_label_create(buttonPause, NULL);
labelStop = lv_label_create(buttonStop, NULL);
labelOperat = lv_label_create(buttonOperat, NULL);
if (gCfgItems.multiple_language != 0) {
if (uiCfg.print_state == WORKING)
lv_label_set_text(labelPause, printing_menu.pause);
else
lv_label_set_text(labelPause, printing_menu.resume);
lv_label_set_text(labelPause, uiCfg.print_state == WORKING ? printing_menu.pause : printing_menu.resume);
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 20, 0);
lv_label_set_text(labelStop, printing_menu.stop);
@ -319,20 +303,15 @@ void lv_draw_printing(void) {
lv_obj_align(labelOperat, buttonOperat, LV_ALIGN_CENTER, 20, 0);
}
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.image.color = lv_color_hex3(0xADF);
lv_bar_style_indic.line.color = lv_color_hex3(0xADF);
lv_bar_style_indic.body.main_color = lv_color_hex3(0xADF);
lv_bar_style_indic.body.grad_color = lv_color_hex3(0xADF);
lv_bar_style_indic.body.border.color = lv_color_hex3(0xADF);
bar1 = lv_bar_create(scr, NULL);
lv_obj_set_pos(bar1, 205, 36);
lv_obj_set_size(bar1, 270, 40);
lv_bar_set_style(bar1, LV_BAR_STYLE_INDIC, &lv_bar_style_indic);
lv_bar_set_anim_time(bar1, 1000);
lv_bar_set_value(bar1, 0, LV_ANIM_ON);
bar1ValueText = lv_label_create(bar1, NULL);
lv_label_set_text(bar1ValueText,"0%");
lv_obj_align(bar1ValueText, bar1, LV_ALIGN_CENTER, 0, 0);
disp_ext_temp();
disp_bed_temp();
@ -419,6 +398,10 @@ void setProBarRate() {
if (disp_state == PRINTING_UI) {
lv_bar_set_value(bar1, rate, LV_ANIM_ON);
ZERO(public_buf_l);
sprintf_P(public_buf_l, "%d%%", rate);
lv_label_set_text(bar1ValueText,public_buf_l);
lv_obj_align(bar1ValueText, bar1, LV_ALIGN_CENTER, 0, 0);
if (marlin_state == MF_SD_COMPLETE) {
if (once_flag == 0) {
@ -432,14 +415,22 @@ void setProBarRate() {
once_flag = 1;
#if HAS_SUICIDE
if (gCfgItems.finish_power_off == 1)
suicide();
if (gCfgItems.finish_power_off == 1) {
gcode.process_subcommands_now_P(PSTR("M1001"));
queue.inject_P(PSTR("M81"));
marlin_state = MF_RUNNING;
}
#endif
}
}
}
}
void lv_clear_printing() { lv_obj_del(scr); }
void lv_clear_printing() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

122
Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp

@ -42,6 +42,7 @@
#include <stdio.h>
//static lv_obj_t *buttonPrint,*buttonTool,*buttonSet;
extern lv_group_t* g;
static lv_obj_t * scr;
#if ENABLED(MKS_TEST)
uint8_t curent_disp_ui = 0;
@ -59,7 +60,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
}
else if (event == LV_EVENT_RELEASED) {
lv_obj_del(scr);
lv_clear_ready_print();
lv_draw_tool();
}
break;
@ -68,7 +69,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
lv_obj_del(scr);
lv_clear_ready_print();
lv_draw_set();
}
break;
@ -77,7 +78,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
lv_obj_del(scr);
lv_clear_ready_print();
lv_draw_print_file();
}
break;
@ -111,7 +112,7 @@ void disp_det_error() {
lv_obj_t *e1, *e2, *e3, *bed;
void mks_disp_test() {
char buf[30] = {0};
//lv_obj_t * label_tool2 = lv_label_create(scr, NULL);
//lv_obj_t *label_tool2 = lv_label_create(scr, NULL);
//lv_obj_set_pos(label_tool,20,50);
ZERO(buf);
sprintf_P(buf, PSTR("e1:%d"), (int)thermalManager.temp_hotend[0].celsius);
@ -132,7 +133,6 @@ void mks_disp_test() {
#endif
}
extern unsigned char bmp_public_buf[17 * 1024];
void lv_draw_ready_print(void) {
char buf[30] = {0};
lv_obj_t *buttonPrint, *buttonTool, *buttonSet;
@ -151,9 +151,7 @@ void lv_draw_ready_print(void) {
//lv_obj_set_hidden(scr,true);
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_pic);
if (mks_test_flag == 0x1e) {
if (mks_test_flag == 0x1E) {
//lv_obj_t * title = lv_label_create(scr, NULL);
//lv_obj_set_style(title, &tft_style_label_rel);
//lv_obj_set_pos(title,TITLE_XPOS,TITLE_YPOS);
@ -164,26 +162,10 @@ void lv_draw_ready_print(void) {
buttonTool = lv_imgbtn_create(scr, NULL);
//buttonSet = lv_imgbtn_create(scr, NULL);
//lv_obj_set_event_cb_mks(buttonPrint, event_handler,ID_PRINT,"bmp_printing.bin",0);
//lv_imgbtn_set_src_mks(buttonPrint, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_printing.bin");
//lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_REL, &bmp_pic);
//lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_PR, &bmp_pic);
//lv_imgbtn_set_style(buttonPrint, LV_BTN_STATE_PR, &tft_style_label_pre);
//lv_imgbtn_set_style(buttonPrint, LV_BTN_STATE_REL, &tft_style_label_rel);
//lv_obj_clear_protect(buttonPrint, LV_PROTECT_FOLLOW);
#if 1
//lv_obj_set_event_cb_mks(buttonSet, event_handler,ID_SET,"bmp_set.bin",0);
//lv_imgbtn_set_src_mks(buttonSet, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_set.bin");
//lv_imgbtn_set_src(buttonSet, LV_BTN_STATE_REL, &bmp_pic);
//lv_imgbtn_set_src(buttonSet, LV_BTN_STATE_PR, &bmp_pic);
//lv_imgbtn_set_style(buttonSet, LV_BTN_STATE_PR, &tft_style_label_pre);
//lv_imgbtn_set_style(buttonSet, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonTool, event_handler, ID_TOOL, "bmp_tool.bin", 0);
//lv_imgbtn_set_src_mks(buttonTool, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_tool.bin");
lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonTool, event_handler, ID_TOOL, NULL, 0);
lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_REL, "F:/bmp_tool.bin");
lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_PR, "F:/bmp_tool.bin");
lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif
@ -266,56 +248,37 @@ void lv_draw_ready_print(void) {
}
else {
//lv_obj_t * title = lv_label_create(scr, NULL);
//lv_obj_set_style(title, &tft_style_label_rel);
//lv_obj_set_pos(title,TITLE_XPOS,TITLE_YPOS);
//lv_label_set_text(title, creat_title_text());
// Create an Image button
buttonTool = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonTool, 20, 90);
lv_obj_set_event_cb_mks(buttonTool, event_handler, ID_TOOL, NULL, 0);
lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_REL, "F:/bmp_tool.bin");
lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_PR, "F:/bmp_tool.bin");
lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_t *label_tool = lv_label_create(buttonTool, NULL);
lv_btn_set_layout(buttonTool, LV_LAYOUT_OFF);
/*Create an Image button*/
buttonPrint = lv_imgbtn_create(scr, NULL);
buttonTool = lv_imgbtn_create(scr, NULL);
buttonSet = lv_imgbtn_create(scr, NULL);
buttonSet = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonSet, 180, 90);
lv_obj_set_event_cb_mks(buttonSet, event_handler, ID_SET, NULL, 0);
lv_imgbtn_set_src(buttonSet, LV_BTN_STATE_REL, "F:/bmp_set.bin");
lv_imgbtn_set_src(buttonSet, LV_BTN_STATE_PR, "F:/bmp_set.bin");
lv_imgbtn_set_style(buttonSet, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonSet, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_t *label_set = lv_label_create(buttonSet, NULL);
lv_btn_set_layout(buttonSet, LV_LAYOUT_OFF);
lv_obj_set_event_cb_mks(buttonPrint, event_handler, ID_PRINT, "bmp_printing.bin", 0);
//lv_imgbtn_set_src_mks(buttonPrint, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_printing.bin");
lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_PR, &bmp_pic);
buttonPrint = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonPrint, 340, 90);
lv_obj_set_event_cb_mks(buttonPrint, event_handler, ID_PRINT, NULL, 0);
lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_REL, "F:/bmp_printing.bin");
lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_PR, "F:/bmp_printing.bin");
lv_imgbtn_set_style(buttonPrint, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonPrint, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_clear_protect(buttonPrint, LV_PROTECT_FOLLOW);
#if 1
lv_obj_set_event_cb_mks(buttonSet, event_handler, ID_SET, "bmp_set.bin", 0);
//lv_imgbtn_set_src_mks(buttonSet, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_set.bin");
lv_imgbtn_set_src(buttonSet, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonSet, LV_BTN_STATE_PR, &bmp_pic);
lv_imgbtn_set_style(buttonSet, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonSet, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonTool, event_handler, ID_TOOL, "bmp_tool.bin", 0);
//lv_imgbtn_set_src_mks(buttonTool, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_tool.bin");
lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_PR, &bmp_pic);
lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif
lv_obj_set_pos(buttonTool, 20, 90);
lv_obj_set_pos(buttonSet, 180, 90);
lv_obj_set_pos(buttonPrint, 340, 90);
//lv_obj_set_pos(buttonTool,SIMPLE_FIRST_PAGE_GRAP+1,(TFT_HEIGHT-BTN_Y_PIXEL)/2+2);
//lv_obj_set_pos(buttonSet,BTN_X_PIXEL+SIMPLE_FIRST_PAGE_GRAP*2+1,(TFT_HEIGHT-BTN_Y_PIXEL)/2+2);
//lv_obj_set_pos(buttonPrint,BTN_X_PIXEL*2+SIMPLE_FIRST_PAGE_GRAP*3+1,(TFT_HEIGHT-BTN_Y_PIXEL)/2+2);
/*Create a label on the Image button*/
lv_obj_t *label_print = lv_label_create(buttonPrint, NULL);
lv_btn_set_layout(buttonPrint, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonSet, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonTool, LV_LAYOUT_OFF);
lv_obj_t * label_print = lv_label_create(buttonPrint, NULL);
lv_obj_t * label_set = lv_label_create(buttonSet, NULL);
lv_obj_t * label_tool = lv_label_create(buttonTool, NULL);
if (gCfgItems.multiple_language != 0) {
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);
@ -323,14 +286,25 @@ void lv_draw_ready_print(void) {
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_style(label_tool,LV_BTN_STATE_PR,&tft_style_label_pre);
//lv_label_set_style(label_tool,LV_BTN_STATE_REL,&tft_style_label_rel);
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
}
}
void lv_clear_ready_print() { lv_obj_del(scr); }
void lv_clear_ready_print() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable == true) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

249
Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp

@ -36,6 +36,7 @@
#include "pic_manager.h"
static lv_obj_t * scr;
extern lv_group_t* g;
#define ID_S_WIFI 1
#define ID_S_FAN 2
@ -48,20 +49,17 @@ static lv_obj_t * scr;
#define ID_S_RETURN 9
static void event_handler(lv_obj_t * obj, lv_event_t event) {
#if ENABLED(USE_WIFI_FUNCTION)
char buf[6] = { 0 };
#endif
switch (obj->mks_obj_id) {
case ID_S_WIFI:
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
}
break;
case ID_S_FAN:
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
lv_obj_del(scr);
lv_clear_set();
lv_draw_fan();
}
break;
@ -70,7 +68,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
lv_obj_del(scr);
lv_clear_set();
lv_draw_about();
}
break;
@ -94,7 +92,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
lv_obj_del(scr);
lv_clear_set();
lv_draw_language();
}
break;
@ -103,7 +101,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
}
else if (event == LV_EVENT_RELEASED) {
lv_obj_del(scr);
lv_clear_set();
lv_draw_machine_para();
}
break;
@ -112,7 +110,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
}
else if (event == LV_EVENT_RELEASED) {
lv_obj_del(scr);
lv_clear_set();
lv_draw_eeprom_settings();
}
break;
@ -121,11 +119,50 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
lv_obj_del(scr);
lv_clear_set();
lv_draw_ready_print();
}
break;
#if ENABLED(USE_WIFI_FUNCTION)
case ID_S_WIFI:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
if (gCfgItems.wifi_mode_sel == STA_MODEL) {
if (wifi_link_state == WIFI_CONNECTED) {
last_disp_state = SET_UI;
lv_clear_set();
lv_draw_wifi();
}
else {
if (uiCfg.command_send == 1) {
buf[0] = 0xA5;
buf[1] = 0x07;
buf[2] = 0x00;
buf[3] = 0x00;
buf[4] = 0xFC;
raw_send_to_wifi(buf, 5);
last_disp_state = SET_UI;
lv_clear_set();
lv_draw_wifi_list();
}
else {
last_disp_state = SET_UI;
lv_clear_set();
lv_draw_dialog(WIFI_ENABLE_TIPS);
}
}
}
else {
last_disp_state = SET_UI;
lv_clear_set();
lv_draw_wifi();
}
}
break;
#endif
}
}
@ -137,6 +174,9 @@ void lv_draw_set(void) {
#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) {
disp_state_stack._disp_index++;
@ -159,79 +199,81 @@ void lv_draw_set(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_pic);
/*Create an Image button*/
//buttonWifi = lv_imgbtn_create(scr, NULL);
buttonFan = lv_imgbtn_create(scr, NULL);
buttonAbout = lv_imgbtn_create(scr, NULL);
//buttonContinue = lv_imgbtn_create(scr, NULL);
buMotorOff = lv_imgbtn_create(scr, NULL);
// Create image buttons
buttonEepromSet = lv_imgbtn_create(scr, NULL);
//buttonWifi = lv_imgbtn_create(scr, NULL);
buttonFan = lv_imgbtn_create(scr, NULL);
buttonAbout = lv_imgbtn_create(scr, NULL);
//buttonContinue = lv_imgbtn_create(scr, NULL);
buMotorOff = lv_imgbtn_create(scr, NULL);
buttonMachinePara = lv_imgbtn_create(scr, NULL);
#if HAS_LANG_SELECT_SCREEN
buttonLanguage = lv_imgbtn_create(scr, NULL);
buttonLanguage = lv_imgbtn_create(scr, NULL);
#endif
#if ENABLED(USE_WIFI_FUNCTION)
buttonWifi = lv_imgbtn_create(scr, NULL);
#endif
buttonMachinePara = lv_imgbtn_create(scr, NULL);
buttonEepromSet = lv_imgbtn_create(scr, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonEepromSet, event_handler, ID_S_EEPROM_SET, NULL, 0);
lv_imgbtn_set_src(buttonEepromSet, LV_BTN_STATE_REL, "F:/bmp_eeprom_settings.bin");
lv_imgbtn_set_src(buttonEepromSet, LV_BTN_STATE_PR, "F:/bmp_eeprom_settings.bin");
lv_imgbtn_set_style(buttonEepromSet, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonEepromSet, LV_BTN_STATE_REL, &tft_style_label_rel);
//lv_obj_set_event_cb_mks(buttonWifi, event_handler,ID_S_WIFI,"bmp_Wifi.bin",0);
//lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_REL, &bmp_pic);
//lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_PR, &bmp_pic);
//lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_PR, &tft_style_label_pre);
//lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_REL, &tft_style_label_rel);
//lv_obj_clear_protect(buttonWifi, LV_PROTECT_FOLLOW);
#if 1
lv_obj_set_event_cb_mks(buttonFan, event_handler, ID_S_FAN, "bmp_fan.bin", 0);
lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonFan, event_handler, ID_S_FAN, NULL, 0);
lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_REL, "F:/bmp_fan.bin");
lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_PR, "F:/bmp_fan.bin");
lv_imgbtn_set_style(buttonFan, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonFan, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonAbout, event_handler, ID_S_ABOUT, "bmp_about.bin", 0);
lv_imgbtn_set_src(buttonAbout, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonAbout, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonAbout, event_handler, ID_S_ABOUT, NULL, 0);
lv_imgbtn_set_src(buttonAbout, LV_BTN_STATE_REL, "F:/bmp_about.bin");
lv_imgbtn_set_src(buttonAbout, LV_BTN_STATE_PR, "F:/bmp_about.bin");
lv_imgbtn_set_style(buttonAbout, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonAbout, LV_BTN_STATE_REL, &tft_style_label_rel);
//lv_obj_set_event_cb_mks(buttonContinue, event_handler,ID_S_CONTINUE,"bmp_Breakpoint.bin",0);
//lv_imgbtn_set_src(buttonContinue, LV_BTN_STATE_REL, &bmp_pic);
//lv_imgbtn_set_src(buttonContinue, LV_BTN_STATE_PR, &bmp_pic);
//lv_imgbtn_set_style(buttonContinue, LV_BTN_STATE_PR, &tft_style_label_pre);
//lv_imgbtn_set_style(buttonContinue, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buMotorOff, event_handler, ID_S_MOTOR_OFF, NULL, 0);
#if HAS_SUICIDE
lv_obj_set_event_cb_mks(buMotorOff, event_handler, ID_S_MOTOR_OFF, "bmp_Mamual.bin", 0);
lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_REL, "F:/bmp_manual_off.bin");
lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_PR, "F:/bmp_manual_off.bin");
#else
lv_obj_set_event_cb_mks(buMotorOff, event_handler, ID_S_MOTOR_OFF, "bmp_function1.bin", 0);
lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_REL, "F:/bmp_function1.bin");
lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_PR, "F:/bmp_function1.bin");
#endif
lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_PR, &bmp_pic);
lv_imgbtn_set_style(buMotorOff, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buMotorOff, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonMachinePara, event_handler, ID_S_MACHINE_PARA, NULL, 0);
lv_imgbtn_set_src(buttonMachinePara, LV_BTN_STATE_REL, "F:/bmp_machine_para.bin");
lv_imgbtn_set_src(buttonMachinePara, LV_BTN_STATE_PR, "F:/bmp_machine_para.bin");
lv_imgbtn_set_style(buttonMachinePara, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonMachinePara, LV_BTN_STATE_REL, &tft_style_label_rel);
#if HAS_LANG_SELECT_SCREEN
lv_obj_set_event_cb_mks(buttonLanguage, event_handler, ID_S_LANGUAGE, "bmp_language.bin", 0);
lv_imgbtn_set_src(buttonLanguage, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonLanguage, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonLanguage, event_handler, ID_S_LANGUAGE, NULL, 0);
lv_imgbtn_set_src(buttonLanguage, LV_BTN_STATE_REL, "F:/bmp_language.bin");
lv_imgbtn_set_src(buttonLanguage, LV_BTN_STATE_PR, "F:/bmp_language.bin");
lv_imgbtn_set_style(buttonLanguage, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonLanguage, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif
lv_obj_set_event_cb_mks(buttonMachinePara, event_handler, ID_S_MACHINE_PARA, "bmp_machine_para.bin", 0);
lv_imgbtn_set_src(buttonMachinePara, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonMachinePara, LV_BTN_STATE_PR, &bmp_pic);
lv_imgbtn_set_style(buttonMachinePara, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonMachinePara, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonEepromSet, event_handler, ID_S_EEPROM_SET, "bmp_eeprom_settings.bin", 0);
lv_imgbtn_set_src(buttonEepromSet, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonEepromSet, LV_BTN_STATE_PR, &bmp_pic);
lv_imgbtn_set_style(buttonEepromSet, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonEepromSet, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_S_RETURN, "bmp_return.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
#if ENABLED(USE_WIFI_FUNCTION)
lv_obj_set_event_cb_mks(buttonWifi, event_handler,ID_S_WIFI,NULL,0);
lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_REL, "F:/bmp_wifi.bin");
lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_PR, "F:/bmp_wifi.bin");
lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_S_RETURN,NULL , 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif // if 1
/*lv_obj_set_pos(buttonWifi,INTERVAL_V,titleHeight);
@ -243,45 +285,56 @@ void lv_draw_set(void) {
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(buttonEepromSet, 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, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight);
lv_obj_set_pos(buttonMachinePara, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
#if HAS_LANG_SELECT_SCREEN
lv_obj_set_pos(buttonLanguage, INTERVAL_V, titleHeight);
lv_obj_set_pos(buttonLanguage, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
#endif
#if ENABLED(USE_WIFI_FUNCTION)
lv_obj_set_pos(buttonWifi,BTN_X_PIXEL*2+INTERVAL_V*3,BTN_Y_PIXEL+INTERVAL_H+titleHeight);
#endif
lv_obj_set_pos(buttonMachinePara, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
lv_obj_set_pos(buttonEepromSet, 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);
/*Create a label on the Image button*/
/// Create labels on the buttons
//lv_btn_set_layout(buttonWifi, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonEepromSet, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonFan, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonAbout, LV_LAYOUT_OFF);
//lv_btn_set_layout(buttonContinue, LV_LAYOUT_OFF);
lv_btn_set_layout(buMotorOff, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonMachinePara, LV_LAYOUT_OFF);
#if HAS_LANG_SELECT_SCREEN
lv_btn_set_layout(buttonLanguage, LV_LAYOUT_OFF);
#endif
lv_btn_set_layout(buttonMachinePara, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonEepromSet, LV_LAYOUT_OFF);
#if ENABLED(USE_WIFI_FUNCTION)
lv_btn_set_layout(buttonWifi, LV_LAYOUT_OFF);
#endif
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
//lv_obj_t * labelWifi= lv_label_create(buttonWifi, NULL);
lv_obj_t * labelFan = lv_label_create(buttonFan, NULL);
lv_obj_t * label_About = lv_label_create(buttonAbout, NULL);
//lv_obj_t * label_Continue = lv_label_create(buttonContinue, NULL);
lv_obj_t * label_MotorOff = lv_label_create(buMotorOff, NULL);
//lv_obj_t *labelWifi= lv_label_create(buttonWifi, NULL);
lv_obj_t *label_EepromSet = lv_label_create(buttonEepromSet, NULL);
lv_obj_t *labelFan = lv_label_create(buttonFan, NULL);
lv_obj_t *label_About = lv_label_create(buttonAbout, NULL);
//lv_obj_t *label_Continue = lv_label_create(buttonContinue, NULL);
lv_obj_t *label_MotorOff = lv_label_create(buMotorOff, NULL);
lv_obj_t *label_MachinePara = lv_label_create(buttonMachinePara, NULL);
#if HAS_LANG_SELECT_SCREEN
lv_obj_t * label_Language = lv_label_create(buttonLanguage, NULL);
lv_obj_t *label_Language = lv_label_create(buttonLanguage, NULL);
#endif
lv_obj_t * label_MachinePara = lv_label_create(buttonMachinePara, NULL);
lv_obj_t * label_EepromSet = lv_label_create(buttonEepromSet, NULL);
lv_obj_t * label_Back = lv_label_create(buttonBack, NULL);
#if ENABLED(USE_WIFI_FUNCTION)
lv_obj_t *label_Wifi = lv_label_create(buttonWifi, NULL);
#endif
lv_obj_t *label_Back = lv_label_create(buttonBack, NULL);
if (gCfgItems.multiple_language != 0) {
//lv_label_set_text(labelWifi, set_menu.wifi);
//lv_obj_align(labelWifi, buttonWifi, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
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);
@ -291,28 +344,46 @@ void lv_draw_set(void) {
//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);
#if HAS_SUICIDE
lv_label_set_text(label_MotorOff, set_menu.shutdown);
#else
lv_label_set_text(label_MotorOff, set_menu.motoroff);
#endif
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
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);
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);
#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
}
void lv_clear_set() { lv_obj_del(scr); }
void lv_clear_set() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

216
Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.cpp

@ -29,6 +29,7 @@
#include "../../../../MarlinCore.h"
#include "../../../../module/planner.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_STEP_RETURN 1
@ -127,11 +128,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
void lv_draw_step_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL;
lv_obj_t *buttonXText = NULL, *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *buttonYText = NULL, *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *buttonZText = NULL, *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t *buttonE0Text = NULL, *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL;
lv_obj_t *buttonE1Text = NULL, *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL;
lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL;
lv_obj_t *labelE1Text = NULL, *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) {
disp_state_stack._disp_index++;
@ -152,166 +153,133 @@ void lv_draw_step_settings(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_para_back);
// LV_IMG_DECLARE(bmp_para_arrow);
LV_IMG_DECLARE(bmp_para_bank);
if (uiCfg.para_ui_page != 1) {
buttonXText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
lv_obj_set_size(buttonXText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonXText, event_handler);
lv_btn_set_style(buttonXText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonXText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonXText, LV_LAYOUT_OFF);
labelXText = lv_label_create(buttonXText, NULL); /*Add a label to the button*/
buttonXValue = lv_imgbtn_create(scr, NULL);
labelXText = lv_label_create(scr, NULL);
lv_obj_set_style(labelXText, &tft_style_label_rel);
lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
lv_label_set_text(labelXText, machine_menu.X_Steps);
buttonXValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_STEP_X, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF);
lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_STEP_X, NULL, 0);
lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value);
labelXValue = lv_label_create(buttonXValue, NULL);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonYText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/
lv_obj_set_size(buttonYText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonYText, event_handler);
lv_btn_set_style(buttonYText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonYText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonYText, LV_LAYOUT_OFF);
labelYText = lv_label_create(buttonYText, NULL); /*Add a label to the button*/
labelYText = lv_label_create(scr, NULL);
lv_obj_set_style(labelYText, &tft_style_label_rel);
lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
lv_label_set_text(labelYText, machine_menu.Y_Steps);
buttonYValue = lv_imgbtn_create(scr, NULL);
buttonYValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_STEP_Y, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF);
lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_STEP_Y, NULL, 0);
lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value);
labelYValue = lv_label_create(buttonYValue, NULL);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
buttonZText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/
lv_obj_set_size(buttonZText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonZText, event_handler);
lv_btn_set_style(buttonZText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonZText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonZText, LV_LAYOUT_OFF);
labelZText = lv_label_create(buttonZText, NULL); /*Add a label to the button*/
labelZText = lv_label_create(scr, NULL);
lv_obj_set_style(labelZText, &tft_style_label_rel);
lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
lv_label_set_text(labelZText, machine_menu.Z_Steps);
buttonZValue = lv_imgbtn_create(scr, NULL);
buttonZValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_STEP_Z, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF);
lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_STEP_Z, NULL, 0);
lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value);
labelZValue = lv_label_create(buttonZValue, NULL);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
buttonE0Text = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4); /*Set its position*/
lv_obj_set_size(buttonE0Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonE0Text, event_handler);
lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonE0Text, LV_LAYOUT_OFF);
labelE0Text = lv_label_create(buttonE0Text, NULL); /*Add a label to the button*/
labelE0Text = lv_label_create(scr, NULL);
lv_obj_set_style(labelE0Text, &tft_style_label_rel);
lv_obj_set_pos(labelE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
lv_label_set_text(labelE0Text, machine_menu.E0_Steps);
buttonE0Value = lv_imgbtn_create(scr, NULL);
buttonE0Value = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonE0Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_STEP_E0, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonE0Value, LV_LAYOUT_OFF);
lv_obj_set_size(buttonE0Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_STEP_E0, NULL, 0);
lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_PR, &style_para_value);
labelE0Value = lv_label_create(buttonE0Value, NULL);
line4 = lv_line_create(scr, NULL);
lv_ex_line(line4, line_points[3]);
buttonTurnPage = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_STEP_DOWN, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back);
lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
buttonTurnPage = lv_btn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_STEP_DOWN, NULL, 0);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, 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 {
buttonE1Text = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonE1Text, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
lv_obj_set_size(buttonE1Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonE1Text, event_handler);
lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonE1Text, LV_LAYOUT_OFF);
labelE1Text = lv_label_create(buttonE1Text, NULL); /*Add a label to the button*/
buttonE1Value = lv_imgbtn_create(scr, NULL);
labelE1Text = lv_label_create(scr, NULL);
lv_obj_set_style(labelE1Text, &tft_style_label_rel);
lv_obj_set_pos(labelE1Text, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
lv_label_set_text(labelE1Text, machine_menu.E1_Steps);
buttonE1Value = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonE1Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_STEP_E1, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonE1Value, LV_LAYOUT_OFF);
lv_obj_set_size(buttonE1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_STEP_E1, NULL, 0);
lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_PR, &style_para_value);
labelE1Value = lv_label_create(buttonE1Value, NULL);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonTurnPage = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_STEP_UP, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back);
lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
buttonTurnPage = lv_btn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_STEP_UP, NULL, 0);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, 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_btn_set_layout(buttonTurnPage, LV_LAYOUT_OFF);
lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
labelTurnPage = lv_label_create(buttonTurnPage, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_STEP_RETURN, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
buttonBack = lv_btn_create(scr, NULL);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
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(buttonBack, NULL);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif
if (gCfgItems.multiple_language != 0) {
if (uiCfg.para_ui_page != 1) {
lv_label_set_text(labelXText, machine_menu.X_Steps);
lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelYText, machine_menu.Y_Steps);
lv_obj_align(labelYText, buttonYText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelZText, machine_menu.Z_Steps);
lv_obj_align(labelZText, buttonZText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelE0Text, machine_menu.E0_Steps);
lv_obj_align(labelE0Text, buttonE0Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelTurnPage, machine_menu.next);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
@ -336,9 +304,6 @@ void lv_draw_step_settings(void) {
lv_obj_align(labelE0Value, buttonE0Value, LV_ALIGN_CENTER, 0, 0);
}
else {
lv_label_set_text(labelE1Text, machine_menu.E1_Steps);
lv_obj_align(labelE1Text, buttonE1Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelTurnPage, machine_menu.previous);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
@ -353,6 +318,11 @@ void lv_draw_step_settings(void) {
}
}
void lv_clear_step_settings() { lv_obj_del(scr); }
void lv_clear_step_settings() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

389
Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.cpp

@ -31,6 +31,7 @@
#include "../../../../module/stepper/indirection.h"
#include "../../../../feature/tmc_util.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_TMC_CURRENT_RETURN 1
@ -54,94 +55,105 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
draw_return_ui();
}
break;
case ID_TMC_CURRENT_X:
#if AXIS_IS_TMC(X)
case ID_TMC_CURRENT_X:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = Xcurrent;
lv_clear_tmc_current_settings();
lv_draw_number_key();
}
break;
#endif
#if AXIS_IS_TMC(Y)
case ID_TMC_CURRENT_Y:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = Xcurrent;
value = Ycurrent;
lv_clear_tmc_current_settings();
lv_draw_number_key();
}
break;
case ID_TMC_CURRENT_Y:
#endif
#if AXIS_IS_TMC(Z)
case ID_TMC_CURRENT_Z:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = Ycurrent;
value = Zcurrent;
lv_clear_tmc_current_settings();
lv_draw_number_key();
}
break;
case ID_TMC_CURRENT_Z:
#endif
#if AXIS_IS_TMC(E0)
case ID_TMC_CURRENT_E0:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = E0current;
lv_clear_tmc_current_settings();
lv_draw_number_key();
}
break;
#endif
#if AXIS_IS_TMC(E1)
case ID_TMC_CURRENT_E1:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = E1current;
lv_clear_tmc_current_settings();
lv_draw_number_key();
}
break;
#endif
case ID_TMC_CURRENT_UP:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = Zcurrent;
uiCfg.para_ui_page = 0;
lv_clear_tmc_current_settings();
lv_draw_number_key();
lv_draw_tmc_current_settings();
}
break;
case ID_TMC_CURRENT_E0:
case ID_TMC_CURRENT_DOWN:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = E0current;
uiCfg.para_ui_page = 1;
lv_clear_tmc_current_settings();
lv_draw_number_key();
lv_draw_tmc_current_settings();
}
break;
#if AXIS_IS_TMC(E1)
case ID_TMC_CURRENT_E1:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
value = E1current;
lv_clear_tmc_current_settings();
lv_draw_number_key();
}
break;
case ID_TMC_CURRENT_UP:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 0;
lv_clear_tmc_current_settings();
lv_draw_tmc_current_settings();
}
break;
case ID_TMC_CURRENT_DOWN:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 1;
lv_clear_tmc_current_settings();
lv_draw_tmc_current_settings();
}
break;
#endif
}
}
void lv_draw_tmc_current_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL;
lv_obj_t *buttonXText = NULL, *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *buttonYText = NULL, *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *buttonZText = NULL, *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t *buttonE0Text = NULL, *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL;
lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
lv_obj_t *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL;
lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
#if AXIS_IS_TMC(E1)
//#if AXIS_IS_TMC(E1)
lv_obj_t *buttonTurnPage = NULL, *labelTurnPage = NULL;
lv_obj_t *buttonE1Text = NULL, *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL;
#endif
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) {
@ -163,217 +175,201 @@ void lv_draw_tmc_current_settings(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_para_back);
// LV_IMG_DECLARE(bmp_para_arrow);
LV_IMG_DECLARE(bmp_para_bank);
if (uiCfg.para_ui_page != 1) {
buttonXText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
lv_obj_set_size(buttonXText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonXText, event_handler);
lv_btn_set_style(buttonXText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonXText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonXText, LV_LAYOUT_OFF);
labelXText = lv_label_create(buttonXText, NULL); /*Add a label to the button*/
buttonXValue = lv_imgbtn_create(scr, NULL);
labelXText = lv_label_create(scr, NULL);
lv_obj_set_style(labelXText, &tft_style_label_rel);
lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
lv_label_set_text(labelXText, machine_menu.X_Current);
buttonXValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_TMC_CURRENT_X, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF);
lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_TMC_CURRENT_X, NULL, 0);
lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value);
labelXValue = lv_label_create(buttonXValue, NULL);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonYText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2); /*Set its position*/
lv_obj_set_size(buttonYText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonYText, event_handler);
lv_btn_set_style(buttonYText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonYText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonYText, LV_LAYOUT_OFF);
labelYText = lv_label_create(buttonYText, NULL); /*Add a label to the button*/
labelYText = lv_label_create(scr, NULL);
lv_obj_set_style(labelYText, &tft_style_label_rel);
lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
lv_label_set_text(labelYText, machine_menu.Y_Current);
buttonYValue = lv_imgbtn_create(scr, NULL);
buttonYValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_TMC_CURRENT_Y, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF);
lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_TMC_CURRENT_Y, NULL, 0);
lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value);
labelYValue = lv_label_create(buttonYValue, NULL);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2, line_points[1]);
buttonZText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3); /*Set its position*/
lv_obj_set_size(buttonZText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonZText, event_handler);
lv_btn_set_style(buttonZText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonZText, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonZText, LV_LAYOUT_OFF);
labelZText = lv_label_create(buttonZText, NULL); /*Add a label to the button*/
labelZText = lv_label_create(scr, NULL);
lv_obj_set_style(labelZText, &tft_style_label_rel);
lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
lv_label_set_text(labelZText, machine_menu.Z_Current);
buttonZValue = lv_imgbtn_create(scr, NULL);
buttonZValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_TMC_CURRENT_Z, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF);
lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_TMC_CURRENT_Z, NULL, 0);
lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value);
labelZValue = lv_label_create(buttonZValue, NULL);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3, line_points[2]);
buttonE0Text = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4); /*Set its position*/
lv_obj_set_size(buttonE0Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonE0Text, event_handler);
lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonE0Text, LV_LAYOUT_OFF);
labelE0Text = lv_label_create(buttonE0Text, NULL); /*Add a label to the button*/
labelE0Text = lv_label_create(scr, NULL);
lv_obj_set_style(labelE0Text, &tft_style_label_rel);
lv_obj_set_pos(labelE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
lv_label_set_text(labelE0Text, machine_menu.E0_Current);
buttonE0Value = lv_imgbtn_create(scr, NULL);
buttonE0Value = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonE0Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_TMC_CURRENT_E0, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonE0Value, LV_LAYOUT_OFF);
lv_obj_set_size(buttonE0Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_TMC_CURRENT_E0, NULL, 0);
lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_PR, &style_para_value);
labelE0Value = lv_label_create(buttonE0Value, NULL);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonXValue);
lv_group_add_obj(g, buttonYValue);
lv_group_add_obj(g, buttonZValue);
lv_group_add_obj(g, buttonE0Value);
}
#endif
line4 = lv_line_create(scr, NULL);
lv_ex_line(line4, line_points[3]);
#if AXIS_IS_TMC(E1)
buttonTurnPage = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_CURRENT_DOWN, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back);
lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif
//#if AXIS_IS_TMC(E1)
buttonTurnPage = lv_btn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_CURRENT_DOWN, NULL, 0);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonTurnPage);
#endif
//#endif
}
else {
#if AXIS_IS_TMC(E1)
buttonE1Text = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonE1Text, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
lv_obj_set_size(buttonE1Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
lv_obj_set_event_cb(buttonE1Text, event_handler);
lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonE1Text, LV_LAYOUT_OFF);
labelE1Text = lv_label_create(buttonE1Text, NULL); /*Add a label to the button*/
buttonE1Value = lv_imgbtn_create(scr, NULL);
//#if AXIS_IS_TMC(E1)
labelE1Text = lv_label_create(scr, NULL);
lv_obj_set_style(labelE1Text, &tft_style_label_rel);
lv_obj_set_pos(labelE1Text, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
lv_label_set_text(labelE1Text, machine_menu.E1_Current);
buttonE1Value = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonE1Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_TMC_CURRENT_E1, "bmp_value_blank.bin", 0);
lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_REL, &bmp_para_bank);
lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_PR, &bmp_para_bank);
lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_REL, &style_para_value_rel);
lv_btn_set_layout(buttonE1Value, LV_LAYOUT_OFF);
lv_obj_set_size(buttonE1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_TMC_CURRENT_E1, NULL, 0);
lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_PR, &style_para_value);
labelE1Value = lv_label_create(buttonE1Value, NULL);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1, line_points[0]);
buttonTurnPage = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_CURRENT_UP, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back);
lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif
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(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonE1Value);
lv_group_add_obj(g, buttonTurnPage);
}
#endif
//#endif
}
#if AXIS_IS_TMC(E1)
//#if AXIS_IS_TMC(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);
lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
labelTurnPage = lv_label_create(buttonTurnPage, NULL);
#endif
//#endif
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_TMC_CURRENT_RETURN, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
buttonBack = lv_btn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_TMC_CURRENT_RETURN, NULL, 0);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
#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);
lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
label_Back = lv_label_create(buttonBack, NULL);
if (gCfgItems.multiple_language != 0) {
if (uiCfg.para_ui_page != 1) {
lv_label_set_text(labelXText, machine_menu.X_Current);
lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelYText, machine_menu.Y_Current);
lv_obj_align(labelYText, buttonYText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelZText, machine_menu.Z_Current);
lv_obj_align(labelZText, buttonZText, LV_ALIGN_IN_LEFT_MID, 0, 0);
lv_label_set_text(labelE0Text, machine_menu.E0_Current);
lv_obj_align(labelE0Text, buttonE0Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
#if AXIS_IS_TMC(E1)
//#if AXIS_IS_TMC(E1)
lv_label_set_text(labelTurnPage, machine_menu.next);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
#endif
//#endif
#if AXIS_IS_TMC(X)
milliamps = stepperX.getMilliamps();
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);
#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();
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);
#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();
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);
#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();
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
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(labelE1Text, machine_menu.E1_Current);
lv_obj_align(labelE1Text, buttonE1Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
//#if AXIS_IS_TMC(E1)
lv_label_set_text(labelTurnPage, machine_menu.previous);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
milliamps = stepperE1.getMilliamps();
#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
//#endif
}
lv_label_set_text(label_Back, common_menu.text_back);
@ -381,6 +377,11 @@ void lv_draw_tmc_current_settings(void) {
}
}
void lv_clear_tmc_current_settings() { lv_obj_del(scr); }
void lv_clear_tmc_current_settings() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI && HAS_TRINAMIC_CONFIG

456
Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.cpp

@ -33,6 +33,7 @@
#include "../../../../gcode/gcode.h"
#include "../../../../module/planner.h"
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_TMC_MODE_RETURN 1
@ -47,9 +48,9 @@ static lv_obj_t * scr;
static lv_obj_t *labelXState = NULL, *labelYState = NULL, *labelZState = NULL, *labelE0State = NULL;
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;
#endif
//#endif
static void event_handler(lv_obj_t * obj, lv_event_t event) {
switch (obj->mks_obj_id) {
@ -63,136 +64,158 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
draw_return_ui();
}
break;
case ID_TMC_MODE_X:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
if (stepperX.stored.stealthChop_enabled == true) {
stepperX.stored.stealthChop_enabled = false;
stepperX.refresh_stepping_mode();
lv_obj_set_event_cb_mks(buttonXState, event_handler, ID_TMC_MODE_X, "bmp_disable.bin", 0);
lv_label_set_text(labelXState, machine_menu.disable);
//lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
// gcode.process_subcommands_now_P(PSTR("M500"));
}
else {
stepperX.stored.stealthChop_enabled = true;
stepperX.refresh_stepping_mode();
lv_obj_set_event_cb_mks(buttonXState, event_handler, ID_TMC_MODE_X, "bmp_enable.bin", 0);
lv_label_set_text(labelXState, machine_menu.enable);
// gcode.process_subcommands_now_P(PSTR("M500"));
}
gcode.process_subcommands_now_P(PSTR("M500"));
}
break;
case ID_TMC_MODE_Y:
if (event == LV_EVENT_CLICKED) {
#if AXIS_HAS_STEALTHCHOP(X)
case ID_TMC_MODE_X:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
if (stepperY.stored.stealthChop_enabled == true) {
stepperY.stored.stealthChop_enabled = false;
stepperY.refresh_stepping_mode();
lv_obj_set_event_cb_mks(buttonYState, event_handler, ID_TMC_MODE_Y, "bmp_disable.bin", 0);
lv_label_set_text(labelYState, machine_menu.disable);
//lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
}
else {
stepperY.stored.stealthChop_enabled = true;
stepperY.refresh_stepping_mode();
lv_obj_set_event_cb_mks(buttonYState, event_handler, ID_TMC_MODE_Y, "bmp_enable.bin", 0);
lv_label_set_text(labelYState, machine_menu.enable);
else if (event == LV_EVENT_RELEASED) {
if (stepperX.stored.stealthChop_enabled) {
stepperX.stored.stealthChop_enabled = false;
stepperX.refresh_stepping_mode();
lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
lv_label_set_text(labelXState, machine_menu.disable);
//lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
// gcode.process_subcommands_now_P(PSTR("M500"));
}
else {
stepperX.stored.stealthChop_enabled = true;
stepperX.refresh_stepping_mode();
lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
lv_label_set_text(labelXState, machine_menu.enable);
// gcode.process_subcommands_now_P(PSTR("M500"));
}
gcode.process_subcommands_now_P(PSTR("M500"));
}
gcode.process_subcommands_now_P(PSTR("M500"));
}
break;
case ID_TMC_MODE_Z:
if (event == LV_EVENT_CLICKED) {
break;
#endif // if AXIS_HAS_STEALTHCHOP(X)
}
else if (event == LV_EVENT_RELEASED) {
if (stepperZ.stored.stealthChop_enabled == true) {
stepperZ.stored.stealthChop_enabled = false;
stepperZ.refresh_stepping_mode();
lv_obj_set_event_cb_mks(buttonZState, event_handler, ID_TMC_MODE_Z, "bmp_disable.bin", 0);
lv_label_set_text(labelZState, machine_menu.disable);
//lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
}
else {
stepperZ.stored.stealthChop_enabled = true;
stepperZ.refresh_stepping_mode();
lv_obj_set_event_cb_mks(buttonZState, event_handler, ID_TMC_MODE_Z, "bmp_enable.bin", 0);
lv_label_set_text(labelZState, machine_menu.enable);
}
gcode.process_subcommands_now_P(PSTR("M500"));
}
break;
case ID_TMC_MODE_E0:
if (event == LV_EVENT_CLICKED) {
#if AXIS_HAS_STEALTHCHOP(Y)
case ID_TMC_MODE_Y:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
if (stepperE0.stored.stealthChop_enabled == true) {
stepperE0.stored.stealthChop_enabled = false;
stepperE0.refresh_stepping_mode();
lv_obj_set_event_cb_mks(buttonE0State, event_handler, ID_TMC_MODE_E0, "bmp_disable.bin", 0);
lv_label_set_text(labelE0State, machine_menu.disable);
//lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
}
else {
stepperE0.stored.stealthChop_enabled = true;
stepperE0.refresh_stepping_mode();
lv_obj_set_event_cb_mks(buttonE0State, event_handler, ID_TMC_MODE_E0, "bmp_enable.bin", 0);
lv_label_set_text(labelE0State, machine_menu.enable);
else if (event == LV_EVENT_RELEASED) {
if (stepperY.stored.stealthChop_enabled) {
stepperY.stored.stealthChop_enabled = false;
stepperY.refresh_stepping_mode();
lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
lv_label_set_text(labelYState, machine_menu.disable);
//lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
}
else {
stepperY.stored.stealthChop_enabled = true;
stepperY.refresh_stepping_mode();
lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
lv_label_set_text(labelYState, machine_menu.enable);
}
gcode.process_subcommands_now_P(PSTR("M500"));
}
gcode.process_subcommands_now_P(PSTR("M500"));
}
break;
#if AXIS_HAS_STEALTHCHOP(E1)
case ID_TMC_MODE_E1:
if (event == LV_EVENT_CLICKED) {
break;
#endif // if AXIS_HAS_STEALTHCHOP(Y)
#if AXIS_HAS_STEALTHCHOP(Z)
case ID_TMC_MODE_Z:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
if (stepperZ.stored.stealthChop_enabled) {
stepperZ.stored.stealthChop_enabled = false;
stepperZ.refresh_stepping_mode();
lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
lv_label_set_text(labelZState, machine_menu.disable);
//lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
}
else if (event == LV_EVENT_RELEASED) {
if (stepperE1.stored.stealthChop_enabled == true) {
stepperE1.stored.stealthChop_enabled = false;
stepperE1.refresh_stepping_mode();
lv_obj_set_event_cb_mks(buttonE1State, event_handler, ID_TMC_MODE_E1, "bmp_disable.bin", 0);
lv_label_set_text(labelE1State, machine_menu.disable);
//lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
}
else {
stepperE1.stored.stealthChop_enabled = true;
stepperE1.refresh_stepping_mode();
lv_obj_set_event_cb_mks(buttonE1State, event_handler, ID_TMC_MODE_E1, "bmp_enable.bin", 0);
lv_label_set_text(labelE1State, machine_menu.enable);
}
gcode.process_subcommands_now_P(PSTR("M500"));
else {
stepperZ.stored.stealthChop_enabled = true;
stepperZ.refresh_stepping_mode();
lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
lv_label_set_text(labelZState, machine_menu.enable);
}
break;
gcode.process_subcommands_now_P(PSTR("M500"));
}
break;
#endif // if AXIS_HAS_STEALTHCHOP(Z)
case ID_TMC_MODE_UP:
if (event == LV_EVENT_CLICKED) {
#if AXIS_HAS_STEALTHCHOP(E0)
case ID_TMC_MODE_E0:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
if (stepperE0.stored.stealthChop_enabled) {
stepperE0.stored.stealthChop_enabled = false;
stepperE0.refresh_stepping_mode();
lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
lv_label_set_text(labelE0State, machine_menu.disable);
//lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
}
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 0;
lv_clear_tmc_step_mode_settings();
lv_draw_tmc_step_mode_settings();
else {
stepperE0.stored.stealthChop_enabled = true;
stepperE0.refresh_stepping_mode();
lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
lv_label_set_text(labelE0State, machine_menu.enable);
}
break;
case ID_TMC_MODE_DOWN:
if (event == LV_EVENT_CLICKED) {
gcode.process_subcommands_now_P(PSTR("M500"));
}
break;
#endif // if AXIS_HAS_STEALTHCHOP(E0)
#if AXIS_HAS_STEALTHCHOP(E1)
case ID_TMC_MODE_E1:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
if (stepperE1.stored.stealthChop_enabled) {
stepperE1.stored.stealthChop_enabled = false;
stepperE1.refresh_stepping_mode();
lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
lv_label_set_text(labelE1State, machine_menu.disable);
//lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
}
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 1;
lv_clear_tmc_step_mode_settings();
lv_draw_tmc_step_mode_settings();
else {
stepperE1.stored.stealthChop_enabled = true;
stepperE1.refresh_stepping_mode();
lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
lv_label_set_text(labelE1State, machine_menu.enable);
}
break;
#endif // if AXIS_HAS_STEALTHCHOP(E1)
gcode.process_subcommands_now_P(PSTR("M500"));
}
break;
#endif // if AXIS_HAS_STEALTHCHOP(E1)
case ID_TMC_MODE_UP:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 0;
lv_clear_tmc_step_mode_settings();
lv_draw_tmc_step_mode_settings();
}
break;
case ID_TMC_MODE_DOWN:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
uiCfg.para_ui_page = 1;
lv_clear_tmc_step_mode_settings();
lv_draw_tmc_step_mode_settings();
}
break;
}
}
@ -204,10 +227,10 @@ void lv_draw_tmc_step_mode_settings(void) {
lv_obj_t *buttonE0Text = NULL, *labelE0Text = NULL;
lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
#if AXIS_HAS_STEALTHCHOP(E1)
//#if AXIS_HAS_STEALTHCHOP(E1)
lv_obj_t *buttonTurnPage = NULL, *labelTurnPage = NULL;
lv_obj_t *buttonE1Text = NULL, *labelE1Text = NULL;
#endif
//#endif
labelXState = NULL;
@ -218,10 +241,10 @@ void lv_draw_tmc_step_mode_settings(void) {
buttonZState = NULL;
labelE0State = NULL;
buttonE0State = NULL;
#if AXIS_HAS_STEALTHCHOP(E1)
//#if AXIS_HAS_STEALTHCHOP(E1)
labelE1State = NULL;
buttonE1State = NULL;
#endif
//#endif
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != TMC_MODE_UI) {
disp_state_stack._disp_index++;
@ -242,10 +265,6 @@ void lv_draw_tmc_step_mode_settings(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_para_back);
LV_IMG_DECLARE(bmp_para_state);
// LV_IMG_DECLARE(bmp_para_bank);
if (uiCfg.para_ui_page != 1) {
buttonXText = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
@ -258,16 +277,28 @@ void lv_draw_tmc_step_mode_settings(void) {
buttonXState = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonXState, PARA_UI_STATE_POS_X, PARA_UI_POS_Y + PARA_UI_STATE_V);
if (stepperX.get_stealthChop_status())
lv_obj_set_event_cb_mks(buttonXState, event_handler, ID_TMC_MODE_X, "bmp_enable.bin", 0);
else
lv_obj_set_event_cb_mks(buttonXState, event_handler, ID_TMC_MODE_X, "bmp_disable.bin", 0);
lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_REL, &bmp_para_state);
lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_PR, &bmp_para_state);
#if AXIS_HAS_STEALTHCHOP(X)
if (stepperX.get_stealthChop_status()) {
lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
}
else {
lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
}
#else
lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
#endif
lv_obj_set_event_cb_mks(buttonXState, event_handler, ID_TMC_MODE_X, NULL, 0);
lv_imgbtn_set_style(buttonXState, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonXState, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonXState, LV_LAYOUT_OFF);
labelXState = lv_label_create(buttonXState, NULL);
#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]);
@ -283,16 +314,28 @@ void lv_draw_tmc_step_mode_settings(void) {
buttonYState = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonYState, PARA_UI_STATE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_STATE_V);
if (stepperY.get_stealthChop_status())
lv_obj_set_event_cb_mks(buttonYState, event_handler, ID_TMC_MODE_Y, "bmp_enable.bin", 0);
else
lv_obj_set_event_cb_mks(buttonYState, event_handler, ID_TMC_MODE_Y, "bmp_disable.bin", 0);
lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_REL, &bmp_para_state);
lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_PR, &bmp_para_state);
#if AXIS_HAS_STEALTHCHOP(Y)
if (stepperY.get_stealthChop_status()) {
lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
}
else {
lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
}
#else
lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
#endif
lv_obj_set_event_cb_mks(buttonYState, event_handler, ID_TMC_MODE_Y, NULL, 0);
lv_imgbtn_set_style(buttonYState, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonYState, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonYState, LV_LAYOUT_OFF);
labelYState = lv_label_create(buttonYState, NULL);
#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]);
@ -308,16 +351,27 @@ void lv_draw_tmc_step_mode_settings(void) {
buttonZState = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonZState, PARA_UI_STATE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_STATE_V);
if (stepperZ.get_stealthChop_status())
lv_obj_set_event_cb_mks(buttonZState, event_handler, ID_TMC_MODE_Z, "bmp_enable.bin", 0);
else
lv_obj_set_event_cb_mks(buttonZState, event_handler, ID_TMC_MODE_Z, "bmp_disable.bin", 0);
lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_REL, &bmp_para_state);
lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_PR, &bmp_para_state);
#if AXIS_HAS_STEALTHCHOP(Z)
if (stepperZ.get_stealthChop_status()) {
lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
}
else {
lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
}
#else
lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
#endif
lv_obj_set_event_cb_mks(buttonZState, event_handler, ID_TMC_MODE_Z, NULL, 0);
lv_imgbtn_set_style(buttonZState, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonZState, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonZState, LV_LAYOUT_OFF);
labelZState = lv_label_create(buttonZState, NULL);
#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]);
@ -333,31 +387,48 @@ void lv_draw_tmc_step_mode_settings(void) {
buttonE0State = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonE0State, PARA_UI_STATE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_STATE_V);
if (stepperE0.get_stealthChop_status())
lv_obj_set_event_cb_mks(buttonE0State, event_handler, ID_TMC_MODE_E0, "bmp_enable.bin", 0);
else
lv_obj_set_event_cb_mks(buttonE0State, event_handler, ID_TMC_MODE_E0, "bmp_disable.bin", 0);
lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_REL, &bmp_para_state);
lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_PR, &bmp_para_state);
#if AXIS_HAS_STEALTHCHOP(E0)
if (stepperE0.get_stealthChop_status()) {
lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
}
else {
lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
}
#else
lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
#endif
lv_obj_set_event_cb_mks(buttonE0State, event_handler, ID_TMC_MODE_E0, NULL, 0);
lv_imgbtn_set_style(buttonE0State, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonE0State, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonE0State, LV_LAYOUT_OFF);
labelE0State = lv_label_create(buttonE0State, NULL);
#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)
//#if AXIS_HAS_STEALTHCHOP(E1)
buttonTurnPage = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_MODE_DOWN, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_MODE_DOWN, NULL, 0);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonTurnPage);
#endif
//#endif
}
else {
#if AXIS_HAS_STEALTHCHOP(E1)
//#if AXIS_HAS_STEALTHCHOP(E1)
buttonE1Text = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonE1Text, PARA_UI_POS_X, PARA_UI_POS_Y); /*Set its position*/
lv_obj_set_size(buttonE1Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
@ -369,40 +440,54 @@ void lv_draw_tmc_step_mode_settings(void) {
buttonE1State = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonE1State, PARA_UI_STATE_POS_X, PARA_UI_POS_Y + PARA_UI_STATE_V);
if (stepperE1.get_stealthChop_status())
lv_obj_set_event_cb_mks(buttonE1State, event_handler, ID_TMC_MODE_E1, "bmp_enable.bin", 0);
else
lv_obj_set_event_cb_mks(buttonE1State, event_handler, ID_TMC_MODE_E1, "bmp_disable.bin", 0);
lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_REL, &bmp_para_state);
lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_PR, &bmp_para_state);
#if AXIS_HAS_STEALTHCHOP(E1)
if (stepperE1.get_stealthChop_status()) {
lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
}
else {
lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
}
#else
lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
#endif
lv_obj_set_event_cb_mks(buttonE1State, event_handler, ID_TMC_MODE_E1, NULL, 0);
lv_imgbtn_set_style(buttonE1State, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonE1State, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonE1State, LV_LAYOUT_OFF);
labelE1State = lv_label_create(buttonE1State, NULL);
#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, NULL);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_MODE_UP, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back);
lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_MODE_UP, NULL, 0);
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif
//#endif
}
#if AXIS_HAS_STEALTHCHOP(E1)
//#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(buttonTurnPage, NULL);
#endif
//#endif
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_TMC_MODE_RETURN, "bmp_back70x40.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_TMC_MODE_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
@ -422,50 +507,68 @@ void lv_draw_tmc_step_mode_settings(void) {
lv_label_set_text(labelE0Text, machine_menu.E0_StepMode);
lv_obj_align(labelE0Text, buttonE0Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
#if AXIS_HAS_STEALTHCHOP(X)
if (stepperX.get_stealthChop_status())
lv_label_set_text(labelXState, machine_menu.enable);
else
lv_label_set_text(labelXState, machine_menu.disable);
#else
lv_label_set_text(labelXState, machine_menu.disable);
#endif
lv_obj_align(labelXState, buttonXState, LV_ALIGN_CENTER, 0, 0);
#if AXIS_HAS_STEALTHCHOP(Y)
if (stepperY.get_stealthChop_status())
lv_label_set_text(labelYState, machine_menu.enable);
else
lv_label_set_text(labelYState, machine_menu.disable);
#else
lv_label_set_text(labelYState, machine_menu.disable);
#endif
lv_obj_align(labelYState, buttonYState, LV_ALIGN_CENTER, 0, 0);
#if AXIS_HAS_STEALTHCHOP(Z)
if (stepperZ.get_stealthChop_status())
lv_label_set_text(labelZState, machine_menu.enable);
else
lv_label_set_text(labelZState, machine_menu.disable);
#else
lv_label_set_text(labelZState, machine_menu.disable);
#endif
lv_obj_align(labelZState, buttonZState, LV_ALIGN_CENTER, 0, 0);
#if AXIS_HAS_STEALTHCHOP(E0)
if (stepperE0.get_stealthChop_status())
lv_label_set_text(labelE0State, machine_menu.enable);
else
lv_label_set_text(labelE0State, machine_menu.disable);
#else
lv_label_set_text(labelE0State, machine_menu.disable);
#endif
lv_obj_align(labelE0State, buttonE0State, LV_ALIGN_CENTER, 0, 0);
#if AXIS_HAS_STEALTHCHOP(E1)
//#if AXIS_HAS_STEALTHCHOP(E1)
lv_label_set_text(labelTurnPage, machine_menu.next);
lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
#endif
//#endif
}
else {
#if AXIS_HAS_STEALTHCHOP(E1)
//#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);
#if AXIS_HAS_STEALTHCHOP(E1)
if (stepperE1.get_stealthChop_status())
lv_label_set_text(labelE1State, machine_menu.enable);
else
lv_label_set_text(labelE1State, machine_menu.disable);
#else
lv_label_set_text(labelE1State, machine_menu.disable);
#endif
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
//#endif
}
lv_label_set_text(label_Back, common_menu.text_back);
@ -473,6 +576,11 @@ void lv_draw_tmc_step_mode_settings(void) {
}
}
void lv_clear_tmc_step_mode_settings() { lv_obj_del(scr); }
void lv_clear_tmc_step_mode_settings() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI && HAS_STEALTHCHOP

171
Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp

@ -32,8 +32,9 @@
#include "../../../../MarlinCore.h"
#include "../../../../gcode/queue.h"
#include "../../../../module/temperature.h"
// static lv_obj_t *buttonMoveZ,*buttonTest,*buttonZ0,*buttonStop,*buttonReturn;
extern lv_group_t * g;
static lv_obj_t * scr;
#define ID_T_PRE_HEAT 1
@ -45,6 +46,10 @@ static lv_obj_t * scr;
#define ID_T_MORE 7
#define ID_T_RETURN 8
#if ENABLED(MKS_TEST)
extern uint8_t curent_disp_ui;
#endif
static void event_handler(lv_obj_t * obj, lv_event_t event) {
switch (obj->mks_obj_id) {
case ID_T_PRE_HEAT:
@ -89,8 +94,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
}
else if (event == LV_EVENT_RELEASED) {
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
queue.enqueue_one_P(PSTR("G28"));
queue.enqueue_one_P(PSTR("G29"));
//queue.enqueue_one_P(PSTR("G28"));
//queue.enqueue_one_P(PSTR("G29"));
get_gcode_command(AUTO_LEVELING_COMMAND_ADDR,(uint8_t *)public_buf_m);
public_buf_m[sizeof(public_buf_m)-1] = 0;
queue.inject_P(PSTR(public_buf_m));
#else
uiCfg.leveling_first_time = 1;
lv_clear_tool();
@ -98,7 +106,16 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
#endif
}
break;
case ID_T_FILAMENT: break;
case ID_T_FILAMENT:
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
uiCfg.desireSprayerTempBak = thermalManager.temp_hotend[uiCfg.curSprayerChoose].target;
lv_clear_tool();
lv_draw_filament_change();
}
break;
case ID_T_MORE: break;
case ID_T_RETURN:
if (event == LV_EVENT_CLICKED) {
@ -106,7 +123,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
}
else if (event == LV_EVENT_RELEASED) {
TERN_(MKS_TEST, curent_disp_ui = 1);
lv_obj_del(scr);
lv_clear_tool();
lv_draw_ready_print();
}
break;
@ -115,6 +132,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
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) {
@ -138,75 +156,64 @@ void lv_draw_tool(void) {
lv_refr_now(lv_refr_get_disp_refreshing());
LV_IMG_DECLARE(bmp_pic);
// Create image buttons
buttonPreHeat = lv_imgbtn_create(scr, NULL);
buttonExtrusion = lv_imgbtn_create(scr, NULL);
buttonMove = lv_imgbtn_create(scr, NULL);
buttonHome = lv_imgbtn_create(scr, NULL);
buttonLevel = lv_imgbtn_create(scr, NULL);
// buttonFilament = lv_imgbtn_create(scr, NULL);
// buttonMore = lv_imgbtn_create(scr, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
buttonFilament = lv_imgbtn_create(scr, NULL);
//buttonMore = lv_imgbtn_create(scr, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonPreHeat, event_handler, ID_T_PRE_HEAT, "bmp_preHeat.bin", 0);
lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_PR, &bmp_pic);
lv_obj_set_event_cb_mks(buttonPreHeat, event_handler, ID_T_PRE_HEAT, NULL, 0);
lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_REL, "F:/bmp_preHeat.bin");
lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_PR, "F:/bmp_preHeat.bin");
lv_imgbtn_set_style(buttonPreHeat, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonPreHeat, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_clear_protect(buttonPreHeat, LV_PROTECT_FOLLOW);
#if 1
lv_obj_set_event_cb_mks(buttonExtrusion, event_handler, ID_T_EXTRUCT, "bmp_extruct.bin", 0);
lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_PR, &bmp_pic);
lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonMove, event_handler, ID_T_MOV, "bmp_mov.bin", 0);
lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_PR, &bmp_pic);
lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonHome, event_handler, ID_T_HOME, "bmp_zero.bin", 0);
lv_imgbtn_set_src(buttonHome, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonHome, LV_BTN_STATE_PR, &bmp_pic);
lv_imgbtn_set_style(buttonHome, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonHome, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonLevel, event_handler, ID_T_LEVELING, "bmp_leveling.bin", 0);
lv_imgbtn_set_src(buttonLevel, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonLevel, LV_BTN_STATE_PR, &bmp_pic);
lv_imgbtn_set_style(buttonLevel, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonLevel, LV_BTN_STATE_REL, &tft_style_label_rel);
//lv_obj_set_event_cb_mks(buttonFilament, event_handler,ID_T_FILAMENT,"bmp_Filamentchange.bin",0);
//lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_REL, &bmp_pic);
//lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_PR, &bmp_pic);
//lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_PR, &tft_style_label_pre);
//lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_REL, &tft_style_label_rel);
//lv_obj_set_event_cb_mks(buttonMore, event_handler,ID_T_MORE,"bmp_More.bin",0);
//lv_imgbtn_set_src(buttonMore, LV_BTN_STATE_REL, &bmp_pic);
//lv_imgbtn_set_src(buttonMore, LV_BTN_STATE_PR, &bmp_pic);
//lv_imgbtn_set_style(buttonMore, LV_BTN_STATE_PR, &tft_style_label_pre);
//lv_imgbtn_set_style(buttonMore, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_T_RETURN, "bmp_return.bin", 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
#endif // if 1
lv_obj_set_event_cb_mks(buttonExtrusion, event_handler, ID_T_EXTRUCT, NULL, 0);
lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_REL, "F:/bmp_extruct.bin");
lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_PR, "F:/bmp_extruct.bin");
lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonMove, event_handler, ID_T_MOV, NULL, 0);
lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_REL, "F:/bmp_mov.bin");
lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_PR, "F:/bmp_mov.bin");
lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonHome, event_handler, ID_T_HOME, NULL, 0);
lv_imgbtn_set_src(buttonHome, LV_BTN_STATE_REL, "F:/bmp_zero.bin");
lv_imgbtn_set_src(buttonHome, LV_BTN_STATE_PR, "F:/bmp_zero.bin");
lv_imgbtn_set_style(buttonHome, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonHome, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonLevel, event_handler, ID_T_LEVELING, NULL, 0);
lv_imgbtn_set_src(buttonLevel, LV_BTN_STATE_REL, "F:/bmp_leveling.bin");
lv_imgbtn_set_src(buttonLevel, LV_BTN_STATE_PR, "F:/bmp_leveling.bin");
lv_imgbtn_set_style(buttonLevel, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonLevel, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonFilament, event_handler,ID_T_FILAMENT,NULL,0);
lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_REL, "F:/bmp_filamentchange.bin");
lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_PR, "F:/bmp_filamentchange.bin");
lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_T_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_pos(buttonPreHeat, INTERVAL_V, titleHeight);
lv_obj_set_pos(buttonExtrusion, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight);
lv_obj_set_pos(buttonMove, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight);
lv_obj_set_pos(buttonHome, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight);
lv_obj_set_pos(buttonLevel, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
//lv_obj_set_pos(buttonFilament,BTN_X_PIXEL+INTERVAL_V*2,BTN_Y_PIXEL+INTERVAL_H+titleHeight);
lv_obj_set_pos(buttonFilament,BTN_X_PIXEL+INTERVAL_V*2,BTN_Y_PIXEL+INTERVAL_H+titleHeight);
//lv_obj_set_pos(buttonMore,BTN_X_PIXEL*2+INTERVAL_V*3, BTN_Y_PIXEL+INTERVAL_H+titleHeight);
lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
@ -216,18 +223,18 @@ void lv_draw_tool(void) {
lv_btn_set_layout(buttonMove, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonHome, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonLevel, LV_LAYOUT_OFF);
//lv_btn_set_layout(buttonFilament, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonFilament, LV_LAYOUT_OFF);
//lv_btn_set_layout(buttonMore, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
lv_obj_t * labelPreHeat = lv_label_create(buttonPreHeat, NULL);
lv_obj_t * labelExtrusion = lv_label_create(buttonExtrusion, NULL);
lv_obj_t * label_Move = lv_label_create(buttonMove, NULL);
lv_obj_t * label_Home = lv_label_create(buttonHome, NULL);
lv_obj_t * label_Level = lv_label_create(buttonLevel, NULL);
//lv_obj_t * label_Filament = lv_label_create(buttonFilament, NULL);
//lv_obj_t * label_More = lv_label_create(buttonMore, NULL);
lv_obj_t * label_Back = lv_label_create(buttonBack, NULL);
lv_obj_t *labelPreHeat = lv_label_create(buttonPreHeat, NULL);
lv_obj_t *labelExtrusion = lv_label_create(buttonExtrusion, NULL);
lv_obj_t *label_Move = lv_label_create(buttonMove, NULL);
lv_obj_t *label_Home = lv_label_create(buttonHome, NULL);
lv_obj_t *label_Level = lv_label_create(buttonLevel, NULL);
lv_obj_t *label_Filament = lv_label_create(buttonFilament, NULL);
//lv_obj_t *label_More = lv_label_create(buttonMore, NULL);
lv_obj_t *label_Back = lv_label_create(buttonBack, NULL);
if (gCfgItems.multiple_language != 0) {
lv_label_set_text(labelPreHeat, tool_menu.preheat);
@ -242,17 +249,11 @@ void lv_draw_tool(void) {
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);
/*
if (gCfgItems.leveling_mode != 2) {
lv_label_set_text(label_Level, gCfgItems.leveling_mode == 1 ? tool_menu.autoleveling : tool_menu.leveling);
lv_obj_align(label_Level, buttonLevel, 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_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);
@ -260,8 +261,24 @@ void lv_draw_tool(void) {
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() { lv_obj_del(scr); }
void lv_clear_tool() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // HAS_TFT_LVGL_UI

495
Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp

@ -55,7 +55,8 @@ DISP_STATE_STACK disp_state_stack;
DISP_STATE disp_state = MAIN_UI;
DISP_STATE last_disp_state;
PRINT_TIME print_time;
value_state value;
num_key_value_state value;
keyboard_value_state keyboard_value;
uint32_t To_pre_view;
uint8_t gcode_preview_over;
@ -73,6 +74,14 @@ extern uint8_t bmp_public_buf[17 * 1024];
extern void LCD_IO_WriteData(uint16_t RegValue);
static const char custom_gcode_command[][100] = {
"G28\nG29\nM500",
"G28",
"G28",
"G28",
"G28"
};
lv_point_t line_points[4][2] = {
{{PARA_UI_POS_X, PARA_UI_POS_Y + PARA_UI_SIZE_Y}, {TFT_WIDTH, PARA_UI_POS_Y + PARA_UI_SIZE_Y}},
{{PARA_UI_POS_X, PARA_UI_POS_Y*2 + PARA_UI_SIZE_Y}, {TFT_WIDTH, PARA_UI_POS_Y*2 + PARA_UI_SIZE_Y}},
@ -108,22 +117,58 @@ void gCfgItems_init() {
#elif LCD_LANGUAGE == pt
gCfgItems.language = LANG_PORTUGUESE;
#endif
gCfgItems.leveling_mode = 0;
gCfgItems.from_flash_pic = 0;
gCfgItems.curFilesize = 0;
gCfgItems.finish_power_off = 0;
gCfgItems.pause_reprint = 0;
gCfgItems.pausePosX = -1;
gCfgItems.pausePosY = -1;
gCfgItems.pausePosZ = 5;
gCfgItems.leveling_mode = 0;
gCfgItems.from_flash_pic = 0;
gCfgItems.curFilesize = 0;
gCfgItems.finish_power_off = 0;
gCfgItems.pause_reprint = 0;
gCfgItems.pausePosX = -1;
gCfgItems.pausePosY = -1;
gCfgItems.pausePosZ = 5;
gCfgItems.levelingPos[0][0] = X_MIN_POS + 30;
gCfgItems.levelingPos[0][1] = Y_MIN_POS + 30;
gCfgItems.levelingPos[1][0] = X_MAX_POS - 30;
gCfgItems.levelingPos[1][1] = Y_MIN_POS + 30;
gCfgItems.levelingPos[2][0] = X_MAX_POS - 30;
gCfgItems.levelingPos[2][1] = Y_MAX_POS - 30;
gCfgItems.levelingPos[3][0] = X_MIN_POS + 30;
gCfgItems.levelingPos[3][1] = Y_MAX_POS - 30;
gCfgItems.levelingPos[4][0] = X_BED_SIZE / 2;
gCfgItems.levelingPos[4][1] = Y_BED_SIZE / 2;
gCfgItems.cloud_enable = true;
#if ENABLED(USE_WIFI_FUNCTION)
gCfgItems.wifi_mode_sel = STA_MODEL;
gCfgItems.fileSysType = FILE_SYS_SD;
gCfgItems.wifi_type = ESP_WIFI;
#endif
gCfgItems.filamentchange_load_length = 200;
gCfgItems.filamentchange_load_speed = 1000;
gCfgItems.filamentchange_unload_length = 200;
gCfgItems.filamentchange_unload_speed = 1000;
gCfgItems.filament_limit_temper = 200;
gCfgItems.encoder_enable = true;
W25QXX.SPI_FLASH_BufferRead((uint8_t *)&gCfgItems.spi_flash_flag, VAR_INF_ADDR, sizeof(gCfgItems.spi_flash_flag));
if (gCfgItems.spi_flash_flag == GCFG_FLAG_VALUE) {
if (gCfgItems.spi_flash_flag == FLASH_INF_VALID_FLAG) {
W25QXX.SPI_FLASH_BufferRead((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems));
}
else {
gCfgItems.spi_flash_flag = GCFG_FLAG_VALUE;
gCfgItems.spi_flash_flag = FLASH_INF_VALID_FLAG;
W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR);
W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems));
//init gcode command
W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[0], AUTO_LEVELING_COMMAND_ADDR, 100);
W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[1], OTHERS_COMMAND_ADDR_1, 100);
W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[2], OTHERS_COMMAND_ADDR_2, 100);
W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[3], OTHERS_COMMAND_ADDR_3, 100);
W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[4], OTHERS_COMMAND_ADDR_4, 100);
}
const byte rot = TERN0(GRAPHICAL_TFT_ROTATE_180, 0xEE);
if (gCfgItems.disp_rotation_180 != rot) {
gCfgItems.disp_rotation_180 = rot;
update_spi_flash();
}
uiCfg.F[0] = 'N';
@ -134,11 +179,6 @@ void gCfgItems_init() {
W25QXX.SPI_FLASH_BufferWrite(uiCfg.F,REFLSHE_FLGA_ADD,4);
}
void gCfg_to_spiFlah() {
W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR);
W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems));
}
void ui_cfg_init() {
uiCfg.curTempType = 0;
uiCfg.curSprayerChoose = 0;
@ -150,12 +190,81 @@ void ui_cfg_init() {
uiCfg.move_dist = 1;
uiCfg.moveSpeed = 3000;
uiCfg.stepPrintSpeed = 10;
uiCfg.command_send = 0;
uiCfg.dialogType = 0;
uiCfg.filament_heat_completed_load = 0;
uiCfg.filament_rate = 0;
uiCfg.filament_loading_completed = 0;
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;
#if ENABLED(USE_WIFI_FUNCTION)
memset(&wifiPara, 0, sizeof(wifiPara));
memset(&ipPara, 0, sizeof(ipPara));
strcpy(wifiPara.ap_name, WIFI_AP_NAME);
strcpy(wifiPara.keyCode, WIFI_KEY_CODE);
//client
strcpy(ipPara.ip_addr, IP_ADDR);
strcpy(ipPara.mask, IP_MASK);
strcpy(ipPara.gate, IP_GATE);
strcpy(ipPara.dns, IP_DNS);
ipPara.dhcp_flag = IP_DHCP_FLAG;
//AP
strcpy(ipPara.dhcpd_ip, AP_IP_ADDR);
strcpy(ipPara.dhcpd_mask, AP_IP_MASK);
strcpy(ipPara.dhcpd_gate, AP_IP_GATE);
strcpy(ipPara.dhcpd_dns, AP_IP_DNS);
strcpy(ipPara.start_ip_addr, IP_START_IP);
strcpy(ipPara.end_ip_addr, IP_END_IP);
ipPara.dhcpd_flag = AP_IP_DHCP_FLAG;
strcpy((char*)uiCfg.cloud_hostUrl, "baizhongyun.cn");
uiCfg.cloud_port = 10086;
#endif
uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length * 60.0 / gCfgItems.filamentchange_load_speed) + 0.5);
uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length * 60.0 / gCfgItems.filamentchange_unload_speed) + 0.5);
}
void update_spi_flash() {
uint8_t command_buf[512];
W25QXX.init(SPI_QUARTER_SPEED);
//read back the gcode command befor erase spi flash
W25QXX.SPI_FLASH_BufferRead((uint8_t *)&command_buf, GCODE_COMMAND_ADDR, sizeof(command_buf));
W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR);
W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems));
W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&command_buf, GCODE_COMMAND_ADDR, sizeof(command_buf));
}
void update_gcode_command(int addr,uint8_t *s) {
uint8_t command_buf[512];
W25QXX.init(SPI_QUARTER_SPEED);
//read back the gcode command befor erase spi flash
W25QXX.SPI_FLASH_BufferRead((uint8_t *)&command_buf, GCODE_COMMAND_ADDR, sizeof(command_buf));
W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR);
W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems));
switch (addr) {
case AUTO_LEVELING_COMMAND_ADDR: memcpy(&command_buf[0*100], s, 100); break;
case OTHERS_COMMAND_ADDR_1: memcpy(&command_buf[1*100], s, 100); break;
case OTHERS_COMMAND_ADDR_2: memcpy(&command_buf[2*100], s, 100); break;
case OTHERS_COMMAND_ADDR_3: memcpy(&command_buf[3*100], s, 100); break;
case OTHERS_COMMAND_ADDR_4: memcpy(&command_buf[4*100], s, 100); break;
default: break;
}
W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&command_buf, GCODE_COMMAND_ADDR, sizeof(command_buf));
}
void get_gcode_command(int addr,uint8_t *d) {
W25QXX.init(SPI_QUARTER_SPEED);
W25QXX.SPI_FLASH_BufferRead((uint8_t *)d, addr, 100);
}
lv_style_t tft_style_scr;
@ -169,6 +278,13 @@ lv_style_t style_num_key_pre;
lv_style_t style_num_key_rel;
lv_style_t style_num_text;
lv_style_t style_sel_text;
lv_style_t style_para_value;
lv_style_t style_para_back;
lv_style_t lv_bar_style_indic;
void tft_style_init() {
lv_style_copy(&tft_style_scr, &lv_style_scr);
tft_style_scr.body.main_color = LV_COLOR_BACKGROUND;
@ -197,12 +313,13 @@ void tft_style_init() {
tft_style_label_rel.text.letter_space = 0;
tft_style_label_pre.text.line_space = -5;
tft_style_label_rel.text.line_space = -5;
lv_style_copy(&style_para_value_pre, &lv_style_scr);
lv_style_copy(&style_para_value_rel, &lv_style_scr);
style_para_value_pre.body.main_color = LV_COLOR_BACKGROUND;
style_para_value_pre.body.grad_color = LV_COLOR_BACKGROUND;
style_para_value_pre.text.color = LV_COLOR_BLACK;
style_para_value_pre.text.sel_color = LV_COLOR_BLACK;
style_para_value_pre.text.color = LV_COLOR_TEXT;
style_para_value_pre.text.sel_color = LV_COLOR_TEXT;
style_para_value_rel.body.main_color = LV_COLOR_BACKGROUND;
style_para_value_rel.body.grad_color = LV_COLOR_BACKGROUND;
style_para_value_rel.text.color = LV_COLOR_BLACK;
@ -215,6 +332,7 @@ void tft_style_init() {
style_para_value_rel.text.letter_space = 0;
style_para_value_pre.text.line_space = -5;
style_para_value_rel.text.line_space = -5;
lv_style_copy(&style_num_key_pre, &lv_style_scr);
lv_style_copy(&style_num_key_rel, &lv_style_scr);
style_num_key_pre.body.main_color = LV_COLOR_KEY_BACKGROUND;
@ -250,10 +368,48 @@ void tft_style_init() {
style_num_text.text.letter_space = 0;
style_num_text.text.line_space = -5;
lv_style_copy(&style_sel_text, &lv_style_scr);
style_sel_text.body.main_color = LV_COLOR_BACKGROUND;
style_sel_text.body.grad_color = LV_COLOR_BACKGROUND;
style_sel_text.text.color = LV_COLOR_YELLOW;
style_sel_text.text.sel_color = LV_COLOR_YELLOW;
style_sel_text.text.font = &gb2312_puhui32;
style_sel_text.line.width = 0;
style_sel_text.text.letter_space = 0;
style_sel_text.text.line_space = -5;
lv_style_copy(&style_line, &lv_style_plain);
style_line.line.color = LV_COLOR_MAKE(0x49, 0x54, 0xff);
style_line.line.width = 1;
style_line.line.rounded = 1;
lv_style_copy(&style_para_value, &lv_style_plain);
style_para_value.body.border.color = LV_COLOR_BACKGROUND;
style_para_value.body.border.width = 1;
style_para_value.body.main_color = LV_COLOR_WHITE;
style_para_value.body.grad_color = LV_COLOR_WHITE;
style_para_value.body.shadow.width = 0;
style_para_value.body.radius = 3;
style_para_value.text.color = LV_COLOR_BLACK;
style_para_value.text.font = &TERN(HAS_SPI_FLASH_FONT, gb2312_puhui32, lv_font_roboto_22);
lv_style_copy(&style_para_back, &lv_style_plain);
style_para_back.body.border.color = LV_COLOR_BACKGROUND;
style_para_back.body.border.width = 1;
style_para_back.body.main_color = TFT_LV_PARA_BACK_BODY_COLOR;
style_para_back.body.grad_color = TFT_LV_PARA_BACK_BODY_COLOR;
style_para_back.body.shadow.width = 0;
style_para_back.body.radius = 3;
style_para_back.text.color = LV_COLOR_WHITE;
style_para_back.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_bar_style_indic.text.color = lv_color_hex3(0xADF);
lv_bar_style_indic.image.color = lv_color_hex3(0xADF);
lv_bar_style_indic.line.color = lv_color_hex3(0xADF);
lv_bar_style_indic.body.main_color = lv_color_hex3(0xADF);
lv_bar_style_indic.body.grad_color = lv_color_hex3(0xADF);
lv_bar_style_indic.body.border.color = lv_color_hex3(0xADF);
}
#define MAX_TITLE_LEN 28
@ -360,15 +516,14 @@ char *getDispText(int index) {
case BIND_UI:
strcpy(public_buf_l, cloud_menu.title);
break;
case ZOFFSET_UI:
strcpy(public_buf_l, zoffset_menu.title);
break;
case TOOL_UI:
strcpy(public_buf_l, tool_menu.title);
break;
case WIFI_LIST_UI:
//strcpy(public_buf_l, list_menu.title);
break;
#if ENABLED(USE_WIFI_FUNCTION)
strcpy(public_buf_l, list_menu.title);
break;
#endif
case MACHINE_PARA_UI:
strcpy(public_buf_l, MachinePara_menu.title);
break;
@ -503,7 +658,7 @@ char *creat_title_text() {
#if ENABLED(TFT_LVGL_UI_SPI)
SPI_TFT.SetWindows(xpos_pixel, ypos_pixel + row, 200, 1);
#else
ili9320_SetWindows(xpos_pixel, ypos_pixel + row, 200, 1);
LCD_setWindowArea(xpos_pixel, ypos_pixel + row, 200, 1);
LCD_WriteRAM_Prepare();
#endif
@ -582,10 +737,10 @@ char *creat_title_text() {
//saved_feedrate_percentage = feedrate_percentage;
planner.flow_percentage[0] = 100;
planner.e_factor[0] = planner.flow_percentage[0] * 0.01;
if (EXTRUDERS == 2) {
#if HAS_MULTI_EXTRUDER
planner.flow_percentage[1] = 100;
planner.e_factor[1] = planner.flow_percentage[1] * 0.01;
}
#endif
card.startFileprint();
TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
once_flag = 0;
@ -615,7 +770,7 @@ char *creat_title_text() {
#if ENABLED(TFT_LVGL_UI_SPI)
SPI_TFT.SetWindows(xpos_pixel, ypos_pixel + row, 200, 1);
#else
ili9320_SetWindows(xpos_pixel, ypos_pixel + row, 200, 1);
LCD_setWindowArea(xpos_pixel, ypos_pixel + row, 200, 1);
LCD_WriteRAM_Prepare();
#endif
@ -714,10 +869,10 @@ char *creat_title_text() {
//saved_feedrate_percentage = feedrate_percentage;
planner.flow_percentage[0] = 100;
planner.e_factor[0] = planner.flow_percentage[0] * 0.01;
if (EXTRUDERS == 2) {
#if HAS_MULTI_EXTRUDER
planner.flow_percentage[1] = 100;
planner.e_factor[1] = planner.flow_percentage[1] * 0.01;
}
#endif
card.startFileprint();
TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
once_flag = 0;
@ -733,17 +888,17 @@ char *creat_title_text() {
void Draw_default_preview(int xpos_pixel, int ypos_pixel, uint8_t sel) {
int index;
int y_off = 0;
W25QXX.init(SPI_QUARTER_SPEED);
for (index = 0; index < 10; index++) { // 200*200
#if HAS_BAK_VIEW_IN_FLASH
if (sel == 1) {
flash_view_Read(bmp_public_buf, 8000); // 20k
}
else {
default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); // 20k
default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); // 8k
}
#else
default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); // 20k
default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); // 8k
#endif
#if ENABLED(TFT_LVGL_UI_SPI)
@ -754,7 +909,7 @@ char *creat_title_text() {
uint16_t temp_p;
int i = 0;
uint16_t *p_index;
ili9320_SetWindows(xpos_pixel, y_off * 20 + ypos_pixel, 200, 20); // 200*200
LCD_setWindowArea(xpos_pixel, y_off * 20 + ypos_pixel, 200, 20); // 200*200
LCD_WriteRAM_Prepare();
@ -904,29 +1059,28 @@ void GUI_RefreshPage() {
*/
break;
case WIFI_UI:
/*
if (wifi_refresh_flg == 1) {
disp_wifi_state();
wifi_refresh_flg = 0;
}
*/
break;
#if ENABLED(USE_WIFI_FUNCTION)
case WIFI_UI:
if (temperature_change_frequency == 1) {
disp_wifi_state();
temperature_change_frequency = 0;
}
break;
#endif
case BIND_UI:
/*refresh_bind_ui();*/
break;
case FILAMENTCHANGE_UI:
/*
if (temperature_change_frequency) {
temperature_change_frequency = 0;
disp_filament_sprayer_temp();
disp_filament_temp();
}
*/
break;
case DIALOG_UI:
/*filament_dialog_handle();
wifi_scan_handle();*/
filament_dialog_handle();
TERN_(USE_WIFI_FUNCTION, wifi_scan_handle());
break;
case MESHLEVELING_UI:
/*disp_zpos();*/
@ -934,66 +1088,68 @@ void GUI_RefreshPage() {
case HARDWARE_TEST_UI:
break;
case WIFI_LIST_UI:
/*
if (wifi_refresh_flg == 1) {
disp_wifi_list();
wifi_refresh_flg = 0;
}
*/
#if ENABLED(USE_WIFI_FUNCTION)
if (printing_rate_update_flag == 1) {
disp_wifi_list();
printing_rate_update_flag = 0;
}
#endif
break;
case KEY_BOARD_UI:
/*update_password_disp();
update_join_state_disp();*/
break;
case TIPS_UI:
/*
switch (tips_type) {
case TIPS_TYPE_JOINING:
if (wifi_link_state == WIFI_CONNECTED && strcmp((const char *)wifi_list.wifiConnectedName, (const char *)wifi_list.wifiName[wifi_list.nameIndex]) == 0) {
tips_disp.timer = TIPS_TIMER_STOP;
tips_disp.timer_count = 0;
Clear_Tips();
tips_type = TIPS_TYPE_WIFI_CONECTED;
draw_Tips();
}
if (tips_disp.timer_count >= 30) {
tips_disp.timer = TIPS_TIMER_STOP;
tips_disp.timer_count = 0;
Clear_Tips();
tips_type = TIPS_TYPE_TAILED_JOIN;
draw_Tips();
}
break;
case TIPS_TYPE_TAILED_JOIN:
if (tips_disp.timer_count >= 3) {
tips_disp.timer = TIPS_TIMER_STOP;
tips_disp.timer_count = 0;
last_disp_state = TIPS_UI;
Clear_Tips();
draw_Wifi_list();
}
break;
case TIPS_TYPE_WIFI_CONECTED:
if (tips_disp.timer_count >= 3) {
tips_disp.timer = TIPS_TIMER_STOP;
tips_disp.timer_count = 0;
last_disp_state = TIPS_UI;
Clear_Tips();
draw_Wifi();
}
break;
default: break;
}
*/
break;
#if ENABLED(USE_WIFI_FUNCTION)
case WIFI_TIPS_UI:
switch (wifi_tips_type) {
case TIPS_TYPE_JOINING:
if (wifi_link_state == WIFI_CONNECTED && strcmp((const char *)wifi_list.wifiConnectedName,(const char *)wifi_list.wifiName[wifi_list.nameIndex]) == 0) {
tips_disp.timer = TIPS_TIMER_STOP;
tips_disp.timer_count = 0;
lv_clear_wifi_tips();
wifi_tips_type = TIPS_TYPE_WIFI_CONECTED;
lv_draw_wifi_tips();
}
if (tips_disp.timer_count >= 30 * 1000) {
tips_disp.timer = TIPS_TIMER_STOP;
tips_disp.timer_count = 0;
lv_clear_wifi_tips();
wifi_tips_type = TIPS_TYPE_TAILED_JOIN;
lv_draw_wifi_tips();
}
break;
case TIPS_TYPE_TAILED_JOIN:
if (tips_disp.timer_count >= 3 * 1000) {
tips_disp.timer = TIPS_TIMER_STOP;
tips_disp.timer_count = 0;
last_disp_state = WIFI_TIPS_UI;
lv_clear_wifi_tips();
lv_draw_wifi_list();
}
break;
case TIPS_TYPE_WIFI_CONECTED:
if (tips_disp.timer_count >= 3 * 1000) {
tips_disp.timer = TIPS_TIMER_STOP;
tips_disp.timer_count = 0;
last_disp_state = WIFI_TIPS_UI;
lv_clear_wifi_tips();
lv_draw_wifi();
}
break;
default: break;
}
break;
#endif
case BABY_STEP_UI:
/*
if (temperature_change_frequency == 1) {
temperature_change_frequency = 0;
disp_z_offset_value();
}
*/
break;
default: break;
}
@ -1060,9 +1216,11 @@ void clear_cur_ui() {
case DISK_UI:
//Clear_Disk();
break;
case WIFI_UI:
//Clear_Wifi();
break;
#if ENABLED(USE_WIFI_FUNCTION)
case WIFI_UI:
lv_clear_wifi();
break;
#endif
case MORE_UI:
//Clear_more();
break;
@ -1078,15 +1236,20 @@ void clear_cur_ui() {
case PRINT_MORE_UI:
//Clear_Printmore();
break;
case FILAMENTCHANGE_UI:
lv_clear_filament_change();
break;
case LEVELING_UI:
lv_clear_manualLevel();
break;
case BIND_UI:
//Clear_Bind();
break;
case ZOFFSET_UI:
//Clear_Zoffset();
break;
#if HAS_BED_PROBE
case NOZZLE_PROBE_OFFSET_UI:
lv_clear_auto_level_offset_settings();
break;
#endif
case TOOL_UI:
lv_clear_tool();
break;
@ -1096,15 +1259,19 @@ void clear_cur_ui() {
case HARDWARE_TEST_UI:
//Clear_Hardwaretest();
break;
case WIFI_LIST_UI:
//Clear_Wifi_list();
break;
#if ENABLED(USE_WIFI_FUNCTION)
case WIFI_LIST_UI:
lv_clear_wifi_list();
break;
#endif
case KEY_BOARD_UI:
//Clear_Keyboard();
break;
case TIPS_UI:
//Clear_Tips();
lv_clear_keyboard();
break;
#if ENABLED(USE_WIFI_FUNCTION)
case WIFI_TIPS_UI:
lv_clear_wifi_tips();
break;
#endif
case MACHINE_PARA_UI:
lv_clear_machine_para();
break;
@ -1130,19 +1297,19 @@ void clear_cur_ui() {
//Clear_EndstopType();
break;
case FILAMENT_SETTINGS_UI:
//Clear_FilamentSettings();
lv_clear_filament_settings();
break;
case LEVELING_SETTIGNS_UI:
//Clear_LevelingSettings();
break;
case LEVELING_PARA_UI:
//Clear_LevelingPara();
lv_clear_level_settings();
break;
case DELTA_LEVELING_PARA_UI:
//Clear_DeltaLevelPara();
break;
case XYZ_LEVELING_PARA_UI:
//Clear_XYZLevelPara();
case MANUAL_LEVELING_POSIGION_UI:
lv_clear_manual_level_pos_settings();
break;
case MAXFEEDRATE_UI:
lv_clear_max_feedrate_settings();
@ -1183,7 +1350,7 @@ void clear_cur_ui() {
lv_clear_number_key();
break;
case BABY_STEP_UI:
//Clear_babyStep();
lv_clear_baby_stepping();
break;
case PAUSE_POS_UI:
lv_clear_pause_position();
@ -1201,8 +1368,22 @@ void clear_cur_ui() {
lv_clear_tmc_step_mode_settings();
break;
#endif
default:
#if ENABLED(USE_WIFI_FUNCTION)
case WIFI_SETTINGS_UI:
lv_clear_wifi_settings();
break;
#endif
#if USE_SENSORLESS
case HOMING_SENSITIVITY_UI:
lv_clear_homing_sensitivity_settings();
break;
#endif
#if HAS_ROTARY_ENCODER
case ENCODER_SETTINGS_UI:
lv_clear_encoder_settings();
break;
#endif
default: break;
}
//GUI_Clear();
}
@ -1267,21 +1448,17 @@ void draw_return_ui() {
lv_draw_about();
break;
#if tan_mask
case LOG_UI:
//draw_Connect();
break;
#endif
case CALIBRATE_UI:
//draw_calibrate();
break;
case DISK_UI:
//draw_Disk();
break;
case WIFI_UI:
//draw_Wifi();
break;
#if ENABLED(USE_WIFI_FUNCTION)
case WIFI_UI:
lv_draw_wifi();
break;
#endif
case MORE_UI:
//draw_More();
break;
@ -1289,7 +1466,7 @@ void draw_return_ui() {
//draw_printmore();
break;
case FILAMENTCHANGE_UI:
//draw_FilamentChange();
lv_draw_filament_change();
break;
case LEVELING_UI:
lv_draw_manualLevel();
@ -1297,13 +1474,11 @@ void draw_return_ui() {
case BIND_UI:
//draw_bind();
break;
#if tan_mask
case ZOFFSET_UI:
//draw_Zoffset();
break;
#endif
#if HAS_BED_PROBE
case NOZZLE_PROBE_OFFSET_UI:
lv_draw_auto_level_offset_settings();
break;
#endif
case TOOL_UI:
lv_draw_tool();
break;
@ -1314,13 +1489,17 @@ void draw_return_ui() {
//draw_Hardwaretest();
break;
case WIFI_LIST_UI:
//draw_Wifi_list();
#if ENABLED(USE_WIFI_FUNCTION)
lv_draw_wifi_list();
#endif
break;
case KEY_BOARD_UI:
//draw_Keyboard();
lv_draw_keyboard();
break;
case TIPS_UI:
//draw_Tips();
case WIFI_TIPS_UI:
#if ENABLED(USE_WIFI_FUNCTION)
lv_draw_wifi_tips();
#endif
break;
case MACHINE_PARA_UI:
lv_draw_machine_para();
@ -1347,19 +1526,19 @@ void draw_return_ui() {
//draw_EndstopType();
break;
case FILAMENT_SETTINGS_UI:
//draw_FilamentSettings();
lv_draw_filament_settings();
break;
case LEVELING_SETTIGNS_UI:
//draw_LevelingSettings();
break;
case LEVELING_PARA_UI:
//draw_LevelingPara();
lv_draw_level_settings();
break;
case DELTA_LEVELING_PARA_UI:
//draw_DeltaLevelPara();
break;
case XYZ_LEVELING_PARA_UI:
//draw_XYZLevelPara();
case MANUAL_LEVELING_POSIGION_UI:
lv_draw_manual_level_pos_settings();
break;
case MAXFEEDRATE_UI:
lv_draw_max_feedrate_settings();
@ -1400,10 +1579,10 @@ void draw_return_ui() {
lv_draw_number_key();
break;
case DIALOG_UI:
//draw_dialog(DialogType);
//draw_dialog(uiCfg.dialogType);
break;
case BABY_STEP_UI:
//draw_babyStep();
lv_draw_baby_stepping();
break;
case PAUSE_POS_UI:
lv_draw_pause_position();
@ -1421,6 +1600,21 @@ void draw_return_ui() {
lv_draw_tmc_step_mode_settings();
break;
#endif
#if ENABLED(USE_WIFI_FUNCTION)
case WIFI_SETTINGS_UI:
lv_draw_wifi_settings();
break;
#endif
#if USE_SENSORLESS
case HOMING_SENSITIVITY_UI:
lv_draw_homing_sensitivity_settings();
break;
#endif
#if HAS_ROTARY_ENCODER
case ENCODER_SETTINGS_UI:
lv_draw_encoder_settings();
break;
#endif
default: break;
}
}
@ -1440,8 +1634,8 @@ void draw_return_ui() {
#endif
void lv_ex_line(lv_obj_t * line, lv_point_t *points) {
/*Copy the previous line and apply the new style*/
lv_line_set_points(line, points, 2); /*Set the points*/
// Copy the previous line and apply the new style
lv_line_set_points(line, points, 2); // Set the points
lv_line_set_style(line, LV_LINE_STYLE_MAIN, &style_line);
lv_obj_align(line, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
}
@ -1450,18 +1644,29 @@ extern volatile uint32_t systick_uptime_millis;
void print_time_count() {
if ((systick_uptime_millis % 1000) == 0)
if (print_time.start == 1) print_time.seconds++;
if (print_time.start == 1) print_time.seconds++;
}
void LV_TASK_HANDLER() {
//lv_tick_inc(1);
lv_task_handler();
if (mks_test_flag == 0x1e) mks_hardware_test();
#if HAS_GCODE_PREVIEW
disp_pre_gcode(2, 36);
#endif
GUI_RefreshPage();
#if ENABLED(USE_WIFI_FUNCTION)
get_wifi_commands();
#endif
//sd_detection();
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_update_encoder();
#endif
}
#endif // HAS_TFT_LVGL_UI

168
Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h

@ -34,7 +34,11 @@
#undef LV_COLOR_BACKGROUND
#define LV_COLOR_BACKGROUND LV_COLOR_MAKE(0x1A, 0x1A, 0x1A) // LV_COLOR_MAKE(0x00, 0x00, 0x00)
#define TFT_LV_PARA_BACK_BODY_COLOR LV_COLOR_MAKE(0x4A, 0x52, 0xFF)
#include "tft_lvgl_configuration.h"
#include "tft_multi_language.h"
#include "pic_manager.h"
#include "draw_ready_print.h"
#include "draw_language.h"
#include "draw_set.h"
@ -66,8 +70,33 @@
#include "draw_eeprom_settings.h"
#include "draw_max_feedrate_settings.h"
#include "draw_tmc_step_mode_settings.h"
#include "draw_level_settings.h"
#include "draw_manual_level_pos_settings.h"
#include "draw_auto_level_offset_settings.h"
#include "draw_filament_change.h"
#include "draw_filament_settings.h"
#include "draw_homing_sensitivity_settings.h"
#include "draw_baby_stepping.h"
#include "draw_keyboard.h"
#include "draw_encoder_settings.h"
#if ENABLED(USE_WIFI_FUNCTION)
#include "wifiSerial.h"
#include "wifi_module.h"
#include "wifi_upload.h"
#include "draw_wifi_settings.h"
#include "draw_wifi.h"
#include "draw_wifi_list.h"
#include "draw_wifi_tips.h"
#endif
#include "../../inc/MarlinConfigPre.h"
#define FILE_SYS_USB 0
#define FILE_SYS_SD 1
#define TICK_CYCLE 1
#define PARA_SEL_ICON_TEXT_COLOR LV_COLOR_MAKE(0x4a, 0x52, 0xff);
#define TFT35
@ -100,30 +129,38 @@
#define PREVIEW_LITTLE_PIC_SIZE 40910 // 400*100+9*101+1
#define PREVIEW_SIZE 202720 // (PREVIEW_LITTLE_PIC_SIZE+800*200+201*9+1)
#define GCFG_FLAG_VALUE 0xEE
// machine parameter ui
#define PARA_UI_POS_X 10
#define PARA_UI_POS_Y 50
#define PARA_UI_POS_X 10
#define PARA_UI_POS_Y 50
#define PARA_UI_SIZE_X 450
#define PARA_UI_SIZE_Y 40
#define PARA_UI_SIZE_X 450
#define PARA_UI_SIZE_Y 40
#define PARA_UI_ARROW_V 12
#define PARA_UI_BACL_POS_X 400
#define PARA_UI_BACL_POS_Y 270
#define PARA_UI_BACL_POS_X 400
#define PARA_UI_BACL_POS_Y 270
#define PARA_UI_TURN_PAGE_POS_X 320
#define PARA_UI_TURN_PAGE_POS_Y 270
#define PARA_UI_TURN_PAGE_POS_X 320
#define PARA_UI_TURN_PAGE_POS_Y 270
#define PARA_UI_VALUE_SIZE_X 370
#define PARA_UI_VALUE_POS_X 400
#define PARA_UI_VALUE_SIZE_X 370
#define PARA_UI_VALUE_POS_X 400
#define PARA_UI_VALUE_V 5
#define PARA_UI_STATE_POS_X 380
#define PARA_UI_STATE_POS_X 380
#define PARA_UI_STATE_V 2
#define PARA_UI_VALUE_SIZE_X_2 200
#define PARA_UI_VALUE_POS_X_2 320
#define PARA_UI_VALUE_V_2 5
#define PARA_UI_VALUE_BTN_X_SIZE 70
#define PARA_UI_VALUE_BTN_Y_SIZE 28
#define PARA_UI_BACK_BTN_X_SIZE 70
#define PARA_UI_BACK_BTN_Y_SIZE 40
#else // ifdef TFT35
#define TFT_WIDTH 320
@ -135,13 +172,25 @@ extern char public_buf_m[100];
extern char public_buf_l[30];
typedef struct {
uint8_t spi_flash_flag;
uint32_t spi_flash_flag;
uint8_t disp_rotation_180;
uint8_t multiple_language;
uint8_t language;
uint8_t leveling_mode;
uint8_t from_flash_pic;
uint8_t finish_power_off;
uint8_t pause_reprint;
uint8_t wifi_mode_sel;
uint8_t fileSysType;
uint8_t wifi_type;
bool cloud_enable;
bool encoder_enable;
int levelingPos[5][2];
int filamentchange_load_length;
int filamentchange_load_speed;
int filamentchange_unload_length;
int filamentchange_unload_speed;
int filament_limit_temper;
float pausePosX;
float pausePosY;
float pausePosZ;
@ -153,15 +202,42 @@ typedef struct {
curSprayerChoose : 3,
stepHeat : 4;
uint8_t leveling_first_time : 1,
para_ui_page : 1;
para_ui_page:1,
configWifi:1,
command_send:1,
filament_load_heat_flg:1,
filament_heat_completed_load:1,
filament_unload_heat_flg:1,
filament_heat_completed_unload:1;
uint8_t filament_loading_completed:1,
filament_unloading_completed:1,
filament_loading_time_flg:1,
filament_unloading_time_flg:1,
curSprayerChoose_bak:4;
uint8_t wifi_name[32];
uint8_t wifi_key[64];
uint8_t cloud_hostUrl[96];
uint8_t extruStep;
uint8_t extruSpeed;
uint8_t print_state;
uint8_t stepPrintSpeed;
uint8_t waitEndMoves;
uint8_t dialogType;
uint8_t F[4];
uint8_t filament_rate;
uint16_t moveSpeed;
uint16_t cloud_port;
uint16_t moveSpeed_bak;
uint32_t totalSend;
uint32_t filament_loading_time;
uint32_t filament_unloading_time;
uint32_t filament_loading_time_cnt;
uint32_t filament_unloading_time_cnt;
float move_dist;
uint8_t F[4];
float desireSprayerTempBak;
float current_x_position_bak;
float current_y_position_bak;
float current_e_position_bak;
} UI_CFG;
typedef enum {
@ -196,12 +272,14 @@ typedef enum {
LEVELING_UI,
MESHLEVELING_UI,
BIND_UI,
ZOFFSET_UI,
#if HAS_BED_PROBE
NOZZLE_PROBE_OFFSET_UI,
#endif
TOOL_UI,
HARDWARE_TEST_UI,
WIFI_LIST_UI,
KEY_BOARD_UI,
TIPS_UI,
WIFI_TIPS_UI,
MACHINE_PARA_UI,
MACHINE_SETTINGS_UI,
TEMPERATURE_SETTINGS_UI,
@ -214,7 +292,7 @@ typedef enum {
LEVELING_SETTIGNS_UI,
LEVELING_PARA_UI,
DELTA_LEVELING_PARA_UI,
XYZ_LEVELING_PARA_UI,
MANUAL_LEVELING_POSIGION_UI,
MAXFEEDRATE_UI,
STEPS_UI,
ACCELERATION_UI,
@ -232,7 +310,10 @@ typedef enum {
PAUSE_POS_UI,
TMC_CURRENT_UI,
TMC_MODE_UI,
EEPROM_SETTINGS_UI
EEPROM_SETTINGS_UI,
WIFI_SETTINGS_UI,
HOMING_SENSITIVITY_UI,
ENCODER_SETTINGS_UI
} DISP_STATE;
typedef struct {
@ -285,10 +366,45 @@ typedef enum {
pause_pos_x,
pause_pos_y,
pause_pos_z
pause_pos_z,
level_pos_x1,
level_pos_y1,
level_pos_x2,
level_pos_y2,
level_pos_x3,
level_pos_y3,
level_pos_x4,
level_pos_y4,
level_pos_x5,
level_pos_y5
#if HAS_BED_PROBE
,
x_offset,
y_offset,
z_offset
#endif
,
load_length,
load_speed,
unload_length,
unload_speed,
filament_temp,
x_sensitivity,
y_sensitivity,
z_sensitivity,
z2_sensitivity
} num_key_value_state;
extern num_key_value_state value;
}value_state;
extern value_state value;
typedef enum {
wifiName,
wifiPassWord,
wifiConfig,
gcodeCommand
} keyboard_value_state;
extern keyboard_value_state keyboard_value;
extern CFG_ITMES gCfgItems;
extern UI_CFG uiCfg;
@ -305,6 +421,10 @@ extern lv_style_t style_para_value_rel;
extern lv_style_t style_num_key_pre;
extern lv_style_t style_num_key_rel;
extern lv_style_t style_num_text;
extern lv_style_t style_sel_text;
extern lv_style_t style_para_value;
extern lv_style_t style_para_back;
extern lv_style_t lv_bar_style_indic;
extern lv_point_t line_points[4][2];
@ -314,6 +434,8 @@ extern void tft_style_init();
extern char *creat_title_text(void);
extern void preview_gcode_prehandle(char *path);
extern void update_spi_flash();
extern void update_gcode_command(int addr,uint8_t *s);
extern void get_gcode_command(int addr,uint8_t *d);
#if HAS_GCODE_PREVIEW
extern void disp_pre_gcode(int xpos_pixel, int ypos_pixel);
#endif

222
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp

@ -0,0 +1,222 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI
#include "lv_conf.h"
#include "draw_ui.h"
#if ENABLED(USE_WIFI_FUNCTION)
#include "../../../../../Configuration.h"
#include "../../../../module/temperature.h"
extern lv_group_t * g;
static lv_obj_t *scr, *wifi_name_text, *wifi_key_text, *wifi_state_text, *wifi_ip_text;
#define ID_W_RETURN 1
#define ID_W_CLOUD 2
#define ID_W_RECONNECT 3
static void event_handler(lv_obj_t * obj, lv_event_t event) {
switch (obj->mks_obj_id) {
case ID_W_RETURN:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
clear_cur_ui();
lv_draw_set();
}
break;
case ID_W_CLOUD:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
//clear_cur_ui();
//draw_return_ui();
}
break;
case ID_W_RECONNECT:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
clear_cur_ui();
lv_draw_wifi_list();
}
break;
}
}
void lv_draw_wifi(void) {
lv_obj_t *buttonBack=NULL,*label_Back=NULL;
lv_obj_t *buttonCloud=NULL,*label_Cloud=NULL;
lv_obj_t *buttonReconnect=NULL,*label_Reconnect=NULL;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_UI) {
disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_UI;
}
disp_state = WIFI_UI;
scr = lv_obj_create(NULL, NULL);
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
lv_obj_t * title = lv_label_create(scr, NULL);
lv_obj_set_style(title, &tft_style_label_rel);
lv_obj_set_pos(title,TITLE_XPOS,TITLE_YPOS);
lv_label_set_text(title, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing());
// Create an Image button
buttonBack = lv_imgbtn_create(scr, NULL);
if (gCfgItems.wifi_mode_sel == STA_MODEL) {
//buttonCloud = lv_imgbtn_create(scr, NULL);
buttonReconnect = lv_imgbtn_create(scr, NULL);
}
lv_obj_set_event_cb_mks(buttonBack, event_handler,ID_W_RETURN, NULL,0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
#endif
lv_obj_set_pos(buttonBack,BTN_X_PIXEL*3+INTERVAL_V*4, BTN_Y_PIXEL+INTERVAL_H+titleHeight);
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
if (gCfgItems.wifi_mode_sel == STA_MODEL) {
lv_obj_set_event_cb_mks(buttonReconnect, event_handler,ID_W_RECONNECT, NULL,0);
lv_imgbtn_set_src(buttonReconnect, LV_BTN_STATE_REL, "F:/bmp_wifi.bin");
lv_imgbtn_set_src(buttonReconnect, LV_BTN_STATE_PR, "F:/bmp_wifi.bin");
lv_imgbtn_set_style(buttonReconnect, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonReconnect, LV_BTN_STATE_REL, &tft_style_label_rel);
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonReconnect);
#endif
lv_obj_set_pos(buttonReconnect,BTN_X_PIXEL*2+INTERVAL_V*3, BTN_Y_PIXEL+INTERVAL_H+titleHeight);
lv_btn_set_layout(buttonReconnect, LV_LAYOUT_OFF);
}
label_Back = lv_label_create(buttonBack, NULL);
if (gCfgItems.wifi_mode_sel == STA_MODEL) {
//label_Cloud = lv_label_create(buttonCloud, NULL);
label_Reconnect = lv_label_create(buttonReconnect, NULL);
}
if (gCfgItems.multiple_language !=0) {
lv_label_set_text(label_Back, common_menu.text_back);
lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
if (gCfgItems.wifi_mode_sel == STA_MODEL) {
//lv_label_set_text(label_Cloud, common_menu.text_back);
//lv_obj_align(label_Cloud, buttonCloud, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
lv_label_set_text(label_Reconnect, wifi_menu.reconnect);
lv_obj_align(label_Reconnect, buttonReconnect, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
}
}
wifi_ip_text = lv_label_create(scr, NULL);
lv_obj_set_style(wifi_ip_text, &tft_style_label_rel);
wifi_name_text = lv_label_create(scr, NULL);
lv_obj_set_style(wifi_name_text, &tft_style_label_rel);
wifi_key_text = lv_label_create(scr, NULL);
lv_obj_set_style(wifi_key_text, &tft_style_label_rel);
wifi_state_text = lv_label_create(scr, NULL);
lv_obj_set_style(wifi_state_text, &tft_style_label_rel);
disp_wifi_state();
}
void disp_wifi_state() {
memset(public_buf_m, 0, sizeof(public_buf_m));
strcpy(public_buf_m,wifi_menu.ip);
strcat(public_buf_m,ipPara.ip_addr);
lv_label_set_text(wifi_ip_text, public_buf_m);
lv_obj_align(wifi_ip_text, NULL, LV_ALIGN_CENTER,0, -100);
memset(public_buf_m, 0, sizeof(public_buf_m));
strcpy(public_buf_m,wifi_menu.wifi);
strcat(public_buf_m,wifiPara.ap_name);
lv_label_set_text(wifi_name_text, public_buf_m);
lv_obj_align(wifi_name_text, NULL, LV_ALIGN_CENTER,0, -70);
if (wifiPara.mode == AP_MODEL) {
memset(public_buf_m, 0, sizeof(public_buf_m));
strcpy(public_buf_m,wifi_menu.key);
strcat(public_buf_m,wifiPara.keyCode);
lv_label_set_text(wifi_key_text, public_buf_m);
lv_obj_align(wifi_key_text, NULL, LV_ALIGN_CENTER,0, -40);
memset(public_buf_m, 0, sizeof(public_buf_m));
strcpy(public_buf_m,wifi_menu.state_ap);
if (wifi_link_state == WIFI_CONNECTED)
strcat(public_buf_m,wifi_menu.connected);
else if (wifi_link_state == WIFI_NOT_CONFIG)
strcat(public_buf_m,wifi_menu.disconnected);
else
strcat(public_buf_m,wifi_menu.exception);
lv_label_set_text(wifi_state_text, public_buf_m);
lv_obj_align(wifi_state_text, NULL, LV_ALIGN_CENTER,0, -10);
}
else {
ZERO(public_buf_m);
strcpy(public_buf_m, wifi_menu.state_sta);
if (wifi_link_state == WIFI_CONNECTED)
strcat(public_buf_m, wifi_menu.connected);
else if (wifi_link_state == WIFI_NOT_CONFIG)
strcat(public_buf_m, wifi_menu.disconnected);
else
strcat(public_buf_m, wifi_menu.exception);
lv_label_set_text(wifi_state_text, public_buf_m);
lv_obj_align(wifi_state_text, NULL, LV_ALIGN_CENTER,0, -40);
lv_label_set_text(wifi_key_text, "");
lv_obj_align(wifi_key_text, NULL, LV_ALIGN_CENTER,0, -10);
}
}
void lv_clear_wifi() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // USE_WIFI_FUNCTION
#endif // HAS_TFT_LVGL_UI

38
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.h

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

235
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.cpp

@ -0,0 +1,235 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI
#include "lv_conf.h"
#include "draw_ui.h"
#if ENABLED(USE_WIFI_FUNCTION)
#include "../../../../../Configuration.h"
#include "../../../../module/temperature.h"
#define NAME_BTN_X 330
#define NAME_BTN_Y 48
#define MARK_BTN_X 0
#define MARK_BTN_Y 68
WIFI_LIST wifi_list;
list_menu_def list_menu;
extern lv_group_t * g;
static lv_obj_t * scr;
static lv_obj_t *buttonWifiN[NUMBER_OF_PAGE];
static lv_obj_t *lableWifiText[NUMBER_OF_PAGE];
static lv_obj_t *lablePageText;
#define ID_WL_RETURN 11
#define ID_WL_DOWN 12
static void event_handler(lv_obj_t * obj, lv_event_t event) {
if (obj->mks_obj_id == ID_WL_RETURN) {
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
clear_cur_ui();
lv_draw_set();
}
}
else if (obj->mks_obj_id == ID_WL_DOWN) {
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
if (wifi_list.getNameNum > 0) {
if ((wifi_list.nameIndex + NUMBER_OF_PAGE) >= wifi_list.getNameNum) {
wifi_list.nameIndex = 0;
wifi_list.currentWifipage = 1;
}
else {
wifi_list.nameIndex += NUMBER_OF_PAGE;
wifi_list.currentWifipage++;
}
disp_wifi_list();
}
}
}
else {
for (uint8_t i = 0; i < NUMBER_OF_PAGE; i++) {
if (obj->mks_obj_id == i + 1) {
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
if (wifi_list.getNameNum != 0) {
const bool do_wifi = wifi_link_state == WIFI_CONNECTED && strcmp((const char *)wifi_list.wifiConnectedName, (const char *)wifi_list.wifiName[wifi_list.nameIndex + i]) == 0;
wifi_list.nameIndex += i;
last_disp_state = WIFI_LIST_UI;
lv_clear_wifi_list();
if (do_wifi)
lv_draw_wifi();
else {
keyboard_value = wifiConfig;
lv_draw_keyboard();
}
}
}
}
}
}
}
void lv_draw_wifi_list(void) {
lv_obj_t *buttonBack = NULL, *buttonDown = NULL;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_LIST_UI) {
disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_LIST_UI;
}
disp_state = WIFI_LIST_UI;
scr = lv_obj_create(NULL, NULL);
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
lv_obj_t * title = lv_label_create(scr, NULL);
lv_obj_set_style(title, &tft_style_label_rel);
lv_obj_set_pos(title,TITLE_XPOS,TITLE_YPOS);
lv_label_set_text(title, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing());
buttonDown = lv_imgbtn_create(scr, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonDown, event_handler,ID_WL_DOWN,NULL,0);
lv_imgbtn_set_src(buttonDown, LV_BTN_STATE_REL, "F:/bmp_pageDown.bin");
lv_imgbtn_set_src(buttonDown, LV_BTN_STATE_PR, "F:/bmp_pageDown.bin");
lv_imgbtn_set_style(buttonDown, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonDown, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_event_cb_mks(buttonBack, event_handler,ID_WL_RETURN,NULL,0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_pos(buttonDown,OTHER_BTN_XPIEL*3+INTERVAL_V*4,titleHeight+OTHER_BTN_YPIEL+INTERVAL_H);
lv_obj_set_pos(buttonBack,OTHER_BTN_XPIEL*3+INTERVAL_V*4,titleHeight+OTHER_BTN_YPIEL*2+INTERVAL_H*2);
lv_btn_set_layout(buttonDown, LV_LAYOUT_OFF);
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
for (uint8_t i = 0; i < NUMBER_OF_PAGE; i++) {
buttonWifiN[i] = lv_btn_create(scr, NULL); /*Add a button the current screen*/
lv_obj_set_pos(buttonWifiN[i], 0,NAME_BTN_Y*i+10+titleHeight); /*Set its position*/
lv_obj_set_size(buttonWifiN[i], NAME_BTN_X,NAME_BTN_Y); /*Set its size*/
lv_obj_set_event_cb_mks(buttonWifiN[i], event_handler,(i+1),NULL,0);
lv_btn_set_style(buttonWifiN[i], LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
lv_btn_set_style(buttonWifiN[i], LV_BTN_STYLE_PR, &tft_style_label_pre); /*Set the button's pressed style*/
lv_btn_set_layout(buttonWifiN[i], LV_LAYOUT_OFF);
lableWifiText[i] = lv_label_create(buttonWifiN[i], NULL);
#if HAS_ROTARY_ENCODER
uint8_t j = 0;
if (gCfgItems.encoder_enable) {
j = wifi_list.nameIndex + i;
if (j < wifi_list.getNameNum) lv_group_add_obj(g, buttonWifiN[i]);
}
#endif
}
lablePageText = lv_label_create(scr, NULL);
lv_obj_set_style(lablePageText, &tft_style_label_rel);
wifi_list.nameIndex = 0;
wifi_list.currentWifipage = 1;
if (wifi_link_state == WIFI_CONNECTED && wifiPara.mode == STA_MODEL) {
memset(wifi_list.wifiConnectedName, 0, sizeof(&wifi_list.wifiConnectedName));
memcpy(wifi_list.wifiConnectedName, wifiPara.ap_name, sizeof(wifi_list.wifiConnectedName));
}
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonDown);
lv_group_add_obj(g, buttonBack);
}
#endif
disp_wifi_list();
}
void disp_wifi_list(void) {
int8_t tmpStr[WIFI_NAME_BUFFER_SIZE] = { 0 };
uint8_t i, j;
sprintf((char *)tmpStr, list_menu.file_pages, wifi_list.currentWifipage, wifi_list.getPage);
lv_label_set_text(lablePageText, (const char *)tmpStr);
lv_obj_align(lablePageText, NULL, LV_ALIGN_CENTER, 50, -100);
for (i = 0; i < NUMBER_OF_PAGE; i++) {
memset(tmpStr, 0, sizeof(tmpStr));
j = wifi_list.nameIndex + i;
if (j >= wifi_list.getNameNum) {
lv_label_set_text(lableWifiText[i], (const char *)tmpStr);
lv_obj_align(lableWifiText[i], buttonWifiN[i], LV_ALIGN_IN_LEFT_MID, 20, 0);
}
else {
lv_label_set_text(lableWifiText[i], (char const *)wifi_list.wifiName[j]);
lv_obj_align(lableWifiText[i], buttonWifiN[i], LV_ALIGN_IN_LEFT_MID, 20, 0);
if (wifi_link_state == WIFI_CONNECTED && strcmp((const char *)wifi_list.wifiConnectedName, (const char *)wifi_list.wifiName[j]) == 0) {
lv_btn_set_style(buttonWifiN[i], LV_BTN_STYLE_REL, &style_sel_text);
}
else {
lv_btn_set_style(buttonWifiN[i], LV_BTN_STYLE_REL, &tft_style_label_rel);
}
}
}
}
void wifi_scan_handle() {
if (uiCfg.dialogType != WIFI_ENABLE_TIPS || uiCfg.command_send != 1) return;
last_disp_state = DIALOG_UI;
lv_clear_dialog();
if (wifi_link_state == WIFI_CONNECTED && wifiPara.mode != AP_MODEL)
lv_draw_wifi();
else
lv_draw_wifi_list();
}
void lv_clear_wifi_list() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // USE_WIFI_FUNCTION
#endif // HAS_TFT_LVGL_UI

76
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.h

@ -0,0 +1,76 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#ifdef __cplusplus
extern "C" { /* C-declarations for C++ */
#endif
extern void lv_draw_wifi_list();
extern void lv_clear_wifi_list();
extern void disp_wifi_list(void);
extern void cutWifiName(char *name, int len,char *outStr);
extern void wifi_scan_handle();
#define NUMBER_OF_PAGE 5
#define WIFI_TOTAL_NUMBER 20
#define WIFI_NAME_BUFFER_SIZE 33
typedef struct {
int8_t getNameNum;
int8_t nameIndex;
int8_t currentWifipage;
int8_t getPage;
int8_t RSSI[WIFI_TOTAL_NUMBER];
uint8_t wifiName[WIFI_TOTAL_NUMBER][WIFI_NAME_BUFFER_SIZE];
uint8_t wifiConnectedName[WIFI_NAME_BUFFER_SIZE];
} WIFI_LIST;
extern WIFI_LIST wifi_list;
typedef struct list_menu_disp {
const char *title;
const char *file_pages;
} list_menu_def;
extern list_menu_def list_menu;
typedef struct keyboard_menu_disp {
const char *title;
const char *apply;
const char *password;
const char *letter;
const char *digital;
const char *symbol;
const char *space;
} keyboard_menu_def;
extern keyboard_menu_def keyboard_menu;
typedef struct tips_menu_disp {
const char *joining;
const char *failedJoin;
const char *wifiConected;
} tips_menu_def;
extern tips_menu_def tips_menu;
#ifdef __cplusplus
} /* C-declarations for C++ */
#endif

299
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.cpp

@ -0,0 +1,299 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI
#include "lv_conf.h"
#include "draw_ui.h"
#if ENABLED(USE_WIFI_FUNCTION)
#include "../../../../../Configuration.h"
#include "../../../../module/planner.h"
extern lv_group_t * g;
static lv_obj_t *scr, *labelModelValue = NULL, *buttonModelValue = NULL, *labelCloudValue = NULL;
#define ID_WIFI_RETURN 1
#define ID_WIFI_MODEL 2
#define ID_WIFI_NAME 3
#define ID_WIFI_PASSWORD 4
#define ID_WIFI_CLOUD 5
#define ID_WIFI_CONFIG 6
static void event_handler(lv_obj_t * obj, lv_event_t event) {
switch (obj->mks_obj_id) {
case ID_WIFI_RETURN:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_wifi_settings();
draw_return_ui();
}
break;
case ID_WIFI_MODEL:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
if (gCfgItems.wifi_mode_sel == AP_MODEL) {
gCfgItems.wifi_mode_sel = STA_MODEL;
lv_label_set_text(labelModelValue, WIFI_STA_TEXT);
lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0);
update_spi_flash();
}
else{
gCfgItems.wifi_mode_sel = AP_MODEL;
lv_label_set_text(labelModelValue, WIFI_AP_TEXT);
lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0);
update_spi_flash();
}
}
break;
case ID_WIFI_NAME:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
keyboard_value=wifiName;
lv_clear_wifi_settings();
lv_draw_keyboard();
}
break;
case ID_WIFI_PASSWORD:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
keyboard_value=wifiPassWord;
lv_clear_wifi_settings();
lv_draw_keyboard();
}
break;
case ID_WIFI_CLOUD:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
if (gCfgItems.cloud_enable) {
gCfgItems.cloud_enable = false;
lv_obj_set_event_cb_mks(obj, event_handler,ID_WIFI_CLOUD,"bmp_disable.bin",0);
lv_label_set_text(labelCloudValue, machine_menu.disable);
update_spi_flash();
}
else {
gCfgItems.cloud_enable = true;
lv_obj_set_event_cb_mks(obj, event_handler,ID_WIFI_CLOUD,"bmp_enable.bin",0);
lv_label_set_text(labelCloudValue, machine_menu.enable);
update_spi_flash();
}
}
break;
case ID_WIFI_CONFIG:
if (event == LV_EVENT_CLICKED) {
}
else if (event == LV_EVENT_RELEASED) {
lv_clear_wifi_settings();
lv_draw_dialog(DIALOG_WIFI_CONFIG_TIPS);
}
break;
}
}
void lv_draw_wifi_settings(void) {
lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonConfig = NULL, *labelConfig = NULL;
lv_obj_t *labelModelText = NULL;
lv_obj_t *labelNameText = NULL, *buttonNameValue = NULL, *labelNameValue = NULL;
lv_obj_t *labelPassWordText = NULL, *buttonPassWordValue = NULL, *labelPassWordValue = NULL;
lv_obj_t *labelCloudText = NULL, *buttonCloudValue = NULL;
lv_obj_t * line1 = NULL, *line2 = NULL, *line3 = NULL, *line4 = NULL;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_SETTINGS_UI) {
disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_SETTINGS_UI;
}
disp_state = WIFI_SETTINGS_UI;
scr = lv_obj_create(NULL, NULL);
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
lv_obj_t * title = lv_label_create(scr, NULL);
lv_obj_set_style(title, &tft_style_label_rel);
lv_obj_set_pos(title,TITLE_XPOS,TITLE_YPOS);
lv_label_set_text(title, machine_menu.WifiConfTitle);
lv_refr_now(lv_refr_get_disp_refreshing());
labelModelText = lv_label_create(scr, NULL);
lv_obj_set_style(labelModelText, &tft_style_label_rel);
lv_obj_set_pos(labelModelText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
lv_label_set_text(labelModelText, machine_menu.wifiMode);
buttonModelValue = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonModelValue,PARA_UI_VALUE_POS_X,PARA_UI_POS_Y+PARA_UI_VALUE_V);
lv_obj_set_event_cb_mks(buttonModelValue, event_handler,ID_WIFI_MODEL, NULL,0);
lv_imgbtn_set_src(buttonModelValue, LV_BTN_STATE_REL, "F:/bmp_blank_sel.bin");
lv_imgbtn_set_src(buttonModelValue, LV_BTN_STATE_PR, "F:/bmp_blank_sel.bin");
lv_imgbtn_set_style(buttonModelValue, LV_BTN_STATE_PR, &style_para_value_pre);
lv_imgbtn_set_style(buttonModelValue, LV_BTN_STATE_REL, &style_para_value_pre);
lv_btn_set_layout(buttonModelValue, LV_LAYOUT_OFF);
labelModelValue = lv_label_create(buttonModelValue, NULL);
line1 = lv_line_create(scr, NULL);
lv_ex_line(line1,line_points[0]);
labelNameText = lv_label_create(scr, NULL);
lv_obj_set_style(labelNameText, &tft_style_label_rel);
lv_obj_set_pos(labelNameText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
buttonNameValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonNameValue,PARA_UI_VALUE_POS_X,PARA_UI_POS_Y*2+PARA_UI_VALUE_V);
lv_obj_set_size(buttonNameValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonNameValue, event_handler,ID_WIFI_NAME, NULL,0);
lv_btn_set_style(buttonNameValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonNameValue, LV_BTN_STYLE_PR, &style_para_value);
labelNameValue = lv_label_create(buttonNameValue, NULL);
line2 = lv_line_create(scr, NULL);
lv_ex_line(line2,line_points[1]);
labelPassWordText = lv_label_create(scr, NULL);
lv_obj_set_style(labelPassWordText, &tft_style_label_rel);
lv_obj_set_pos(labelPassWordText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
buttonPassWordValue = lv_btn_create(scr, NULL);
lv_obj_set_pos(buttonPassWordValue,PARA_UI_VALUE_POS_X,PARA_UI_POS_Y*3+PARA_UI_VALUE_V);
lv_obj_set_size(buttonPassWordValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
lv_obj_set_event_cb_mks(buttonPassWordValue, event_handler,ID_WIFI_PASSWORD, NULL,0);
lv_btn_set_style(buttonPassWordValue, LV_BTN_STYLE_REL, &style_para_value);
lv_btn_set_style(buttonPassWordValue, LV_BTN_STYLE_PR, &style_para_value);
labelPassWordValue = lv_label_create(buttonPassWordValue, NULL);
line3 = lv_line_create(scr, NULL);
lv_ex_line(line3,line_points[2]);
labelCloudText = lv_label_create(scr, NULL);
lv_obj_set_style(labelCloudText, &tft_style_label_rel);
lv_obj_set_pos(labelCloudText, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
lv_label_set_text(labelCloudText, machine_menu.wifiCloud);
buttonCloudValue = lv_imgbtn_create(scr, NULL);
lv_obj_set_pos(buttonCloudValue,PARA_UI_STATE_POS_X,PARA_UI_POS_Y*4+PARA_UI_STATE_V);
if (gCfgItems.cloud_enable) {
lv_imgbtn_set_src(buttonCloudValue, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
lv_imgbtn_set_src(buttonCloudValue, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
}
else {
lv_imgbtn_set_src(buttonCloudValue, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
lv_imgbtn_set_src(buttonCloudValue, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
}
lv_obj_set_event_cb_mks(buttonCloudValue, event_handler,ID_WIFI_CLOUD, NULL,0);
lv_imgbtn_set_style(buttonCloudValue, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonCloudValue, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_btn_set_layout(buttonCloudValue, LV_LAYOUT_OFF);
labelCloudValue = lv_label_create(buttonCloudValue, NULL);
line4 = lv_line_create(scr, NULL);
lv_ex_line(line4,line_points[3]);
buttonConfig = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonConfig, event_handler,ID_WIFI_CONFIG, NULL,0);
lv_imgbtn_set_src(buttonConfig, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
lv_imgbtn_set_src(buttonConfig, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
lv_imgbtn_set_style(buttonConfig, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonConfig, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_pos(buttonConfig, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
lv_btn_set_layout(buttonConfig, LV_LAYOUT_OFF);
labelConfig = lv_label_create(buttonConfig, NULL);
buttonBack = lv_imgbtn_create(scr, NULL);
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_WIFI_RETURN, NULL, 0);
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
label_Back = lv_label_create(buttonBack, NULL);
if (gCfgItems.multiple_language !=0) {
if (gCfgItems.wifi_mode_sel == AP_MODEL) {
lv_label_set_text(labelModelValue, WIFI_AP_TEXT);
lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0);
}
else {
lv_label_set_text(labelModelValue, WIFI_STA_TEXT);
lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0);
}
memset(public_buf_m,0,sizeof(public_buf_m));
strcat(public_buf_m,machine_menu.wifiName);
strcat(public_buf_m,(const char *)uiCfg.wifi_name);
lv_label_set_text(labelNameText,public_buf_m);
lv_label_set_text(labelNameValue,machine_menu.wifiEdit);
lv_obj_align(labelNameValue, buttonNameValue, LV_ALIGN_CENTER,0, 0);
memset(public_buf_m,0,sizeof(public_buf_m));
strcat(public_buf_m,machine_menu.wifiPassWord);
strcat(public_buf_m,(const char *)uiCfg.wifi_key);
lv_label_set_text(labelPassWordText,public_buf_m);
lv_label_set_text(labelPassWordValue,machine_menu.wifiEdit);
lv_obj_align(labelPassWordValue, buttonPassWordValue, LV_ALIGN_CENTER,0, 0);
lv_label_set_text(labelCloudValue, gCfgItems.cloud_enable ? machine_menu.enable : machine_menu.disable);
lv_obj_align(labelCloudValue, buttonCloudValue, LV_ALIGN_CENTER,0, 0);
lv_label_set_text(labelConfig,machine_menu.wifiConfig);
lv_obj_align(labelConfig, buttonConfig, LV_ALIGN_CENTER,0, 0);
lv_label_set_text(label_Back, common_menu.text_back);
lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER,0, 0);
}
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
lv_group_add_obj(g, buttonModelValue);
lv_group_add_obj(g, buttonNameValue);
lv_group_add_obj(g, buttonPassWordValue);
lv_group_add_obj(g, buttonCloudValue);
lv_group_add_obj(g, buttonConfig);
lv_group_add_obj(g, buttonBack);
}
#endif
}
void lv_clear_wifi_settings() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
#endif
lv_obj_del(scr);
}
#endif // USE_WIFI_FUNCTION
#endif // HAS_TFT_LVGL_UI

36
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.h

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

85
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.cpp

@ -0,0 +1,85 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI
#include "lv_conf.h"
#include "draw_ui.h"
#if ENABLED(USE_WIFI_FUNCTION)
#include "../../../../../Configuration.h"
#include "../../../../module/temperature.h"
static lv_obj_t * scr;
TIPS_TYPE wifi_tips_type;
TIPS_DISP tips_disp;
tips_menu_def tips_menu;
void lv_draw_wifi_tips(void) {
static lv_obj_t * text_tips,*wifi_name;
if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_TIPS_UI) {
disp_state_stack._disp_index++;
disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_TIPS_UI;
}
disp_state = WIFI_TIPS_UI;
scr = lv_obj_create(NULL, NULL);
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
lv_refr_now(lv_refr_get_disp_refreshing());
text_tips = lv_label_create(scr, NULL);
lv_obj_set_style(text_tips, &tft_style_label_rel);
wifi_name = lv_label_create(scr, NULL);
lv_obj_set_style(wifi_name, &tft_style_label_rel);
if (wifi_tips_type == TIPS_TYPE_JOINING) {
lv_label_set_text(text_tips, tips_menu.joining);
lv_obj_align(text_tips, NULL, LV_ALIGN_CENTER,0, -60);
}
else if (wifi_tips_type == TIPS_TYPE_TAILED_JOIN) {
lv_label_set_text(text_tips, tips_menu.failedJoin);
lv_obj_align(text_tips, NULL, LV_ALIGN_CENTER,0, -60);
}
else if (wifi_tips_type == TIPS_TYPE_WIFI_CONECTED) {
lv_label_set_text(text_tips, tips_menu.wifiConected);
lv_obj_align(text_tips, NULL, LV_ALIGN_CENTER,0, -60);
}
lv_label_set_text(wifi_name, (const char *)wifi_list.wifiName[wifi_list.nameIndex]);
lv_obj_align(wifi_name, NULL, LV_ALIGN_CENTER,0, -20);
tips_disp.timer = TIPS_TIMER_START;
tips_disp.timer_count = 0;
}
void lv_clear_wifi_tips() { lv_obj_del(scr); }
#endif // USE_WIFI_FUNCTION
#endif // HAS_TFT_LVGL_UI

51
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.h

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

69
Marlin/src/lcd/extui/lib/mks_ui/irq_overrid.cpp

@ -0,0 +1,69 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI
#include "draw_ui.h"
#if ENABLED(USE_WIFI_FUNCTION)
#include "wifiSerial.h"
#include <libmaple/libmaple.h>
#include <libmaple/gpio.h>
#include <libmaple/timer.h>
#include <libmaple/usart.h>
#include <libmaple/ring_buffer.h>
#include "../../../../inc/MarlinConfig.h"
#ifdef __cplusplus
extern "C" { /* C-declarations for C++ */
#endif
#define WIFI_IO1_SET() WRITE(WIFI_IO1_PIN, HIGH);
#define WIFI_IO1_RESET() WRITE(WIFI_IO1_PIN, LOW);
void __irq_usart1(void) {
WIFISERIAL.wifi_usart_irq(USART1_BASE);
if (wifi_link_state == WIFI_TRANS_FILE) {
if (WIFISERIAL.available() == (400)) WIFI_IO1_SET();
if (WIFISERIAL.wifi_rb_is_full()) {
if (esp_state == TRANSFER_IDLE) esp_state = TRANSFERING;
if (storeRcvData(UART_RX_BUFFER_SIZE)) {
if (wifiTransError.flag != 0x1) WIFI_IO1_RESET();
}
else {
WIFI_IO1_SET();
esp_state = TRANSFER_STORE;
}
}
}
}
#ifdef __cplusplus
} /* C-declarations for C++ */
#endif
#endif // USE_WIFI_FUNCTION
#endif // HAS_TFT_LVGL_UI

100
Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp

@ -38,7 +38,10 @@
#include "../../../../module/temperature.h"
#include "../../../../sd/cardreader.h"
uint8_t pw_det_sta, pw_off_sta, mt_det_sta, mt_det2_sta, mt_det3_sta;
uint8_t pw_det_sta, pw_off_sta, mt_det_sta, mt_det3_sta;
#if PIN_EXISTS(MT_DET_2)
uint8_t mt_det2_sta;
#endif
uint8_t endstopx1_sta, endstopx2_sta, endstopy1_sta, endstopy2_sta, endstopz1_sta, endstopz2_sta;
void test_gpio_readlevel_L() {
#if ENABLED(MKS_TEST)
@ -46,15 +49,17 @@ void test_gpio_readlevel_L() {
WRITE(WIFI_IO0_PIN, HIGH);
itest = 10000;
while (itest--);
pw_det_sta = (READ(POWER_LOSS_PIN) == 0);
pw_off_sta = (READ(PS_ON_PIN) == 0);
pw_det_sta = (READ(MKS_TEST_POWER_LOSS_PIN) == 0);
pw_off_sta = (READ(MKS_TEST_PS_ON_PIN) == 0);
mt_det_sta = (READ(MT_DET_1_PIN) == 0);
mt_det2_sta = (READ(MT_DET_2_PIN) == 0);
#if PIN_EXISTS(MT_DET_2)
mt_det2_sta = (READ(MT_DET_2_PIN) == 0);
#endif
//mt_det3_sta = (READ(FIL_RUNOUT_3_PIN) == 0);
endstopx1_sta = (READ(X_MIN_PIN) == 0);
endstopx2_sta = (READ(X_MAX_PIN) == 0);
//endstopx2_sta = (READ(X_MAX_PIN) == 0);
endstopy1_sta = (READ(Y_MIN_PIN) == 0);
endstopy2_sta = (READ(Y_MAX_PIN) == 0);
//endstopy2_sta = (READ(Y_MAX_PIN) == 0);
endstopz1_sta = (READ(Z_MIN_PIN) == 0);
endstopz2_sta = (READ(Z_MAX_PIN) == 0);
#endif
@ -66,15 +71,17 @@ void test_gpio_readlevel_H() {
WRITE(WIFI_IO0_PIN, LOW);
itest = 10000;
while (itest--);
pw_det_sta = (READ(POWER_LOSS_PIN) == 1);
pw_off_sta = (READ(PS_ON_PIN) == 1);
pw_det_sta = (READ(MKS_TEST_POWER_LOSS_PIN) == 1);
pw_off_sta = (READ(MKS_TEST_PS_ON_PIN) == 1);
mt_det_sta = (READ(MT_DET_1_PIN) == 1);
mt_det2_sta = (READ(MT_DET_2_PIN) == 1);
#if PIN_EXISTS(MT_DET_2)
mt_det2_sta = (READ(MT_DET_2_PIN) == 1);
#endif
//mt_det3_sta = (READ(MT_DET_3_PIN) == 1);
endstopx1_sta = (READ(X_MIN_PIN) == 1);
endstopx2_sta = (READ(X_MAX_PIN) == 1);
//endstopx2_sta = (READ(X_MAX_PIN) == 1);
endstopy1_sta = (READ(Y_MIN_PIN) == 1);
endstopy2_sta = (READ(Y_MAX_PIN) == 1);
//endstopy2_sta = (READ(Y_MAX_PIN) == 1);
endstopz1_sta = (READ(Z_MIN_PIN) == 1);
endstopz2_sta = (READ(Z_MAX_PIN) == 1);
#endif
@ -83,20 +90,22 @@ void test_gpio_readlevel_H() {
void init_test_gpio() {
#ifdef MKS_TEST
SET_INPUT_PULLUP(X_MIN_PIN);
SET_INPUT_PULLUP(X_MAX_PIN);
//SET_INPUT_PULLUP(X_MAX_PIN);
SET_INPUT_PULLUP(Y_MIN_PIN);
SET_INPUT_PULLUP(Y_MAX_PIN);
//SET_INPUT_PULLUP(Y_MAX_PIN);
SET_INPUT_PULLUP(Z_MIN_PIN);
SET_INPUT_PULLUP(Z_MAX_PIN);
SET_OUTPUT(WIFI_IO0_PIN);
SET_INPUT_PULLUP(MT_DET_1_PIN);
SET_INPUT_PULLUP(MT_DET_2_PIN);
#if PIN_EXISTS(MT_DET_2)
SET_INPUT_PULLUP(MT_DET_2_PIN);
#endif
//SET_INPUT_PULLUP(MT_DET_3_PIN);
SET_INPUT_PULLUP(POWER_LOSS_PIN);
SET_INPUT_PULLUP(PS_ON_PIN);
SET_INPUT_PULLUP(MKS_TEST_POWER_LOSS_PIN);
SET_INPUT_PULLUP(MKS_TEST_PS_ON_PIN);
SET_INPUT_PULLUP(SERVO0_PIN);
@ -104,14 +113,28 @@ void init_test_gpio() {
SET_OUTPUT(Y_ENABLE_PIN);
SET_OUTPUT(Z_ENABLE_PIN);
SET_OUTPUT(E0_ENABLE_PIN);
SET_OUTPUT(E1_ENABLE_PIN);
#if !MB(MKS_ROBIN_E3P)
SET_OUTPUT(E1_ENABLE_PIN);
#endif
WRITE(X_ENABLE_PIN, LOW);
WRITE(Y_ENABLE_PIN, LOW);
WRITE(Z_ENABLE_PIN, LOW);
WRITE(E0_ENABLE_PIN, LOW);
WRITE(E1_ENABLE_PIN, LOW);
#if !MB(MKS_ROBIN_E3P)
WRITE(E1_ENABLE_PIN, LOW);
#endif
//WRITE(E2_ENABLE_PIN, LOW);
#if MB(MKS_ROBIN_E3P)
SET_INPUT_PULLUP(PA1);
SET_INPUT_PULLUP(PA3);
SET_INPUT_PULLUP(PC2);
SET_INPUT_PULLUP(PD8);
SET_INPUT_PULLUP(PE5);
SET_INPUT_PULLUP(PE6);
SET_INPUT_PULLUP(PE7);
#endif
#endif
}
@ -124,22 +147,37 @@ void mks_test_beeper() {
#endif
}
void mks_gpio_test(){
void mks_gpio_test() {
#if ENABLED(MKS_TEST)
init_test_gpio();
test_gpio_readlevel_L();
test_gpio_readlevel_H();
test_gpio_readlevel_L();
if ((pw_det_sta == 1) && (mt_det_sta == 1) && (mt_det2_sta == 1)) // &&(mt_det3_sta == 1))
if ((pw_det_sta == 1)
&& (pw_off_sta == 1)
&& (mt_det_sta == 1)
#if PIN_EXISTS(MT_DET_2)
&& (mt_det2_sta == 1)
#endif
#if MB(MKS_ROBIN_E3P)
&& (READ(PA1) == 0)
&& (READ(PA3) == 0)
&& (READ(PC2) == 0)
&& (READ(PD8) == 0)
&& (READ(PE5) == 0)
&& (READ(PE6) == 0)
&& (READ(PE7) == 0)
#endif
) // &&(mt_det3_sta == 1))
disp_det_ok();
else
disp_det_error();
if ( (endstopx1_sta == 1)
&& (endstopx2_sta == 1)
//&& (endstopx2_sta == 1)
&& (endstopy1_sta == 1)
&& (endstopy2_sta == 1)
//&& (endstopy2_sta == 1)
&& (endstopz1_sta == 1)
&& (endstopz2_sta == 1)
)
@ -149,18 +187,22 @@ void mks_gpio_test(){
#endif
}
void mks_hardware_test(){
void mks_hardware_test() {
#if ENABLED(MKS_TEST)
if (millis() % 2000 < 1000) {
WRITE(X_DIR_PIN, LOW);
WRITE(Y_DIR_PIN, LOW);
WRITE(Z_DIR_PIN, LOW);
WRITE(E0_DIR_PIN, LOW);
WRITE(E1_DIR_PIN, LOW);
#if !MB(MKS_ROBIN_E3P)
WRITE(E1_DIR_PIN, LOW);
#endif
//WRITE(E2_DIR_PIN, LOW);
thermalManager.fan_speed[0] = 255;
//WRITE(HEATER_2_PIN, HIGH); // HE2
WRITE(HEATER_1_PIN, HIGH); // HE1
#if !MB(MKS_ROBIN_E3P)
WRITE(HEATER_1_PIN, HIGH); // HE1
#endif
WRITE(HEATER_0_PIN, HIGH); // HE0
WRITE(HEATER_BED_PIN, HIGH); // HOT-BED
}
@ -169,11 +211,15 @@ void mks_hardware_test(){
WRITE(Y_DIR_PIN, HIGH);
WRITE(Z_DIR_PIN, HIGH);
WRITE(E0_DIR_PIN, HIGH);
WRITE(E1_DIR_PIN, HIGH);
#if !MB(MKS_ROBIN_E3P)
WRITE(E1_DIR_PIN, HIGH);
#endif
//WRITE(E2_DIR_PIN, HIGH);
thermalManager.fan_speed[0] = 0;
//WRITE(HEATER_2_PIN, LOW); // HE2
WRITE(HEATER_1_PIN, LOW); // HE1
#if !MB(MKS_ROBIN_E3P)
WRITE(HEATER_1_PIN, LOW); // HE1
#endif
WRITE(HEATER_0_PIN, LOW); // HE0
WRITE(HEATER_BED_PIN, LOW); // HOT-BED
}

174
Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp

@ -24,6 +24,7 @@
#if HAS_TFT_LVGL_UI
#include "string.h"
#include "draw_ui.h"
#include "pic_manager.h"
#include "draw_ready_print.h"
#include "mks_hardware_test.h"
@ -41,59 +42,61 @@ extern unsigned char bmp_public_buf[17 * 1024];
extern char *createFilename(char * const buffer, const dir_t &p);
#endif
static char assets[][LONG_FILENAME_LENGTH] = {
static const char assets[][LONG_FILENAME_LENGTH] = {
//homing screen
"bmp_Zero.bin",
"bmp_zeroAll.bin",
"bmp_zero.bin",
"bmp_zeroX.bin",
"bmp_zeroY.bin",
"bmp_zeroZ.bin",
"bmp_manual_off.bin",
//tool screen
"bmp_PreHeat.bin",
"bmp_Extruct.bin",
"bmp_Mov.bin",
"bmp_preHeat.bin",
"bmp_extruct.bin",
"bmp_mov.bin",
// "bmp_Zero.bin",
"bmp_Leveling.bin",
"bmp_leveling.bin",
"bmp_filamentchange.bin",
//fan screen
"bmp_Add.bin",
"bmp_Dec.bin",
"bmp_Speed255.bin",
"bmp_Speed127.bin",
"bmp_Speed0.bin",
"bmp_speed255.bin",
"bmp_speed127.bin",
"bmp_speed0.bin",
//preheat screen
// "bmp_Add.bin",
// "bmp_Dec.bin",
"bmp_Speed0.bin",
"bmp_speed0.bin",
// "bmp_Extru2.bin",
// "bmp_Extru1.bin",
"bmp_Bed.bin",
"bmp_Step1_degree.bin",
"bmp_Step5_degree.bin",
"bmp_Step10_degree.bin",
"bmp_bed.bin",
"bmp_step1_degree.bin",
"bmp_step5_degree.bin",
"bmp_step10_degree.bin",
//extrusion screen
"bmp_In.bin",
"bmp_Out.bin",
"bmp_Extru1.bin",
#if EXTRUDERS > 1
"bmp_Extru2.bin",
"bmp_in.bin",
"bmp_out.bin",
"bmp_extru1.bin",
#if HAS_MULTI_EXTRUDER
"bmp_extru2.bin",
#endif
"bmp_Speed_high.bin",
"bmp_Speed_slow.bin",
"bmp_Speed_normal.bin",
"bmp_Step1_mm.bin",
"bmp_Step5_mm.bin",
"bmp_Step10_mm.bin",
"bmp_speed_high.bin",
"bmp_speed_slow.bin",
"bmp_speed_normal.bin",
"bmp_step1_mm.bin",
"bmp_step5_mm.bin",
"bmp_step10_mm.bin",
//select file screen
"bmp_pageUp.bin",
"bmp_pageDown.bin",
"bmp_Back.bin", //TODO: why two back buttons? Why not just one? (return / back)
"bmp_Dir.bin",
"bmp_File.bin",
"bmp_back.bin", //TODO: why two back buttons? Why not just one? (return / back)
"bmp_dir.bin",
"bmp_file.bin",
//move motor screen
//TODO: 6 equal icons, just in diffenct rotation... it may be optimized too
@ -103,68 +106,69 @@ static char assets[][LONG_FILENAME_LENGTH] = {
"bmp_yDec.bin",
"bmp_zAdd.bin",
"bmp_zDec.bin",
"bmp_Step_move0_1.bin",
"bmp_Step_move1.bin",
"bmp_Step_move10.bin",
"bmp_step_move0_1.bin",
"bmp_step_move1.bin",
"bmp_step_move10.bin",
//operation screen
"bmp_auto_off.bin",
"bmp_Speed.bin",
"bmp_speed.bin",
//"bmp_Mamual.bin", //TODO: didn't find it.. changed to bmp_manual_off.bin
"bmp_Fan.bin",
//"bmp_PreHeat.bin",
//"bmp_Extruct.bin",
// "bmp_Mov.bin",
"bmp_fan.bin",
"bmp_temp.bin",
"bmp_extrude_opr.bin",
"bmp_move_opr.bin",
//change speed screen
"bmp_Step1_percent.bin",
"bmp_Step5_percent.bin",
"bmp_Step10_percent.bin",
"bmp_step1_percent.bin",
"bmp_step5_percent.bin",
"bmp_step10_percent.bin",
"bmp_extruct_sel.bin",
"bmp_mov_changespeed.bin",
// "bmp_extrude_opr.bin", equal to "bmp_Extruct.bin"
"bmp_mov_sel.bin",
"bmp_speed_extruct.bin",
//printing screen
"bmp_Pause.bin",
"bmp_Resume.bin",
"bmp_Stop.bin",
"bmp_Ext1_state.bin",
#if EXTRUDERS > 1
"bmp_Ext2_state.bin",
"bmp_pause.bin",
"bmp_resume.bin",
"bmp_stop.bin",
"bmp_ext1_state.bin",
#if HAS_MULTI_EXTRUDER
"bmp_ext2_state.bin",
#endif
"bmp_Bed_state.bin",
"bmp_Fan_state.bin",
"bmp_Time_state.bin",
"bmp_Zpos_state.bin",
"bmp_Operate.bin",
"bmp_bed_state.bin",
"bmp_fan_state.bin",
"bmp_time_state.bin",
"bmp_zpos_state.bin",
"bmp_operate.bin",
//manual leval screen (only if disabled auto level)
#if DISABLED(AUTO_BED_LEVELING_BILINEAR)
"bmp_Leveling1.bin",
"bmp_Leveling2.bin",
"bmp_Leveling3.bin",
"bmp_Leveling4.bin",
"bmp_Leveling5.bin",
"bmp_leveling1.bin",
"bmp_leveling2.bin",
"bmp_leveling3.bin",
"bmp_leveling4.bin",
"bmp_leveling5.bin",
#endif
//lang select screen
#if HAS_LANG_SELECT_SCREEN
"bmp_Language.bin",
"bmp_language.bin",
"bmp_simplified_cn.bin",
"bmp_simplified_cn_sel.bin",
"bmp_traditional_cn.bin",
"bmp_traditional_cn_sel.bin",
"bmp_English.bin",
"bmp_English_sel.bin",
"bmp_Russian.bin",
"bmp_Russian_sel.bin",
"bmp_Spanish.bin",
"bmp_Spanish_sel.bin",
"bmp_French.bin",
"bmp_French_sel.bin",
"bmp_Italy.bin",
"bmp_Italy_sel.bin",
"bmp_english.bin",
"bmp_english_sel.bin",
"bmp_russian.bin",
"bmp_russian_sel.bin",
"bmp_spanish.bin",
"bmp_spanish_sel.bin",
"bmp_french.bin",
"bmp_french_sel.bin",
"bmp_italy.bin",
"bmp_italy_sel.bin",
#endif // HAS_LANG_SELECT_SCREEN
// gcode preview
@ -177,21 +181,15 @@ static char assets[][LONG_FILENAME_LENGTH] = {
#endif
// settings screen
"bmp_About.bin",
"bmp_about.bin",
//"bmp_Language.bin",
//"bmp_Fan.bin",
//"bmp_manual_off.bin",
//start screen
"bmp_printing.bin",
"bmp_Set.bin",
"bmp_Tool.bin",
#if ENABLED(HAS_STEALTHCHOP)
//"bmp_back70x40.bin",
"bmp_disable.bin",
"bmp_enable.bin",
#endif
"bmp_set.bin",
"bmp_tool.bin",
// settings screen
"bmp_eeprom_settings.bin",
@ -202,14 +200,27 @@ static char assets[][LONG_FILENAME_LENGTH] = {
"bmp_arrow.bin",
"bmp_back70x40.bin",
"bmp_value_blank.bin",
"bmp_Return.bin"
"bmp_blank_sel.bin",
"bmp_disable.bin",
"bmp_enable.bin",
"bmp_return.bin",
#if ENABLED(USE_WIFI_FUNCTION)
//wifi screen
"bmp_wifi.bin",
#endif
//babystep screen
"bmp_baby_move0_01.bin",
"bmp_baby_move0_05.bin",
"bmp_baby_move0_1.bin"
};
#if HAS_SPI_FLASH_FONT
static char fonts[][LONG_FILENAME_LENGTH] = { "FontUNIGBK.bin" };
#endif
static uint8_t currentFlashPage = 0;
uint8_t currentFlashPage = 0;
uint32_t lv_get_pic_addr(uint8_t *Pname) {
uint8_t Pic_cnt;
@ -253,8 +264,13 @@ const char *bakPath = "_assets";
void spiFlashErase_PIC() {
volatile uint32_t pic_sectorcnt = 0;
W25QXX.init(SPI_QUARTER_SPEED);
for (pic_sectorcnt = 0; pic_sectorcnt < PIC_SIZE_xM * 1024 / 64; pic_sectorcnt++)
W25QXX.SPI_FLASH_BlockErase(PICINFOADDR + pic_sectorcnt * 64 * 1024);
//erase 0x001000 -64K
for (pic_sectorcnt = 0; pic_sectorcnt < (64 - 4) / 4; pic_sectorcnt++) {
W25QXX.SPI_FLASH_SectorErase(PICINFOADDR + pic_sectorcnt * 4 * 1024);
}
//erase 64K -- 6M
for (pic_sectorcnt = 0; pic_sectorcnt < (PIC_SIZE_xM * 1024 / 64 - 1); pic_sectorcnt++)
W25QXX.SPI_FLASH_BlockErase((pic_sectorcnt + 1) * 64 * 1024);
}
#if HAS_SPI_FLASH_FONT

13
Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h

@ -21,7 +21,7 @@
*/
#pragma once
#include "../../../../inc/MarlinConfig.h"
#include "../../../../inc/MarlinConfigPre.h"
#include "../../../../libs/W25Qxx.h"
@ -119,9 +119,18 @@
// Flash flag
#define REFLSHE_FLGA_ADD (0X800000-32)
#define FLASH_INF_VALID_FLAG 0xAA558761
// SD card information first addr
#define VAR_INF_ADDR 0x000000
#define FLASH_INF_VALID_FLAG 0x20200831
//Store some gcode commands, such as auto leveling commands
#define GCODE_COMMAND_ADDR VAR_INF_ADDR + 3*1024
#define AUTO_LEVELING_COMMAND_ADDR GCODE_COMMAND_ADDR
#define OTHERS_COMMAND_ADDR_1 AUTO_LEVELING_COMMAND_ADDR + 100
#define OTHERS_COMMAND_ADDR_2 OTHERS_COMMAND_ADDR_1 + 100
#define OTHERS_COMMAND_ADDR_3 OTHERS_COMMAND_ADDR_2 + 100
#define OTHERS_COMMAND_ADDR_4 OTHERS_COMMAND_ADDR_3 + 100
#ifdef __cplusplus
extern "C" { /* C-declarations for C++ */

44
Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp

@ -53,6 +53,11 @@ void printer_state_polling() {
planner.synchronize();
gcode.process_subcommands_now_P(PSTR("M25"));
//save the positon
uiCfg.current_x_position_bak = current_position.x;
uiCfg.current_y_position_bak = current_position.y;
if (gCfgItems.pausePosZ != (float)-1) {
gcode.process_subcommands_now_P(PSTR("G91"));
ZERO(public_buf_l);
@ -66,6 +71,7 @@ void printer_state_polling() {
gcode.process_subcommands_now(public_buf_l);
}
uiCfg.print_state = PAUSED;
uiCfg.current_e_position_bak = current_position.e;
// #if ENABLED(POWER_LOSS_RECOVERY)
// if (recovery.enabled) recovery.save(true);
@ -83,7 +89,19 @@ void printer_state_polling() {
if (uiCfg.print_state == RESUMING) {
if (IS_SD_PAUSED()) {
gcode.process_subcommands_now_P(PSTR("M24\nG91\nG1 Z-5\nG90"));
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);
gcode.process_subcommands_now(public_buf_m);
}
if (gCfgItems.pausePosZ != (float)-1) {
gcode.process_subcommands_now_P(PSTR("G91"));
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("G1 Z-%.1f"), gCfgItems.pausePosZ);
gcode.process_subcommands_now(public_buf_l);
gcode.process_subcommands_now_P(PSTR("G90"));
}
gcode.process_subcommands_now_P(PSTR("M24"));
uiCfg.print_state = WORKING;
start_print_time();
@ -108,11 +126,25 @@ void printer_state_polling() {
}
#endif
if (gCfgItems.pause_reprint == 1) {
gcode.process_subcommands_now_P(PSTR("G91\nG1 Z-5\nG90"));
}
recovery.resume();
#if 0
// Move back to the saved XY
char str_1[16], str_2[16];
ZERO(public_buf_m);
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.y, 1, 3, str_2)
);
gcode.process_subcommands_now(public_buf_m);
if ((gCfgItems.pause_reprint) == 1 && (gCfgItems.pausePosZ != (float)-1)) {
gcode.process_subcommands_now_P(PSTR("G91"));
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("G1 Z-%.1f"), gCfgItems.pausePosZ);
gcode.process_subcommands_now(public_buf_l);
gcode.process_subcommands_now_P(PSTR("G90"));
}
#endif
uiCfg.print_state = WORKING;
start_print_time();
@ -123,6 +155,8 @@ void printer_state_polling() {
if (uiCfg.print_state == WORKING)
filament_check();
TERN_(USE_WIFI_FUNCTION, wifi_looping());
}
void filament_pin_setup() {

54
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_en.h

@ -46,8 +46,8 @@
#define MACHINE_PARA_TITLE_EN "Config"
#define MACHINE_TYPE_CNOFIG_EN "Machine settings"
#define TEMPERATURE_CONFIG_EN "Temperature settings"
#define MOTOR_CONFIG_EN "Motor settings"
#define MACHINE_LEVELING_CONFIG_EN "Leveling settings"
#define ADVANCE_CONFIG_EN "Adavance settings"
#define MACHINE_CONFIG_TITLE_EN "Machine Settings"
@ -56,7 +56,6 @@
#define MACHINE_HOMEDIR_EN "Home direction"
#define MACHINE_ENDSTOP_TYPE_EN "Endstop type"
#define MACHINE_FILAMENT_CONFIG_EN "Filament settings"
#define MACHINE_LEVELING_CONFIG_EN "Leveling settings"
#define MACHINE_TYPE_CONFIG_TITLE_EN "Machine Settings>Machine type"
#define MACHINE_TYPE_XYZ_EN "XYZ Machine"
@ -91,18 +90,18 @@
#define ENDSTOP_OPENED_EN "Open"
#define ENDSTOP_CLOSED_EN "Close"
#define FILAMENT_CONF_TITLE_EN "Filament settings"
#define FILAMENT_IN_TEMPERATURE_EN "Load temperature"
#define FILAMENT_CONF_TITLE_EN "Machine Settings>Filament settings"
#define FILAMENT_IN_LENGTH_EN "Load length"
#define FILAMENT_IN_SPEED_EN "Load speed"
#define FILAMENT_OUT_TEMPERATURE_EN "Unload temperature"
#define FILAMENT_TEMPERATURE_EN "Filament temperature"
#define FILAMENT_OUT_LENGTH_EN "Unload length"
#define FILAMENT_OUT_SPEED_EN "Unload speed"
#define LEVELING_CONF_TITLE_EN "Leveling settings"
#define LEVELING_CONF_TITLE_EN "Machine Settings>Leveling settings"
#define LEVELING_PARA_CONF_EN "Leveling settings"
#define LEVELING_DELTA_EN "delta machine leveling"
#define LEVELING_XYZ_EN "Manual leveling coordinate settings"
#define LEVELING_MANUAL_POS_EN "Manual leveling coordinate settings"
#define LEVELING_AUTO_COMMAND_EN "AutoLeveling command settings"
#define LEVELING_AUTO_ZOFFSET_EN "Nozzle-to-probe offsets settings"
#define LEVELING_PARA_CONF_TITLE_EN "leveling setting"
#define AUTO_LEVELING_ENABLE_EN "Enable auto leveling"
@ -226,6 +225,9 @@
#define HAVE_UPS_EN "Has UPS power supply"
#define Z2_AND_Z2ENDSTOP_CONF_EN "Z2 Settings"
#define ENABLE_PINS_CONF_EN "Enable pins level settings"
#define WIFI_SETTINGS_EN "Wi-Fi parameter settings"
#define HOMING_SENSITIVITY_CONF_EN "Homing sensitivity settings"
#define ENCODER_SETTINGS_EN "Rotary encoder settings"
#define Z2_AND_Z2ENDSTOP_CONF_TITLE_EN "Z2 Settings"
#define Z2_ENABLE_EN "Z2 Enable"
@ -243,6 +245,29 @@
#define PAUSE_POSITION_Y_EN "Y axis position (Absolute position,-1 invalid)"
#define PAUSE_POSITION_Z_EN "Z axis position (Relative position,-1 invalid)"
#define WIFI_SETTINGS_TITLE_EN "Machine Settings>Wi-Fi Parameter"
#define WIFI_SETTINGS_MODE_EN "Wi-Fi Mode"
#define WIFI_SETTINGS_NAME_EN "Wi-Fi Name: "
#define WIFI_SETTINGS_PASSWORD_EN "Wi-Fi Password: "
#define WIFI_SETTINGS_CLOUD_EN "Do you use cloud services?"
#define WIFI_SETTINGS_CONFIG_EN "Config"
#define WIFI_SETTINGS_EDIT_EN "Edit"
#define WIFI_CONFIG_TIPS_EN "Wi-Fi configuration?"
#define OFFSET_TITLE_EN "Machine Settings>Offset"
#define OFFSET_X_EN "X offset"
#define OFFSET_Y_EN "Y offset"
#define OFFSET_Z_EN "Z offset"
#define HOMING_SENSITIVITY_CONF_TITLE_EN "Machine Settings>Sensitivity"
#define X_SENSITIVITY_EN "X Axis Sensitivity"
#define Y_SENSITIVITY_EN "Y Axis Sensitivity"
#define Z_SENSITIVITY_EN "Z Axis Sensitivity"
#define Z2_SENSITIVITY_EN "Z2 Axis Sensitivity"
#define ENCODER_CONF_TITLE_EN "Machine Settings>Rotary encoder settings"
#define ENCODER_CONF_TEXT_EN "Is the encoder function used?"
#define TOOL_TEXT_EN "Tool"
#define PREHEAT_TEXT_EN "Preheat"
#define MOVE_TEXT_EN "Move"
@ -429,10 +454,6 @@
#define STEP_5PERCENT_EN "5%"
#define STEP_10PERCENT_EN "10%"
#define ZOFFSET_EN "Z Offset"
#define ZOFFSET_INC_EN "Add"
#define ZOFFSET_DEC_EN "Dec"
#define TITLE_READYPRINT_EN "ReadyPrint"
#define TITLE_PREHEAT_EN "Preheat"
#define TITLE_MOVE_EN "Move"
@ -455,7 +476,6 @@
#define TITLE_CLOUD_TEXT_EN "Cloud"
#define TITLE_DIALOG_CONFIRM_EN "Confirm"
#define TITLE_FILESYS_EN "FileSys"
#define TITLE_ZOFFSET_EN "Z Offset"
#define AUTO_SHUTDOWN_EN "Auto"
#define MANUAL_SHUTDOWN_EN "Manual"
@ -494,11 +514,9 @@
#define TEXT_WIFI_SYMBOL_EN "#+="
#define TEXT_WIFI_PASSWORD_EN "Password"
#define TEXT_WIFI_POINT_BOLD_EN "`"
#define TEXT_WIFI_JOINING_EN "Joining\nNetwork..."
#define TEXT_WIFI_FAILED_JOIN_EN "Failed to\nJoin Wi-Fi"
#define TEXT_WIFI_WIFI_CONECTED_EN "Wi-Fi\nConnected"
#define TEXT_WIFI_JOINING_EN "Joining Network..."
#define TEXT_WIFI_FAILED_JOIN_EN "Failed to Join Wi-Fi"
#define TEXT_WIFI_WIFI_CONECTED_EN "Wi-Fi Connected"
#define TEXT_BUTTON_DISCONECTED_EN "Disconnect"
#define TEXT_WIFI_FORGET_EN "Forget Network"

5
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_fr.h

@ -208,10 +208,6 @@
#define STEP_5PERCENT_FR "5%"
#define STEP_10PERCENT_FR "10%"
#define ZOFFSET_FR "Z Offset"
#define ZOFFSET_INC_FR "Ajouter"
#define ZOFFSET_DEC_FR "Réduire"
#define TITLE_READYPRINT_FR "Prête"
#define TITLE_PREHEAT_FR "Préchauffe"
#define TITLE_MOVE_FR "Déplace"
@ -234,7 +230,6 @@
#define TITLE_CLOUD_TEXT_FR "Cloud"
#define TITLE_DIALOG_CONFIRM_FR "Confirm"
#define TITLE_FILESYS_FR "FileSys"
#define TITLE_ZOFFSET_FR "Z Offset"
#define DIALOG_CLOSE_MACHINE_FR "Closing machine......"

5
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_it.h

@ -205,10 +205,6 @@
#define STEP_5PERCENT_IT "5%"
#define STEP_10PERCENT_IT "10%"
#define ZOFFSET_IT "Z Offset"
#define ZOFFSET_INC_IT "Add"
#define ZOFFSET_DEC_IT "Dec"
#define TITLE_READYPRINT_IT "Pronto"
#define TITLE_PREHEAT_IT "Preris"
#define TITLE_MOVE_IT "Muovi"
@ -231,7 +227,6 @@
#define TITLE_CLOUD_TEXT_IT "Cloud"
#define TITLE_DIALOG_CONFIRM_IT "Confirm"
#define TITLE_FILESYS_IT "FileSys"
#define TITLE_ZOFFSET_IT "Z Offset"
#define AUTO_SHUTDOWN_IT "Auto"
#define MANUAL_SHUTDOWN_IT "Manuale"

5
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_ru.h

@ -205,10 +205,6 @@
#define STEP_5PERCENT_RU "5%"
#define STEP_10PERCENT_RU "10%"
#define ZOFFSET_RU "Z Offset"
#define ZOFFSET_INC_RU "добавить"
#define ZOFFSET_DEC_RU "уменьшить"
#define TITLE_READYPRINT_RU "готов к"
#define TITLE_PREHEAT_RU "движение"
#define TITLE_MOVE_RU "движение"
@ -232,7 +228,6 @@
#define TITLE_CLOUD_TEXT_RU "Cloud"
#define TITLE_DIALOG_CONFIRM_RU "Confirm"
#define TITLE_FILESYS_RU "FileSys"
#define TITLE_ZOFFSET_RU "Z Offset"
#define AUTO_SHUTDOWN_RU "авто-откл"
#define MANUAL_SHUTDOWN_RU "ручн-откл"

52
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_s_cn.h

@ -31,8 +31,8 @@
#define MACHINE_PARA_TITLE_CN "机器参数"
#define MACHINE_TYPE_CNOFIG_CN "机器设置"
#define TEMPERATURE_CONFIG_CN "温度设置"
#define MOTOR_CONFIG_CN "电机设置"
#define MACHINE_LEVELING_CONFIG_CN "调平设置"
#define ADVANCE_CONFIG_CN "高级设置"
#define MACHINE_CONFIG_TITLE_CN "机器参数>机器配置"
@ -41,7 +41,6 @@
#define MACHINE_HOMEDIR_CN "归零方向"
#define MACHINE_ENDSTOP_TYPE_CN "限位开关类型"
#define MACHINE_FILAMENT_CONFIG_CN "换料设置"
#define MACHINE_LEVELING_CONFIG_CN "调平设置"
#define MACHINE_TYPE_CONFIG_TITLE_CN "机器参数>机型选择"
#define MACHINE_TYPE_XYZ_CN "XYZ机型"
@ -77,17 +76,17 @@
#define ENDSTOP_CLOSED_CN "常闭"
#define FILAMENT_CONF_TITLE_CN "换料设置"
#define FILAMENT_IN_TEMPERATURE_CN "进料温度"
#define FILAMENT_IN_LENGTH_CN "进料长度"
#define FILAMENT_IN_SPEED_CN "进料速度"
#define FILAMENT_OUT_TEMPERATURE_CN "退料温度"
#define FILAMENT_TEMPERATURE_CN "换料温度"
#define FILAMENT_OUT_LENGTH_CN "退料长度"
#define FILAMENT_OUT_SPEED_CN "退料速度"
#define LEVELING_CONF_TITLE_CN "调平设置"
#define LEVELING_CONF_TITLE_CN "机器参数>调平设置"
#define LEVELING_PARA_CONF_CN "调平设置"
#define LEVELING_DELTA_CN "delta机型设置"
#define LEVELING_XYZ_CN "手动调平坐标设置"
#define LEVELING_MANUAL_POS_CN "手动调平坐标设置"
#define LEVELING_AUTO_COMMAND_CN "自动调平指令设置"
#define LEVELING_AUTO_ZOFFSET_CN "挤出头与调平开关偏移设置"
#define LEVELING_PARA_CONF_TITLE_CN "调平参数"
#define AUTO_LEVELING_ENABLE_CN "自动调平"
@ -146,6 +145,7 @@
#define TMC_STEP_MODE_CN "TMC 驱动模式设置"
#define MOTORDIRCONF_CN "电机方向设置"
#define HOMEFEEDRATECONF_CN "归零速度设置"
#define HOMING_SENSITIVITY_CONF_CN "无限位回零灵敏度调节"
#define MAXFEEDRATE_CONF_TITLE_CN "机器参数>最大速度"
#define X_MAXFEEDRATE_CN "X轴最大速度"
@ -211,6 +211,8 @@
#define HAVE_UPS_CN "机器配备UPS电源"
#define Z2_AND_Z2ENDSTOP_CONF_CN "双Z轴双限位功能设置"
#define ENABLE_PINS_CONF_CN "电机使能脚电平设置"
#define WIFI_SETTINGS_CN "Wi-Fi参数设置"
#define ENCODER_SETTINGS_CN "旋钮设置"
#define Z2_AND_Z2ENDSTOP_CONF_TITLE_CN "双z双限位设置"
#define Z2_ENABLE_CN "启用Z2轴"
@ -223,10 +225,33 @@
#define Z_ENABLE_PINS_INVERT_CN "Z轴电机使能电平"
#define E_ENABLE_PINS_INVERT_CN "E轴电机使能电平"
#define PAUSE_POSITION_CN "打印暂停位置设置"
#define PAUSE_POSITION_X_CN "X轴暂停位置(绝对位置,-1无效)"
#define PAUSE_POSITION_Y_CN "Y轴暂停位置(绝对位置,-1无效)"
#define PAUSE_POSITION_Z_CN "Z轴暂停位置(相对位置,-1无效)"
#define PAUSE_POSITION_CN "打印暂停位置设置"
#define PAUSE_POSITION_X_CN "X轴暂停位置(绝对位置,-1无效)"
#define PAUSE_POSITION_Y_CN "Y轴暂停位置(绝对位置,-1无效)"
#define PAUSE_POSITION_Z_CN "Z轴暂停位置(相对位置,-1无效)"
#define WIFI_SETTINGS_TITLE_CN "机器参数>Wi-Fi设置"
#define WIFI_SETTINGS_MODE_CN "Wi-Fi 模式"
#define WIFI_SETTINGS_NAME_CN "Wi-Fi 名称: "
#define WIFI_SETTINGS_PASSWORD_CN "Wi-Fi 密码: "
#define WIFI_SETTINGS_CLOUD_CN "是否使用云服务?"
#define WIFI_SETTINGS_CONFIG_CN "配置"
#define WIFI_SETTINGS_EDIT_CN "编辑"
#define WIFI_CONFIG_TIPS_CN "进行Wi-Fi配置?"
#define OFFSET_TITLE_CN "机器参数>偏移设置"
#define OFFSET_X_CN "X轴与调平开关偏移"
#define OFFSET_Y_CN "Y轴与调平开关偏移"
#define OFFSET_Z_CN "Z轴与调平开关偏移"
#define HOMING_SENSITIVITY_CONF_TITLE_CN "机器参数>灵敏度调节"
#define X_SENSITIVITY_CN "X轴灵敏度"
#define Y_SENSITIVITY_CN "Y轴灵敏度"
#define Z_SENSITIVITY_CN "Z轴灵敏度"
#define Z2_SENSITIVITY_CN "Z2轴灵敏度"
#define ENCODER_CONF_TITLE_CN "机器参数>旋钮设置"
#define ENCODER_CONF_TEXT_CN "是否使用旋钮功能?"
#define TOOL_TEXT_CN "工具"
#define PREHEAT_TEXT_CN "预热"
#define MOVE_TEXT_CN "移动"
@ -395,10 +420,6 @@
#define STEP_5PERCENT_CN "5%"
#define STEP_10PERCENT_CN "10%"
#define ZOFFSET_CN "Z Offset"
#define ZOFFSET_INC_CN "增加"
#define ZOFFSET_DEC_CN "减少"
#define TITLE_READYPRINT_CN "准备打印"
#define TITLE_PREHEAT_CN "预热"
#define TITLE_MOVE_CN "移动"
@ -421,7 +442,6 @@
#define TITLE_CLOUD_TEXT_CN "云服务"
#define TITLE_DIALOG_CONFIRM_CN "确认"
#define TITLE_FILESYS_CN "文件系统"
#define TITLE_ZOFFSET_CN "Z Offset"
#define AUTO_SHUTDOWN_CN "自动关机"
#define MANUAL_SHUTDOWN_CN "手动关机"

5
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_sp.h

@ -206,10 +206,6 @@
#define STEP_5PERCENT_SP "5%"
#define STEP_10PERCENT_SP "10%"
#define ZOFFSET_SP "Z Offset"
#define ZOFFSET_INC_SP "Más"
#define ZOFFSET_DEC_SP "Menos"
#define TITLE_READYPRINT_SP "Inicio"
#define TITLE_PREHEAT_SP "Precalentar"
#define TITLE_MOVE_SP "Mover"
@ -233,7 +229,6 @@
#define TITLE_CLOUD_TEXT_SP "Cloud"
#define TITLE_DIALOG_CONFIRM_SP "Confirmar"
#define TITLE_FILESYS_SP "Puerto"
#define TITLE_ZOFFSET_SP "Z Offset"
#define AUTO_SHUTDOWN_SP "Auto"
#define MANUAL_SHUTDOWN_SP "manual"

51
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_t_cn.h

@ -31,8 +31,8 @@
#define MACHINE_PARA_TITLE_T_CN "機器參數"
#define MACHINE_TYPE_CNOFIG_T_CN "機器設置"
#define TEMPERATURE_CONFIG_T_CN "溫度設置"
#define MOTOR_CONFIG_T_CN "電機設置"
#define MACHINE_LEVELING_CONFIG_T_CN "調平設置"
#define ADVANCE_CONFIG_T_CN "高級設置"
#define MACHINE_CONFIG_TITLE_T_CN "機器參數>機器配置"
@ -41,7 +41,6 @@
#define MACHINE_HOMEDIR_T_CN "歸零方向"
#define MACHINE_ENDSTOP_TYPE_T_CN "限位開關類型"
#define MACHINE_FILAMENT_CONFIG_T_CN "換料設置"
#define MACHINE_LEVELING_CONFIG_T_CN "調平設置"
#define MACHINE_TYPE_CONFIG_TITLE_T_CN "機器參數>機型選擇"
#define MACHINE_TYPE_XYZ_T_CN "XYZ機型"
@ -77,17 +76,17 @@
#define ENDSTOP_CLOSED_T_CN "常閉"
#define FILAMENT_CONF_TITLE_T_CN "換料設置"
#define FILAMENT_IN_TEMPERATURE_T_CN "進料溫度"
#define FILAMENT_IN_LENGTH_T_CN "進料長度"
#define FILAMENT_IN_SPEED_T_CN "進料速度"
#define FILAMENT_OUT_TEMPERATURE_T_CN "退料溫度"
#define FILAMENT_TEMPERATURE_T_CN "換料溫度"
#define FILAMENT_OUT_LENGTH_T_CN "退料長度"
#define FILAMENT_OUT_SPEED_T_CN "退料速度"
#define LEVELING_CONF_TITLE_T_CN "調平設置"
#define LEVELING_CONF_TITLE_T_CN "機器參數>調平設置"
#define LEVELING_PARA_CONF_T_CN "調平設置"
#define LEVELING_DELTA_T_CN "delta機型設置"
#define LEVELING_XYZ_T_CN "手動調平坐標設置"
#define LEVELING_MANUAL_POS_T_CN "手動調平坐標設置"
#define LEVELING_AUTO_COMMAND_T_CN "自動調平指令設置"
#define LEVELING_AUTO_ZOFFSET_T_CN "擠出頭與調平開關偏移設置"
#define LEVELING_PARA_CONF_TITLE_T_CN "調平參數"
#define AUTO_LEVELING_ENABLE_T_CN "自動調平"
@ -146,6 +145,7 @@
#define TMC_STEP_MODE_T_CN "TMC 驅動模式設置"
#define MOTORDIRCONF_T_CN "電機方向設置"
#define HOMEFEEDRATECONF_T_CN "歸零速度設置"
#define HOMING_SENSITIVITY_CONF_T_CN "無限位回零靈敏度調節"
#define MAXFEEDRATE_CONF_TITLE_T_CN "機器參數>最大速度"
#define X_MAXFEEDRATE_T_CN "X軸最大速度"
@ -211,6 +211,8 @@
#define HAVE_UPS_T_CN "機器配備UPS電壓"
#define Z2_AND_Z2ENDSTOP_CONF_T_CN "雙z軸雙限位功能設置"
#define ENABLE_PINS_CONF_T_CN "電機使能腳電平設置"
#define WIFI_SETTINGS_T_CN "Wi-Fi參數設置"
#define ENCODER_SETTINGS_T_CN "旋鈕設置"
#define Z2_AND_Z2ENDSTOP_CONF_TITLE_T_CN "雙z軸雙限位設置"
#define Z2_ENABLE_T_CN "啟用Z2軸"
@ -223,10 +225,32 @@
#define Z_ENABLE_PINS_INVERT_T_CN "Z軸電機使能電平"
#define E_ENABLE_PINS_INVERT_T_CN "E軸電機使能電平"
#define PAUSE_POSITION_T_CN "打印暫停位置設置"
#define PAUSE_POSITION_X_T_CN "X軸暫停位置(絕對位置,-1無效)"
#define PAUSE_POSITION_Y_T_CN "Y軸暫停位置(絕對位置,-1無效)"
#define PAUSE_POSITION_Z_T_CN "Z軸暫停位置(相對位置,-1無效)"
#define PAUSE_POSITION_T_CN "打印暫停位置設置"
#define PAUSE_POSITION_X_T_CN "X軸暫停位置(絕對位置,-1無效)"
#define PAUSE_POSITION_Y_T_CN "Y軸暫停位置(絕對位置,-1無效)"
#define PAUSE_POSITION_Z_T_CN "Z軸暫停位置(相對位置,-1無效)"
#define WIFI_SETTINGS_TITLE_T_CN "機器參數>Wi-Fi設置"
#define WIFI_SETTINGS_MODE_T_CN "Wi-Fi 模式"
#define WIFI_SETTINGS_NAME_T_CN "Wi-Fi 名稱: "
#define WIFI_SETTINGS_PASSWORD_T_CN "Wi-Fi 密碼: "
#define WIFI_SETTINGS_CLOUD_T_CN "是否使用雲服務?"
#define WIFI_SETTINGS_CONFIG_T_CN "配置"
#define WIFI_SETTINGS_EDIT_T_CN "編輯"
#define WIFI_CONFIG_TIPS_T_CN "進行Wi-Fi配置?"
#define OFFSET_TITLE_T_CN "機器參數>偏移設置"
#define OFFSET_X_T_CN "X軸與調平開關偏移"
#define OFFSET_Y_T_CN "Y軸與調平開關偏移"
#define OFFSET_Z_T_CN "Z軸與調平開關偏移"
#define HOMING_SENSITIVITY_CONF_TITLE_T_CN "機器參數>靈敏度調節"
#define X_SENSITIVITY_T_CN "X軸靈敏度"
#define Y_SENSITIVITY_T_CN "Y軸靈敏度"
#define Z_SENSITIVITY_T_CN "Z軸靈敏度"
#define Z2_SENSITIVITY_T_CN "Z2軸靈敏度"
#define ENCODER_CONF_TITLE_T_CN "機器參數>旋鈕設置"
#define ENCODER_CONF_TEXT_T_CN "是否使用旋鈕功能?"
#define TOOL_TEXT_T_CN "工具"
#define PREHEAT_TEXT_T_CN "預熱"
@ -398,10 +422,6 @@
#define STEP_5PERCENT_T_CN "5%%"
#define STEP_10PERCENT_T_CN "10%%"
#define ZOFFSET_T_CN "Z Offset"
#define ZOFFSET_INC_T_CN "增加"
#define ZOFFSET_DEC_T_CN "減少"
#define TITLE_READYPRINT_T_CN "準備打印"
#define TITLE_PREHEAT_T_CN "預熱"
#define TITLE_MOVE_T_CN "移動"
@ -424,7 +444,6 @@
#define TITLE_CLOUD_TEXT_T_CN "雲服務"
#define TITLE_DIALOG_CONFIRM_T_CN "確認"
#define TITLE_FILESYS_T_CN "文件系統"
#define TITLE_ZOFFSET_T_CN "Z Offset"
#define AUTO_SHUTDOWN_T_CN "自動關機"
#define MANUAL_SHUTDOWN_T_CN "手動關機"

880
Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp

File diff suppressed because it is too large

51
Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h

@ -22,25 +22,44 @@
#pragma once
/**
* @file tft_lvgl_configuration.h
* @date 2020-02-21
* */
* @file lcd/extui/lib/mks_ui/tft_lvgl_configuration.h
* @date 2020-02-21
*/
//#ifdef __cplusplus
//extern "C" {
//#endif
#ifdef __cplusplus
extern "C" { /* C-declarations for C++ */
#endif
#include <lvgl.h>
void tft_lvgl_init();
void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p);
bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data);
//#define GRAPHICAL_TFT_ROTATE_180
#define USE_WIFI_FUNCTION 0
extern void tft_lvgl_init();
extern void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p);
extern bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data);
extern bool my_mousewheel_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
extern void LCD_Clear(uint16_t Color);
extern void tft_set_point(uint16_t x, uint16_t y, uint16_t point);
extern void LCD_setWindowArea(uint16_t StartX, uint16_t StartY, uint16_t width, uint16_t heigh);
extern void LCD_WriteRAM_Prepare(void);
extern void lcd_draw_logo();
extern void lv_encoder_pin_init();
extern void lv_update_encoder();
extern lv_fs_res_t spi_flash_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode);
extern lv_fs_res_t spi_flash_close_cb (lv_fs_drv_t * drv, void * file_p);
extern lv_fs_res_t spi_flash_read_cb (lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br);
extern lv_fs_res_t spi_flash_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos);
extern lv_fs_res_t spi_flash_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p);
void LCD_Clear(uint16_t Color);
void tft_set_point(uint16_t x, uint16_t y, uint16_t point);
void ili9320_SetWindows(uint16_t StartX, uint16_t StartY, uint16_t width, uint16_t heigh);
void LCD_WriteRAM_Prepare(void);
extern lv_fs_res_t sd_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode);
extern lv_fs_res_t sd_close_cb (lv_fs_drv_t * drv, void * file_p);
extern lv_fs_res_t sd_read_cb (lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br);
extern lv_fs_res_t sd_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos);
extern lv_fs_res_t sd_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p);
//#ifdef __cplusplus
//} /* extern "C" */
//#endif
#ifdef __cplusplus
} /* C-declarations for C++ */
#endif

291
Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.cpp

@ -54,11 +54,8 @@ dialog_menu_def dialog_menu;
language_menu_def language_menu;
print_file_dialog_menu_def print_file_dialog_menu;
filesys_menu_def filesys_menu;
zoffset_menu_def zoffset_menu;
tool_menu_def tool_menu;
MachinePara_menu_def MachinePara_menu;
MachineSettings_menu_def MachineSettings_menu;
TemperatureSettings_menu_def TemperatureSettings_menu;
pause_msg_def pause_msg_menu;
eeprom_def eeprom_menu;
@ -67,8 +64,8 @@ void machine_setting_disp() {
if (gCfgItems.language == LANG_SIMPLE_CHINESE) {
MachinePara_menu.title = MACHINE_PARA_TITLE_CN;
MachinePara_menu.MachineSetting = MACHINE_TYPE_CNOFIG_CN;
MachinePara_menu.TemperatureSetting = TEMPERATURE_CONFIG_CN;
MachinePara_menu.MotorSetting = MOTOR_CONFIG_CN;
MachinePara_menu.leveling = MACHINE_LEVELING_CONFIG_CN;
MachinePara_menu.AdvanceSetting = ADVANCE_CONFIG_CN;
machine_menu.default_value = DEFAULT_CN;
@ -81,7 +78,6 @@ void machine_setting_disp() {
machine_menu.HomeDir = MACHINE_HOMEDIR_CN;
machine_menu.EndStopType = MACHINE_ENDSTOP_TYPE_CN;
machine_menu.FilamentConf = MACHINE_FILAMENT_CONFIG_CN;
machine_menu.LevelingConf = MACHINE_LEVELING_CONFIG_CN;
machine_menu.MachineTypeConfTitle = MACHINE_TYPE_CONFIG_TITLE_CN;
machine_menu.xyz = MACHINE_TYPE_XYZ_CN;
@ -116,18 +112,18 @@ void machine_setting_disp() {
machine_menu.opened = ENDSTOP_OPENED_CN;
machine_menu.closed = ENDSTOP_CLOSED_CN;
machine_menu.FilamentConfTitle = FILAMENT_CONF_TITLE_CN;
machine_menu.InTemperature = FILAMENT_IN_TEMPERATURE_CN;
machine_menu.InLength = FILAMENT_IN_LENGTH_CN;
machine_menu.InSpeed = FILAMENT_IN_SPEED_CN;
machine_menu.OutTemperature = FILAMENT_OUT_TEMPERATURE_CN;
machine_menu.OutLength = FILAMENT_OUT_LENGTH_CN;
machine_menu.OutSpeed = FILAMENT_OUT_SPEED_CN;
machine_menu.FilamentConfTitle = FILAMENT_CONF_TITLE_CN;
machine_menu.InLength = FILAMENT_IN_LENGTH_CN;
machine_menu.InSpeed = FILAMENT_IN_SPEED_CN;
machine_menu.FilamentTemperature = FILAMENT_TEMPERATURE_CN;
machine_menu.OutLength = FILAMENT_OUT_LENGTH_CN;
machine_menu.OutSpeed = FILAMENT_OUT_SPEED_CN;
machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_CN;
machine_menu.LevelingParaConf = LEVELING_PARA_CONF_CN;
machine_menu.DeltaLevelConf = LEVELING_DELTA_CN;
machine_menu.XYZLevelconf = LEVELING_XYZ_CN;
machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_CN;
machine_menu.LevelingParaConf = LEVELING_PARA_CONF_CN;
machine_menu.LevelingManuPosConf = LEVELING_MANUAL_POS_CN;
machine_menu.LevelingAutoCommandConf = LEVELING_AUTO_COMMAND_CN;
machine_menu.LevelingAutoZoffsetConf = LEVELING_AUTO_ZOFFSET_CN;
machine_menu.LevelingSubConfTitle = LEVELING_PARA_CONF_TITLE_CN;
machine_menu.AutoLevelEnable = AUTO_LEVELING_ENABLE_CN;
@ -177,16 +173,19 @@ void machine_setting_disp() {
machine_menu.HotbedMinTemperature = HOTBED_MIN_TEMPERATURE_CN;
machine_menu.HotbedMaxTemperature = HOTBED_MAX_TEMPERATURE_CN;
machine_menu.MotorConfTitle = MOTOR_CONF_TITLE_CN;
machine_menu.MaxFeedRateConf = MAXFEEDRATE_CONF_CN;
machine_menu.AccelerationConf = ACCELERATION_CONF_CN;
machine_menu.JerkConf = JERKCONF_CN;
machine_menu.StepsConf = STEPSCONF_CN;
machine_menu.TMCcurrentConf = TMC_CURRENT_CN;
machine_menu.TMCStepModeConf = TMC_STEP_MODE_CN;
machine_menu.MotorDirConf = MOTORDIRCONF_CN;
machine_menu.HomeFeedRateConf = HOMEFEEDRATECONF_CN;
machine_menu.PausePosition = PAUSE_POSITION_CN;
machine_menu.MotorConfTitle = MOTOR_CONF_TITLE_CN;
machine_menu.MaxFeedRateConf = MAXFEEDRATE_CONF_CN;
machine_menu.AccelerationConf = ACCELERATION_CONF_CN;
machine_menu.JerkConf = JERKCONF_CN;
machine_menu.StepsConf = STEPSCONF_CN;
machine_menu.TMCcurrentConf = TMC_CURRENT_CN;
machine_menu.TMCStepModeConf = TMC_STEP_MODE_CN;
machine_menu.MotorDirConf = MOTORDIRCONF_CN;
machine_menu.HomeFeedRateConf = HOMEFEEDRATECONF_CN;
machine_menu.PausePosition = PAUSE_POSITION_CN;
machine_menu.WifiSettings = WIFI_SETTINGS_CN;
machine_menu.HomingSensitivityConf = HOMING_SENSITIVITY_CONF_CN;
machine_menu.EncoderSettings = ENCODER_SETTINGS_CN;
machine_menu.MaxFeedRateConfTitle = MAXFEEDRATE_CONF_TITLE_CN;
machine_menu.XMaxFeedRate = X_MAXFEEDRATE_CN;
@ -268,16 +267,38 @@ void machine_setting_disp() {
machine_menu.key_reset = KEY_REST_CN;
machine_menu.key_confirm = KEY_CONFIRM_CN;
machine_menu.PausePosText = PAUSE_POSITION_CN;
machine_menu.xPos = PAUSE_POSITION_X_CN;
machine_menu.yPos = PAUSE_POSITION_Y_CN;
machine_menu.zPos = PAUSE_POSITION_Z_CN;
machine_menu.PausePosText = PAUSE_POSITION_CN;
machine_menu.xPos = PAUSE_POSITION_X_CN;
machine_menu.yPos = PAUSE_POSITION_Y_CN;
machine_menu.zPos = PAUSE_POSITION_Z_CN;
machine_menu.WifiConfTitle = WIFI_SETTINGS_TITLE_CN;
machine_menu.wifiMode = WIFI_SETTINGS_MODE_CN;
machine_menu.wifiName = WIFI_SETTINGS_NAME_CN;
machine_menu.wifiPassWord = WIFI_SETTINGS_PASSWORD_CN;
machine_menu.wifiCloud = WIFI_SETTINGS_CLOUD_CN;
machine_menu.wifiConfig = WIFI_SETTINGS_CONFIG_CN;
machine_menu.wifiEdit = WIFI_SETTINGS_EDIT_CN;
machine_menu.wifiConfigTips = WIFI_CONFIG_TIPS_CN;
machine_menu.OffsetConfTitle = OFFSET_TITLE_CN;
machine_menu.Xoffset = OFFSET_X_CN;
machine_menu.Yoffset = OFFSET_Y_CN;
machine_menu.Zoffset = OFFSET_Z_CN;
machine_menu.HomingSensitivityConfTitle = HOMING_SENSITIVITY_CONF_TITLE_CN;
machine_menu.X_Sensitivity = X_SENSITIVITY_CN;
machine_menu.Y_Sensitivity = Y_SENSITIVITY_CN;
machine_menu.Z_Sensitivity = Z_SENSITIVITY_CN;
machine_menu.Z2_Sensitivity = Z2_SENSITIVITY_CN;
machine_menu.EncoderConfTitle = ENCODER_CONF_TITLE_CN;
machine_menu.EncoderConfText = ENCODER_CONF_TEXT_CN;
}
else if (gCfgItems.language == LANG_COMPLEX_CHINESE) {
MachinePara_menu.title = MACHINE_PARA_TITLE_T_CN;
MachinePara_menu.MachineSetting = MACHINE_TYPE_CNOFIG_T_CN;
MachinePara_menu.TemperatureSetting = TEMPERATURE_CONFIG_T_CN;
MachinePara_menu.MotorSetting = MOTOR_CONFIG_T_CN;
MachinePara_menu.leveling = MACHINE_LEVELING_CONFIG_T_CN;
MachinePara_menu.AdvanceSetting = ADVANCE_CONFIG_T_CN;
machine_menu.default_value = DEFAULT_T_CN;
@ -290,7 +311,6 @@ void machine_setting_disp() {
machine_menu.HomeDir = MACHINE_HOMEDIR_T_CN;
machine_menu.EndStopType = MACHINE_ENDSTOP_TYPE_T_CN;
machine_menu.FilamentConf = MACHINE_FILAMENT_CONFIG_T_CN;
machine_menu.LevelingConf = MACHINE_LEVELING_CONFIG_T_CN;
machine_menu.MachineTypeConfTitle = MACHINE_TYPE_CONFIG_TITLE_T_CN;
machine_menu.xyz = MACHINE_TYPE_XYZ_T_CN;
@ -325,18 +345,18 @@ void machine_setting_disp() {
machine_menu.opened = ENDSTOP_OPENED_T_CN;
machine_menu.closed = ENDSTOP_CLOSED_T_CN;
machine_menu.FilamentConfTitle = FILAMENT_CONF_TITLE_T_CN;
machine_menu.InTemperature = FILAMENT_IN_TEMPERATURE_T_CN;
machine_menu.InLength = FILAMENT_IN_LENGTH_T_CN;
machine_menu.InSpeed = FILAMENT_IN_SPEED_T_CN;
machine_menu.OutTemperature = FILAMENT_OUT_TEMPERATURE_T_CN;
machine_menu.OutLength = FILAMENT_OUT_LENGTH_T_CN;
machine_menu.OutSpeed = FILAMENT_OUT_SPEED_T_CN;
machine_menu.FilamentConfTitle = FILAMENT_CONF_TITLE_T_CN;
machine_menu.InLength = FILAMENT_IN_LENGTH_T_CN;
machine_menu.InSpeed = FILAMENT_IN_SPEED_T_CN;
machine_menu.FilamentTemperature = FILAMENT_TEMPERATURE_T_CN;
machine_menu.OutLength = FILAMENT_OUT_LENGTH_T_CN;
machine_menu.OutSpeed = FILAMENT_OUT_SPEED_T_CN;
machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_T_CN;
machine_menu.LevelingParaConf = LEVELING_PARA_CONF_T_CN;
machine_menu.DeltaLevelConf = LEVELING_DELTA_T_CN;
machine_menu.XYZLevelconf = LEVELING_XYZ_T_CN;
machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_T_CN;
machine_menu.LevelingParaConf = LEVELING_PARA_CONF_T_CN;
machine_menu.LevelingManuPosConf = LEVELING_MANUAL_POS_T_CN;
machine_menu.LevelingAutoCommandConf = LEVELING_AUTO_COMMAND_T_CN;
machine_menu.LevelingAutoZoffsetConf = LEVELING_AUTO_ZOFFSET_T_CN;
machine_menu.LevelingSubConfTitle = LEVELING_PARA_CONF_TITLE_T_CN;
machine_menu.AutoLevelEnable = AUTO_LEVELING_ENABLE_T_CN;
@ -386,16 +406,19 @@ void machine_setting_disp() {
machine_menu.HotbedMinTemperature = HOTBED_MIN_TEMPERATURE_T_CN;
machine_menu.HotbedMaxTemperature = HOTBED_MAX_TEMPERATURE_T_CN;
machine_menu.MotorConfTitle = MOTOR_CONF_TITLE_T_CN;
machine_menu.MaxFeedRateConf = MAXFEEDRATE_CONF_T_CN;
machine_menu.AccelerationConf = ACCELERATION_CONF_T_CN;
machine_menu.JerkConf = JERKCONF_T_CN;
machine_menu.StepsConf = STEPSCONF_T_CN;
machine_menu.TMCcurrentConf = TMC_CURRENT_T_CN;
machine_menu.TMCStepModeConf = TMC_STEP_MODE_T_CN;
machine_menu.MotorDirConf = MOTORDIRCONF_T_CN;
machine_menu.HomeFeedRateConf = HOMEFEEDRATECONF_T_CN;
machine_menu.PausePosition = PAUSE_POSITION_T_CN;
machine_menu.MotorConfTitle = MOTOR_CONF_TITLE_T_CN;
machine_menu.MaxFeedRateConf = MAXFEEDRATE_CONF_T_CN;
machine_menu.AccelerationConf = ACCELERATION_CONF_T_CN;
machine_menu.JerkConf = JERKCONF_T_CN;
machine_menu.StepsConf = STEPSCONF_T_CN;
machine_menu.TMCcurrentConf = TMC_CURRENT_T_CN;
machine_menu.TMCStepModeConf = TMC_STEP_MODE_T_CN;
machine_menu.MotorDirConf = MOTORDIRCONF_T_CN;
machine_menu.HomeFeedRateConf = HOMEFEEDRATECONF_T_CN;
machine_menu.PausePosition = PAUSE_POSITION_T_CN;
machine_menu.WifiSettings = WIFI_SETTINGS_T_CN;
machine_menu.HomingSensitivityConf = HOMING_SENSITIVITY_CONF_T_CN;
machine_menu.EncoderSettings = ENCODER_SETTINGS_T_CN;
machine_menu.MaxFeedRateConfTitle = MAXFEEDRATE_CONF_TITLE_T_CN;
machine_menu.XMaxFeedRate = X_MAXFEEDRATE_T_CN;
@ -484,12 +507,34 @@ void machine_setting_disp() {
machine_menu.yPos = PAUSE_POSITION_Y_T_CN;
machine_menu.zPos = PAUSE_POSITION_Z_T_CN;
machine_menu.WifiConfTitle = WIFI_SETTINGS_TITLE_T_CN;
machine_menu.wifiMode = WIFI_SETTINGS_MODE_T_CN;
machine_menu.wifiName = WIFI_SETTINGS_NAME_T_CN;
machine_menu.wifiPassWord = WIFI_SETTINGS_PASSWORD_T_CN;
machine_menu.wifiCloud = WIFI_SETTINGS_CLOUD_T_CN;
machine_menu.wifiConfig = WIFI_SETTINGS_CONFIG_T_CN;
machine_menu.wifiEdit = WIFI_SETTINGS_EDIT_T_CN;
machine_menu.wifiConfigTips = WIFI_CONFIG_TIPS_T_CN;
machine_menu.OffsetConfTitle = OFFSET_TITLE_T_CN;
machine_menu.Xoffset = OFFSET_X_T_CN;
machine_menu.Yoffset = OFFSET_Y_T_CN;
machine_menu.Zoffset = OFFSET_Z_T_CN;
machine_menu.HomingSensitivityConfTitle = HOMING_SENSITIVITY_CONF_TITLE_T_CN;
machine_menu.X_Sensitivity = X_SENSITIVITY_T_CN;
machine_menu.Y_Sensitivity = Y_SENSITIVITY_T_CN;
machine_menu.Z_Sensitivity = Z_SENSITIVITY_T_CN;
machine_menu.Z2_Sensitivity = Z2_SENSITIVITY_T_CN;
machine_menu.EncoderConfTitle = ENCODER_CONF_TITLE_T_CN;
machine_menu.EncoderConfText = ENCODER_CONF_TEXT_T_CN;
}
else {
MachinePara_menu.title = MACHINE_PARA_TITLE_EN;
MachinePara_menu.MachineSetting = MACHINE_TYPE_CNOFIG_EN;
MachinePara_menu.TemperatureSetting = TEMPERATURE_CONFIG_EN;
MachinePara_menu.MotorSetting = MOTOR_CONFIG_EN;
MachinePara_menu.leveling = MACHINE_LEVELING_CONFIG_EN;
MachinePara_menu.AdvanceSetting = ADVANCE_CONFIG_EN;
machine_menu.default_value = DEFAULT_EN;
@ -502,7 +547,6 @@ void machine_setting_disp() {
machine_menu.HomeDir = MACHINE_HOMEDIR_EN;
machine_menu.EndStopType = MACHINE_ENDSTOP_TYPE_EN;
machine_menu.FilamentConf = MACHINE_FILAMENT_CONFIG_EN;
machine_menu.LevelingConf = MACHINE_LEVELING_CONFIG_EN;
machine_menu.MachineTypeConfTitle = MACHINE_TYPE_CONFIG_TITLE_EN;
machine_menu.xyz = MACHINE_TYPE_XYZ_EN;
@ -537,18 +581,18 @@ void machine_setting_disp() {
machine_menu.opened = ENDSTOP_OPENED_EN;
machine_menu.closed = ENDSTOP_CLOSED_EN;
machine_menu.FilamentConfTitle = FILAMENT_CONF_TITLE_EN;
machine_menu.InTemperature = FILAMENT_IN_TEMPERATURE_EN;
machine_menu.InLength = FILAMENT_IN_LENGTH_EN;
machine_menu.InSpeed = FILAMENT_IN_SPEED_EN;
machine_menu.OutTemperature = FILAMENT_OUT_TEMPERATURE_EN;
machine_menu.OutLength = FILAMENT_OUT_LENGTH_EN;
machine_menu.OutSpeed = FILAMENT_OUT_SPEED_EN;
machine_menu.FilamentConfTitle = FILAMENT_CONF_TITLE_EN;
machine_menu.InLength = FILAMENT_IN_LENGTH_EN;
machine_menu.InSpeed = FILAMENT_IN_SPEED_EN;
machine_menu.FilamentTemperature = FILAMENT_TEMPERATURE_EN;
machine_menu.OutLength = FILAMENT_OUT_LENGTH_EN;
machine_menu.OutSpeed = FILAMENT_OUT_SPEED_EN;
machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_EN;
machine_menu.LevelingParaConf = LEVELING_PARA_CONF_EN;
machine_menu.DeltaLevelConf = LEVELING_DELTA_EN;
machine_menu.XYZLevelconf = LEVELING_XYZ_EN;
machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_EN;
machine_menu.LevelingParaConf = LEVELING_PARA_CONF_EN;
machine_menu.LevelingManuPosConf = LEVELING_MANUAL_POS_EN;
machine_menu.LevelingAutoCommandConf = LEVELING_AUTO_COMMAND_EN;
machine_menu.LevelingAutoZoffsetConf = LEVELING_AUTO_ZOFFSET_EN;
machine_menu.LevelingSubConfTitle = LEVELING_PARA_CONF_TITLE_EN;
machine_menu.AutoLevelEnable = AUTO_LEVELING_ENABLE_EN;
@ -598,16 +642,19 @@ void machine_setting_disp() {
machine_menu.HotbedMinTemperature = HOTBED_MIN_TEMPERATURE_EN;
machine_menu.HotbedMaxTemperature = HOTBED_MAX_TEMPERATURE_EN;
machine_menu.MotorConfTitle = MOTOR_CONF_TITLE_EN;
machine_menu.MaxFeedRateConf = MAXFEEDRATE_CONF_EN;
machine_menu.AccelerationConf = ACCELERATION_CONF_EN;
machine_menu.JerkConf = JERKCONF_EN;
machine_menu.StepsConf = STEPSCONF_EN;
machine_menu.TMCcurrentConf = TMC_CURRENT_EN;
machine_menu.TMCStepModeConf = TMC_STEP_MODE_EN;
machine_menu.MotorDirConf = MOTORDIRCONF_EN;
machine_menu.HomeFeedRateConf = HOMEFEEDRATECONF_EN;
machine_menu.PausePosition = PAUSE_POSITION_EN;
machine_menu.MotorConfTitle = MOTOR_CONF_TITLE_EN;
machine_menu.MaxFeedRateConf = MAXFEEDRATE_CONF_EN;
machine_menu.AccelerationConf = ACCELERATION_CONF_EN;
machine_menu.JerkConf = JERKCONF_EN;
machine_menu.StepsConf = STEPSCONF_EN;
machine_menu.TMCcurrentConf = TMC_CURRENT_EN;
machine_menu.TMCStepModeConf = TMC_STEP_MODE_EN;
machine_menu.MotorDirConf = MOTORDIRCONF_EN;
machine_menu.HomeFeedRateConf = HOMEFEEDRATECONF_EN;
machine_menu.PausePosition = PAUSE_POSITION_EN;
machine_menu.WifiSettings = WIFI_SETTINGS_EN;
machine_menu.HomingSensitivityConf = HOMING_SENSITIVITY_CONF_EN;
machine_menu.EncoderSettings = ENCODER_SETTINGS_EN;
machine_menu.MaxFeedRateConfTitle = MAXFEEDRATE_CONF_TITLE_EN;
machine_menu.XMaxFeedRate = X_MAXFEEDRATE_EN;
@ -692,10 +739,32 @@ void machine_setting_disp() {
machine_menu.high_level = MOTOR_EN_HIGH_LEVEL_EN;
machine_menu.low_level = MOTOR_EN_LOW_LEVEL_EN;
machine_menu.PausePosText = PAUSE_POSITION_EN;
machine_menu.xPos = PAUSE_POSITION_X_EN;
machine_menu.yPos = PAUSE_POSITION_Y_EN;
machine_menu.zPos = PAUSE_POSITION_Z_EN;
machine_menu.PausePosText = PAUSE_POSITION_EN;
machine_menu.xPos = PAUSE_POSITION_X_EN;
machine_menu.yPos = PAUSE_POSITION_Y_EN;
machine_menu.zPos = PAUSE_POSITION_Z_EN;
machine_menu.WifiConfTitle = WIFI_SETTINGS_TITLE_EN;
machine_menu.wifiMode = WIFI_SETTINGS_MODE_EN;
machine_menu.wifiName = WIFI_SETTINGS_NAME_EN;
machine_menu.wifiPassWord = WIFI_SETTINGS_PASSWORD_EN;
machine_menu.wifiCloud = WIFI_SETTINGS_CLOUD_EN;
machine_menu.wifiConfig = WIFI_SETTINGS_CONFIG_EN;
machine_menu.wifiEdit = WIFI_SETTINGS_EDIT_EN;
machine_menu.wifiConfigTips = WIFI_CONFIG_TIPS_EN;
machine_menu.OffsetConfTitle = OFFSET_TITLE_EN;
machine_menu.Xoffset = OFFSET_X_EN;
machine_menu.Yoffset = OFFSET_Y_EN;
machine_menu.Zoffset = OFFSET_Z_EN;
machine_menu.HomingSensitivityConfTitle = HOMING_SENSITIVITY_CONF_TITLE_EN;
machine_menu.X_Sensitivity = X_SENSITIVITY_EN;
machine_menu.Y_Sensitivity = Y_SENSITIVITY_EN;
machine_menu.Z_Sensitivity = Z_SENSITIVITY_EN;
machine_menu.Z2_Sensitivity = Z2_SENSITIVITY_EN;
machine_menu.EncoderConfTitle = ENCODER_CONF_TITLE_EN;
machine_menu.EncoderConfText = ENCODER_CONF_TEXT_EN;
}
}
@ -771,10 +840,6 @@ void disp_language_init() {
filament_menu.stat_temp = TEXT_VALUE;
zoffset_menu.step001 = ZOFFSET_STEP001;
zoffset_menu.step01 = ZOFFSET_STEP01;
zoffset_menu.step1 = ZOFFSET_STEP1;
machine_menu.key_0 = KEYBOARD_KEY0_EN;
machine_menu.key_1 = KEYBOARD_KEY1_EN;
machine_menu.key_2 = KEYBOARD_KEY2_EN;
@ -788,22 +853,15 @@ void disp_language_init() {
machine_menu.key_point = KEYBOARD_KEY_POINT_EN;
machine_menu.negative = KEYBOARD_KEY_NEGATIVE_EN;
// wifi-list
#if 0
list_menu.title = TEXT_WIFI_MENU_TITLE_EN;
list_menu.file_pages = FILE_PAGES_EN;
// keyboard
keyboard_menu.apply = MANUAL_IP_APPLY_EN;
keyboard_menu.password = TEXT_WIFI_PASSWORD_EN;
keyboard_menu.space = TEXT_WIFI_SAPCE_EN;
keyboard_menu.letter = TEXT_WIFI_LETTER_EN;
keyboard_menu.digital = TEXT_WIFI_DIGITAL_EN;
keyboard_menu.symbol = TEXT_WIFI_SYMBOL_EN;
#if ENABLED(USE_WIFI_FUNCTION)
list_menu.title = TEXT_WIFI_MENU_TITLE_EN;
list_menu.file_pages = FILE_PAGES_EN;
// tips
tips_menu.pointBold = TEXT_WIFI_POINT_BOLD_EN;
tips_menu.joining = TEXT_WIFI_JOINING_EN;
tips_menu.failedJoin = TEXT_WIFI_FAILED_JOIN_EN;
tips_menu.wifiConected = TEXT_WIFI_WIFI_CONECTED_EN;
#endif
#endif //USE_WIFI_FUNCTION
machine_setting_disp();
operation_menu.babystep = TEXT_BABY_STEP_EN;
@ -904,7 +962,6 @@ void disp_language_init() {
filesys_menu.usb_sys = U_DISK_TEXT_CN;
//
more_menu.title = TITLE_MORE_CN;
more_menu.zoffset = ZOFFSET_CN;
// WIFI
wifi_menu.title = WIFI_TEXT;
// wifi_menu.key = WIFI_KEY_TEXT_CN;
@ -1016,11 +1073,6 @@ void disp_language_init() {
print_file_dialog_menu.reprint = DIALOG_REPRINT_CN;
print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_CN;
// ZOFFSET
zoffset_menu.title = TITLE_ZOFFSET_CN;
zoffset_menu.inc = ZOFFSET_INC_CN;
zoffset_menu.dec = ZOFFSET_DEC_CN;
pause_msg_menu.pausing = MESSAGE_PAUSING_CN;
pause_msg_menu.changing = MESSAGE_CHANGING_CN;
pause_msg_menu.unload = MESSAGE_UNLOAD_CN;
@ -1092,7 +1144,6 @@ void disp_language_init() {
preheat_menu.step_10c = TEXT_10C_T_CN;
//
move_menu.title = MOVE_TEXT_T_CN;
more_menu.zoffset = ZOFFSET_T_CN;
//
home_menu.title = TITLE_HOME_T_CN;
home_menu.stopmove = HOME_STOPMOVE_T_CN;
@ -1249,10 +1300,6 @@ void disp_language_init() {
print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_T_CN;
print_file_dialog_menu.reprint = DIALOG_REPRINT_T_CN;
print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_T_CN;
// ZOFFSET
zoffset_menu.title = TITLE_ZOFFSET_T_CN;
zoffset_menu.inc = ZOFFSET_INC_T_CN;
zoffset_menu.dec = ZOFFSET_DEC_T_CN;
pause_msg_menu.pausing = MESSAGE_PAUSING_T_CN;
pause_msg_menu.changing = MESSAGE_CHANGING_T_CN;
@ -1359,7 +1406,6 @@ void disp_language_init() {
set_menu.machine_para = MACHINE_PARA_EN;
set_menu.eepromSet = EEPROM_SETTINGS_EN;
more_menu.title = TITLE_MORE_EN;
more_menu.zoffset = ZOFFSET_EN;
//
filesys_menu.title = TITLE_FILESYS_EN;
filesys_menu.sd_sys = SD_CARD_TEXT_EN;
@ -1469,10 +1515,6 @@ void disp_language_init() {
print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_EN;
print_file_dialog_menu.reprint = DIALOG_REPRINT_EN;
print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_EN;
// ZOFFSET
zoffset_menu.title = TITLE_ZOFFSET_EN;
zoffset_menu.inc = ZOFFSET_INC_EN;
zoffset_menu.dec = ZOFFSET_DEC_EN;
pause_msg_menu.pausing = MESSAGE_PAUSING_EN;
pause_msg_menu.changing = MESSAGE_CHANGING_EN;
@ -1579,7 +1621,6 @@ void disp_language_init() {
set_menu.machine_para = MACHINE_PARA_RU;
set_menu.eepromSet = EEPROM_SETTINGS_RU;
more_menu.title = TITLE_MORE_RU;
more_menu.zoffset = ZOFFSET_RU;
//
filesys_menu.title = TITLE_FILESYS_RU;
filesys_menu.sd_sys = SD_CARD_TEXT_RU;
@ -1689,10 +1730,6 @@ void disp_language_init() {
print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_RU;
print_file_dialog_menu.reprint = DIALOG_REPRINT_RU;
print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_RU;
// ZOFFSET
zoffset_menu.title = TITLE_ZOFFSET_RU;
zoffset_menu.inc = ZOFFSET_INC_RU;
zoffset_menu.dec = ZOFFSET_DEC_RU;
pause_msg_menu.pausing = MESSAGE_PAUSING_RU;
pause_msg_menu.changing = MESSAGE_CHANGING_RU;
@ -1803,7 +1840,6 @@ void disp_language_init() {
set_menu.machine_para = MACHINE_PARA_SP;
set_menu.eepromSet = EEPROM_SETTINGS_SP;
more_menu.title = TITLE_MORE_SP;
more_menu.zoffset = ZOFFSET_SP;
//
filesys_menu.title = TITLE_FILESYS_SP;
filesys_menu.sd_sys = SD_CARD_TEXT_SP;
@ -1914,10 +1950,6 @@ void disp_language_init() {
print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_SP;
print_file_dialog_menu.reprint = DIALOG_REPRINT_SP;
print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_SP;
// ZOFFSET
zoffset_menu.title = TITLE_ZOFFSET_SP;
zoffset_menu.inc = ZOFFSET_INC_SP;
zoffset_menu.dec = ZOFFSET_DEC_SP;
pause_msg_menu.pausing = MESSAGE_PAUSING_SP;
pause_msg_menu.changing = MESSAGE_CHANGING_SP;
@ -2025,7 +2057,6 @@ void disp_language_init() {
set_menu.machine_para = MACHINE_PARA_FR;
set_menu.eepromSet = EEPROM_SETTINGS_FR;
more_menu.title = TITLE_MORE_FR;
more_menu.zoffset = ZOFFSET_FR;
//
filesys_menu.title = TITLE_FILESYS_FR;
filesys_menu.sd_sys = SD_CARD_TEXT_FR;
@ -2137,10 +2168,6 @@ void disp_language_init() {
print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_FR;
print_file_dialog_menu.reprint = DIALOG_REPRINT_FR;
print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_FR;
// ZOFFSET
zoffset_menu.title = TITLE_ZOFFSET_FR;
zoffset_menu.inc = ZOFFSET_INC_FR;
zoffset_menu.dec = ZOFFSET_DEC_FR;
pause_msg_menu.pausing = MESSAGE_PAUSING_FR;
pause_msg_menu.changing = MESSAGE_CHANGING_FR;
@ -2249,7 +2276,6 @@ void disp_language_init() {
set_menu.machine_para = MACHINE_PARA_IT;
set_menu.eepromSet = EEPROM_SETTINGS_IT;
more_menu.title = TITLE_MORE_IT;
more_menu.zoffset = ZOFFSET_IT;
//
filesys_menu.title = TITLE_FILESYS_IT;
filesys_menu.sd_sys = SD_CARD_TEXT_IT;
@ -2358,10 +2384,6 @@ void disp_language_init() {
print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_IT;
print_file_dialog_menu.reprint = DIALOG_REPRINT_IT;
print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_IT;
// ZOFFSET
zoffset_menu.title = TITLE_ZOFFSET_IT;
zoffset_menu.inc = ZOFFSET_INC_IT;
zoffset_menu.dec = ZOFFSET_DEC_IT;
pause_msg_menu.pausing = MESSAGE_PAUSING_IT;
pause_msg_menu.changing = MESSAGE_CHANGING_IT;
@ -2472,7 +2494,6 @@ void disp_language_init() {
set_menu.eepromSet = EEPROM_SETTINGS_EN;
//
more_menu.title = TITLE_MORE_EN;
more_menu.zoffset = ZOFFSET_EN;
//
filesys_menu.title = TITLE_FILESYS_EN;
filesys_menu.sd_sys = SD_CARD_TEXT_EN;
@ -2582,10 +2603,6 @@ void disp_language_init() {
print_file_dialog_menu.print_time = DIALOG_PRINT_TIME_EN;
print_file_dialog_menu.reprint = DIALOG_REPRINT_EN;
print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_EN;
// ZOFFSET
zoffset_menu.title = TITLE_ZOFFSET_EN;
zoffset_menu.inc = ZOFFSET_INC_EN;
zoffset_menu.dec = ZOFFSET_DEC_EN;
pause_msg_menu.pausing = MESSAGE_PAUSING_EN;
pause_msg_menu.changing = MESSAGE_CHANGING_EN;

75
Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.h

@ -60,7 +60,6 @@ typedef struct machine_common_disp{
const char *HomeDir;
const char *EndStopType;
const char *FilamentConf;
const char *LevelingConf;
const char *MachineTypeConfTitle;
const char *xyz;
@ -96,17 +95,17 @@ typedef struct machine_common_disp{
const char *closed;
const char *FilamentConfTitle;
const char *InTemperature;
const char *InLength;
const char *InSpeed;
const char *OutTemperature;
const char *FilamentTemperature;
const char *OutLength;
const char *OutSpeed;
const char *LevelingParaConfTitle;
const char *LevelingParaConf;
const char *DeltaLevelConf;
const char *XYZLevelconf;
const char *LevelingManuPosConf;
const char *LevelingAutoCommandConf;
const char *LevelingAutoZoffsetConf;
const char *LevelingSubConfTitle;
const char *AutoLevelEnable;
@ -165,6 +164,7 @@ typedef struct machine_common_disp{
const char *HomeFeedRateConf;
const char *TMCcurrentConf;
const char *TMCStepModeConf;
const char *HomingSensitivityConf;
const char *MaxFeedRateConfTitle;
const char *XMaxFeedRate;
@ -210,6 +210,12 @@ typedef struct machine_common_disp{
const char *E0_StepMode;
const char *E1_StepMode;
const char *HomingSensitivityConfTitle;
const char *X_Sensitivity;
const char *Y_Sensitivity;
const char *Z_Sensitivity;
const char *Z2_Sensitivity;
const char *MotorDirConfTitle;
const char *X_MotorDir;
const char *Y_MotorDir;
@ -231,6 +237,8 @@ typedef struct machine_common_disp{
const char *Z2andZ2Endstop;
const char *EnablePinsInvert;
const char *PausePosition;
const char *WifiSettings;
const char *EncoderSettings;
const char *Z2ConfTitle;
const char *Z2Enable;
@ -266,6 +274,23 @@ typedef struct machine_common_disp{
const char *yPos;
const char *zPos;
const char *WifiConfTitle;
const char *wifiMode;
const char *wifiName;
const char *wifiPassWord;
const char *wifiCloud;
const char *wifiConfig;
const char *wifiEdit;
const char *wifiConfigTips;
const char *OffsetConfTitle;
const char *Xoffset;
const char *Yoffset;
const char *Zoffset;
const char *EncoderConfTitle;
const char *EncoderConfText;
} machine_common_def;
extern machine_common_def machine_menu;
@ -435,7 +460,6 @@ extern filesys_menu_def filesys_menu;
typedef struct more_menu_disp {
const char *title;
const char *zoffset;
const char *back;
} more_menu_def;
@ -661,18 +685,6 @@ typedef struct print_file_dialog_disp {
extern print_file_dialog_menu_def print_file_dialog_menu;
typedef struct zoffset_menu_disp {
const char *title;
const char *inc;
const char *dec;
const char *step001;
const char *step01;
const char *step1;
const char *back;
} zoffset_menu_def;
extern zoffset_menu_def zoffset_menu;
typedef struct tool_menu_disp {
const char *title;
const char *preheat;
@ -691,37 +703,13 @@ extern tool_menu_def tool_menu;
typedef struct MachinePara_menu_disp {
const char *title;
const char *MachineSetting;
const char *TemperatureSetting;
const char *MotorSetting;
const char *leveling;
const char *AdvanceSetting;
//const char *back;
} MachinePara_menu_def;
extern MachinePara_menu_def MachinePara_menu;
typedef struct MachineSettings_menu_disp {
const char *title;
const char *Machine;
const char *Stroke;
const char *HomeDir;
const char *EndStopType;
const char *filamet;
const char *leveling;
const char *back;
} MachineSettings_menu_def;
extern MachineSettings_menu_def MachineSettings_menu;
typedef struct TemperatureSettings_menu_disp {
const char *title;
const char *nozzle;
const char *hotbed;
const char *preheat;
const char *back;
} TemperatureSettings_menu_def;
extern TemperatureSettings_menu_def TemperatureSettings_menu;
typedef struct pause_msg_disp {
const char *pausing;
const char *changing;
@ -842,6 +830,7 @@ extern eeprom_def eeprom_menu;
#define DIALOG_UPLOAD_SPEED_EN "Speed"
#define DIALOG_UPDATE_WIFI_FIRMWARE_EN "Updating wifi model firmware"
#define DIALOG_UPDATE_WIFI_WEB_EN "Updating wifi model web data"
#define DIALOG_UPDATE_NO_DEVICE_EN "please check \nwether memory device insert!"
#define ZOFFSET_STEP001 "0.01mm"
#define ZOFFSET_STEP01 "0.1mm"

120
Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.cpp

@ -0,0 +1,120 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI
#include "draw_ui.h"
#include "wifiSerial.h"
#if ENABLED(USE_WIFI_FUNCTION)
#include <libmaple/libmaple.h>
#include <libmaple/gpio.h>
#include <libmaple/timer.h>
#include <libmaple/usart.h>
#include <libmaple/ring_buffer.h>
#include "../../../../MarlinCore.h"
DEFINE_WFSERIAL(WifiSerial1, 1);
WifiSerial::WifiSerial(usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin) {
this->usart_device = usart_device;
this->tx_pin = tx_pin;
this->rx_pin = rx_pin;
}
/**
* Set up / tear down
*/
#if STM32_MCU_SERIES == STM32_SERIES_F1
/* F1 MCUs have no GPIO_AFR[HL], so turn off PWM if there's a conflict
* on this GPIO bit. */
static void disable_timer_if_necessary(timer_dev *dev, uint8 ch) {
if (dev != nullptr) timer_set_mode(dev, ch, TIMER_DISABLED);
}
#elif STM32_MCU_SERIES == STM32_SERIES_F2 || STM32_MCU_SERIES == STM32_SERIES_F4
#define disable_timer_if_necessary(dev, ch) ((void)0)
#else
#warning "Unsupported STM32 series; timer conflicts are possible"
#endif
void WifiSerial::begin(uint32 baud) { begin(baud, SERIAL_8N1); }
/**
* Roger Clark.
* Note. The config parameter is not currently used. This is a work in progress.
* Code needs to be written to set the config of the hardware serial control register in question.
*/
void WifiSerial::begin(uint32 baud, uint8_t config) {
//ASSERT(baud <= this->usart_device->max_baud); // Roger Clark. Assert doesn't do anything useful, we may as well save the space in flash and ram etc
if (baud > this->usart_device->max_baud) return;
const stm32_pin_info *txi = &PIN_MAP[this->tx_pin],
*rxi = &PIN_MAP[this->rx_pin];
disable_timer_if_necessary(txi->timer_device, txi->timer_channel);
usart_init(this->usart_device);
// Reinitialize the receive buffer, mks_esp8266 fixed data frame length is 1k bytes
rb_init(this->usart_device->rb, WIFI_RX_BUF_SIZE, wifiRxBuf);
usart_config_gpios_async(this->usart_device,
rxi->gpio_device, rxi->gpio_bit,
txi->gpio_device, txi->gpio_bit,
config);
usart_set_baud_rate(this->usart_device, USART_USE_PCLK, baud);
usart_enable(this->usart_device);
}
void WifiSerial::end(void) {
usart_disable(this->usart_device);
}
int WifiSerial::available(void) {
return usart_data_available(this->usart_device);
}
//
// I/O
//
int WifiSerial::read(void) {
if (usart_data_available(usart_device) <= 0) return -1;
return usart_getc(usart_device);
}
int WifiSerial::write(unsigned char ch) {
usart_putc(this->usart_device, ch);
return 1;
}
int WifiSerial::wifi_rb_is_full(void) {
return rb_is_full(this->usart_device->rb);
}
#endif // USE_WIFI_FUNCTION
#endif // HAS_TFT_LVGL_UI

102
Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.h

@ -0,0 +1,102 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "tft_lvgl_configuration.h"
#if ENABLED(USE_WIFI_FUNCTION)
#if SERIAL_PORT_2 != -1
#error "SERIAL_PORT_2 must be set to -1 with HAS_TFT_LVGL_UI and USE_WIFI_FUNCTION."
#endif
#define WIFI_BAUDRATE 115200
#define WIFI_UPLOAD_BAUDRATE 1958400
#define USART_SAFE_INSERT
#define WIFI_RX_BUF_SIZE (1024+1)
#include <libmaple/libmaple_types.h>
#include <libmaple/usart.h>
#include <libmaple/libmaple.h>
#include <libmaple/gpio.h>
#include <libmaple/timer.h>
#include <libmaple/ring_buffer.h>
#define DEFINE_WFSERIAL(name, n)\
WifiSerial name(USART##n, \
BOARD_USART##n##_TX_PIN, \
BOARD_USART##n##_RX_PIN)
class WifiSerial {
public:
uint8 wifiRxBuf[WIFI_RX_BUF_SIZE];
public:
WifiSerial(struct usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin);
/* Set up/tear down */
void begin(uint32 baud);
void begin(uint32 baud,uint8_t config);
void end();
int available(void);
int read(void);
int write(uint8_t);
inline void wifi_usart_irq(usart_reg_map *regs) {
/* Handling RXNEIE and TXEIE interrupts.
* RXNE signifies availability of a byte in DR.
*
* See table 198 (sec 27.4, p809) in STM document RM0008 rev 15.
* We enable RXNEIE.
*/
if ((regs->CR1 & USART_CR1_RXNEIE) && (regs->SR & USART_SR_RXNE)) {
#ifdef USART_SAFE_INSERT
/* If the buffer is full and the user defines USART_SAFE_INSERT,
* ignore new bytes. */
rb_safe_insert(this->usart_device->rb, (uint8)regs->DR);
#else
/* By default, push bytes around in the ring buffer. */
rb_push_insert(this->usart_device->rb, (uint8)regs->DR);
#endif
}
/* TXE signifies readiness to send a byte to DR. */
if ((regs->CR1 & USART_CR1_TXEIE) && (regs->SR & USART_SR_TXE)) {
if (!rb_is_empty(this->usart_device->wb))
regs->DR=rb_remove(this->usart_device->wb);
else
regs->CR1 &= ~((uint32)USART_CR1_TXEIE); // disable TXEIE
}
}
int wifi_rb_is_full(void);
private:
struct usart_dev *usart_device;
uint8 tx_pin;
uint8 rx_pin;
};
extern WifiSerial WifiSerial1;
#define WIFISERIAL WifiSerial1
#endif // USE_WIFI_FUNCTION

1927
Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp

File diff suppressed because it is too large

202
Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h

@ -0,0 +1,202 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#ifdef __cplusplus
extern "C" { /* C-declarations for C++ */
#endif
#include "../../inc/MarlinConfigPre.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define UART_RX_BUFFER_SIZE 1024
#define UART_FIFO_BUFFER_SIZE 1024
#define ESP_WIFI 0x02
#define AP_MODEL 0x01
#define STA_MODEL 0x02
#define WIFI_DECODE_TYPE 1
#define IP_DHCP_FLAG 1
#define WIFI_AP_NAME "TP-LINK_MKS"
#define WIFI_KEY_CODE "makerbase"
#define IP_ADDR "192.168.3.100"
#define IP_MASK "255.255.255.0"
#define IP_GATE "192.168.3.1"
#define IP_DNS "192.168.3.1"
#define AP_IP_DHCP_FLAG 1
#define AP_IP_ADDR "192.168.3.100"
#define AP_IP_MASK "255.255.255.0"
#define AP_IP_GATE "192.168.3.1"
#define AP_IP_DNS "192.168.3.1"
#define IP_START_IP "192.168.3.1"
#define IP_END_IP "192.168.3.255"
#define UDISKBUFLEN 1024
typedef enum{
udisk_buf_empty = 0,
udisk_buf_full,
} UDISK_DATA_BUFFER_STATE;
#define TRANS_RCV_FIFO_BLOCK_NUM 8
typedef struct {
unsigned char *bufferAddr[TRANS_RCV_FIFO_BLOCK_NUM];
unsigned char *p;
UDISK_DATA_BUFFER_STATE state[TRANS_RCV_FIFO_BLOCK_NUM];
unsigned char read_cur;
unsigned char write_cur;
} WIFI_DMA_RCV_FIFO;
typedef struct {
uint8_t flag; // 0x0: no error; 0x01: error
uint32_t start_tick; //error start time
uint32_t now_tick;
} WIFI_TRANS_ERROR;
extern volatile WIFI_TRANS_ERROR wifiTransError;
typedef struct {
char ap_name[32]; //wifi-name
char keyCode[64]; //wifi password
int decodeType;
int baud;
int mode;
} WIFI_PARA;
typedef struct {
char state;
char hostUrl[96];
int port;
char id[21];
} CLOUD_PARA;
typedef struct {
char dhcp_flag;
char ip_addr[16];
char mask[16];
char gate[16];
char dns[16];
char dhcpd_flag;
char dhcpd_ip[16];
char dhcpd_mask[16];
char dhcpd_gate[16];
char dhcpd_dns[16];
char start_ip_addr[16];
char end_ip_addr[16];
} IP_PARA;
typedef enum {
WIFI_NOT_CONFIG,
WIFI_CONFIG_MODE,
WIFI_CONFIG_DHCP,
WIFI_CONFIG_AP,
WIFI_CONFIG_IP_INF,
WIFI_CONFIG_DNS,
WIFI_CONFIG_TCP,
WIFI_CONFIG_SERVER,
WIFI_CONFIG_REMOTE_PORT,
WIFI_CONFIG_BAUD,
WIFI_CONFIG_COMMINT,
WIFI_CONFIG_OK,
WIFI_GET_IP_OK,
WIFI_RECONN,
WIFI_CONNECTED,
WIFI_WAIT_TRANS_START,
WIFI_TRANS_FILE,
WIFI_CONFIG_DHCPD,
WIFI_COFIG_DHCPD_IP,
WIFI_COFIG_DHCPD_DNS,
WIFI_EXCEPTION,
} WIFI_STATE;
typedef enum {
TRANSFER_IDLE,
TRANSFERING,
TRANSFER_STORE,
} TRANSFER_STATE;
extern volatile TRANSFER_STATE esp_state;
typedef struct {
char buf[20][80];
int rd_index;
int wt_index;
} QUEUE;
typedef enum {
WIFI_PARA_SET, // 0x0:net parameter
WIFI_PRINT_INF, // 0x1:print message
WIFI_TRANS_INF, // 0x2:Pass through information
WIFI_EXCEP_INF, // 0x3:Exception information
WIFI_CLOUD_CFG, // 0x4:cloud config
WIFI_CLOUD_UNBIND, // 0x5:Unbind ID
} WIFI_RET_TYPE;
typedef struct {
uint32_t uart_read_point;
uint32_t uart_write_point;
uint8_t uartTxBuffer[UART_FIFO_BUFFER_SIZE];
} SZ_USART_FIFO;
#define WIFI_GCODE_BUFFER_LEAST_SIZE 96
#define WIFI_GCODE_BUFFER_SIZE (WIFI_GCODE_BUFFER_LEAST_SIZE * 3)
typedef struct {
uint8_t wait_tick;
uint8_t Buffer[WIFI_GCODE_BUFFER_SIZE];
uint32_t r;
uint32_t w;
} WIFI_GCODE_BUFFER;
extern volatile WIFI_STATE wifi_link_state;
extern WIFI_PARA wifiPara;
extern IP_PARA ipPara;
extern CLOUD_PARA cloud_para;
extern WIFI_GCODE_BUFFER espGcodeFifo;
extern uint32_t getWifiTick();
extern uint32_t getWifiTickDiff(int32_t lastTick, int32_t curTick);
extern void mks_esp_wifi_init();
extern int cfg_cloud_flag;
extern int send_to_wifi(char *buf, int len);
extern void wifi_looping();
extern int raw_send_to_wifi(char *buf, int len);
extern int package_to_wifi(WIFI_RET_TYPE type,char *buf, int len);
extern void get_wifi_list_command_send();
extern void get_wifi_commands();
extern int readWifiBuf(int8_t *buf, int32_t len);
extern int storeRcvData(int32_t len);
#ifdef __cplusplus
} /* C-declarations for C++ */
#endif

847
Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp

@ -0,0 +1,847 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI
#include "draw_ui.h"
#include "wifi_module.h"
#include "wifi_upload.h"
#include "../../../../MarlinCore.h"
#define WIFI_SET() WRITE(WIFI_RESET_PIN, HIGH);
#define WIFI_RESET() WRITE(WIFI_RESET_PIN, LOW);
#define WIFI_IO1_SET() WRITE(WIFI_IO1_PIN, HIGH);
#define WIFI_IO1_RESET() WRITE(WIFI_IO1_PIN, LOW);
extern SZ_USART_FIFO WifiRxFifo;
extern int readUsartFifo(SZ_USART_FIFO *fifo, int8_t *buf, int32_t len);
extern int writeUsartFifo(SZ_USART_FIFO * fifo, int8_t * buf, int32_t len);
extern void esp_port_begin(uint8_t interrupt);
extern int usartFifoAvailable(SZ_USART_FIFO *fifo);
extern void wifi_delay(int n);
#define ARRAY_SIZE(a) sizeof(a) / sizeof((a)[0])
//typedef signed char bool;
// ESP8266 command codes
const uint8_t ESP_FLASH_BEGIN = 0x02;
const uint8_t ESP_FLASH_DATA = 0x03;
const uint8_t ESP_FLASH_END = 0x04;
const uint8_t ESP_MEM_BEGIN = 0x05;
const uint8_t ESP_MEM_END = 0x06;
const uint8_t ESP_MEM_DATA = 0x07;
const uint8_t ESP_SYNC = 0x08;
const uint8_t ESP_WRITE_REG = 0x09;
const uint8_t ESP_READ_REG = 0x0a;
// MAC address storage locations
const uint32_t ESP_OTP_MAC0 = 0x3ff00050;
const uint32_t ESP_OTP_MAC1 = 0x3ff00054;
const uint32_t ESP_OTP_MAC2 = 0x3ff00058;
const uint32_t ESP_OTP_MAC3 = 0x3ff0005c;
const size_t EspFlashBlockSize = 0x0400; // 1K byte blocks
const uint8_t ESP_IMAGE_MAGIC = 0xe9;
const uint8_t ESP_CHECKSUM_MAGIC = 0xef;
const uint32_t ESP_ERASE_CHIP_ADDR = 0x40004984; // &SPIEraseChip
const uint32_t ESP_SEND_PACKET_ADDR = 0x40003c80; // &send_packet
const uint32_t ESP_SPI_READ_ADDR = 0x40004b1c; // &SPIRead
const uint32_t ESP_UNKNOWN_ADDR = 0x40001121; // not used
const uint32_t ESP_USER_DATA_RAM_ADDR = 0x3ffe8000; // &user data ram
const uint32_t ESP_IRAM_ADDR = 0x40100000; // instruction RAM
const uint32_t ESP_FLASH_ADDR = 0x40200000; // address of start of Flash
//const uint32_t ESP_FLASH_READ_STUB_BEGIN = IRAM_ADDR + 0x18;
UPLOAD_STRUCT esp_upload;
static const unsigned int retriesPerReset = 3;
static const uint32_t connectAttemptInterval = 50;
static const unsigned int percentToReportIncrement = 5; // how often we report % complete
static const uint32_t defaultTimeout = 500;
static const uint32_t eraseTimeout = 15000;
static const uint32_t blockWriteTimeout = 200;
static const uint32_t blockWriteInterval = 15; // 15ms is long enough, 10ms is mostly too short
// Messages corresponding to result codes, should make sense when followed by " error"
const char *resultMessages[] = {
"no",
"timeout",
"comm write",
"connect",
"bad reply",
"file read",
"empty file",
"response header",
"slip frame",
"slip state",
"slip data"
};
// A note on baud rates.
// The ESP8266 supports 921600, 460800, 230400, 115200, 74880 and some lower baud rates.
// 921600b is not reliable because even though it sometimes succeeds in connecting, we get a bad response during uploading after a few blocks.
// Probably our UART ISR cannot receive bytes fast enough, perhaps because of the latency of the system tick ISR.
// 460800b doesn't always manage to connect, but if it does then uploading appears to be reliable.
// 230400b always manages to connect.
static const uint32_t uploadBaudRates[] = { 460800, 230400, 115200, 74880 };
signed char IsReady() {
return esp_upload.state == upload_idle;
}
void uploadPort_write(const uint8_t *buf, size_t len) {
#if 0
int i;
for(i = 0; i < len; i++) {
while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET);
USART_SendData(USART1, *(buf + i));
}
#endif
}
char uploadPort_read() {
uint8_t retChar;
if (readUsartFifo(&WifiRxFifo, (int8_t *)&retChar, 1) == 1)
return retChar;
else
return 0;
}
int uploadPort_available() {
return usartFifoAvailable(&WifiRxFifo);
}
void uploadPort_begin() {
esp_port_begin(1);
}
void uploadPort_close() {
//WIFI_COM.end();
//WIFI_COM.begin(115200, true);
esp_port_begin(0);
}
void flushInput() {
while (uploadPort_available() != 0) {
(void)uploadPort_read();
//IWDG_ReloadCounter();
}
}
// Extract 1-4 bytes of a value in little-endian order from a buffer beginning at a specified offset
uint32_t getData(unsigned byteCnt, const uint8_t *buf, int ofst) {
uint32_t val = 0;
if (buf && byteCnt) {
unsigned int shiftCnt = 0;
if (byteCnt > 4)
byteCnt = 4;
do{
val |= (uint32_t)buf[ofst++] << shiftCnt;
shiftCnt += 8;
} while (--byteCnt);
}
return(val);
}
// Put 1-4 bytes of a value in little-endian order into a buffer beginning at a specified offset.
void putData(uint32_t val, unsigned byteCnt, uint8_t *buf, int ofst) {
if (buf && byteCnt) {
if (byteCnt > 4) {
byteCnt = 4;
}
do {
buf[ofst++] = (uint8_t)(val & 0xff);
val >>= 8;
} while (--byteCnt);
}
}
// Read a byte optionally performing SLIP decoding. The return values are:
//
// 2 - an escaped byte was read successfully
// 1 - a non-escaped byte was read successfully
// 0 - no data was available
// -1 - the value 0xc0 was encountered (shouldn't happen)
// -2 - a SLIP escape byte was found but the following byte wasn't available
// -3 - a SLIP escape byte was followed by an invalid byte
int ReadByte(uint8_t *data, signed char slipDecode) {
if (uploadPort_available() == 0) {
return(0);
}
// at least one byte is available
*data = uploadPort_read();
if (!slipDecode) {
return(1);
}
if (*data == 0xc0) {
// this shouldn't happen
return(-1);
}
// if not the SLIP escape, we're done
if (*data != 0xdb) {
return(1);
}
// SLIP escape, check availability of subsequent byte
if (uploadPort_available() == 0) {
return(-2);
}
// process the escaped byte
*data = uploadPort_read();
if (*data == 0xdc) {
*data = 0xc0;
return(2);
}
if (*data == 0xdd) {
*data = 0xdb;
return(2);
}
// invalid
return(-3);
}
// When we write a sync packet, there must be no gaps between most of the characters.
// So use this function, which does a block write to the UART buffer in the latest CoreNG.
void _writePacketRaw(const uint8_t *buf, size_t len) {
uploadPort_write(buf, len);
}
// Write a byte to the serial port optionally SLIP encoding. Return the number of bytes actually written.
void WriteByteRaw(uint8_t b) {
uploadPort_write((const uint8_t *)&b, 1);
}
// Write a byte to the serial port optionally SLIP encoding. Return the number of bytes actually written.
void WriteByteSlip(uint8_t b) {
if (b == 0xC0) {
WriteByteRaw(0xDB);
WriteByteRaw(0xDC);
}
else if (b == 0xDB) {
WriteByteRaw(0xDB);
WriteByteRaw(0xDD);
}
else {
uploadPort_write((const uint8_t *)&b, 1);
}
}
// Wait for a data packet to be returned. If the body of the packet is
// non-zero length, return an allocated buffer indirectly containing the
// data and return the data length. Note that if the pointer for returning
// the data buffer is NULL, the response is expected to be two bytes of zero.
//
// If an error occurs, return a negative value. Otherwise, return the number
// of bytes in the response (or zero if the response was not the standard "two bytes of zero").
EspUploadResult readPacket(uint8_t op, uint32_t *valp, size_t *bodyLen, uint32_t msTimeout) {
typedef enum {
begin = 0,
header,
body,
end,
done
} PacketState;
uint8_t resp, opRet;
const size_t headerLength = 8;
uint32_t startTime = getWifiTick();
uint8_t hdr[headerLength];
uint16_t hdrIdx = 0;
uint16_t bodyIdx = 0;
uint8_t respBuf[2];
// wait for the response
uint16_t needBytes = 1;
PacketState state = begin;
*bodyLen = 0;
while (state != done) {
uint8_t c;
EspUploadResult stat;
//IWDG_ReloadCounter();
if (getWifiTickDiff(startTime, getWifiTick()) > msTimeout) {
return(timeout);
}
if (uploadPort_available() < needBytes) {
// insufficient data available
// preferably, return to Spin() here
continue;
}
// sufficient bytes have been received for the current state, process them
switch(state) {
case begin: // expecting frame start
c = uploadPort_read();
if (c != (uint8_t)0xc0) {
break;
}
state = header;
needBytes = 2;
break;
case end: // expecting frame end
c = uploadPort_read();
if (c != (uint8_t)0xc0) {
return slipFrame;
}
state = done;
break;
case header: // reading an 8-byte header
case body: // reading the response body
{
int rslt;
// retrieve a byte with SLIP decoding
rslt = ReadByte(&c, 1);
if (rslt != 1 && rslt != 2) {
// some error occurred
stat = (rslt == 0 || rslt == -2) ? slipData : slipFrame;
return stat;
}
else if (state == header) {
//store the header byte
hdr[hdrIdx++] = c;
if (hdrIdx >= headerLength) {
// get the body length, prepare a buffer for it
*bodyLen = (uint16_t)getData(2, hdr, 2);
// extract the value, if requested
if (valp != 0) {
*valp = getData(4, hdr, 4);
}
if (*bodyLen != 0) {
state = body;
}
else {
needBytes = 1;
state = end;
}
}
}
else {
// Store the response body byte, check for completion
if (bodyIdx < ARRAY_SIZE(respBuf)) {
respBuf[bodyIdx] = c;
}
++bodyIdx;
if (bodyIdx >= *bodyLen) {
needBytes = 1;
state = end;
}
}
}
break;
default: // this shouldn't happen
return slipState;
}
}
// Extract elements from the header
resp = (uint8_t)getData(1, hdr, 0);
opRet = (uint8_t)getData(1, hdr, 1);
// Sync packets often provoke a response with a zero opcode instead of ESP_SYNC
if (resp != 0x01 || opRet != op) {
//debug//printf("resp %02x %02x\n", resp, opRet);
return respHeader;
}
return success;
}
// Send a block of data performing SLIP encoding of the content.
void _writePacket(const uint8_t *data, size_t len) {
unsigned char outBuf[2048] = {0};
unsigned int outIndex = 0;
while (len != 0) {
if (*data == 0xC0) {
outBuf[outIndex++] = 0xDB;
outBuf[outIndex++] = 0xDC;
}
else if (*data == 0xDB) {
outBuf[outIndex++] = 0xDB;
outBuf[outIndex++] = 0xDD;
}
else {
outBuf[outIndex++] = *data;
}
data++;
--len;
}
uploadPort_write((const uint8_t *)outBuf, outIndex);
}
// Send a packet to the serial port while performing SLIP framing. The packet data comprises a header and an optional data block.
// A SLIP packet begins and ends with 0xc0. The data encapsulated has the bytes
// 0xc0 and 0xdb replaced by the two-byte sequences {0xdb, 0xdc} and {0xdb, 0xdd} respectively.
void writePacket(const uint8_t *hdr, size_t hdrLen, const uint8_t *data, size_t dataLen) {
WriteByteRaw(0xc0); // send the packet start character
_writePacket(hdr, hdrLen); // send the header
_writePacket(data, dataLen); // send the data block
WriteByteRaw(0xc0); // send the packet end character
}
// Send a packet to the serial port while performing SLIP framing. The packet data comprises a header and an optional data block.
// This is like writePacket except that it does a fast block write for both the header and the main data with no SLIP encoding. Used to send sync commands.
void writePacketRaw(const uint8_t *hdr, size_t hdrLen, const uint8_t *data, size_t dataLen) {
WriteByteRaw(0xc0); // send the packet start character
_writePacketRaw(hdr, hdrLen); // send the header
_writePacketRaw(data, dataLen); // send the data block in raw mode
WriteByteRaw(0xc0); // send the packet end character
}
// Send a command to the attached device together with the supplied data, if any.
// The data is supplied via a list of one or more segments.
void sendCommand(uint8_t op, uint32_t checkVal, const uint8_t *data, size_t dataLen) {
// populate the header
uint8_t hdr[8];
putData(0, 1, hdr, 0);
putData(op, 1, hdr, 1);
putData(dataLen, 2, hdr, 2);
putData(checkVal, 4, hdr, 4);
// send the packet
//flushInput();
if (op == ESP_SYNC) {
writePacketRaw(hdr, sizeof(hdr), data, dataLen);
}
else {
writePacket(hdr, sizeof(hdr), data, dataLen);
}
}
// Send a command to the attached device together with the supplied data, if any, and get the response
EspUploadResult doCommand(uint8_t op, const uint8_t *data, size_t dataLen, uint32_t checkVal, uint32_t *valp, uint32_t msTimeout) {
size_t bodyLen;
EspUploadResult stat;
sendCommand(op, checkVal, data, dataLen);
stat = readPacket(op, valp, &bodyLen, msTimeout);
if (stat == success && bodyLen != 2) {
stat = badReply;
}
return stat;
}
// Send a synchronising packet to the serial port in an attempt to induce
// the ESP8266 to auto-baud lock on the baud rate.
EspUploadResult Sync(uint16_t timeout) {
uint8_t buf[36];
EspUploadResult stat;
int i ;
// compose the data for the sync attempt
memset(buf, 0x55, sizeof(buf));
buf[0] = 0x07;
buf[1] = 0x07;
buf[2] = 0x12;
buf[3] = 0x20;
stat = doCommand(ESP_SYNC, buf, sizeof(buf), 0, 0, timeout);
// If we got a response other than sync, discard it and wait for a sync response. This happens at higher baud rates.
for (i = 0; i < 10 && stat == respHeader; ++i) {
size_t bodyLen;
stat = readPacket(ESP_SYNC, 0, &bodyLen, timeout);
}
if (stat == success) {
// Read and discard additional replies
for (;;) {
size_t bodyLen;
EspUploadResult rc = readPacket(ESP_SYNC, 0, &bodyLen, defaultTimeout);
if (rc != success || bodyLen != 2) {
break;
}
}
}
//DEBUG
//else debug//printf("stat=%d\n", (int)stat);
return stat;
}
// Send a command to the device to begin the Flash process.
EspUploadResult flashBegin(uint32_t addr, uint32_t size) {
// determine the number of blocks represented by the size
uint32_t blkCnt;
uint8_t buf[16];
uint32_t timeout;
blkCnt = (size + EspFlashBlockSize - 1) / EspFlashBlockSize;
// ensure that the address is on a block boundary
addr &= ~(EspFlashBlockSize - 1);
// begin the Flash process
putData(size, 4, buf, 0);
putData(blkCnt, 4, buf, 4);
putData(EspFlashBlockSize, 4, buf, 8);
putData(addr, 4, buf, 12);
timeout = (size != 0) ? eraseTimeout : defaultTimeout;
return doCommand(ESP_FLASH_BEGIN, buf, sizeof(buf), 0, 0, timeout);
}
// Send a command to the device to terminate the Flash process
EspUploadResult flashFinish(signed char reboot) {
uint8_t buf[4];
putData(reboot ? 0 : 1, 4, buf, 0);
return doCommand(ESP_FLASH_END, buf, sizeof(buf), 0, 0, defaultTimeout);
}
// Compute the checksum of a block of data
uint16_t checksum(const uint8_t *data, uint16_t dataLen, uint16_t cksum) {
if (data != NULL) {
while (dataLen--) {
cksum ^= (uint16_t)*data++;
}
}
return(cksum);
}
EspUploadResult flashWriteBlock(uint16_t flashParmVal, uint16_t flashParmMask) {
#if 0
const uint32_t blkSize = EspFlashBlockSize;
int i;
// Allocate a data buffer for the combined header and block data
const uint16_t hdrOfst = 0;
const uint16_t dataOfst = 16;
const uint16_t blkBufSize = dataOfst + blkSize;
uint32_t blkBuf32[blkBufSize/4];
uint8_t * const blkBuf = (uint8_t*)(blkBuf32);
uint32_t cnt;
uint16_t cksum;
EspUploadResult stat;
// Prepare the header for the block
putData(blkSize, 4, blkBuf, hdrOfst + 0);
putData(esp_upload.uploadBlockNumber, 4, blkBuf, hdrOfst + 4);
putData(0, 4, blkBuf, hdrOfst + 8);
putData(0, 4, blkBuf, hdrOfst + 12);
// Get the data for the block
f_read(&esp_upload.uploadFile, blkBuf + dataOfst, blkSize, &cnt );//->Read(reinterpret_cast<char *>(blkBuf + dataOfst), blkSize);
if (cnt != blkSize) {
if (f_tell(&esp_upload.uploadFile) == esp_upload.fileSize) {
// partial last block, fill the remainder
memset(blkBuf + dataOfst + cnt, 0xff, blkSize - cnt);
}
else {
return fileRead;
}
}
// Patch the flash parameters into the first block if it is loaded at address 0
if (esp_upload.uploadBlockNumber == 0 && esp_upload.uploadAddress == 0 && blkBuf[dataOfst] == ESP_IMAGE_MAGIC && flashParmMask != 0) {
// update the Flash parameters
uint32_t flashParm = getData(2, blkBuf + dataOfst + 2, 0) & ~(uint32_t)flashParmMask;
putData(flashParm | flashParmVal, 2, blkBuf + dataOfst + 2, 0);
}
// Calculate the block checksum
cksum = checksum(blkBuf + dataOfst, blkSize, ESP_CHECKSUM_MAGIC);
for (i = 0; i < 3; i++) {
if ((stat = doCommand(ESP_FLASH_DATA, blkBuf, blkBufSize, cksum, 0, blockWriteTimeout)) == success) {
break;
}
}
//printf("Upload %d\%\n", ftell(&esp_upload.uploadFile) * 100 / esp_upload.fileSize);
return stat;
#endif
}
void upload_spin() {
#if 0
switch (esp_upload.state) {
case resetting:
if (esp_upload.connectAttemptNumber == 9) {
// Time to give up
//Network::ResetWiFi();
esp_upload.uploadResult = connected;
esp_upload.state = done;
}
else{
// Reset the serial port at the new baud rate. Also reset the ESP8266.
// const uint32_t baud = uploadBaudRates[esp_upload.connectAttemptNumber/esp_upload.retriesPerBaudRate];
if (esp_upload.connectAttemptNumber % esp_upload.retriesPerBaudRate == 0) {
}
// uploadPort.begin(baud);
// uploadPort_close();
uploadPort_begin();
wifi_delay(2000);
flushInput();
esp_upload.lastAttemptTime = esp_upload.lastResetTime = getWifiTick();
esp_upload.state = connecting;
}
break;
case connecting:
if ((getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= connectAttemptInterval) && (getWifiTickDiff(esp_upload.lastResetTime, getWifiTick()) >= 500)) {
// Attempt to establish a connection to the ESP8266.
EspUploadResult res = Sync(5000);
esp_upload.lastAttemptTime = getWifiTick();
if (res == success) {
// Successful connection
// //MessageF(" success on attempt %d\n", (connectAttemptNumber % retriesPerBaudRate) + 1);
//printf("connect success\n");
esp_upload.state = erasing;
}
else {
// This attempt failed
esp_upload.connectAttemptNumber++;
if (esp_upload.connectAttemptNumber % retriesPerReset == 0) {
esp_upload.state = resetting; // try a reset and a lower baud rate
}
}
}
break;
case erasing:
if (getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= blockWriteInterval) {
uint32_t eraseSize;
const uint32_t sectorsPerBlock = 16;
const uint32_t sectorSize = 4096;
const uint32_t numSectors = (esp_upload.fileSize + sectorSize - 1)/sectorSize;
const uint32_t startSector = esp_upload.uploadAddress/sectorSize;
uint32_t headSectors = sectorsPerBlock - (startSector % sectorsPerBlock);
if (numSectors < headSectors) {
headSectors = numSectors;
}
eraseSize = (numSectors < 2 * headSectors)
? (numSectors + 1) / 2 * sectorSize
: (numSectors - headSectors) * sectorSize;
//MessageF("Erasing %u bytes...\n", fileSize);
esp_upload.uploadResult = flashBegin(esp_upload.uploadAddress, eraseSize);
if (esp_upload.uploadResult == success) {
//MessageF("Uploading file...\n");
esp_upload.uploadBlockNumber = 0;
esp_upload.uploadNextPercentToReport = percentToReportIncrement;
esp_upload.lastAttemptTime = getWifiTick();
esp_upload.state = uploading;
}
else {
//MessageF("Erase failed\n");
esp_upload.state = done;
}
}
break;
case uploading:
// The ESP needs several milliseconds to recover from one packet before it will accept another
if (getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= 15) {
unsigned int percentComplete;
const uint32_t blkCnt = (esp_upload.fileSize + EspFlashBlockSize - 1) / EspFlashBlockSize;
if (esp_upload.uploadBlockNumber < blkCnt) {
esp_upload.uploadResult = flashWriteBlock(0, 0);
esp_upload.lastAttemptTime = getWifiTick();
if (esp_upload.uploadResult != success) {
//MessageF("Flash block upload failed\n");
esp_upload.state = done;
}
percentComplete = (100 * esp_upload.uploadBlockNumber)/blkCnt;
++esp_upload.uploadBlockNumber;
if (percentComplete >= esp_upload.uploadNextPercentToReport) {
//MessageF("%u%% complete\n", percentComplete);
esp_upload.uploadNextPercentToReport += percentToReportIncrement;
}
}
else {
esp_upload.state = done;
}
}
break;
case done:
f_close(&esp_upload.uploadFile);
//uploadPort.end();
//uploadPort_close();
//WIFI_COM.begin(115200, true);
//wifi_init();
if (esp_upload.uploadResult == success) {
//printf("upload successfully\n");
}
else {
//printf("upload failed\n");
}
esp_upload.state = upload_idle;//idle;
break;
default:
break;
}
#endif
}
// Try to upload the given file at the given address
void SendUpdateFile(const char *file, uint32_t address) {
#if 0
FRESULT res = f_open(&esp_upload.uploadFile, file, FA_OPEN_EXISTING | FA_READ);
if (res != FR_OK) return;
esp_upload.fileSize = f_size(&esp_upload.uploadFile);
if (esp_upload.fileSize == 0) {
f_close(&esp_upload.uploadFile);
return;
}
f_lseek(&esp_upload.uploadFile, 0);
esp_upload.uploadAddress = address;
esp_upload.connectAttemptNumber = 0;
esp_upload.state = resetting;
#endif
}
static const uint32_t FirmwareAddress = 0x00000000, WebFilesAddress = 0x00100000;
void ResetWiFiForUpload(int begin_or_end) {
#if 0
uint32_t start, now;
GPIO_InitTypeDef GPIO_InitStructure;
#if V1_0_V1_1
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStructure.Pin = GPIO_Pin_8;
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
#else
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStructure.Pin = GPIO_Pin_13;
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
#endif
start = getWifiTick();
now = start;
if (begin_or_end == 0) {
#if V1_0_V1_1
HAL_GPIO_WritePin(GPIOA,GPIO_Pin_8,GPIO_PIN_RESET); //update mode
#else
HAL_GPIO_WritePin(GPIOC,GPIO_Pin_13,GPIO_PIN_RESET); //update mode
#endif
}
else {
#if V1_0_V1_1
#if V1_0_V1_1
HAL_GPIO_WritePin(GPIOA,GPIO_Pin_8,GPIO_PIN_SET); //boot mode
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStructure.Pin = GPIO_Pin_8;
GPIO_InitStructure.Mode = GPIO_MODE_INPUT;
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
#endif
#else
HAL_GPIO_WritePin(GPIOC,GPIO_Pin_13,GPIO_PIN_SET); //boot mode
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStructure.Pin = GPIO_Pin_13;
GPIO_InitStructure.Mode = GPIO_MODE_INPUT;
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
#endif
}
WIFI_RESET();
while (getWifiTickDiff(start, now) < 500) now = getWifiTick();
WIFI_SET();
#endif
}
int32_t wifi_upload(int type) {
esp_upload.retriesPerBaudRate = 9;
ResetWiFiForUpload(0);
if (type == 0)
SendUpdateFile(ESP_FIRMWARE_FILE, FirmwareAddress);
else if (type == 1)
SendUpdateFile(ESP_WEB_FIRMWARE_FILE, FirmwareAddress);
else if (type == 2)
SendUpdateFile(ESP_WEB_FILE, WebFilesAddress);
else
return -1;
while (esp_upload.state != upload_idle) {
upload_spin();
//IWDG_ReloadCounter();
}
ResetWiFiForUpload(1);
return esp_upload.uploadResult == success ? 0 : -1;
}
#endif // HAS_TFT_LVGL_UI

74
Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.h

@ -0,0 +1,74 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#ifdef __cplusplus
extern "C" { /* C-declarations for C++ */
#endif
#define ESP_FIRMWARE_FILE "1:/MksWifi.bin"
#define ESP_WEB_FIRMWARE_FILE "1:/MksWifi_Web.bin"
#define ESP_WEB_FILE "1:/MksWifi_WebView.bin"
typedef enum {
upload_idle,
resetting,
connecting,
erasing,
uploading,
done
} UploadState;
typedef enum {
success = 0,
timeout,
connected,
badReply,
fileRead,
emptyFile,
respHeader,
slipFrame,
slipState,
slipData,
} EspUploadResult;
typedef struct {
//FIL uploadFile;
uint32_t fileSize;
uint32_t uploadAddress;
UploadState state;
uint32_t retriesPerBaudRate;
uint32_t connectAttemptNumber;
uint32_t lastAttemptTime;
uint32_t lastResetTime;
uint32_t uploadBlockNumber;
uint32_t uploadNextPercentToReport;
EspUploadResult uploadResult;
} UPLOAD_STRUCT;
extern UPLOAD_STRUCT esp_upload;
int32_t wifi_upload(int type);
#ifdef __cplusplus
} /* C-declarations for C++ */
#endif

14
Marlin/src/module/stepper.h

@ -253,6 +253,13 @@ class Stepper {
static bool initialized;
#endif
// Last-moved extruder, as set when the last movement was fetched from planner
#if HAS_MULTI_EXTRUDER
static uint8_t last_moved_extruder;
#else
static constexpr uint8_t last_moved_extruder = 0;
#endif
private:
static block_t* current_block; // A pointer to the block currently being traced
@ -262,13 +269,6 @@ class Stepper {
static bool abort_current_block; // Signals to the stepper that current block should be aborted
// Last-moved extruder, as set when the last movement was fetched from planner
#if HAS_MULTI_EXTRUDER
static uint8_t last_moved_extruder;
#else
static constexpr uint8_t last_moved_extruder = 0;
#endif
#if ENABLED(X_DUAL_ENDSTOPS)
static bool locked_X_motor, locked_X2_motor;
#endif

2
Marlin/src/pins/pins.h

@ -526,6 +526,8 @@
#include "stm32f1/pins_MKS_ROBIN_E3.h" // STM32F1 env:mks_robin_e3
#elif MB(MKS_ROBIN_E3D)
#include "stm32f1/pins_MKS_ROBIN_E3D.h" // STM32F1 env:mks_robin_e3
#elif MB(MKS_ROBIN_E3P)
#include "stm32f1/pins_MKS_ROBIN_E3P.h" // STM32F1 env:mks_robin_e3p
#elif MB(BTT_SKR_MINI_V1_1)
#include "stm32f1/pins_BTT_SKR_MINI_V1_1.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_512K env:STM32F103RC_btt_USB env:STM32F103RC_btt_512K_USB
#elif MB(BTT_SKR_MINI_E3_V1_0)

377
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h

@ -0,0 +1,377 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* MKS Robin nano (STM32F130VET6) board pin assignments
*/
#ifndef __STM32F1__
#error "Oops! Select an STM32F1 board in 'Tools > Board.'"
#elif HOTENDS > 1 || E_STEPPERS > 1
#error "MKS Robin e3p supports up to 1 hotends / E-steppers. Comment out this line to continue."
#elif HAS_FSMC_TFT
#error "MKS Robin e3p doesn't support FSMC-based TFT displays."
#endif
#define BOARD_INFO_NAME "MKS Robin e3p"
//
// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role
//
#define DISABLE_DEBUG
//
// EEPROM
//
//#define FLASH_EEPROM_EMULATION
//#define SDCARD_EEPROM_EMULATION
#if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM)
#define I2C_EEPROM // EEPROM on I2C-0
#define MARLIN_EEPROM_SIZE 0x1000 // 4KB
#endif
//
// Note: MKS Robin board is using SPI2 interface.
//
//#define SPI_MODULE 2
#define ENABLE_SPI2
//
// Limit Switches
//
#define X_DIAG_PIN PA15
#define Y_DIAG_PIN PA12
#define Z_DIAG_PIN PA11
#define E0_DIAG_PIN PC4
#define X_STOP_PIN PA15
#define Y_STOP_PIN PA12
#define Z_MIN_PIN PA11
#define Z_MAX_PIN PC4
//
// Steppers
//
#define X_ENABLE_PIN PE4
#define X_STEP_PIN PE3
#define X_DIR_PIN PE2
#ifndef X_CS_PIN
#define X_CS_PIN PD5
#endif
#define Y_ENABLE_PIN PE1
#define Y_STEP_PIN PE0
#define Y_DIR_PIN PB9
#ifndef Y_CS_PIN
#define Y_CS_PIN PD7
#endif
#define Z_ENABLE_PIN PB8
#define Z_STEP_PIN PB5
#define Z_DIR_PIN PB4
#ifndef Z_CS_PIN
#define Z_CS_PIN PD4
#endif
#define E0_ENABLE_PIN PB3
#define E0_STEP_PIN PD6
#define E0_DIR_PIN PD3
#ifndef E0_CS_PIN
#define E0_CS_PIN PD9
#endif
//
// Software SPI pins for TMC2130 stepper drivers
//
#if ENABLED(TMC_USE_SW_SPI)
#ifndef TMC_SW_MOSI
#define TMC_SW_MOSI PD14
#endif
#ifndef TMC_SW_MISO
#define TMC_SW_MISO PD1
#endif
#ifndef TMC_SW_SCK
#define TMC_SW_SCK PD0
#endif
#endif
#if HAS_TMC_UART
/**
* TMC2208/TMC2209 stepper drivers
*
* Hardware serial communication ports.
* If undefined software serial is used according to the pins below
*/
//#define X_HARDWARE_SERIAL Serial
//#define X2_HARDWARE_SERIAL Serial1
//#define Y_HARDWARE_SERIAL Serial1
//#define Y2_HARDWARE_SERIAL Serial1
//#define Z_HARDWARE_SERIAL Serial1
//#define Z2_HARDWARE_SERIAL Serial1
//#define E0_HARDWARE_SERIAL Serial1
//#define E1_HARDWARE_SERIAL Serial1
//#define E2_HARDWARE_SERIAL Serial1
//#define E3_HARDWARE_SERIAL Serial1
//#define E4_HARDWARE_SERIAL Serial1
//
// Software serial
//
#define X_SERIAL_TX_PIN PD5
#define X_SERIAL_RX_PIN PD5
#define Y_SERIAL_TX_PIN PD7
#define Y_SERIAL_RX_PIN PD7
#define Z_SERIAL_TX_PIN PD4
#define Z_SERIAL_RX_PIN PD4
#define E0_SERIAL_TX_PIN PD9
#define E0_SERIAL_RX_PIN PD9
// Reduce baud rate to improve software serial reliability
#define TMC_BAUD_RATE 19200
#endif // TMC2208 || TMC2209
//
// Temperature Sensors
//
#define TEMP_0_PIN PC1 // TH1
#define TEMP_BED_PIN PC0 // TB1
//
// Heaters / Fans
//
#define HEATER_0_PIN PC3 // HEATER1
#define HEATER_BED_PIN PA0 // HOT BED
#define FAN_PIN PB1 // FAN
//
// Misc. Functions
//
#if HAS_TFT_LVGL_UI
//#define MKSPWC
#ifdef MKSPWC
#define SUICIDE_PIN PB2 // Enable MKSPWC SUICIDE PIN
#define SUICIDE_PIN_INVERTING false // Enable MKSPWC PIN STATE
#define KILL_PIN PA2 // Enable MKSPWC DET PIN
#define KILL_PIN_STATE true // Enable MKSPWC PIN STATE
#endif
#define MT_DET_1_PIN PA4 // LVGL UI FILAMENT RUNOUT1 PIN
#define MT_DET_PIN_INVERTING false // LVGL UI filament RUNOUT PIN STATE
#define WIFI_IO0_PIN PC13 // MKS ESP WIFI IO0 PIN
#define WIFI_IO1_PIN PC7 // MKS ESP WIFI IO1 PIN
#define WIFI_RESET_PIN PE9 // MKS ESP WIFI RESET PIN
#if ENABLED(MKS_TEST)
#define MKS_TEST_POWER_LOSS_PIN PA2 // PW_DET
#define MKS_TEST_PS_ON_PIN PB0 // PW_OFF
#endif
#else
//#define POWER_LOSS_PIN PA2 // PW_DET
//#define PS_ON_PIN PB2 // PW_OFF
#define FIL_RUNOUT_PIN PA4
#endif
#define SERVO0_PIN PA8 // Enable BLTOUCH
//#define LED_PIN PB2
//
// SD Card
//
#ifndef SDCARD_CONNECTION
#define SDCARD_CONNECTION ONBOARD
#endif
#define SDIO_SUPPORT
#define SDIO_CLOCK 4500000 // 4.5 MHz
#define SD_DETECT_PIN PD12
#define ONBOARD_SD_CS_PIN PC11
//
// LCD / Controller
//
#ifndef BEEPER_PIN
#define BEEPER_PIN PC5
#endif
/**
* Note: MKS Robin TFT screens use various TFT controllers.
* If the screen stays white, disable 'LCD_RESET_PIN'
* to let the bootloader init the screen.
*/
#if HAS_SPI_TFT
// Shared SPI TFT
#define LCD_BACKLIGHT_PIN PD13
#define TOUCH_CS_PIN PE14 // SPI1_NSS
#define TOUCH_SCK_PIN PA5 // SPI1_SCK
#define TOUCH_MISO_PIN PA6 // SPI1_MISO
#define TOUCH_MOSI_PIN PA7 // SPI1_MOSI
#define BTN_EN1 PE8
#define BTN_EN2 PE11
#define BTN_ENC PE13
#define TFT_CS_PIN PD11
#define TFT_SCK_PIN PA5
#define TFT_MISO_PIN PA6
#define TFT_MOSI_PIN PA7
#define TFT_DC_PIN PD10
#define TFT_RST_PIN PC6
#define TFT_A0_PIN TFT_DC_PIN
#define TFT_RESET_PIN PC6
#define TFT_BACKLIGHT_PIN PD13
#define TOUCH_BUTTONS_HW_SPI
#define TOUCH_BUTTONS_HW_SPI_DEVICE 1
#ifndef TFT_WIDTH
#define TFT_WIDTH 480
#endif
#ifndef TFT_HEIGHT
#define TFT_HEIGHT 320
#endif
#define LCD_READ_ID 0xD3
#define LCD_USE_DMA_SPI
#endif
#if ENABLED(TFT_LVGL_UI_SPI)
// LVGL
#define XPT2046_X_CALIBRATION -17253
#define XPT2046_Y_CALIBRATION 11579
#define XPT2046_X_OFFSET 514
#define XPT2046_Y_OFFSET -24
#elif ENABLED(SPI_GRAPHICAL_TFT)
// Emulated DOGM SPI
#ifndef XPT2046_X_CALIBRATION
#define XPT2046_X_CALIBRATION -11386
#endif
#ifndef XPT2046_Y_CALIBRATION
#define XPT2046_Y_CALIBRATION 8684
#endif
#ifndef XPT2046_X_OFFSET
#define XPT2046_X_OFFSET 339
#endif
#ifndef XPT2046_Y_OFFSET
#define XPT2046_Y_OFFSET -18
#endif
#ifndef GRAPHICAL_TFT_UPSCALE
#define GRAPHICAL_TFT_UPSCALE 3
#endif
#ifndef TFT_PIXEL_OFFSET_Y
#define TFT_PIXEL_OFFSET_Y 32
#endif
#define BTN_ENC PE13
#define BTN_EN1 PE8
#define BTN_EN2 PE11
#define LCD_PINS_ENABLE PD13
#define LCD_PINS_RS PC6
#elif ENABLED(TFT_480x320_SPI)
#define XPT2046_X_CALIBRATION -17253
#define XPT2046_Y_CALIBRATION 11579
#define XPT2046_X_OFFSET 514
#define XPT2046_Y_OFFSET -24
#define TFT_DRIVER ST7796
#define TFT_BUFFER_SIZE 14400
#endif
#if HAS_SPI_LCD && !HAS_SPI_TFT
// NON TFT Displays
#if ENABLED(MKS_MINI_12864)
// MKS MINI12864 and MKS LCD12864B
// If using MKS LCD12864A (Need to remove RPK2 resistor)
#define LCD_BACKLIGHT_PIN -1
#define LCD_RESET_PIN -1
#define DOGLCD_A0 PD11
#define DOGLCD_CS PE15
#define DOGLCD_SCK PA5
#define DOGLCD_MOSI PA7
// Required for MKS_MINI_12864 with this board
#define MKS_LCD12864B
#undef SHOW_BOOTSCREEN
#else // !MKS_MINI_12864
#define LCD_PINS_D4 PE14
#if ENABLED(ULTIPANEL)
#define LCD_PINS_D5 PE15
#define LCD_PINS_D6 PD11
#define LCD_PINS_D7 PD10
#endif
#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 DELAY_NS(125)
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 DELAY_NS(125)
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 DELAY_NS(125)
#endif
#endif // !MKS_MINI_12864
#endif // HAS_SPI_LCD && !HAS_SPI_TFT
#define HAS_SPI_FLASH 1
#define SPI_FLASH_SIZE 0x1000000 // 16MB
#if HAS_SPI_FLASH
#define W25QXX_CS_PIN PB12
#define W25QXX_MOSI_PIN PB15
#define W25QXX_MISO_PIN PB14
#define W25QXX_SCK_PIN PB13
#endif
#if ENABLED(SPEAKER) && BEEPER_PIN == PC5
#error "MKS Robin nano default BEEPER_PIN is not a SPEAKER."
#endif

38
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h

@ -58,10 +58,6 @@
#define Z_MIN_PIN PA11
#define Z_MAX_PIN PC4
#ifndef FIL_RUNOUT_PIN
#define FIL_RUNOUT_PIN PA4 // MT_DET
#endif
//
// Steppers
//
@ -123,25 +119,33 @@
//
// Misc. Functions
//
#define POWER_LOSS_PIN PA2 // PW_DET
#define PS_ON_PIN PA3 // PW_OFF
#if HAS_TFT_LVGL_UI
//#define MKSPWC
#ifdef MKSPWC
#define SUICIDE_PIN PB2 // Enable MKSPWC SUICIDE PIN
#define SUICIDE_PIN_INVERTING false // Enable MKSPWC PIN STATE
#define KILL_PIN PA2 // Enable MKSPWC DET PIN
#define KILL_PIN_STATE true // Enable MKSPWC PIN STATE
#endif
//#define SUICIDE_PIN PB2 // Enable MKSPWC support ROBIN NANO v1.2 ONLY
//#define SUICIDE_PIN_INVERTING false
#define MT_DET_1_PIN PA4 // LVGL UI FILAMENT RUNOUT1 PIN
#define MT_DET_2_PIN PE6 // LVGL UI FILAMENT RUNOUT2 PIN
#define MT_DET_PIN_INVERTING false // LVGL UI filament RUNOUT PIN STATE
//#define KILL_PIN PA2 // Enable MKSPWC support ROBIN NANO v1.2 ONLY
//#define KILL_PIN_INVERTING true // Enable MKSPWC support ROBIN NANO v1.2 ONLY
#define WIFI_IO0_PIN PC13 // MKS ESP WIFI IO0 PIN
#define WIFI_IO1_PIN PC7 // MKS ESP WIFI IO1 PIN
#define WIFI_RESET_PIN PA5 // MKS ESP WIFI RESET PIN
#else
//#define POWER_LOSS_PIN PA2 // PW_DET
//#define PS_ON_PIN PB2 // PW_OFF
#define FIL_RUNOUT_PIN PA4
#define FIL_RUNOUT2_PIN PE6
#endif
#define SERVO0_PIN PA8 // Enable BLTOUCH support ROBIN NANO v1.2 ONLY
#define SERVO0_PIN PA8 // Enable BLTOUCH support
//#define LED_PIN PB2
#define MT_DET_1_PIN PA4
#define MT_DET_2_PIN PE6
#define MT_DET_PIN_INVERTING false
#define WIFI_IO0_PIN PC13
//
// SD Card
//

48
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h

@ -192,32 +192,38 @@
//
// Misc. Functions
//
#define POWER_LOSS_PIN PA2 // PW_DET
#define PS_ON_PIN PA3 // PW_OFF
//#define SUICIDE_PIN PB2 // Enable MKSPWC support ROBIN NANO v1.2 ONLY
//#define SUICIDE_PIN_INVERTING false
#if HAS_TFT_LVGL_UI
//#define MKSPWC
#ifdef MKSPWC
#define SUICIDE_PIN PB2 // Enable MKSPWC SUICIDE PIN
#define SUICIDE_PIN_INVERTING false // Enable MKSPWC PIN STATE
#define KILL_PIN PA2 // Enable MKSPWC DET PIN
#define KILL_PIN_STATE true // Enable MKSPWC PIN STATE
#endif
//#define KILL_PIN PA2 // Enable MKSPWC support ROBIN NANO v1.2 ONLY
//#define KILL_PIN_INVERTING true // Enable MKSPWC support ROBIN NANO v1.2 ONLY
#define MT_DET_1_PIN PA4 // LVGL UI FILAMENT RUNOUT1 PIN
#define MT_DET_2_PIN PE6 // LVGL UI FILAMENT RUNOUT2 PIN
#define MT_DET_PIN_INVERTING false // LVGL UI filament RUNOUT PIN STATE
#define WIFI_IO0_PIN PC13 // MKS ESP WIFI IO0 PIN
#define WIFI_IO1_PIN PC7 // MKS ESP WIFI IO1 PIN
#define WIFI_RESET_PIN PE9 // MKS ESP WIFI RESET PIN
#if ENABLED(MKS_TEST)
#define MKS_TEST_POWER_LOSS_PIN PA2 // PW_DET
#define MKS_TEST_PS_ON_PIN PB2 // PW_OFF
#endif
#else
//#define POWER_LOSS_PIN PA2 // PW_DET
//#define PS_ON_PIN PB2 // PW_OFF
#define FIL_RUNOUT_PIN PA4
#define FIL_RUNOUT2_PIN PE6
#endif
#define SERVO0_PIN PA8 // Enable BLTOUCH support ROBIN NANO v1.2 ONLY
#define SERVO0_PIN PA8 // Enable BLTOUCH
//#define LED_PIN PB2
#define MT_DET_1_PIN PA4
#define MT_DET_2_PIN PE6
#define MT_DET_PIN_INVERTING false
#ifndef FIL_RUNOUT_PIN
#define FIL_RUNOUT_PIN MT_DET_1_PIN
#endif
#ifndef FIL_RUNOUT2_PIN
#define FIL_RUNOUT2_PIN MT_DET_2_PIN
#endif
#define WIFI_IO0_PIN PC13
//
// SD Card
//

14
buildroot/share/PlatformIO/ldscripts/mks_robin_e3p.ld

@ -0,0 +1,14 @@
MEMORY
{
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K - 40
rom (rx) : ORIGIN = 0x08007000, LENGTH = 512K - 28K - 4K
}
/* Provide memory region aliases for common.inc */
REGION_ALIAS("REGION_TEXT", rom);
REGION_ALIAS("REGION_DATA", ram);
REGION_ALIAS("REGION_BSS", ram);
REGION_ALIAS("REGION_RODATA", rom);
/* Let common.inc handle the real work. */
INCLUDE common.inc

40
buildroot/share/PlatformIO/scripts/mks_robin_e3p.py

@ -0,0 +1,40 @@
import os
Import("env")
# Relocate firmware from 0x08000000 to 0x08007000
for define in env['CPPDEFINES']:
if define[0] == "VECT_TAB_ADDR":
env['CPPDEFINES'].remove(define)
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_e3p.ld")
for i, flag in enumerate(env["LINKFLAGS"]):
if "-Wl,-T" in flag:
env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
elif flag == "-T":
env["LINKFLAGS"][i + 1] = custom_ld_script
# Encrypt ${PROGNAME}.bin and save it as 'mks_robin_e3p.bin'
def encrypt(source, target, env):
import sys
key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E]
firmware = open(target[0].path, "rb")
robin = open(target[0].dir.path +'/Robin_e3p.bin', "wb")
length = os.path.getsize(target[0].path)
position = 0
try:
while position < length:
byte = firmware.read(1)
if position >= 320 and position < 31040:
byte = chr(ord(byte) ^ key[position & 31])
if sys.version_info[0] > 2:
byte = bytes(byte, 'latin1')
robin.write(byte)
position += 1
finally:
firmware.close()
robin.close()
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);

18
platformio.ini

@ -191,7 +191,7 @@ lib_deps =
# Feature Dependencies
#
[features]
HAS_TFT_LVGL_UI = lvgl=https://github.com/makerbase-mks/MKS-LittlevGL/archive/master.zip
HAS_TFT_LVGL_UI = lvgl=https://github.com/makerbase-mks/LVGL-6.1.1-MKS/archive/master.zip
src_filter=+<src/lcd/extui/lib/mks_ui>
extra_scripts=download_mks_assets.py
HAS_TRINAMIC_CONFIG = TMCStepper@~0.7.1
@ -955,6 +955,22 @@ extra_scripts = ${common.extra_scripts}
build_flags = ${common_stm32f1.build_flags}
-DDEBUG_LEVEL=0 -DSS_TIMER=4
#
# MKS Robin E3p (STM32F103VET6)
# - LVGL UI
#
[env:mks_robin_e3p]
platform = ${common_stm32f1.platform}
extends = common_stm32f1
board = genericSTM32F103VE
platform_packages = tool-stm32duino
extra_scripts = ${common.extra_scripts}
buildroot/share/PlatformIO/scripts/mks_robin_e3p.py
build_flags = ${common_stm32f1.build_flags}
-DMCU_STM32F103VE -DSS_TIMER=4
debug_tool = jlink
upload_protocol = jlink
#
# MKS Robin Lite/Lite2 (STM32F103RCT6)
#

Loading…
Cancel
Save