|
@@ -32,8 +32,7 @@
|
32
|
32
|
#include "../../../../inc/MarlinConfig.h"
|
33
|
33
|
|
34
|
34
|
extern lv_group_t *g;
|
35
|
|
-static lv_obj_t *scr;
|
36
|
|
-static lv_obj_t *fanText;
|
|
35
|
+static lv_obj_t *scr, *fanText;
|
37
|
36
|
|
38
|
37
|
enum {
|
39
|
38
|
ID_F_ADD = 1,
|
|
@@ -44,43 +43,23 @@ enum {
|
44
|
43
|
ID_F_RETURN
|
45
|
44
|
};
|
46
|
45
|
|
47
|
|
-static uint8_t fanSpeed;
|
48
|
|
-
|
49
|
46
|
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
50
|
47
|
if (event != LV_EVENT_RELEASED) return;
|
51
|
|
-
|
|
48
|
+ uint8_t fanPercent = map(thermalManager.fan_speed[0], 0, 255, 0, 100);
|
52
|
49
|
switch (obj->mks_obj_id) {
|
53
|
|
- case ID_F_ADD:
|
54
|
|
- if (fanSpeed < 254) fanSpeed++;
|
55
|
|
- break;
|
56
|
|
- case ID_F_DEC:
|
57
|
|
- if (fanSpeed > 0) fanSpeed--;
|
58
|
|
- break;
|
59
|
|
- case ID_F_HIGH:
|
60
|
|
- fanSpeed = 255;
|
61
|
|
- break;
|
62
|
|
- case ID_F_MID:
|
63
|
|
- fanSpeed = 127;
|
64
|
|
- break;
|
65
|
|
- case ID_F_OFF:
|
66
|
|
- gcode.process_subcommands_now_P(PSTR("M107"));
|
67
|
|
- return;
|
68
|
|
- case ID_F_RETURN:
|
69
|
|
- clear_cur_ui();
|
70
|
|
- draw_return_ui();
|
71
|
|
- return;
|
|
50
|
+ case ID_F_ADD: if (fanPercent < 100) fanPercent++; break;
|
|
51
|
+ case ID_F_DEC: if (fanPercent != 0) fanPercent--; break;
|
|
52
|
+ case ID_F_HIGH: fanPercent = 100; break;
|
|
53
|
+ case ID_F_MID: fanPercent = 50; break;
|
|
54
|
+ case ID_F_OFF: fanPercent = 0; break;
|
|
55
|
+ case ID_F_RETURN: clear_cur_ui(); draw_return_ui(); return;
|
72
|
56
|
}
|
73
|
|
- sprintf_P(public_buf_l, PSTR("M106 S%d"), fanSpeed);
|
74
|
|
- gcode.process_subcommands_now(public_buf_l);
|
|
57
|
+ thermalManager.set_fan_speed(0, map(fanPercent, 0, 100, 0, 255));
|
75
|
58
|
}
|
76
|
59
|
|
77
|
60
|
void lv_draw_fan() {
|
78
|
61
|
lv_obj_t *buttonAdd;
|
79
|
62
|
|
80
|
|
- #if HAS_FAN
|
81
|
|
- fanSpeed = thermalManager.fan_speed[0];
|
82
|
|
- #endif
|
83
|
|
-
|
84
|
63
|
scr = lv_screen_create(FAN_UI);
|
85
|
64
|
// Create an Image button
|
86
|
65
|
buttonAdd = lv_big_button_create(scr, "F:/bmp_Add.bin", fan_menu.add, INTERVAL_V, titleHeight, event_handler, ID_F_ADD);
|
|
@@ -97,12 +76,11 @@ void lv_draw_fan() {
|
97
|
76
|
}
|
98
|
77
|
|
99
|
78
|
void disp_fan_value() {
|
100
|
|
- char buf1[10] = {0};
|
101
|
|
- public_buf_l[0] = '\0';
|
102
|
|
- strcat(public_buf_l, fan_menu.state);
|
103
|
|
- strcat_P(public_buf_l, PSTR(": "));
|
104
|
|
- sprintf_P(buf1, PSTR("%3d"), thermalManager.fan_speed[0]);
|
105
|
|
- strcat(public_buf_l, buf1);
|
|
79
|
+ #if HAS_FAN
|
|
80
|
+ sprintf_P(public_buf_l, PSTR("%s: %3d%%"), fan_menu.state, (int)map(thermalManager.fan_speed[0], 0, 255, 0, 100));
|
|
81
|
+ #else
|
|
82
|
+ sprintf_P(public_buf_l, PSTR("%s: ---"), fan_menu.state);
|
|
83
|
+ #endif
|
106
|
84
|
lv_label_set_text(fanText, public_buf_l);
|
107
|
85
|
lv_obj_align(fanText, nullptr, LV_ALIGN_CENTER, 0, -65);
|
108
|
86
|
}
|