mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-02-05 17:28:23 +08:00
screen->window, win.update() is ok
This commit is contained in:
parent
d82a078077
commit
db5710d50f
@ -3,17 +3,29 @@ import Arm2D
|
|||||||
|
|
||||||
mem = PikaStdLib.MemChecker()
|
mem = PikaStdLib.MemChecker()
|
||||||
|
|
||||||
screen = Arm2D.Screen()
|
win = Arm2D.Window()
|
||||||
screen.init()
|
win.init()
|
||||||
screen.background.setColor('white')
|
win.background.setColor('white')
|
||||||
|
|
||||||
screen.elems.b1 = Arm2D.Box()
|
win.elems.b1 = Arm2D.Box()
|
||||||
screen.elems.b1.init()
|
win.elems.b1.init()
|
||||||
screen.elems.b1.setColor('blue')
|
win.elems.b1.setColor('blue')
|
||||||
screen.elems.b1.move(100, 100)
|
win.elems.b1.move(100, 100)
|
||||||
|
win.update()
|
||||||
|
|
||||||
print('hello world')
|
print('hello pikaScript')
|
||||||
print('mem used max:')
|
print('mem used max:')
|
||||||
mem.max()
|
mem.max()
|
||||||
print('mem used now:')
|
print('mem used now:')
|
||||||
mem.now()
|
mem.now()
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
x0 = 100
|
||||||
|
y0 = 100
|
||||||
|
while i < 100:
|
||||||
|
x = x0 + i
|
||||||
|
y = y0 + i
|
||||||
|
win.elems.b1.move(x, y)
|
||||||
|
win.update()
|
||||||
|
i = i + 1
|
||||||
|
print(i)
|
||||||
|
@ -11,12 +11,12 @@ class BackGround(TinyObj):
|
|||||||
def getColor() -> str:
|
def getColor() -> str:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def update(ptTile: pointer, bIsNewFrame: int):
|
def update():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ElementList(BaseObj):
|
class ElementList(BaseObj):
|
||||||
def update(ptTile: pointer, bIsNewFrame: int):
|
def update():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@ -39,13 +39,13 @@ class Element(TinyObj):
|
|||||||
def down(y: int):
|
def down(y: int):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def update(ptTile: pointer, bIsNewFrame: int):
|
def update():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Box(Element):
|
class Box(Element):
|
||||||
# override
|
# override
|
||||||
def update(ptTile: pointer, bIsNewFrame: int):
|
def update():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
@ -60,7 +60,7 @@ class Box(Element):
|
|||||||
|
|
||||||
class Star(Element):
|
class Star(Element):
|
||||||
# override
|
# override
|
||||||
def update(ptTile: pointer, bIsNewFrame: int):
|
def update():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
@ -73,12 +73,12 @@ class Star(Element):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Screen(BaseObj):
|
class Window(BaseObj):
|
||||||
background = BackGround()
|
background = BackGround()
|
||||||
elems = ElementList()
|
elems = ElementList()
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def update(ptTile: pointer, bIsNewFrame: int):
|
def update():
|
||||||
pass
|
pass
|
||||||
|
@ -11,11 +11,13 @@ char *Arm2D_BackGround_getColor(PikaObj *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Arm2D_BackGround_update(PikaObj *self, int bIsNewFrame, void * ptTile)
|
void Arm2D_BackGround_update(PikaObj *self)
|
||||||
{
|
{
|
||||||
|
void *target_tile = pika_arm2d_window.pfb_tile_now;
|
||||||
|
|
||||||
char *color = obj_getStr(self, "color");
|
char *color = obj_getStr(self, "color");
|
||||||
uint16_t backGroundColor = getColorCode(color);
|
uint16_t backGroundColor = getColorCode(color);
|
||||||
arm_2d_rgb16_fill_colour(ptTile, NULL, backGroundColor);
|
arm_2d_rgb16_fill_colour(target_tile, NULL, backGroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Arm2D_BackGround_setColor(PikaObj *self, char *color)
|
void Arm2D_BackGround_setColor(PikaObj *self, char *color)
|
||||||
|
@ -1,32 +1,32 @@
|
|||||||
#include "Arm2D_common.h"
|
#include "Arm2D_common.h"
|
||||||
|
#include "Arm2D_Box.h"
|
||||||
|
|
||||||
void Arm2D_Box_init(PikaObj *self)
|
void Arm2D_Box_init(PikaObj *self) {
|
||||||
{
|
obj_setInt(self, "posX", 0);
|
||||||
obj_setInt(self, "posX", 0);
|
obj_setInt(self, "posY", 0);
|
||||||
obj_setInt(self, "posY", 0);
|
obj_setInt(self, "sizeX", 50);
|
||||||
obj_setInt(self, "sizeX", 50);
|
obj_setInt(self, "sizeY", 50);
|
||||||
obj_setInt(self, "sizeY", 50);
|
obj_setStr(self, "color", "blue");
|
||||||
obj_setStr(self, "color", "blue");
|
|
||||||
}
|
}
|
||||||
void Arm2D_Box_update(PikaObj *self, int bIsNewFrame, void * ptTile)
|
|
||||||
{
|
void Arm2D_Box_update(PikaObj *self) {
|
||||||
int posX = obj_getInt(self, "posX");
|
void *target_tile = pika_arm2d_window.pfb_tile_now;
|
||||||
int posY = obj_getInt(self, "posY");
|
|
||||||
int sizeX = obj_getInt(self, "sizeX");
|
int posX = obj_getInt(self, "posX");
|
||||||
int sizeY = obj_getInt(self, "sizeY");
|
int posY = obj_getInt(self, "posY");
|
||||||
char *color = obj_getStr(self, "color");
|
int sizeX = obj_getInt(self, "sizeX");
|
||||||
arm_2d_region_t tBox = {
|
int sizeY = obj_getInt(self, "sizeY");
|
||||||
.tLocation = {posX, posY},
|
char *color = obj_getStr(self, "color");
|
||||||
.tSize = {sizeX, sizeY},
|
arm_2d_region_t tBox = { .tLocation = { posX, posY }, .tSize = { sizeX,
|
||||||
};
|
sizeY }, };
|
||||||
arm_2d_rgb16_fill_colour(ptTile, &tBox, getColorCode(color));
|
arm_2d_rgb16_fill_colour(target_tile, &tBox, getColorCode(color));
|
||||||
}
|
}
|
||||||
void Arm2D_Box_setColor(PikaObj *self, char *color)
|
|
||||||
{
|
void Arm2D_Box_setColor(PikaObj *self, char *color) {
|
||||||
obj_setStr(self, "color", color);
|
obj_setStr(self, "color", color);
|
||||||
}
|
}
|
||||||
void Arm2D_Box_setSize(PikaObj *self, int x, int y)
|
|
||||||
{
|
void Arm2D_Box_setSize(PikaObj *self, int x, int y) {
|
||||||
obj_setInt(self, "sizeX", x);
|
obj_setInt(self, "sizeX", x);
|
||||||
obj_setInt(self, "sizeY", y);
|
obj_setInt(self, "sizeY", y);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "Arm2D_common.h"
|
#include "Arm2D_common.h"
|
||||||
|
|
||||||
void Arm2D_Element_update(PikaObj *self, int bIsNewFrame, void * ptTile)
|
void Arm2D_Element_update(PikaObj *self)
|
||||||
{
|
{
|
||||||
/* need to be override */
|
/* need to be override */
|
||||||
obj_setErrorCode(self, 1);
|
obj_setErrorCode(self, 1);
|
||||||
|
@ -3,23 +3,15 @@
|
|||||||
int32_t __foreach_ElementList_update(Arg *elem, Args *buffs)
|
int32_t __foreach_ElementList_update(Arg *elem, Args *buffs)
|
||||||
{
|
{
|
||||||
char *type = arg_getType(elem);
|
char *type = arg_getType(elem);
|
||||||
void *ptTile = args_getPtr(buffs, "ptTile");
|
|
||||||
int bIsNewFrame = args_getInt(buffs, "bIsNewFrame");
|
|
||||||
if (strIsStartWith(type, "_class"))
|
if (strIsStartWith(type, "_class"))
|
||||||
{
|
{
|
||||||
PikaObj *elemObj = arg_getPtr(elem);
|
PikaObj *elemObj = arg_getPtr(elem);
|
||||||
obj_setPtr(elemObj, "ptTile", ptTile);
|
obj_run(elemObj, "update()");
|
||||||
obj_setInt(elemObj, "bIsNewFrame", bIsNewFrame);
|
|
||||||
obj_run(elemObj, "update(ptTile, bIsNewFrame)");
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Arm2D_ElementList_update(PikaObj *self, int bIsNewFrame, void *ptTile)
|
void Arm2D_ElementList_update(PikaObj *self)
|
||||||
{
|
{
|
||||||
Args *buffs = New_args(NULL);
|
args_foreach(self->attributeList, __foreach_ElementList_update, NULL);
|
||||||
args_setPtr(buffs, "ptTile", (void *)ptTile);
|
}
|
||||||
args_setInt(buffs, "bIsNewFrame", bIsNewFrame);
|
|
||||||
args_foreach(self->attributeList, __foreach_ElementList_update, buffs);
|
|
||||||
args_deinit(buffs);
|
|
||||||
}
|
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
#include "Arm2D_common.h"
|
|
||||||
|
|
||||||
void Arm2D_Screen_init(PikaObj *self)
|
|
||||||
{
|
|
||||||
obj_run(self, "background.init()");
|
|
||||||
}
|
|
||||||
|
|
||||||
void Arm2D_Screen_update(PikaObj *self, int bIsNewFrame, void *ptTile)
|
|
||||||
{
|
|
||||||
obj_setPtr(self, "ptTile", (void *)ptTile);
|
|
||||||
obj_setInt(self, "bIsNewFrame", bIsNewFrame);
|
|
||||||
obj_run(self, "background.update(ptTile, bIsNewFrame)");
|
|
||||||
obj_run(self, "elems.update(ptTile, bIsNewFrame)");
|
|
||||||
}
|
|
92
package/Arm2D/Arm2D_Window.c
Normal file
92
package/Arm2D/Arm2D_Window.c
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
#include "Arm2D_common.h"
|
||||||
|
#include "Arm2D_Window.h"
|
||||||
|
#include "Arm2D_Background.h"
|
||||||
|
#include "Arm2D_ElementList.h"
|
||||||
|
#include <rtthread.h>
|
||||||
|
#include <board.h>
|
||||||
|
|
||||||
|
#include "arm_2d.h"
|
||||||
|
#include "arm_2d_helper.h"
|
||||||
|
#include "lcd_printf.h"
|
||||||
|
#include "pikaScript.h"
|
||||||
|
|
||||||
|
pika_arm2d_window_t pika_arm2d_window;
|
||||||
|
extern int32_t GLCD_DrawBitmap(uint32_t x, uint32_t y, uint32_t width,
|
||||||
|
uint32_t height, const uint8_t *bitmap);
|
||||||
|
static arm_2d_helper_pfb_t s_tPFBHelper;
|
||||||
|
|
||||||
|
static IMPL_PFB_ON_LOW_LV_RENDERING(__pfb_render_handler) {
|
||||||
|
const arm_2d_tile_t *pfb_tile = &(ptPFB->tTile);
|
||||||
|
|
||||||
|
ARM_2D_UNUSED(pTarget);
|
||||||
|
ARM_2D_UNUSED(bIsNewFrame);
|
||||||
|
|
||||||
|
GLCD_DrawBitmap(pfb_tile->tRegion.tLocation.iX,
|
||||||
|
pfb_tile->tRegion.tLocation.iY, pfb_tile->tRegion.tSize.iWidth,
|
||||||
|
pfb_tile->tRegion.tSize.iHeight, pfb_tile->pchBuffer);
|
||||||
|
|
||||||
|
arm_2d_helper_pfb_report_rendering_complete(&s_tPFBHelper,
|
||||||
|
(arm_2d_pfb_t *) ptPFB);
|
||||||
|
}
|
||||||
|
|
||||||
|
static IMPL_PFB_ON_DRAW(pika_pfb_drow_window_hanlder) {
|
||||||
|
ARM_2D_UNUSED(pTarget);
|
||||||
|
ARM_2D_UNUSED(bIsNewFrame);
|
||||||
|
|
||||||
|
pika_arm2d_window.pfb_tile_now = (arm_2d_tile_t *) ptTile;
|
||||||
|
pika_arm2d_window.pfb_is_new_frame = bIsNewFrame;
|
||||||
|
PikaObj * win = pika_arm2d_window.pika_windows_object;
|
||||||
|
PikaObj * background = args_getPtr(win, "background");
|
||||||
|
PikaObj * elems = args_getPtr(win, "elems");
|
||||||
|
Arm2D_BackGround_update(background);
|
||||||
|
Arm2D_ElementList_update(elems);
|
||||||
|
return arm_fsm_rt_cpl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pika_arm2d_init(void) {
|
||||||
|
arm_irq_safe
|
||||||
|
{
|
||||||
|
arm_2d_init()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! initialise FPB helper
|
||||||
|
if (ARM_2D_HELPER_PFB_INIT(
|
||||||
|
&s_tPFBHelper, //!< FPB Helper object
|
||||||
|
LCD_WIDTH,//!< screen width
|
||||||
|
LCD_HEIGHT,//!< screen height
|
||||||
|
uint16_t,//!< colour date type
|
||||||
|
LCD_WIDTH,//!< PFB block width
|
||||||
|
80,//!< PFB block height
|
||||||
|
1,//!< number of PFB in the PFB pool
|
||||||
|
{
|
||||||
|
.evtOnLowLevelRendering =
|
||||||
|
{
|
||||||
|
//! callback for low level rendering
|
||||||
|
.fnHandler = &__pfb_render_handler,
|
||||||
|
},
|
||||||
|
.evtOnDrawing =
|
||||||
|
{
|
||||||
|
//! callback for drawing GUI
|
||||||
|
.fnHandler = &pika_pfb_drow_window_hanlder,
|
||||||
|
},
|
||||||
|
}) < 0) {
|
||||||
|
//! error detected
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void pika_arm2d_update() {
|
||||||
|
while (arm_fsm_rt_cpl != arm_2d_helper_pfb_task(&s_tPFBHelper, NULL))
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Arm2D_Window_init(PikaObj *self) {
|
||||||
|
pika_arm2d_init();
|
||||||
|
obj_run(self, "background.init()");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Arm2D_Window_update(PikaObj *self) {
|
||||||
|
pika_arm2d_window.pika_windows_object = self;
|
||||||
|
pika_arm2d_update();
|
||||||
|
}
|
@ -5,20 +5,53 @@
|
|||||||
#include "arm_2d_helper.h"
|
#include "arm_2d_helper.h"
|
||||||
#include "lcd_printf.h"
|
#include "lcd_printf.h"
|
||||||
#include "pikaScript.h"
|
#include "pikaScript.h"
|
||||||
#include "app-arm2d.h"
|
|
||||||
#include "Arm2D_Box.h"
|
#include "Arm2D_Box.h"
|
||||||
#include "dataStrs.h"
|
#include "dataStrs.h"
|
||||||
#include "BaseObj.h"
|
#include "BaseObj.h"
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#ifndef ARM2DQEMUBOOTER_APP_ARM2D_H_
|
||||||
|
#define APPLICATIONS_APP_ARM2D_H_
|
||||||
|
|
||||||
|
typedef struct pika_arm2d_window_t_ {
|
||||||
|
arm_2d_tile_t *pfb_tile_now;
|
||||||
|
bool pfb_is_new_frame;
|
||||||
|
PikaObj * pika_windows_object;
|
||||||
|
} pika_arm2d_window_t;
|
||||||
|
|
||||||
|
extern pika_arm2d_window_t pika_arm2d_window;
|
||||||
|
|
||||||
|
/* GLCD RGB color definitions */
|
||||||
|
#define GLCD_COLOR_BLACK 0x0000 /* 0, 0, 0 */
|
||||||
|
#define GLCD_COLOR_NAVY 0x000F /* 0, 0, 128 */
|
||||||
|
#define GLCD_COLOR_DARK_GREEN 0x03E0 /* 0, 128, 0 */
|
||||||
|
#define GLCD_COLOR_DARK_CYAN 0x03EF /* 0, 128, 128 */
|
||||||
|
#define GLCD_COLOR_MAROON 0x7800 /* 128, 0, 0 */
|
||||||
|
#define GLCD_COLOR_PURPLE 0x780F /* 128, 0, 128 */
|
||||||
|
#define GLCD_COLOR_OLIVE 0x7BE0 /* 128, 128, 0 */
|
||||||
|
#define GLCD_COLOR_LIGHT_GREY 0xC618 /* 192, 192, 192 */
|
||||||
|
#define GLCD_COLOR_DARK_GREY 0x7BEF /* 128, 128, 128 */
|
||||||
|
#define GLCD_COLOR_BLUE 0x001F /* 0, 0, 255 */
|
||||||
|
#define GLCD_COLOR_GREEN 0x07E0 /* 0, 255, 0 */
|
||||||
|
#define GLCD_COLOR_CYAN 0x07FF /* 0, 255, 255 */
|
||||||
|
#define GLCD_COLOR_RED 0xF800 /* 255, 0, 0 */
|
||||||
|
#define GLCD_COLOR_MAGENTA 0xF81F /* 255, 0, 255 */
|
||||||
|
#define GLCD_COLOR_YELLOW 0xFFE0 /* 255, 255, 0 */
|
||||||
|
#define GLCD_COLOR_WHITE 0xFFFF /* 255, 255, 255 */
|
||||||
|
|
||||||
|
void pika_arm2d_init(void);
|
||||||
|
void pika_arm2d_update();
|
||||||
|
|
||||||
|
#endif /* ARM2DQEMUBOOTER_APP_ARM2D_H_ */
|
||||||
|
|
||||||
uint16_t getColorCode(char *colorName);
|
uint16_t getColorCode(char *colorName);
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
arm_2d_op_rotate_t tOP;
|
||||||
arm_2d_op_rotate_t tOP;
|
const arm_2d_tile_t *ptTile;
|
||||||
const arm_2d_tile_t *ptTile;
|
float fAngle;
|
||||||
float fAngle;
|
float fAngleSpeed;
|
||||||
float fAngleSpeed;
|
arm_2d_location_t tCentre;
|
||||||
arm_2d_location_t tCentre;
|
arm_2d_region_t tRegion;
|
||||||
arm_2d_region_t tRegion;
|
|
||||||
} rotate_tile_t;
|
} rotate_tile_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,79 +1,67 @@
|
|||||||
#include "Arm2d_common.h"
|
#include "Arm2d_common.h"
|
||||||
|
|
||||||
extern const uint8_t c_bmpSun[56 * 57 * sizeof(uint16_t)];
|
extern const uint8_t c_bmpSun[56 * 57 * sizeof(uint16_t)];
|
||||||
const static arm_2d_tile_t c_tPictureSun = {
|
const static arm_2d_tile_t c_tPictureSun = { .tRegion = { .tSize = { .iWidth =
|
||||||
.tRegion = {
|
56, .iHeight = 57 }, }, .tInfo.bIsRoot = true, .phwBuffer =
|
||||||
.tSize = {
|
(uint16_t *) c_bmpSun, };
|
||||||
.iWidth = 56,
|
|
||||||
.iHeight = 57},
|
|
||||||
},
|
|
||||||
.tInfo.bIsRoot = true,
|
|
||||||
.phwBuffer = (uint16_t *)c_bmpSun,
|
|
||||||
};
|
|
||||||
|
|
||||||
void Arm2D_Star_centra(PikaObj *self, int x, int y)
|
void Arm2D_Star_centra(PikaObj *self, int x, int y) {
|
||||||
{
|
obj_setInt(self, "centreX", x);
|
||||||
obj_setInt(self, "centreX", x);
|
obj_setInt(self, "centreY", y);
|
||||||
obj_setInt(self, "centreY", y);
|
|
||||||
}
|
}
|
||||||
void Arm2D_Star_speed(PikaObj *self, float speed)
|
void Arm2D_Star_speed(PikaObj *self, float speed) {
|
||||||
{
|
obj_setFloat(self, "angleSpeed", speed);
|
||||||
obj_setFloat(self, "angleSpeed", speed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Arm2D_Star_init(PikaObj *self)
|
void Arm2D_Star_init(PikaObj *self) {
|
||||||
{
|
obj_setInt(self, "posX", 250);
|
||||||
// obj_setInt(self, "posX", 250);
|
obj_setInt(self, "posY", 250);
|
||||||
// obj_setInt(self, "posY", 250);
|
obj_setInt(self, "centreX", 0);
|
||||||
// obj_setInt(self, "centreX", 0);
|
obj_setInt(self, "centreY", 0);
|
||||||
// obj_setInt(self, "centreY", 0);
|
obj_setFloat(self, "angleSpeed", 0.5f);
|
||||||
// obj_setFloat(self, "angleSpeed", 0.5f);
|
obj_setFloat(self, "angle", 0.0f);
|
||||||
// obj_setFloat(self, "angle", 0.0f);
|
|
||||||
//
|
rotate_tile_t rotateTile = {
|
||||||
// rotate_tile_t rotateTile = {
|
.ptTile = &c_tPictureSun,
|
||||||
// .ptTile = &c_tPictureSun,
|
.fAngleSpeed = 0.0f,
|
||||||
// .fAngleSpeed = 0.0f,
|
.tCentre = {
|
||||||
// .tCentre = {
|
.iX = 0,
|
||||||
// .iX = 0,
|
.iY = 0,
|
||||||
// .iY = 0,
|
},
|
||||||
// },
|
.tRegion = {
|
||||||
// .tRegion = {
|
.tLocation = {
|
||||||
// .tLocation = {
|
.iX = 200,
|
||||||
// .iX = 200,
|
.iY = 200,
|
||||||
// .iY = 200,
|
},
|
||||||
// },
|
.tSize = c_tPictureSun.tRegion.tSize,
|
||||||
// .tSize = c_tPictureSun.tRegion.tSize,
|
},
|
||||||
// },
|
.fAngle = 0.0,
|
||||||
// .fAngle = 0.0,
|
};
|
||||||
// };
|
|
||||||
//
|
Arg *rotateTileArg = New_arg(NULL);
|
||||||
// Arg *rotateTileArg = New_arg(NULL);
|
arg_setContent(rotateTileArg, &rotateTile, sizeof(rotate_tile_t));
|
||||||
// arg_setcontent(rotateTileArg, &rotateTile, sizeof(rotate_tile_t));
|
arg_setName(rotateTileArg, "rotateTile");
|
||||||
// arg_setName(rotateTileArg, "rotateTile");
|
arg_setType(rotateTileArg, "rotate_tile_t");
|
||||||
// arg_setType(rotateTileArg, "rotate_tile_t");
|
obj_setArg(self, "rotateTile", rotateTileArg);
|
||||||
// obj_setArg(self, "rotateTile", rotateTileArg);
|
arg_deinit(rotateTileArg);
|
||||||
// arg_deinit(rotateTileArg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Arm2D_Star_update(PikaObj *self, int bIsNewFrame, void *ptTile)
|
void Arm2D_Star_update(PikaObj *self) {
|
||||||
{
|
int bIsNewFrame = pika_arm2d_window.pfb_is_new_frame;
|
||||||
// Arg *rotateTileArg = obj_getArg(self, "rotateTile");
|
void *target_tile = pika_arm2d_window.pfb_tile_now;
|
||||||
// rotate_tile_t *s_tSun = arg_getcontent(rotateTileArg);
|
|
||||||
// s_tSun->tRegion.tLocation.iX = obj_getInt(self, "posX");
|
Arg *rotateTileArg = obj_getArg(self, "rotateTile");
|
||||||
// s_tSun->tRegion.tLocation.iY = obj_getInt(self, "posY");
|
rotate_tile_t *s_tSun = arg_getContent(rotateTileArg);
|
||||||
// s_tSun->tCentre.iX = obj_getInt(self, "centreX");
|
s_tSun->tRegion.tLocation.iX = obj_getInt(self, "posX");
|
||||||
// s_tSun->tCentre.iY = obj_getInt(self, "centreY");
|
s_tSun->tRegion.tLocation.iY = obj_getInt(self, "posY");
|
||||||
// s_tSun->fAngleSpeed = obj_getFloat(self, "angleSpeed");
|
s_tSun->tCentre.iX = obj_getInt(self, "centreX");
|
||||||
//
|
s_tSun->tCentre.iY = obj_getInt(self, "centreY");
|
||||||
// if (bIsNewFrame)
|
s_tSun->fAngleSpeed = obj_getFloat(self, "angleSpeed");
|
||||||
// {
|
|
||||||
// s_tSun->fAngle += s_tSun->fAngleSpeed;
|
if (bIsNewFrame) {
|
||||||
// }
|
s_tSun->fAngle += s_tSun->fAngleSpeed;
|
||||||
// arm_2dp_rgb565_tile_rotation(&(s_tSun->tOP),
|
}
|
||||||
// s_tSun->ptTile,
|
arm_2dp_rgb565_tile_rotation(&(s_tSun->tOP), s_tSun->ptTile, target_tile,
|
||||||
// ptTile,
|
&(s_tSun->tRegion), s_tSun->tCentre, s_tSun->fAngle,
|
||||||
// &(s_tSun->tRegion),
|
GLCD_COLOR_WHITE);
|
||||||
// s_tSun->tCentre,
|
|
||||||
// s_tSun->fAngle,
|
|
||||||
// GLCD_COLOR_WHITE);
|
|
||||||
}
|
}
|
||||||
|
@ -1,93 +0,0 @@
|
|||||||
#include "app-arm2d.h"
|
|
||||||
|
|
||||||
#include <rtthread.h>
|
|
||||||
#include <board.h>
|
|
||||||
|
|
||||||
#include "arm_2d.h"
|
|
||||||
#include "arm_2d_helper.h"
|
|
||||||
#include "lcd_printf.h"
|
|
||||||
#include "pikaScript.h"
|
|
||||||
extern PikaObj *pikaMain;
|
|
||||||
|
|
||||||
static arm_2d_helper_pfb_t s_tPFBHelper;
|
|
||||||
|
|
||||||
extern int32_t GLCD_DrawBitmap(uint32_t x,
|
|
||||||
uint32_t y,
|
|
||||||
uint32_t width,
|
|
||||||
uint32_t height,
|
|
||||||
const uint8_t *bitmap);
|
|
||||||
|
|
||||||
static IMPL_PFB_ON_LOW_LV_RENDERING(__pfb_render_handler)
|
|
||||||
{
|
|
||||||
const arm_2d_tile_t *ptTile = &(ptPFB->tTile);
|
|
||||||
|
|
||||||
ARM_2D_UNUSED(pTarget);
|
|
||||||
ARM_2D_UNUSED(bIsNewFrame);
|
|
||||||
|
|
||||||
GLCD_DrawBitmap(ptTile->tRegion.tLocation.iX,
|
|
||||||
ptTile->tRegion.tLocation.iY,
|
|
||||||
ptTile->tRegion.tSize.iWidth,
|
|
||||||
ptTile->tRegion.tSize.iHeight,
|
|
||||||
ptTile->pchBuffer);
|
|
||||||
|
|
||||||
arm_2d_helper_pfb_report_rendering_complete(&s_tPFBHelper,
|
|
||||||
(arm_2d_pfb_t *)ptPFB);
|
|
||||||
}
|
|
||||||
|
|
||||||
static IMPL_PFB_ON_DRAW(__pfb_draw_handler_t)
|
|
||||||
{
|
|
||||||
ARM_2D_UNUSED(pTarget);
|
|
||||||
ARM_2D_UNUSED(bIsNewFrame);
|
|
||||||
|
|
||||||
obj_setPtr(pikaMain, "ptTile", (void *)ptTile);
|
|
||||||
obj_setInt(pikaMain, "bIsNewFrame", bIsNewFrame);
|
|
||||||
obj_run(pikaMain, "screen.update(ptTile, bIsNewFrame)");
|
|
||||||
|
|
||||||
return arm_fsm_rt_cpl;
|
|
||||||
}
|
|
||||||
|
|
||||||
__OVERRIDE_WEAK
|
|
||||||
void example_gui_on_refresh_evt_handler(const arm_2d_tile_t *ptFrameBuffer)
|
|
||||||
{
|
|
||||||
ARM_2D_UNUSED(ptFrameBuffer);
|
|
||||||
|
|
||||||
//! print performance info
|
|
||||||
}
|
|
||||||
|
|
||||||
void arm_2d_app_init(void)
|
|
||||||
{
|
|
||||||
arm_irq_safe
|
|
||||||
{
|
|
||||||
arm_2d_init();
|
|
||||||
}
|
|
||||||
|
|
||||||
//! initialise FPB helper
|
|
||||||
if (ARM_2D_HELPER_PFB_INIT(
|
|
||||||
&s_tPFBHelper, //!< FPB Helper object
|
|
||||||
LCD_WIDTH, //!< screen width
|
|
||||||
LCD_HEIGHT, //!< screen height
|
|
||||||
uint16_t, //!< colour date type
|
|
||||||
LCD_WIDTH, //!< PFB block width
|
|
||||||
80, //!< PFB block height
|
|
||||||
1, //!< number of PFB in the PFB pool
|
|
||||||
{
|
|
||||||
.evtOnLowLevelRendering = {
|
|
||||||
//! callback for low level rendering
|
|
||||||
.fnHandler = &__pfb_render_handler,
|
|
||||||
},
|
|
||||||
.evtOnDrawing = {
|
|
||||||
//! callback for drawing GUI
|
|
||||||
.fnHandler = &__pfb_draw_handler_t,
|
|
||||||
},
|
|
||||||
}) < 0)
|
|
||||||
{
|
|
||||||
//! error detected
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void arm_2d_app_update()
|
|
||||||
{
|
|
||||||
while (arm_fsm_rt_cpl != arm_2d_helper_pfb_task(&s_tPFBHelper, NULL))
|
|
||||||
;
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* Change Logs:
|
|
||||||
* Date Author Notes
|
|
||||||
* 2021-08-28 lyon the first version
|
|
||||||
*/
|
|
||||||
#ifndef ARM2DQEMUBOOTER_APP_ARM2D_H_
|
|
||||||
#define APPLICATIONS_APP_ARM2D_H_
|
|
||||||
|
|
||||||
/* GLCD RGB color definitions */
|
|
||||||
#define GLCD_COLOR_BLACK 0x0000 /* 0, 0, 0 */
|
|
||||||
#define GLCD_COLOR_NAVY 0x000F /* 0, 0, 128 */
|
|
||||||
#define GLCD_COLOR_DARK_GREEN 0x03E0 /* 0, 128, 0 */
|
|
||||||
#define GLCD_COLOR_DARK_CYAN 0x03EF /* 0, 128, 128 */
|
|
||||||
#define GLCD_COLOR_MAROON 0x7800 /* 128, 0, 0 */
|
|
||||||
#define GLCD_COLOR_PURPLE 0x780F /* 128, 0, 128 */
|
|
||||||
#define GLCD_COLOR_OLIVE 0x7BE0 /* 128, 128, 0 */
|
|
||||||
#define GLCD_COLOR_LIGHT_GREY 0xC618 /* 192, 192, 192 */
|
|
||||||
#define GLCD_COLOR_DARK_GREY 0x7BEF /* 128, 128, 128 */
|
|
||||||
#define GLCD_COLOR_BLUE 0x001F /* 0, 0, 255 */
|
|
||||||
#define GLCD_COLOR_GREEN 0x07E0 /* 0, 255, 0 */
|
|
||||||
#define GLCD_COLOR_CYAN 0x07FF /* 0, 255, 255 */
|
|
||||||
#define GLCD_COLOR_RED 0xF800 /* 255, 0, 0 */
|
|
||||||
#define GLCD_COLOR_MAGENTA 0xF81F /* 255, 0, 255 */
|
|
||||||
#define GLCD_COLOR_YELLOW 0xFFE0 /* 255, 255, 0 */
|
|
||||||
#define GLCD_COLOR_WHITE 0xFFFF /* 255, 255, 255 */
|
|
||||||
|
|
||||||
void arm_2d_app_init(void);
|
|
||||||
void arm_2d_app_update();
|
|
||||||
|
|
||||||
#endif /* ARM2DQEMUBOOTER_APP_ARM2D_H_ */
|
|
@ -17,92 +17,76 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "pikaScript.h"
|
#include "pikaScript.h"
|
||||||
#include "dataStrs.h"
|
#include "dataStrs.h"
|
||||||
#include "app-arm2d.h"
|
#include "Arm2D_common.h"
|
||||||
|
|
||||||
#define SAMPLE_UART_NAME "uart1" /* 串口设备名称 */
|
#define SAMPLE_UART_NAME "uart1" /* 串口设备名称 */
|
||||||
static rt_device_t serial; /* 串口设备句柄 */
|
static rt_device_t serial; /* 串口设备句柄 */
|
||||||
static struct rt_semaphore rx_sem; /* 用于接收消息的信号量 */
|
static struct rt_semaphore rx_sem; /* 用于接收消息的信号量 */
|
||||||
|
|
||||||
#define RX_Buff_SIZE 256
|
#define RX_Buff_SIZE 256
|
||||||
char rxBuff[RX_Buff_SIZE] = {0};
|
char rxBuff[RX_Buff_SIZE] = { 0 };
|
||||||
Args *rxArgs;
|
Args *rxArgs;
|
||||||
uint8_t isRxOk = 0;
|
uint8_t isRxOk = 0;
|
||||||
PikaObj *pikaMain;
|
PikaObj *pikaMain;
|
||||||
|
|
||||||
void rxSingleLineCallBack(char *line)
|
void rx_single_line_handle(char *line) {
|
||||||
{
|
Args * resArgs = obj_runDirect(pikaMain, line);
|
||||||
Args * resArgs = obj_runDirect(pikaMain, line);
|
char * sysOut = args_getSysOut(resArgs);
|
||||||
char * sysOut = args_getSysOut(resArgs);
|
rt_kprintf("\r\n");
|
||||||
rt_kprintf("\r\n");
|
|
||||||
|
|
||||||
if (!strEqu(sysOut, ""))
|
if (!strEqu(sysOut, "")) {
|
||||||
{
|
rt_kprintf("%s\r\n", sysOut);
|
||||||
rt_kprintf("%s\r\n", sysOut);
|
}
|
||||||
}
|
args_deinit(resArgs);
|
||||||
args_deinit(resArgs);
|
|
||||||
|
|
||||||
rt_kprintf(">>>");
|
rt_kprintf(">>>");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 接收数据回调函数 */
|
/* 接收数据回调函数 */
|
||||||
static rt_err_t uart_input(rt_device_t dev, rt_size_t size)
|
static rt_err_t uart_input_callback(rt_device_t dev, rt_size_t size) {
|
||||||
{
|
/* 串口接收到数据后产生中断,调用此回调函数,然后发送接收信号量 */
|
||||||
/* 串口接收到数据后产生中断,调用此回调函数,然后发送接收信号量 */
|
char inputChar;
|
||||||
char inputChar;
|
rt_device_read(serial, -1, &inputChar, 1);
|
||||||
rt_device_read(serial, -1, &inputChar, 1);
|
rt_device_write(serial, 0, &inputChar, 1);
|
||||||
rt_device_write(serial, 0, &inputChar, 1);
|
if (inputChar != '\r' && inputChar != '\n') {
|
||||||
|
strAppendWithSize(rxBuff, &inputChar, 1);
|
||||||
if (inputChar != '\r' && inputChar != '\n')
|
}
|
||||||
{
|
if (inputChar == '\r') {
|
||||||
strAppendWithSize(rxBuff, &inputChar, 1);
|
isRxOk = 1;
|
||||||
}
|
}
|
||||||
if (inputChar == '\r')
|
return RT_EOK;
|
||||||
{
|
|
||||||
isRxOk = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RT_EOK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clearBuff(char *buff, uint32_t size)
|
static void clearBuff(char *buff, uint32_t size) {
|
||||||
{
|
for (int i = 0; i < size; i++) {
|
||||||
for (int i =0;i <size; i++)
|
buff[i] = 0;
|
||||||
{
|
}
|
||||||
buff[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void uart_init()
|
static void uart_init() {
|
||||||
{
|
serial = rt_device_find(SAMPLE_UART_NAME);
|
||||||
serial = rt_device_find(SAMPLE_UART_NAME);
|
|
||||||
|
|
||||||
/* 以中断接收及轮询发送模式打开串口设备 */
|
/* 以中断接收及轮询发送模式打开串口设备 */
|
||||||
rt_device_open(serial, RT_DEVICE_FLAG_INT_RX);
|
rt_device_open(serial, RT_DEVICE_FLAG_INT_RX);
|
||||||
|
|
||||||
/* 初始化信号量 */
|
/* 初始化信号量 */
|
||||||
rt_sem_init(&rx_sem, "rx_sem", 0, RT_IPC_FLAG_FIFO);
|
rt_sem_init(&rx_sem, "rx_sem", 0, RT_IPC_FLAG_FIFO);
|
||||||
|
|
||||||
/* 设置接收回调函数 */
|
/* 设置接收回调函数 */
|
||||||
rt_device_set_rx_indicate(serial, uart_input);
|
rt_device_set_rx_indicate(serial, uart_input_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void) {
|
||||||
{
|
uart_init();
|
||||||
uart_init();
|
pikaMain = pikaScriptInit();
|
||||||
pikaMain = pikaScriptInit();
|
clearBuff(rxBuff, RX_Buff_SIZE);
|
||||||
clearBuff(rxBuff, RX_Buff_SIZE);
|
rt_kprintf(">>>");
|
||||||
arm_2d_app_init();
|
while (1) {
|
||||||
|
if (isRxOk) {
|
||||||
rt_kprintf(">>>");
|
isRxOk = 0;
|
||||||
while(1)
|
rx_single_line_handle(rxBuff);
|
||||||
{
|
clearBuff(rxBuff, RX_Buff_SIZE);
|
||||||
if(isRxOk)
|
}
|
||||||
{
|
}
|
||||||
isRxOk = 0;
|
return RT_EOK;
|
||||||
rxSingleLineCallBack(rxBuff);
|
|
||||||
clearBuff(rxBuff, RX_Buff_SIZE);
|
|
||||||
}
|
|
||||||
arm_2d_app_update();
|
|
||||||
}
|
|
||||||
return RT_EOK;
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user