Skip to content

Commit

Permalink
Merge pull request #18 from rhapsodyv/18500
Browse files Browse the repository at this point in the history
Fixes 18500
  • Loading branch information
makerbase-mks authored Jul 8, 2020
2 parents 99970e5 + 6aa1976 commit b1112ac
Show file tree
Hide file tree
Showing 9 changed files with 273 additions and 262 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void tft_style_init() {
style_num_text.body.grad_color = LV_COLOR_WHITE;
style_num_text.text.color = LV_COLOR_BLACK;
style_num_text.text.sel_color = LV_COLOR_BLACK;
style_num_text.text.font = TERN(HAS_SPI_FLASH_FONT, &gb2312_puhui32, LV_FONT_DEFAULT)
style_num_text.text.font = TERN(HAS_SPI_FLASH_FONT, &gb2312_puhui32, LV_FONT_DEFAULT);
style_num_text.line.width = 0;
style_num_text.text.letter_space = 0;
style_num_text.text.line_space = -5;
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
#undef LV_COLOR_BACKGROUND
#define LV_COLOR_BACKGROUND LV_COLOR_MAKE(0x1A, 0x1A, 0x1A) // LV_COLOR_MAKE(0x00, 0x00, 0x00)

#include "../../inc/MarlinConfigPre.h"
#include "tft_multi_language.h"
#include "pic_manager.h"
#include "draw_ready_print.h"
#include "draw_language.h"
#include "draw_set.h"
Expand Down Expand Up @@ -294,8 +294,8 @@ extern DISP_STATE last_disp_state;
extern DISP_STATE_STACK disp_state_stack;

extern lv_style_t tft_style_scr;
extern lv_style_t tft_style_lable_pre;
extern lv_style_t tft_style_lable_rel;
extern lv_style_t tft_style_label_pre;
extern lv_style_t tft_style_label_rel;
extern lv_style_t style_line;
extern lv_style_t style_para_value_pre;
extern lv_style_t style_para_value_rel;
Expand Down
256 changes: 135 additions & 121 deletions Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,158 +29,171 @@
#include "W25Qxx.h"
#include "mks_hardware_test.h"
#include "draw_ui.h"
#include "pic_manager.h"

#if ENABLED(SPI_GRAPHICAL_TFT)
#include "SPI_TFT.h"
#endif

#include "../../../../MarlinCore.h"
#include "pic_manager.h"
#include "../../../../module/temperature.h"
#include "../../../../feature/touch/xpt2046.h"
#include "../../../../sd/cardreader.h"

uint8_t pw_det_sta, pw_off_sta, mt_det_sta, mt_det2_sta, mt_det3_sta;
uint8_t endstopx1_sta, endstopx2_sta, endstopy1_sta, endstopy2_sta, endstopz1_sta, endstopz2_sta;
void test_gpio_readlevel_L() {
volatile uint32_t itest;
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);
mt_det_sta = (READ(MT_DET_1_PIN) == 0);
mt_det2_sta = (READ(MT_DET_2_PIN) == 0);
//mt_det3_sta = (READ(FIL_RUNOUT_3_PIN) == 0);
endstopx1_sta = (READ(X_MIN_PIN) == 0);
endstopx2_sta = (READ(X_MAX_PIN) == 0);
endstopy1_sta = (READ(Y_MIN_PIN) == 0);
endstopy2_sta = (READ(Y_MAX_PIN) == 0);
endstopz1_sta = (READ(Z_MIN_PIN) == 0);
endstopz2_sta = (READ(Z_MAX_PIN) == 0);
#if ENABLED(MKS_TEST)
volatile uint32_t itest;
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);
mt_det_sta = (READ(MT_DET_1_PIN) == 0);
mt_det2_sta = (READ(MT_DET_2_PIN) == 0);
//mt_det3_sta = (READ(FIL_RUNOUT_3_PIN) == 0);
endstopx1_sta = (READ(X_MIN_PIN) == 0);
endstopx2_sta = (READ(X_MAX_PIN) == 0);
endstopy1_sta = (READ(Y_MIN_PIN) == 0);
endstopy2_sta = (READ(Y_MAX_PIN) == 0);
endstopz1_sta = (READ(Z_MIN_PIN) == 0);
endstopz2_sta = (READ(Z_MAX_PIN) == 0);
#endif
}

void test_gpio_readlevel_H() {
volatile uint32_t itest;
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);
mt_det_sta = (READ(MT_DET_1_PIN) == 1);
mt_det2_sta = (READ(MT_DET_2_PIN) == 1);
//mt_det3_sta = (READ(MT_DET_3_PIN) == 1);
endstopx1_sta = (READ(X_MIN_PIN) == 1);
endstopx2_sta = (READ(X_MAX_PIN) == 1);
endstopy1_sta = (READ(Y_MIN_PIN) == 1);
endstopy2_sta = (READ(Y_MAX_PIN) == 1);
endstopz1_sta = (READ(Z_MIN_PIN) == 1);
endstopz2_sta = (READ(Z_MAX_PIN) == 1);
#if ENABLED(MKS_TEST)
volatile uint32_t itest;
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);
mt_det_sta = (READ(MT_DET_1_PIN) == 1);
mt_det2_sta = (READ(MT_DET_2_PIN) == 1);
//mt_det3_sta = (READ(MT_DET_3_PIN) == 1);
endstopx1_sta = (READ(X_MIN_PIN) == 1);
endstopx2_sta = (READ(X_MAX_PIN) == 1);
endstopy1_sta = (READ(Y_MIN_PIN) == 1);
endstopy2_sta = (READ(Y_MAX_PIN) == 1);
endstopz1_sta = (READ(Z_MIN_PIN) == 1);
endstopz2_sta = (READ(Z_MAX_PIN) == 1);
#endif
}

void init_test_gpio() {
SET_INPUT_PULLUP(X_MIN_PIN);
SET_INPUT_PULLUP(X_MAX_PIN);
SET_INPUT_PULLUP(Y_MIN_PIN);
SET_INPUT_PULLUP(Y_MAX_PIN);
SET_INPUT_PULLUP(Z_MIN_PIN);
SET_INPUT_PULLUP(Z_MAX_PIN);
#ifdef MKS_TEST
SET_INPUT_PULLUP(X_MIN_PIN);
SET_INPUT_PULLUP(X_MAX_PIN);
SET_INPUT_PULLUP(Y_MIN_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_OUTPUT(WIFI_IO0_PIN);

SET_INPUT_PULLUP(MT_DET_1_PIN);
SET_INPUT_PULLUP(MT_DET_2_PIN);
//SET_INPUT_PULLUP(MT_DET_3_PIN);
SET_INPUT_PULLUP(MT_DET_1_PIN);
SET_INPUT_PULLUP(MT_DET_2_PIN);
//SET_INPUT_PULLUP(MT_DET_3_PIN);

SET_INPUT_PULLUP(POWER_LOSS_PIN);
SET_INPUT_PULLUP(PS_ON_PIN);
SET_INPUT_PULLUP(POWER_LOSS_PIN);
SET_INPUT_PULLUP(PS_ON_PIN);

SET_INPUT_PULLUP(SERVO0_PIN);
SET_INPUT_PULLUP(SERVO0_PIN);

SET_OUTPUT(X_ENABLE_PIN);
SET_OUTPUT(Y_ENABLE_PIN);
SET_OUTPUT(Z_ENABLE_PIN);
SET_OUTPUT(E0_ENABLE_PIN);
SET_OUTPUT(E1_ENABLE_PIN);
SET_OUTPUT(X_ENABLE_PIN);
SET_OUTPUT(Y_ENABLE_PIN);
SET_OUTPUT(Z_ENABLE_PIN);
SET_OUTPUT(E0_ENABLE_PIN);
SET_OUTPUT(E1_ENABLE_PIN);

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);
//WRITE(E2_ENABLE_PIN, LOW);
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);
//WRITE(E2_ENABLE_PIN, LOW);
#endif
}

void mks_test_beeper() {
WRITE(BEEPER_PIN, HIGH);
delay(100);
WRITE(BEEPER_PIN, LOW);
delay(100);
#ifdef MKS_TEST
WRITE(BEEPER_PIN, HIGH);
delay(100);
WRITE(BEEPER_PIN, LOW);
delay(100);
#endif
}

void mks_gpio_test(){
init_test_gpio();
#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))
disp_det_ok();
else
disp_det_error();
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))
disp_det_ok();
else
disp_det_error();

if ( (endstopx1_sta == 1)
&& (endstopx2_sta == 1)
&& (endstopy1_sta == 1)
&& (endstopy2_sta == 1)
&& (endstopz1_sta == 1)
&& (endstopz2_sta == 1)
)
disp_Limit_ok();
else
disp_Limit_error();
if ( (endstopx1_sta == 1)
&& (endstopx2_sta == 1)
&& (endstopy1_sta == 1)
&& (endstopy2_sta == 1)
&& (endstopz1_sta == 1)
&& (endstopz2_sta == 1)
)
disp_Limit_ok();
else
disp_Limit_error();
#endif
}

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);
WRITE(E1_DIR_PIN, LOW);
//WRITE(E2_DIR_PIN, LOW);
thermalManager.fan_speed[0] = 255;
//WRITE(HEATER_2_PIN, HIGH); // HE2
WRITE(HEATER_1_PIN, HIGH); // HE1
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);
WRITE(E1_DIR_PIN, HIGH);
//WRITE(E2_DIR_PIN, HIGH);
thermalManager.fan_speed[0] = 0;
//WRITE(HEATER_2_PIN, LOW); // HE2
WRITE(HEATER_1_PIN, LOW); // HE1
WRITE(HEATER_0_PIN, LOW); // HE0
WRITE(HEATER_BED_PIN, LOW); // HOT-BED
}
#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);
//WRITE(E2_DIR_PIN, LOW);
thermalManager.fan_speed[0] = 255;
//WRITE(HEATER_2_PIN, HIGH); // HE2
WRITE(HEATER_1_PIN, HIGH); // HE1
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);
WRITE(E1_DIR_PIN, HIGH);
//WRITE(E2_DIR_PIN, HIGH);
thermalManager.fan_speed[0] = 0;
//WRITE(HEATER_2_PIN, LOW); // HE2
WRITE(HEATER_1_PIN, LOW); // HE1
WRITE(HEATER_0_PIN, LOW); // HE0
WRITE(HEATER_BED_PIN, LOW); // HOT-BED
}

if ( (endstopx1_sta == 1) && (endstopx2_sta == 1)
&& (endstopy1_sta == 1) && (endstopy2_sta == 1)
&& (endstopz1_sta == 1) && (endstopz2_sta == 1)
) {
// nothing here
}
else {
//mks_test_beeper();
}
if ( (endstopx1_sta == 1) && (endstopx2_sta == 1)
&& (endstopy1_sta == 1) && (endstopy2_sta == 1)
&& (endstopz1_sta == 1) && (endstopz2_sta == 1)
) {
// nothing here
}
else {
//mks_test_beeper();
}

if (disp_state == PRINT_READY_UI)
mks_disp_test();

if (disp_state == PRINT_READY_UI)
mks_disp_test();
#endif
}

static const uint16_t ASCII_Table_16x24[] PROGMEM = {
Expand Down Expand Up @@ -585,18 +598,19 @@ void disp_string(uint16_t x, uint16_t y, const char * string, uint16_t charColor
}

//static lv_obj_t * scr_test;
void disp_pic_update() {
void disp_assets_update() {
#if DISABLED(SPI_GRAPHICAL_TFT)
LCD_Clear(0x0000);
#endif
disp_string(120, 150, "PIC Updating...", 0xFFFF, 0x0000);
disp_string(100, 150, "Assets Updating...", 0xFFFF, 0x0000);
}

void disp_font_update() {
#if DISABLED(SPI_GRAPHICAL_TFT)
LCD_Clear(0x0000);
#endif
disp_string(120, 150, "FONT Updating...", 0xFFFF, 0x0000);
void disp_assets_update_progress(const char *msg) {
char buf[30];
memset(buf, ' ', COUNT(buf));
strncpy(buf, msg, strlen(msg));
buf[COUNT(buf)-1] = '\0';
disp_string(100, 200, buf, 0xFFFF, 0x0000);
}

uint8_t mks_test_flag = 0;
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void mks_gpio_test();
void disp_char_1624(uint16_t x, uint16_t y, uint8_t c, uint16_t charColor, uint16_t bkColor);
void disp_string(uint16_t x, uint16_t y, const char * string, uint16_t charColor, uint16_t bkColor);
void mks_hardware_test();
void disp_pic_update();
void disp_font_update();
void disp_assets_update();
void disp_assets_update_progress(const char *msg);
void mks_test_get();
extern uint8_t mks_test_flag;
Loading

0 comments on commit b1112ac

Please sign in to comment.