This commit is contained in:
graduateDesign 2021-09-21 12:35:44 +08:00
parent 292ede2b50
commit 9c648df6c9
8 changed files with 88 additions and 62 deletions

View File

@ -313,7 +313,7 @@
</ArmAdsMisc>
<Cads>
<interw>1</interw>
<Optim>5</Optim>
<Optim>7</Optim>
<oTime>0</oTime>
<SplitLS>0</SplitLS>
<OneElfS>1</OneElfS>

View File

@ -16,4 +16,6 @@ class RGB(PikaStdLib.SysObj):
pass
def white():
pass
def flow():
pass

View File

@ -18,11 +18,5 @@ mem = PikaStdLib.MemChecker()
print('mem max:')
mem.max()
while True:
time.sleep_ms(250)
rgb.red()
time.sleep_ms(250)
rgb.green()
time.sleep_ms(250)
rgb.white()
time.sleep_ms(250)
rgb.blue()
time.sleep_ms(50)
rgb.flow()

View File

@ -16,6 +16,10 @@ void PikaPiZero_RGB_enableMethod(PikaObj *self, Args *args){
PikaPiZero_RGB_enable(self);
}
void PikaPiZero_RGB_flowMethod(PikaObj *self, Args *args){
PikaPiZero_RGB_flow(self);
}
void PikaPiZero_RGB_greenMethod(PikaObj *self, Args *args){
PikaPiZero_RGB_green(self);
}
@ -38,6 +42,7 @@ PikaObj *New_PikaPiZero_RGB(Args *args){
obj_newObj(self, "pin", "STM32_GPIO");
class_defineMethod(self, "blue()", PikaPiZero_RGB_blueMethod);
class_defineMethod(self, "enable()", PikaPiZero_RGB_enableMethod);
class_defineMethod(self, "flow()", PikaPiZero_RGB_flowMethod);
class_defineMethod(self, "green()", PikaPiZero_RGB_greenMethod);
class_defineMethod(self, "init()", PikaPiZero_RGB_initMethod);
class_defineMethod(self, "red()", PikaPiZero_RGB_redMethod);

View File

@ -11,6 +11,7 @@ PikaObj *New_PikaPiZero_RGB(Args *args);
void PikaPiZero_RGB_blue(PikaObj *self);
void PikaPiZero_RGB_enable(PikaObj *self);
void PikaPiZero_RGB_flow(PikaObj *self);
void PikaPiZero_RGB_green(PikaObj *self);
void PikaPiZero_RGB_init(PikaObj *self);
void PikaPiZero_RGB_red(PikaObj *self);

File diff suppressed because one or more lines are too long

View File

@ -17,14 +17,8 @@ PikaObj * pikaScriptInit(){
obj_run(pikaMain, "print('mem max:')");
obj_run(pikaMain, "mem.max()");
obj_run(pikaMain, "while True:");
obj_run(pikaMain, " time.sleep_ms(250)");
obj_run(pikaMain, " rgb.red()");
obj_run(pikaMain, " time.sleep_ms(250)");
obj_run(pikaMain, " rgb.green()");
obj_run(pikaMain, " time.sleep_ms(250)");
obj_run(pikaMain, " rgb.white()");
obj_run(pikaMain, " time.sleep_ms(250)");
obj_run(pikaMain, " rgb.blue()");
obj_run(pikaMain, " time.sleep_ms(50)");
obj_run(pikaMain, " rgb.flow()");
obj_run(pikaMain, "");
return pikaMain;
}

View File

@ -1,63 +1,93 @@
#include "PikaPiZero_RGB.h"
#include <stdint.h>
#include "BaseObj.h"
#include "RGB_ASM.h"
#include "STM32_common.h"
#include "dataStrs.h"
#include "RGB_ASM.h"
#include <stdint.h>
void RGB_reset(){
GPIOB->BRR = GPIO_PIN_12; // reset
delay_us(50);
void RGB_reset() {
GPIOB->BRR = GPIO_PIN_12; // reset
delay_us(50);
}
#define RED 0x000F00
#define GREEN 0x0F0000
#define BLUE 0x00000F
#define WHITE 0x0F0F0F
#define CUTDOWN 0x000000
#define RED 0x000100
#define GREEN 0x010000
#define BLUE 0x000001
#define WHITE 0x010101
#define CUTDOWN 0x000000
void RGB_setVoid(){
__asm(
"nop"
);
void RGB_setVoid() { __asm("nop"); }
void PikaPiZero_RGB_enable(PikaObj *self) {
obj_run(self, "pin.init()");
obj_run(self, "pin.setPin('PB12')");
obj_run(self, "pin.setMode('out')");
obj_run(self, "pin.enable()");
}
void PikaPiZero_RGB_init(PikaObj *self) {}
void PikaPiZero_RGB_red(PikaObj *self) {
RGB_set(RED);
RGB_set(RED);
RGB_set(RED);
RGB_set(RED);
}
void PikaPiZero_RGB_enable(PikaObj *self){
obj_run(self, "pin.init()");
obj_run(self, "pin.setPin('PB12')");
obj_run(self, "pin.setMode('out')");
obj_run(self, "pin.enable()");
}
void PikaPiZero_RGB_init(PikaObj *self){
void PikaPiZero_RGB_blue(PikaObj *self) {
RGB_set(BLUE);
RGB_set(BLUE);
RGB_set(BLUE);
RGB_set(BLUE);
}
void PikaPiZero_RGB_red(PikaObj *self){
RGB_set(RED);
void PikaPiZero_RGB_green(PikaObj *self) {
RGB_set(GREEN);
RGB_set(GREEN);
RGB_set(GREEN);
RGB_set(GREEN);
}
void PikaPiZero_RGB_white(PikaObj *self) {
RGB_set(WHITE);
RGB_set(WHITE);
RGB_set(WHITE);
RGB_set(WHITE);
}
void PikaPiZero_RGB_flow(PikaObj *self) {
if (!obj_isArgExist(self, "flowState")) {
obj_setInt(self, "flowState", 0);
}
int flowState = obj_getInt(self, "flowState");
if (0 == flowState) {
RGB_set(RED);
RGB_set(BLUE);
RGB_set(GREEN);
RGB_set(WHITE);
goto exit;
}
if (1 == flowState) {
RGB_set(BLUE);
RGB_set(GREEN);
RGB_set(WHITE);
RGB_set(RED);
goto exit;
}
if (2 == flowState) {
RGB_set(GREEN);
RGB_set(WHITE);
RGB_set(RED);
}
void PikaPiZero_RGB_blue(PikaObj *self){
RGB_set(BLUE);
RGB_set(BLUE);
goto exit;
}
if (3 == flowState) {
RGB_set(WHITE);
RGB_set(RED);
RGB_set(BLUE);
RGB_set(BLUE);
}
RGB_set(GREEN);
goto exit;
}
void PikaPiZero_RGB_green(PikaObj *self){
RGB_set(GREEN);
RGB_set(GREEN);
RGB_set(GREEN);
RGB_set(GREEN);
}
void PikaPiZero_RGB_white(PikaObj *self){
RGB_set(WHITE);
RGB_set(WHITE);
RGB_set(WHITE);
RGB_set(WHITE);
exit:
obj_setInt(self, "flowState", (flowState + 1) % 4);
}