mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
Merge branch 'master' of https://github.com/mimilib/pikascript
This commit is contained in:
commit
dad0fc0952
@ -123,6 +123,7 @@ int main(void) {
|
||||
if( code[0] == 'i'){
|
||||
/* boot from flash */
|
||||
pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
obj_run(pikaMain, "uart = STM32.UART()");
|
||||
obj_run(pikaMain, "uart.init()");
|
||||
obj_run(pikaMain, "uart.setId(1)");
|
||||
obj_run(pikaMain, "uart.setBaudRate(115200)");
|
||||
|
@ -16,7 +16,7 @@
|
||||
<TargetCommonOption>
|
||||
<Device>STM32G030C8Tx</Device>
|
||||
<Vendor>STMicroelectronics</Vendor>
|
||||
<PackID>Keil.STM32G0xx_DFP.1.2.0</PackID>
|
||||
<PackID>Keil.STM32G0xx_DFP.1.3.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IRAM(0x20000000-0x20001FFF) IROM(0x8000000-0x800FFFF) CLOCK(8000000) CPUTYPE("Cortex-M0+") TZ</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
|
@ -11,3 +11,15 @@ pwm = STM32.PWM()
|
||||
rgb = PikaPiZero.RGB()
|
||||
mem = PikaStdLib.MemChecker()
|
||||
|
||||
rgb.init()
|
||||
rgb.enable()
|
||||
|
||||
print('hello 2')
|
||||
print('mem used max:')
|
||||
mem.max()
|
||||
|
||||
while True:
|
||||
time.sleep_ms(10)
|
||||
rgb.flow()
|
||||
print('flowing...')
|
||||
|
||||
|
@ -12,3 +12,4 @@ mem.max()
|
||||
while True:
|
||||
time.sleep_ms(10)
|
||||
rgb.flow()
|
||||
print('flowing...')
|
||||
|
@ -17,18 +17,11 @@
|
||||
PikaObj *New_PikaMain(Args *args){
|
||||
PikaObj *self = New_PikaStdLib_SysObj(args);
|
||||
obj_import(self, "STM32_ADC", New_STM32_ADC);
|
||||
obj_newObj(self, "adc", "STM32_ADC");
|
||||
obj_import(self, "PikaStdLib_MemChecker", New_PikaStdLib_MemChecker);
|
||||
obj_newObj(self, "mem", "PikaStdLib_MemChecker");
|
||||
obj_import(self, "STM32_GPIO", New_STM32_GPIO);
|
||||
obj_newObj(self, "pin", "STM32_GPIO");
|
||||
obj_import(self, "STM32_PWM", New_STM32_PWM);
|
||||
obj_newObj(self, "pwm", "STM32_PWM");
|
||||
obj_import(self, "PikaPiZero_RGB", New_PikaPiZero_RGB);
|
||||
obj_newObj(self, "rgb", "PikaPiZero_RGB");
|
||||
obj_import(self, "STM32_Time", New_STM32_Time);
|
||||
obj_newObj(self, "time", "STM32_Time");
|
||||
obj_import(self, "STM32_UART", New_STM32_UART);
|
||||
obj_newObj(self, "uart", "STM32_UART");
|
||||
return self;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "PikaObj.h"
|
||||
#include <stdarg.h>
|
||||
#include "BaseObj.h"
|
||||
#include "PikaBlock.h"
|
||||
#include "PikaIf.h"
|
||||
#include "PikaInvoke.h"
|
||||
@ -511,7 +512,8 @@ Args* getRightRes(PikaObj* self, char* cmd) {
|
||||
}
|
||||
res = New_args(NULL);
|
||||
args_setSysOut(res, "");
|
||||
int err = obj_getAnyArg(self, "return", cmd, res);
|
||||
char* value = cmd;
|
||||
int err = obj_getAnyArg(self, "return", value, res);
|
||||
if (err != 0) {
|
||||
args_setSysOut(res, "[error] get value faild.");
|
||||
args_setErrorCode(res, 1);
|
||||
@ -614,6 +616,24 @@ Args* obj_runDirect(PikaObj* self, char* cmd) {
|
||||
/* this line processed ok */
|
||||
goto exit;
|
||||
}
|
||||
/* check class */
|
||||
if (strIsContain(cmd, '(') && strIsContain(cmd, ')') &&
|
||||
strIsContain(cmd, '=')) {
|
||||
/* check class */
|
||||
char* classCmd = strsGetCleanCmd(buffs, cmd);
|
||||
char* newObj = strsGetFirstToken(buffs, classCmd, '=');
|
||||
char* classPath = strsGetLastToken(buffs, classCmd, '=');
|
||||
classPath = strsGetFirstToken(buffs, classPath, '(');
|
||||
/* replace . with _ */
|
||||
for (int i = 0; i < strGetSize(classPath); i++) {
|
||||
if ('.' == classPath[i]) {
|
||||
classPath[i] = '_';
|
||||
}
|
||||
}
|
||||
if (0 == obj_newObj(self, newObj, classPath)) {
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
/* run script */
|
||||
if (strIsContain(cmd, '(') && strIsContain(cmd, ')')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user