pikapython/package/pika_lvgl/pika_lv_timer_t.c

44 lines
1.4 KiB
C
Raw Normal View History

2022-09-17 13:57:17 +08:00
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
2022-08-22 18:44:14 +08:00
#include "lvgl.h"
2022-09-17 13:57:17 +08:00
#else
#include "../../lvgl.h"
#endif
#ifdef PIKASCRIPT
2022-08-22 18:44:14 +08:00
#include "pika_lvgl_lv_timer_t.h"
PikaEventListener* g_pika_lv_timer_event_listener;
void __pika_timer_cb(lv_timer_t* timer) {
PikaObj* eventHandleObj = pks_eventLisener_getEventHandleObj(
2022-08-25 13:06:59 +08:00
g_pika_lv_timer_event_listener, (uint32_t)timer);
2022-08-22 18:44:14 +08:00
obj_newDirectObj(eventHandleObj, "timer", New_pika_lvgl_lv_timer_t);
obj_setPtr(obj_getPtr(eventHandleObj, "timer"), "lv_timer", timer);
obj_run(eventHandleObj, "eventCallBack(timer)");
}
void pika_lvgl_lv_timer_t_set_period(PikaObj* self, int period) {
lv_timer_t* lv_timer = obj_getPtr(self, "lv_timer");
lv_timer_set_period(lv_timer, period);
}
void pika_lvgl_lv_timer_t_set_cb(PikaObj* self, Arg* cb) {
2022-08-25 13:06:59 +08:00
lv_timer_t* lv_timer = obj_getPtr(self, "lv_timer");
lv_timer_set_cb(lv_timer, __pika_timer_cb);
2022-08-22 18:44:14 +08:00
obj_setArg(self, "eventCallBack", cb);
/* init event_listener for the first time */
if (NULL == g_pika_lv_timer_event_listener) {
pks_eventLisener_init(&g_pika_lv_timer_event_listener);
}
pks_eventLicener_registEvent(g_pika_lv_timer_event_listener,
2022-08-25 13:06:59 +08:00
(uint32_t)lv_timer, self);
2022-08-22 18:44:14 +08:00
}
2022-08-25 13:06:59 +08:00
void pika_lvgl_lv_timer_t__del(PikaObj* self) {
2022-08-22 18:44:14 +08:00
lv_timer_t* lv_timer = obj_getPtr(self, "lv_timer");
lv_timer_del(lv_timer);
}
2022-09-17 13:57:17 +08:00
#endif