mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
fix typo of Device_GPIO.c, add __init__() for all stddevice
This commit is contained in:
parent
93ee9424a8
commit
df33500696
@ -74,6 +74,9 @@ class Time(TinyObj):
|
||||
|
||||
|
||||
class ADC(TinyObj):
|
||||
def __init__():
|
||||
pass
|
||||
|
||||
def init():
|
||||
pass
|
||||
|
||||
@ -96,6 +99,9 @@ class ADC(TinyObj):
|
||||
|
||||
|
||||
class UART(TinyObj):
|
||||
def __init__():
|
||||
pass
|
||||
|
||||
def init():
|
||||
pass
|
||||
|
||||
@ -128,6 +134,9 @@ class UART(TinyObj):
|
||||
|
||||
|
||||
class IIC(TinyObj):
|
||||
def __init__():
|
||||
pass
|
||||
|
||||
def init():
|
||||
pass
|
||||
|
||||
@ -163,6 +172,9 @@ class IIC(TinyObj):
|
||||
|
||||
|
||||
class PWM(TinyObj):
|
||||
def __init__():
|
||||
pass
|
||||
|
||||
def init():
|
||||
pass
|
||||
|
||||
|
@ -1,110 +0,0 @@
|
||||
#include "BaseObj.h"
|
||||
#include "PikaStdDevice_GPIO.h"
|
||||
|
||||
|
||||
void PikaStdDevice_GPIO_init(PikaObj* self) {
|
||||
obj_setInt(self, "isEnable", 0);
|
||||
obj_setStr(self, "pin", "PA0");
|
||||
obj_setStr(self, "mode", "out");
|
||||
obj_setInt(self, "isOn", 0);
|
||||
obj_setStr(self, "pull", "none");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO___init__(PikaObj *self){
|
||||
PikaStdDevice_GPIO_init(self);
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_disable(PikaObj* self) {
|
||||
obj_setInt(self, "isEnable", 0);
|
||||
obj_run(self, "platformDisable()");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_enable(PikaObj* self) {
|
||||
obj_setInt(self, "isEnable", 1);
|
||||
obj_run(self, "platformEnable()");
|
||||
}
|
||||
|
||||
char* PikaStdDevice_GPIO_getMode(PikaObj* self) {
|
||||
return obj_getStr(self, "mode");
|
||||
}
|
||||
|
||||
char* PikaStdDevice_GPIO_getPin(PikaObj* self) {
|
||||
return obj_getStr(self, "pin");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_low(PikaObj* self) {
|
||||
obj_setInt(self, "isOn", 0);
|
||||
obj_run(self, "platformLow()");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_high(PikaObj* self) {
|
||||
obj_setInt(self, "isOn", 1);
|
||||
obj_run(self, "platformHigh()");
|
||||
}
|
||||
|
||||
int PikaStdDevice_GPIO_read(PikaObj *self){
|
||||
obj_run(self, "platformRead()");
|
||||
return obj_getInt(self, "readBuff");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_setMode(PikaObj* self, char* mode) {
|
||||
if(strEqu(mode, "out")||strEqu(mode, "in")){
|
||||
obj_setStr(self, "mode", mode);
|
||||
obj_run(self, "platformSetMode()");
|
||||
}else{
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] GPIO mode should be 'out' or 'in'.");
|
||||
}
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_setPull(PikaObj *self, char * pull){
|
||||
if(strEqu(pull, "up")||strEqu(pull, "down")||strEqu(pull, "none")){
|
||||
obj_setStr(self, "pull", pull);
|
||||
}else{
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] GPIO pull should be 'up', 'down' or 'none'.");
|
||||
}
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_setPin(PikaObj* self, char *pinName) {
|
||||
obj_setStr(self, "pin", pinName);
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_platformDisable(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_platformEnable(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
void PikaStdDevice_GPIO_platformLow(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_platformHigh(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_platformSetMode(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_platformOff(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_platformOn(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_platformRead(PikaObj *self){
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
@ -9,12 +9,16 @@ void PikaStdDevice_ADC_init(PikaObj* self) {
|
||||
obj_setStr(self, "pin", "PA0");
|
||||
}
|
||||
|
||||
void PikaStdDevice_ADC___init__(PikaObj* self) {
|
||||
PikaStdDevice_ADC_init(self);
|
||||
}
|
||||
|
||||
float PikaStdDevice_ADC_read(PikaObj* self) {
|
||||
obj_run(self, "platformRead()");
|
||||
return obj_getFloat(self, "val");
|
||||
}
|
||||
|
||||
void PikaStdDevice_ADC_setPin(PikaObj* self, char *pin) {
|
||||
void PikaStdDevice_ADC_setPin(PikaObj* self, char* pin) {
|
||||
obj_setStr(self, "pin", pin);
|
||||
}
|
||||
|
||||
|
@ -1,80 +1,109 @@
|
||||
#include "PikaStdDevice_GPIO.h"
|
||||
#include "BaseObj.h"
|
||||
#include "PikaStdDevice_GPIO.h"
|
||||
|
||||
void PikaStdDeivce_GPIO_init(PikaObj* self) {
|
||||
void PikaStdDevice_GPIO_init(PikaObj* self) {
|
||||
obj_setInt(self, "isEnable", 0);
|
||||
obj_setStr(self, "pin", "PA0");
|
||||
obj_setStr(self, "mode", "out");
|
||||
obj_setInt(self, "isOn", 0);
|
||||
obj_setStr(self, "pull", "none");
|
||||
}
|
||||
|
||||
void PikaStdDeivce_GPIO_disable(PikaObj* self) {
|
||||
void PikaStdDevice_GPIO___init__(PikaObj* self) {
|
||||
PikaStdDevice_GPIO_init(self);
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_disable(PikaObj* self) {
|
||||
obj_setInt(self, "isEnable", 0);
|
||||
obj_run(self, "platformDisable()");
|
||||
}
|
||||
|
||||
void PikaStdDeivce_GPIO_enable(PikaObj* self) {
|
||||
void PikaStdDevice_GPIO_enable(PikaObj* self) {
|
||||
obj_setInt(self, "isEnable", 1);
|
||||
obj_run(self, "platformEnable()");
|
||||
}
|
||||
|
||||
char* PikaStdDeivce_GPIO_getMode(PikaObj* self) {
|
||||
char* PikaStdDevice_GPIO_getMode(PikaObj* self) {
|
||||
return obj_getStr(self, "mode");
|
||||
}
|
||||
|
||||
char* PikaStdDeivce_GPIO_getPin(PikaObj* self) {
|
||||
char* PikaStdDevice_GPIO_getPin(PikaObj* self) {
|
||||
return obj_getStr(self, "pin");
|
||||
}
|
||||
|
||||
void PikaStdDeivce_GPIO_low(PikaObj* self) {
|
||||
void PikaStdDevice_GPIO_low(PikaObj* self) {
|
||||
obj_setInt(self, "isOn", 0);
|
||||
obj_run(self, "platformLow()");
|
||||
}
|
||||
|
||||
void PikaStdDeivce_GPIO_high(PikaObj* self) {
|
||||
void PikaStdDevice_GPIO_high(PikaObj* self) {
|
||||
obj_setInt(self, "isOn", 1);
|
||||
obj_run(self, "platformHigh()");
|
||||
}
|
||||
|
||||
void PikaStdDeivce_GPIO_setMode(PikaObj* self, char* mode) {
|
||||
obj_setStr(self, "mode", mode);
|
||||
obj_run(self, "platformSetMode(mode)");
|
||||
int PikaStdDevice_GPIO_read(PikaObj *self){
|
||||
obj_run(self, "platformRead()");
|
||||
return obj_getInt(self, "readBuff");
|
||||
}
|
||||
|
||||
void PikaStdDeivce_GPIO_setPin(PikaObj* self, char* pinName) {
|
||||
void PikaStdDevice_GPIO_setMode(PikaObj* self, char* mode) {
|
||||
if(strEqu(mode, "out")||strEqu(mode, "in")){
|
||||
obj_setStr(self, "mode", mode);
|
||||
obj_run(self, "platformSetMode()");
|
||||
}else{
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] GPIO mode should be 'out' or 'in'.");
|
||||
}
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_setPull(PikaObj *self, char * pull){
|
||||
if(strEqu(pull, "up")||strEqu(pull, "down")||strEqu(pull, "none")){
|
||||
obj_setStr(self, "pull", pull);
|
||||
}else{
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] GPIO pull should be 'up', 'down' or 'none'.");
|
||||
}
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_setPin(PikaObj* self, char *pinName) {
|
||||
obj_setStr(self, "pin", pinName);
|
||||
}
|
||||
|
||||
void PikaStdDeivce_GPIO_platformDisable(PikaObj* self) {
|
||||
void PikaStdDevice_GPIO_platformDisable(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDeivce_GPIO_platformEnable(PikaObj* self) {
|
||||
void PikaStdDevice_GPIO_platformEnable(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
void PikaStdDeivce_GPIO_platformLow(PikaObj* self) {
|
||||
void PikaStdDevice_GPIO_platformLow(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDeivce_GPIO_platformHigh(PikaObj* self) {
|
||||
void PikaStdDevice_GPIO_platformHigh(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDeivce_GPIO_platformSetMode(PikaObj* self, char* mode) {
|
||||
void PikaStdDevice_GPIO_platformSetMode(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDeivce_GPIO_platformOff(PikaObj* self) {
|
||||
void PikaStdDevice_GPIO_platformOff(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDeivce_GPIO_platformOn(PikaObj* self) {
|
||||
void PikaStdDevice_GPIO_platformOn(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_platformRead(PikaObj *self){
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
@ -7,6 +7,10 @@ void PikaStdDevice_IIC_init(PikaObj *self){
|
||||
obj_run(self, "SDApin = 'PA1'");
|
||||
}
|
||||
|
||||
void PikaStdDevice_IIC___init__(PikaObj* self) {
|
||||
PikaStdDevice_IIC_init(self);
|
||||
}
|
||||
|
||||
void PikaStdDevice_IIC_enable(PikaObj *self){
|
||||
obj_run(self, "platformEnable()");
|
||||
}
|
||||
|
@ -7,6 +7,10 @@ void PikaStdDevice_PWM_init(PikaObj* self) {
|
||||
obj_setFloat(self, "duty", 0.5f);
|
||||
}
|
||||
|
||||
void PikaStdDevice_PWM___init__(PikaObj* self) {
|
||||
PikaStdDevice_PWM_init(self);
|
||||
}
|
||||
|
||||
void PikaStdDevice_PWM_setPin(PikaObj* self, char* pin) {
|
||||
obj_setStr(self, "pin", pin);
|
||||
}
|
||||
|
@ -9,6 +9,11 @@ void PikaStdDevice_UART_init(PikaObj* self) {
|
||||
obj_setInt(self, "id", 1);
|
||||
obj_setStr(self, "readBuff", "");
|
||||
}
|
||||
|
||||
void PikaStdDevice_UART___init__(PikaObj* self) {
|
||||
PikaStdDevice_UART_init(self);
|
||||
}
|
||||
|
||||
char* PikaStdDevice_UART_read(PikaObj* self, int length) {
|
||||
obj_setInt(self, "length", length);
|
||||
obj_run(self, "platformRead()");
|
||||
|
Loading…
x
Reference in New Issue
Block a user