Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
solawc committed Sep 15, 2021
1 parent ddec130 commit 79d6d5d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
15 changes: 12 additions & 3 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,15 @@ enum {
ID_F_RETURN
};

uint8_t fanPercent = 0;
static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
uint8_t fanPercent = map(thermalManager.fan_speed[0], 0, 255, 0, 100);

// uint8_t fanPercent = map(thermalManager.fan_speed[0], 0, 255, 0, 100);
uint8_t temp = map(thermalManager.fan_speed[0], 0, 255, 0, 100);

if( fanPercent != temp ) { if( abs(fanPercent - temp) > 2 ) fanPercent = temp; }

switch (obj->mks_obj_id) {
case ID_F_ADD: if (fanPercent < 100) fanPercent++; break;
case ID_F_DEC: if (fanPercent != 0) fanPercent--; break;
Expand All @@ -55,12 +61,14 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
case ID_F_RETURN: lv_clear_cur_ui(); lv_draw_return_ui(); return;
}
thermalManager.set_fan_speed(0, map(fanPercent, 0, 100, 0, 255));
if(obj->mks_obj_id != ID_F_RETURN) disp_fan_value();
}

void lv_draw_fan(void) {
lv_obj_t *buttonAdd;

scr = lv_screen_create(FAN_UI);

// Create an Image button
buttonAdd = lv_big_button_create(scr, "F:/bmp_Add.bin", fan_menu.add, INTERVAL_V, titleHeight, event_handler, ID_F_ADD);
lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW);
Expand All @@ -77,7 +85,8 @@ void lv_draw_fan(void) {

void disp_fan_value() {
#if HAS_FAN
sprintf_P(public_buf_l, PSTR("%s: %3d%%"), fan_menu.state, (int)map(thermalManager.fan_speed[0], 0, 255, 0, 100));
// sprintf_P(public_buf_l, PSTR("%s: %3d%%"), fan_menu.state, (int)map(thermalManager.fan_speed[0], 0, 255, 0, 100));
sprintf_P(public_buf_l, PSTR("%s: %3d%%"), fan_menu.state, fanPercent);
#else
sprintf_P(public_buf_l, PSTR("%s: ---"), fan_menu.state);
#endif
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
}
}


void lv_draw_operation(void) {
lv_obj_t *buttonExtrusion = nullptr, *buttonSpeed = nullptr,
*buttonBack = nullptr,
Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,9 @@ void lv_print_finished() {
}

void LV_TASK_HANDLER() {

lv_task_handler();

if (mks_test_flag == 0x1E) mks_hardware_test();

TERN_(HAS_GCODE_PREVIEW, disp_pre_gcode(2, 36));
Expand All @@ -1485,6 +1487,7 @@ void LV_TASK_HANDLER() {
#if HAS_ROTARY_ENCODER
if (gCfgItems.encoder_enable) lv_update_encoder();
#endif

if (marlin_state == MF_SD_COMPLETE) lv_print_finished();
}

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ void printer_state_polling() {
#endif

recovery.resume();

#if 0
// Move back to the saved XY
char str_1[16], str_2[16];
Expand All @@ -150,10 +151,9 @@ void printer_state_polling() {
#endif

if (uiCfg.print_state == WORKING) {
filament_check_2(); // filament_check();
filament_check(); // filament_check();
}


TERN_(MKS_WIFI_MODULE, wifi_looping());

#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void SysTick_Callback() {

void tft_lvgl_init() {

W25QXX.init(SPI_QUARTER_SPEED);
W25QXX.init(SPI_FULL_SPEED); // SPI_QUARTER_SPEED

gCfgItems_init();
ui_cfg_init();
Expand Down Expand Up @@ -267,9 +267,9 @@ void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * co

SPI_TFT.setWindow((uint16_t)area->x1, (uint16_t)area->y1, width, height);

// for (uint16_t i = 0; i < height; i++)
// SPI_TFT.tftio.WriteSequence((uint16_t*)(color_p + width * i), width);
SPI_TFT.tftio.WriteSequence((uint16_t*)color_p, width * height);
for (uint16_t i = 0; i < height; i++)
SPI_TFT.tftio.WriteSequence((uint16_t*)(color_p + width * i), width);
// SPI_TFT.tftio.WriteSequence((uint16_t*)color_p, width * height);

lv_disp_flush_ready(disp); // Indicate you are ready with the flushing

Expand Down

0 comments on commit 79d6d5d

Please sign in to comment.