pikapython/package/PikaStdDevice/PikaStdDevice_BaseDev.c
李昂 b0840b9869 !30 add pks_eventLister and support event signal
* format
* use inner_bytecode instead of obj_run
* add asserts for event-test
* test event for PikaStdDevice is ok
* adding event fealure
* fetch PikaStdDevice_Time to port linux
2022-06-17 05:22:47 +00:00

23 lines
818 B
C

#include "PikaStdDevice_BaseDev.h"
#include "BaseObj.h"
#include "PikaObj.h"
#include "dataStrs.h"
PikaEventListener* g_pika_device_event_listener;
void PikaStdDevice_BaseDev_addEventCallBack(PikaObj* self, Arg* eventCallBack) {
obj_setArg(self, "eventCallBack", eventCallBack);
if (PIKA_RES_OK != obj_runNativeMethod(self, "platformGetEventId", NULL)) {
obj_setErrorCode(self, 1);
__platform_printf("Error: Method %s no found.\r\n",
"platformGetEventId");
}
uint32_t eventId = obj_getInt(self, "eventId");
pks_eventLicener_registEvent(g_pika_device_event_listener, eventId, self);
}
void PikaStdDevice_BaseDev_platformGetEventId(PikaObj* self) {
obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override.");
}