-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcallbacks.ino
63 lines (47 loc) · 1.57 KB
/
callbacks.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
void printEvent(String Event, lv_event_t event)
{
// Serial.print(Event);
// printf(" ");
switch(event) {
case LV_EVENT_PRESSED:
//printf("Pressed\n");
break;
case LV_EVENT_SHORT_CLICKED:
//printf("Short clicked\n");
break;
case LV_EVENT_CLICKED:
// printf("Clicked\n");
break;
case LV_EVENT_LONG_PRESSED:
//printf("Long press\n");
break;
case LV_EVENT_LONG_PRESSED_REPEAT:
//printf("Long press repeat\n");
break;
case LV_EVENT_RELEASED:
//printf("Released\n");
break;
}
}
void event_handler(lv_obj_t * obj, lv_event_t event)
{
if(event == LV_EVENT_VALUE_CHANGED) {
const char * txt = lv_btnm_get_active_btn_text(obj);
printf("%s was pressed\n", txt);
}
}
void slider_event_cb(lv_obj_t * slider, lv_event_t event)
{
printEvent("Slider", event);
if(event == LV_EVENT_VALUE_CHANGED) {
static char buf[4]; /* max 3 bytes for number plus 1 null terminating byte */
snprintf(buf, 4, "%u", lv_slider_get_value(slider));
lv_obj_align(slider_label, slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
lv_label_set_text(slider_label, buf); /*Refresh the text*/
slider_value=lv_slider_get_value(slider);
Serial.print("VALUE=");
Serial.println(map(slider_value, 1, 100, 400, 800));
BL= map(slider_value, 1, 100, 400, 800);
// ledcWrite(10,BL);
}
}