2021-10-01 20:00:15 +08:00
|
|
|
#include "PikaStdDevice_ADC.h"
|
|
|
|
#include "BaseObj.h"
|
|
|
|
|
|
|
|
void PikaStdDevice_ADC_enable(PikaObj* self) {
|
2022-03-19 09:53:48 +08:00
|
|
|
obj_runNativeMethod(self, "platformEnable", NULL);
|
2022-03-19 09:49:19 +08:00
|
|
|
}
|
|
|
|
|
2022-03-19 09:53:48 +08:00
|
|
|
void PikaStdDevice_ADC_disable(PikaObj* self) {
|
|
|
|
obj_runNativeMethod(self, "platformDisable", NULL);
|
2022-03-07 14:58:21 +08:00
|
|
|
}
|
|
|
|
|
2021-10-01 20:00:15 +08:00
|
|
|
void PikaStdDevice_ADC_init(PikaObj* self) {
|
|
|
|
obj_setStr(self, "pin", "PA0");
|
|
|
|
}
|
|
|
|
|
2021-12-10 23:02:40 +08:00
|
|
|
void PikaStdDevice_ADC___init__(PikaObj* self) {
|
|
|
|
PikaStdDevice_ADC_init(self);
|
|
|
|
}
|
|
|
|
|
2022-06-13 10:02:59 +00:00
|
|
|
double PikaStdDevice_ADC_read(PikaObj* self) {
|
2022-03-19 09:53:48 +08:00
|
|
|
obj_runNativeMethod(self, "platformRead", NULL);
|
2021-10-01 20:00:15 +08:00
|
|
|
return obj_getFloat(self, "val");
|
|
|
|
}
|
|
|
|
|
2021-12-10 23:02:40 +08:00
|
|
|
void PikaStdDevice_ADC_setPin(PikaObj* self, char* pin) {
|
2021-10-01 20:00:15 +08:00
|
|
|
obj_setStr(self, "pin", pin);
|
|
|
|
}
|
|
|
|
|
2021-11-14 19:40:06 +08:00
|
|
|
void PikaStdDevice_ADC_platformEnable(PikaObj* self) {
|
2021-10-01 20:00:15 +08:00
|
|
|
obj_setErrorCode(self, 1);
|
|
|
|
obj_setSysOut(self, "[error] platform method need to be override.");
|
|
|
|
}
|
|
|
|
|
2022-03-19 09:53:48 +08:00
|
|
|
void PikaStdDevice_ADC_platformDisable(PikaObj* self) {
|
2022-03-07 14:58:21 +08:00
|
|
|
obj_setErrorCode(self, 1);
|
|
|
|
obj_setSysOut(self, "[error] platform method need to be override.");
|
|
|
|
}
|
|
|
|
|
2021-11-14 19:40:06 +08:00
|
|
|
void PikaStdDevice_ADC_platformRead(PikaObj* self) {
|
2021-10-01 20:00:15 +08:00
|
|
|
obj_setErrorCode(self, 1);
|
|
|
|
obj_setSysOut(self, "[error] platform method need to be override.");
|
2021-11-14 19:44:15 +08:00
|
|
|
}
|