From f1161a9a5f104ba2d06eb84c4241290e614a7d2b Mon Sep 17 00:00:00 2001 From: Malderin <52313714+Malderin@users.noreply.github.com> Date: Mon, 19 Jul 2021 05:21:51 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20MKS=20UI=20compile=20(#223?= =?UTF-8?q?88,=20#22395)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/MarlinCore.cpp | 2 +- .../lcd/extui/mks_ui/draw_error_message.cpp | 7 +- .../src/lcd/extui/mks_ui/draw_ready_print.cpp | 7 +- Marlin/src/lcd/extui/mks_ui/draw_ui.cpp | 4 +- ...mks_hardware_test.cpp => mks_hardware.cpp} | 141 +++++++++--------- .../{mks_hardware_test.h => mks_hardware.h} | 16 +- Marlin/src/lcd/extui/mks_ui/pic_manager.cpp | 7 +- .../extui/mks_ui/tft_lvgl_configuration.cpp | 6 +- 8 files changed, 92 insertions(+), 98 deletions(-) rename Marlin/src/lcd/extui/mks_ui/{mks_hardware_test.cpp => mks_hardware.cpp} (91%) rename Marlin/src/lcd/extui/mks_ui/{mks_hardware_test.h => mks_hardware.h} (81%) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index cc497abe82..d77993631a 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -70,7 +70,7 @@ #if HAS_TFT_LVGL_UI #include "lcd/extui/mks_ui/tft_lvgl_configuration.h" #include "lcd/extui/mks_ui/draw_ui.h" - #include "lcd/extui/mks_ui/mks_hardware_test.h" + #include "lcd/extui/mks_ui/mks_hardware.h" #include #endif diff --git a/Marlin/src/lcd/extui/mks_ui/draw_error_message.cpp b/Marlin/src/lcd/extui/mks_ui/draw_error_message.cpp index 7ee2617326..48ff56253b 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_error_message.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_error_message.cpp @@ -25,15 +25,10 @@ #include "draw_ui.h" #include - #include "tft_lvgl_configuration.h" - #include "SPI_TFT.h" #include "../../../inc/MarlinConfig.h" - -#if ENABLED(MKS_TEST) - #include "mks_hardware_test.h" -#endif +#include "mks_hardware.h" static lv_obj_t *scr; diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp index 83aec7613e..6f24d81b49 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp @@ -39,10 +39,7 @@ #include "draw_touch_calibration.h" #endif -#if ENABLED(MKS_TEST) - #include "mks_hardware_test.h" -#endif - +#include "mks_hardware.h" #include #define ICON_POS_Y 38 @@ -129,7 +126,7 @@ void lv_draw_ready_print() { ZERO(disp_state_stack._disp_state); scr = lv_screen_create(PRINT_READY_UI, ""); - if (mks_test_flag == 0x1E) { + if (TERN0(SDSUPPORT, mks_test_flag == 0x1E)) { // Create image buttons buttonTool = lv_imgbtn_create(scr, "F:/bmp_tool.bin", event_handler, ID_TOOL); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp index 30e08e03ed..1c1e5cc1f5 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp @@ -52,7 +52,7 @@ #endif #if ENABLED(MKS_TEST) - #include "mks_hardware_test.h" + #include "mks_hardware.h" #endif CFG_ITMES gCfgItems; @@ -1366,7 +1366,7 @@ void print_time_count() { void LV_TASK_HANDLER() { lv_task_handler(); - #if ENABLED(MKS_TEST) + #if BOTH(MKS_TEST, SDSUPPORT) if (mks_test_flag == 0x1E) mks_hardware_test(); #endif diff --git a/Marlin/src/lcd/extui/mks_ui/mks_hardware_test.cpp b/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp similarity index 91% rename from Marlin/src/lcd/extui/mks_ui/mks_hardware_test.cpp rename to Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp index 125f8be0f6..3c7eb55532 100644 --- a/Marlin/src/lcd/extui/mks_ui/mks_hardware_test.cpp +++ b/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp @@ -37,7 +37,7 @@ #if ENABLED(MKS_TEST) - #include "mks_hardware_test.h" + #include "mks_hardware.h" bool pw_det_sta, pw_off_sta, mt_det_sta; #if PIN_EXISTS(MT_DET_2) @@ -127,77 +127,81 @@ delay(100); } - void mks_gpio_test() { - init_test_gpio(); + #if ENABLED(SDSUPPORT) - test_gpio_readlevel_L(); - test_gpio_readlevel_H(); - test_gpio_readlevel_L(); - if (pw_det_sta && pw_off_sta && mt_det_sta - #if PIN_EXISTS(MT_DET_2) - && mt_det2_sta - #endif - #if ENABLED(MKS_HARDWARE_TEST_ONLY_E0) - && (READ(PA1) == LOW) - && (READ(PA3) == LOW) - && (READ(PC2) == LOW) - && (READ(PD8) == LOW) - && (READ(PE5) == LOW) - && (READ(PE6) == LOW) - && (READ(PE7) == LOW) - #endif - ) - disp_det_ok(); - else - disp_det_error(); + void mks_gpio_test() { + init_test_gpio(); - if (endstopx1_sta && endstopy1_sta && endstopz1_sta && endstopz2_sta) - disp_Limit_ok(); - else - disp_Limit_error(); - } + test_gpio_readlevel_L(); + test_gpio_readlevel_H(); + test_gpio_readlevel_L(); + if (pw_det_sta && pw_off_sta && mt_det_sta + #if PIN_EXISTS(MT_DET_2) + && mt_det2_sta + #endif + #if ENABLED(MKS_HARDWARE_TEST_ONLY_E0) + && (READ(PA1) == LOW) + && (READ(PA3) == LOW) + && (READ(PC2) == LOW) + && (READ(PD8) == LOW) + && (READ(PE5) == LOW) + && (READ(PE6) == LOW) + && (READ(PE7) == LOW) + #endif + ) + disp_det_ok(); + else + disp_det_error(); - void mks_hardware_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); - #if DISABLED(MKS_HARDWARE_TEST_ONLY_E0) - WRITE(E1_DIR_PIN, LOW); - #endif - thermalManager.fan_speed[0] = 255; - #if DISABLED(MKS_HARDWARE_TEST_ONLY_E0) - WRITE(HEATER_1_PIN, HIGH); // HE1 - #endif - WRITE(HEATER_0_PIN, HIGH); // HE0 - WRITE(HEATER_BED_PIN, HIGH); // HOT-BED - } - else { - WRITE(X_DIR_PIN, HIGH); - WRITE(Y_DIR_PIN, HIGH); - WRITE(Z_DIR_PIN, HIGH); - WRITE(E0_DIR_PIN, HIGH); - #if DISABLED(MKS_HARDWARE_TEST_ONLY_E0) - WRITE(E1_DIR_PIN, HIGH); - #endif - thermalManager.fan_speed[0] = 0; - #if DISABLED(MKS_HARDWARE_TEST_ONLY_E0) - WRITE(HEATER_1_PIN, LOW); // HE1 - #endif - WRITE(HEATER_0_PIN, LOW); // HE0 - WRITE(HEATER_BED_PIN, LOW); // HOT-BED + if (endstopx1_sta && endstopy1_sta && endstopz1_sta && endstopz2_sta) + disp_Limit_ok(); + else + disp_Limit_error(); } - if (endstopx1_sta && endstopx2_sta && endstopy1_sta && endstopy2_sta && endstopz1_sta && endstopz2_sta) { - // nothing here - } - else { + void mks_hardware_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); + #if DISABLED(MKS_HARDWARE_TEST_ONLY_E0) + WRITE(E1_DIR_PIN, LOW); + #endif + thermalManager.fan_speed[0] = 255; + #if DISABLED(MKS_HARDWARE_TEST_ONLY_E0) + WRITE(HEATER_1_PIN, HIGH); // HE1 + #endif + WRITE(HEATER_0_PIN, HIGH); // HE0 + WRITE(HEATER_BED_PIN, HIGH); // HOT-BED + } + else { + WRITE(X_DIR_PIN, HIGH); + WRITE(Y_DIR_PIN, HIGH); + WRITE(Z_DIR_PIN, HIGH); + WRITE(E0_DIR_PIN, HIGH); + #if DISABLED(MKS_HARDWARE_TEST_ONLY_E0) + WRITE(E1_DIR_PIN, HIGH); + #endif + thermalManager.fan_speed[0] = 0; + #if DISABLED(MKS_HARDWARE_TEST_ONLY_E0) + WRITE(HEATER_1_PIN, LOW); // HE1 + #endif + WRITE(HEATER_0_PIN, LOW); // HE0 + WRITE(HEATER_BED_PIN, LOW); // HOT-BED + } + + if (endstopx1_sta && endstopx2_sta && endstopy1_sta && endstopy2_sta && endstopz1_sta && endstopz2_sta) { + // nothing here + } + else { + } + + if (disp_state == PRINT_READY_UI) + mks_disp_test(); } - if (disp_state == PRINT_READY_UI) - mks_disp_test(); - } + #endif #endif // MKS_TEST @@ -613,10 +617,9 @@ void disp_assets_update_progress(const char *msg) { disp_string(100, 165, buf, 0xFFFF, 0x0000); } -uint8_t mks_test_flag = 0; -const char *MKSTestPath = "MKS_TEST"; - -#if ENABLED(SDSUPPORT) +#if BOTH(MKS_TEST, SDSUPPORT) + uint8_t mks_test_flag = 0; + const char *MKSTestPath = "MKS_TEST"; void mks_test_get() { SdFile dir, root = card.getroot(); if (dir.open(&root, MKSTestPath, O_RDONLY)) diff --git a/Marlin/src/lcd/extui/mks_ui/mks_hardware_test.h b/Marlin/src/lcd/extui/mks_ui/mks_hardware.h similarity index 81% rename from Marlin/src/lcd/extui/mks_ui/mks_hardware_test.h rename to Marlin/src/lcd/extui/mks_ui/mks_hardware.h index 1b46d4b0e6..f41c4e18ac 100644 --- a/Marlin/src/lcd/extui/mks_ui/mks_hardware_test.h +++ b/Marlin/src/lcd/extui/mks_ui/mks_hardware.h @@ -21,15 +21,19 @@ */ #pragma once +#include "../../../inc/MarlinConfigPre.h" + #include -void mks_gpio_test(); -void mks_hardware_test(); -void mks_test_get(); +// Functions for MKS_TEST +#if BOTH(MKS_TEST, SDSUPPORT) + void mks_hardware_test(); + void mks_test_get(); + void mks_gpio_test(); + extern uint8_t mks_test_flag; +#endif -void disp_char_1624(uint16_t x, uint16_t y, uint8_t c, uint16_t charColor, uint16_t bkColor); +// String display and assets void disp_string(uint16_t x, uint16_t y, const char * string, uint16_t charColor, uint16_t bkColor); void disp_assets_update(); void disp_assets_update_progress(const char *msg); - -extern uint8_t mks_test_flag; diff --git a/Marlin/src/lcd/extui/mks_ui/pic_manager.cpp b/Marlin/src/lcd/extui/mks_ui/pic_manager.cpp index 03e408e32a..68344e770c 100644 --- a/Marlin/src/lcd/extui/mks_ui/pic_manager.cpp +++ b/Marlin/src/lcd/extui/mks_ui/pic_manager.cpp @@ -27,14 +27,9 @@ #include "draw_ui.h" #include "pic_manager.h" #include "draw_ready_print.h" - -#if ENABLED(MKS_TEST) - #include "mks_hardware_test.h" -#endif - +#include "mks_hardware.h" #include "SPIFlashStorage.h" #include "../../../libs/W25Qxx.h" - #include "../../../sd/cardreader.h" #include "../../../MarlinCore.h" diff --git a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp index 7f84277ef0..2127b23a15 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp +++ b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp @@ -29,7 +29,7 @@ #include "draw_ready_print.h" #include "pic_manager.h" -#include "mks_hardware_test.h" +#include "mks_hardware.h" #include "draw_ui.h" #include "SPIFlashStorage.h" #include @@ -139,7 +139,7 @@ void tft_lvgl_init() { #if ENABLED(SDSUPPORT) UpdateAssets(); watchdog_refresh(); // LVGL init takes time - mks_test_get(); + TERN_(MKS_TEST, mks_test_get()); #endif touch.Init(); @@ -231,7 +231,7 @@ void tft_lvgl_init() { if (ready) lv_draw_ready_print(); - #if ENABLED(MKS_TEST) + #if BOTH(MKS_TEST, SDSUPPORT) if (mks_test_flag == 0x1E) mks_gpio_test(); #endif }