Skip to content

Commit

Permalink
MKS UI prelim. cleanup (MarlinFirmware#20763)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead authored and kpishere committed Feb 19, 2021
1 parent 71ba921 commit 66f6ab8
Show file tree
Hide file tree
Showing 78 changed files with 301 additions and 942 deletions.
2 changes: 0 additions & 2 deletions Marlin/src/lcd/extui/lib/mks_ui/SPIFlashStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ void SPIFlashStorage::endWrite() {

void SPIFlashStorage::savePage(uint8_t* buffer) {
W25QXX.SPI_FLASH_BufferWrite(buffer, m_startAddress + (SPI_FLASH_PageSize * m_currentPage), SPI_FLASH_PageSize);

// Test env
// char fname[256];
// snprintf(fname, sizeof(fname), "./pages/page-%03d.data", m_currentPage);
Expand All @@ -180,7 +179,6 @@ void SPIFlashStorage::savePage(uint8_t* buffer) {

void SPIFlashStorage::loadPage(uint8_t* buffer) {
W25QXX.SPI_FLASH_BufferRead(buffer, m_startAddress + (SPI_FLASH_PageSize * m_currentPage), SPI_FLASH_PageSize);

// Test env
// char fname[256];
// snprintf(fname, sizeof(fname), "./pages/page-%03d.data", m_currentPage);
Expand Down
2 changes: 0 additions & 2 deletions Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ void TFT::LCD_clear(uint16_t color) {
tftio.WriteMultiple(color, (uint32_t)(TFT_WIDTH) * (TFT_HEIGHT));
}

extern unsigned char bmp_public_buf[17 * 1024];

void TFT::LCD_Draw_Logo() {
#if HAS_LOGO_IN_FLASH
setWindow(0, 0, TFT_WIDTH, TFT_HEIGHT);
Expand Down
9 changes: 1 addition & 8 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,12 @@

#include "draw_ui.h"
#include <lv_conf.h>
//#include "../lvgl/src/lv_objx/lv_imgbtn.h"
//#include "../lvgl/src/lv_objx/lv_img.h"
//#include "../lvgl/src/lv_core/lv_disp.h"
//#include "../lvgl/src/lv_core/lv_refr.h"

#include "../../../../inc/MarlinConfig.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;

enum { ID_A_RETURN = 1 };

Expand All @@ -52,9 +48,6 @@ void lv_draw_about(void) {
scr = lv_screen_create(ABOUT_UI);
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_A_RETURN);

//fw_version = lv_label_create(scr, SHORT_BUILD_VERSION);
//lv_obj_align(fw_version, nullptr, LV_ALIGN_CENTER, 0, -60);

fw_type = lv_label_create(scr, "Firmware: Marlin " SHORT_BUILD_VERSION);
lv_obj_align(fw_type, nullptr, LV_ALIGN_CENTER, 0, -20);

Expand Down
1 change: 0 additions & 1 deletion Marlin/src/lcd/extui/lib/mks_ui/draw_about.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
extern void lv_draw_about(void);
extern void lv_clear_about();

//extern void disp_temp_ready_print();
#ifdef __cplusplus
} /* C-declarations for C++ */
#endif
3 changes: 1 addition & 2 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
has_adjust_z = 1;
break;
case ID_BABY_STEP_Z_N:
sprintf_P(baby_buf, PSTR("M290 Z%.3f"), babystep_dist);
sprintf_P(baby_buf, PSTR("M290 Z%.3f"), -babystep_dist);
gcode.process_subcommands_now_P(PSTR(baby_buf));
has_adjust_z = 1;
break;
Expand Down Expand Up @@ -136,7 +136,6 @@ void lv_draw_baby_stepping(void) {
}

void disp_baby_step_dist() {
// char buf[30] = {0};
if ((int)(100 * babystep_dist) == 1)
lv_imgbtn_set_src_both(buttonV, "F:/bmp_baby_move0_01.bin");
else if ((int)(100 * babystep_dist) == 5)
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ 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
16 changes: 3 additions & 13 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@

#include "draw_ui.h"
#include <lv_conf.h>
//#include "../lvgl/src/lv_objx/lv_imgbtn.h"
//#include "../lvgl/src/lv_objx/lv_img.h"
//#include "../lvgl/src/lv_core/lv_disp.h"
//#include "../lvgl/src/lv_core/lv_refr.h"

#include "../../../../module/planner.h"
#include "../../../../inc/MarlinConfig.h"
Expand Down Expand Up @@ -65,9 +61,6 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
planner.flow_percentage[0] += uiCfg.stepPrintSpeed;
else
planner.flow_percentage[0] = MAX_EXT_SPEED_PERCENT;
//planner.e_factor[0]= planner.flow_percentage[0]*0.01;
//planner.flow_percentage[1] = planner.flow_percentage[0];
//planner.e_factor[1]= planner.flow_percentage[1]*0.01;
planner.refresh_e_factor(0);
#if HAS_MULTI_EXTRUDER
planner.flow_percentage[1] = planner.flow_percentage[0];
Expand All @@ -88,9 +81,6 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
planner.flow_percentage[0] -= uiCfg.stepPrintSpeed;
else
planner.flow_percentage[0] = MIN_EXT_SPEED_PERCENT;
//planner.e_factor[0]= planner.flow_percentage[0] * 0.01;
//planner.flow_percentage[1] = planner.flow_percentage[0];
//planner.e_factor[1]= planner.flow_percentage[1] * 0.01;
planner.refresh_e_factor(0);
#if HAS_MULTI_EXTRUDER
planner.flow_percentage[1] = planner.flow_percentage[0];
Expand Down Expand Up @@ -143,9 +133,9 @@ void lv_draw_change_speed(void) {
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_RETURN);

// Create labels on the image buttons
labelMov = lv_label_create_empty(buttonMov);
labelExt = lv_label_create_empty(buttonExt);
labelStep = lv_label_create_empty(buttonStep);
labelMov = lv_label_create_empty(buttonMov);
labelExt = lv_label_create_empty(buttonExt);
labelStep = lv_label_create_empty(buttonStep);

#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) {
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ extern void disp_speed_step();
extern void disp_print_speed();
extern void disp_speed_type();

//extern void disp_temp_ready_print();
#ifdef __cplusplus
} /* C-declarations for C++ */
#endif
32 changes: 7 additions & 25 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@
#include "draw_ui.h"
#include <lv_conf.h>

//#include "../lvgl/src/lv_objx/lv_imgbtn.h"
//#include "../lvgl/src/lv_objx/lv_img.h"
//#include "../lvgl/src/lv_core/lv_disp.h"
//#include "../lvgl/src/lv_core/lv_refr.h"

#include "../../../../sd/cardreader.h"
#include "../../../../gcode/queue.h"
#include "../../../../module/temperature.h"
Expand Down Expand Up @@ -100,7 +95,6 @@ static void btn_ok_event_cb(lv_obj_t *btn, lv_event_t event) {
card.openFileRead(cur_name);
if (card.isFileOpen()) {
feedrate_percentage = 100;
//saved_feedrate_percentage = feedrate_percentage;
planner.flow_percentage[0] = 100;
planner.e_factor[0] = planner.flow_percentage[0] * 0.01f;
#if HAS_MULTI_EXTRUDER
Expand All @@ -123,20 +117,8 @@ static void btn_ok_event_cb(lv_obj_t *btn, lv_event_t event) {
lv_draw_ready_print();

#if ENABLED(SDSUPPORT)
//card.endFilePrint();
//wait_for_heatup = false;
uiCfg.print_state = IDLE;
card.flag.abort_sd_printing = true;
//queue.clear();
//quickstop_stepper();
//print_job_timer.stop();
//thermalManager.disable_all_heaters();

//#if ENABLED(POWER_LOSS_RECOVERY)
// recovery.purge();
//#endif
//queue.enqueue_now_P(PSTR("G91\nG1 Z10\nG90\nG28 X0 Y0"));
//queue.inject_P(PSTR("G91\nG1 Z10\nG90\nG28 X0 Y0\nM84\nM107"));
#endif
}
else if (DIALOG_IS(TYPE_FINISH_PRINT)) {
Expand Down Expand Up @@ -244,19 +226,19 @@ void lv_draw_dialog(uint8_t type) {
else if (DIALOG_IS(WIFI_ENABLE_TIPS)) {
btnCancel = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancel);
}
else if (DIALOG_IS(TRANSFER_NO_DEVICE)) {
btnCancel = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancel);
}
#if ENABLED(MKS_WIFI_MODULE)
else if (DIALOG_IS(TYPE_UPLOAD_FILE)) {
if (upload_result == 2) {
btnCancel = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancel);
}
else if (upload_result == 3) {
btnOk = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_ok_event_cb);
Expand All @@ -268,7 +250,7 @@ void lv_draw_dialog(uint8_t type) {
else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT, TYPE_FILAMENT_UNLOAD_HEAT)) {
btnCancel = lv_button_btn_create(scr, BTN_OK_X+90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancel);

tempText1 = lv_label_create_empty(scr);
filament_sprayer_temp();
Expand All @@ -281,7 +263,7 @@ void lv_draw_dialog(uint8_t type) {
else if (DIALOG_IS(TYPE_FILAMENT_LOADING, TYPE_FILAMENT_UNLOADING)) {
btnCancel = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancel);

filament_bar = lv_bar_create(scr, nullptr);
lv_obj_set_pos(filament_bar, (TFT_WIDTH-400)/2, ((TFT_HEIGHT - titleHeight)-40)/2);
Expand All @@ -303,7 +285,7 @@ void lv_draw_dialog(uint8_t type) {
}
else {
lv_label_set_text(labelOk, print_file_dialog_menu.confirm); // Set the labels text
lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
lv_label_set_text(labelCancel, print_file_dialog_menu.cancel);
}
}
if (DIALOG_IS(TYPE_PRINT_FILE)) {
Expand All @@ -314,7 +296,7 @@ void lv_draw_dialog(uint8_t type) {
lv_obj_align(labelFile, nullptr, LV_ALIGN_CENTER, 0, -60);
}
else if (DIALOG_IS(TYPE_STOP)) {
lv_label_set_text(labelDialog, print_file_dialog_menu.cancle_print);
lv_label_set_text(labelDialog, print_file_dialog_menu.cancel_print);
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
}
else if (DIALOG_IS(TYPE_FINISH_PRINT)) {
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ enum {
DIALOG_TYPE_M80_FAIL,
DIALOG_TYPE_MESSAGE_ERR1,

DIALOG_TYPE_UPDATE_ESP_FIRMARE,
DIALOG_TYPE_UPDATE_ESP_FIRMWARE,
DIALOG_TYPE_UPDATE_ESP_DATA,
DIALOG_TYPE_UPLOAD_FILE,
DIALOG_TYPE_UNBIND,
Expand Down Expand Up @@ -85,7 +85,6 @@ extern void filament_sprayer_temp();
extern void filament_dialog_handle();
extern void lv_filament_setbar();

//extern void disp_temp_ready_print();
#ifdef __cplusplus
} /* C-declarations for C++ */
#endif
23 changes: 0 additions & 23 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
#include <lv_conf.h>

#include "tft_lvgl_configuration.h"
//#include "../lvgl/src/lv_objx/lv_imgbtn.h"
//#include "../lvgl/src/lv_objx/lv_img.h"
//#include "../lvgl/src/lv_core/lv_disp.h"
//#include "../lvgl/src/lv_core/lv_refr.h"

#include "SPI_TFT.h"
#include "mks_hardware_test.h"
Expand All @@ -39,25 +35,6 @@
static lv_obj_t *scr;

void lv_draw_error_message(PGM_P const msg) {
#if 0
static lv_obj_t *message = nullptr, *kill_message = nullptr, *reset_tips = nullptr;

scr = lv_screen_create(ERROR_MESSAGE_UI, "");

if (msg) {
message = lv_label_create(scr, msg);
lv_obj_align(message, nullptr, LV_ALIGN_CENTER, 0, -50);
}

kill_message = lv_label_create(scr, "PRINTER HALTED");
lv_obj_align(kill_message, nullptr, LV_ALIGN_CENTER, 0, -10);

reset_tips = lv_label_create(scr, "Please Reset");
lv_obj_align(reset_tips, nullptr, LV_ALIGN_CENTER, 0, 30);

lv_task_handler();
#endif

SPI_TFT.LCD_clear(0x0000);
if (msg) disp_string((TFT_WIDTH - strlen(msg) * 16) / 2, 100, msg, 0xFFFF, 0x0000);
disp_string((TFT_WIDTH - strlen("PRINTER HALTED") * 16) / 2, 140, "PRINTER HALTED", 0xFFFF, 0x0000);
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
extern void lv_draw_error_message(PGM_P const msg);
extern void lv_clear_error_message();

//extern void disp_temp_ready_print();
#ifdef __cplusplus
} /* C-declarations for C++ */
#endif
4 changes: 0 additions & 4 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@

#include "draw_ui.h"
#include <lv_conf.h>
//#include "../lvgl/src/lv_objx/lv_imgbtn.h"
//#include "../lvgl/src/lv_objx/lv_img.h"
//#include "../lvgl/src/lv_core/lv_disp.h"
//#include "../lvgl/src/lv_core/lv_refr.h"

#include "../../../../module/temperature.h"
#include "../../../../gcode/queue.h"
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ extern void disp_ext_speed();
extern void disp_hotend_temp();
extern void disp_extru_amount();

//extern void disp_temp_ready_print();
#ifdef __cplusplus
} /* C-declarations for C++ */
#endif
27 changes: 9 additions & 18 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@

#include "draw_ui.h"
#include <lv_conf.h>
//#include "../lvgl/src/lv_objx/lv_imgbtn.h"
//#include "../lvgl/src/lv_objx/lv_img.h"
//#include "../lvgl/src/lv_core/lv_disp.h"
//#include "../lvgl/src/lv_core/lv_refr.h"

#include "../../../../module/temperature.h"
#include "../../../../gcode/queue.h"
Expand All @@ -52,35 +48,30 @@ static uint8_t fanSpeed;

static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;

switch (obj->mks_obj_id) {
case ID_F_ADD:
if (fanSpeed + 1 <= 255) {
fanSpeed++;
sprintf_P(public_buf_l, PSTR("M106 S%d"), fanSpeed);
gcode.process_subcommands_now(public_buf_l);
}
if (fanSpeed < 254) fanSpeed++;
break;
case ID_F_DEC:
if (fanSpeed > 0) {
fanSpeed--;
sprintf_P(public_buf_l, PSTR("M106 S%d"), fanSpeed);
gcode.process_subcommands_now(public_buf_l);
}
if (fanSpeed > 0) fanSpeed--;
break;
case ID_F_HIGH:
gcode.process_subcommands_now_P(PSTR("M106 S255"));
fanSpeed = 255;
break;
case ID_F_MID:
gcode.process_subcommands_now_P(PSTR("M106 S127"));
fanSpeed = 127;
break;
case ID_F_OFF:
gcode.process_subcommands_now_P(PSTR("M107"));
break;
return;
case ID_F_RETURN:
clear_cur_ui();
draw_return_ui();
break;
return;
}
sprintf_P(public_buf_l, PSTR("M106 S%d"), fanSpeed);
gcode.process_subcommands_now(public_buf_l);
}

void lv_draw_fan(void) {
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/lcd/extui/lib/mks_ui/draw_fan.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ extern void lv_draw_fan(void);
extern void lv_clear_fan();
extern void disp_fan_value();

//extern void disp_temp_ready_print();
#ifdef __cplusplus
} /* C-declarations for C++ */
#endif
Loading

0 comments on commit 66f6ab8

Please sign in to comment.