mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
30 lines
815 B
C
30 lines
815 B
C
#include "PikaStdDevice_ADC.h"
|
|
#include "BaseObj.h"
|
|
|
|
void PikaStdDevice_ADC_enable(PikaObj* self) {
|
|
obj_run(self, "platformEnable(pin)");
|
|
}
|
|
|
|
void PikaStdDevice_ADC_init(PikaObj* self) {
|
|
obj_setStr(self, "pin", "PA0");
|
|
}
|
|
|
|
float PikaStdDevice_ADC_read(PikaObj* self) {
|
|
obj_run(self, "val = platformRead(pin)");
|
|
return obj_getFloat(self, "val");
|
|
}
|
|
|
|
void PikaStdDevice_ADC_setPin(PikaObj* self, char* pin) {
|
|
obj_setStr(self, "pin", pin);
|
|
}
|
|
|
|
void PikaStdDevice_ADC_platformEnable(PikaObj* self, char* pin) {
|
|
obj_setErrorCode(self, 1);
|
|
obj_setSysOut(self, "[error] platform method need to be override.");
|
|
}
|
|
|
|
float PikaStdDevice_ADC_platformRead(PikaObj* self, char* pin) {
|
|
obj_setErrorCode(self, 1);
|
|
obj_setSysOut(self, "[error] platform method need to be override.");
|
|
return -1;
|
|
} |