Use custom build of ev3-api, and own screen refresh
This commit is contained in:
parent
6fb7908b21
commit
43b167957b
6
TODO.md
Normal file
6
TODO.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
* [ ] try unlink ELF file before uploading
|
||||||
|
* [ ] implement serialPoll
|
||||||
|
* [ ] try some motors
|
||||||
|
|
||||||
|
## Further down
|
||||||
|
* [ ] have some protocol for restarting user app if it's running (flag file somewhere?)
|
@ -117,6 +117,14 @@ namespace pxt.editor {
|
|||||||
}).filter(v => !!v))
|
}).filter(v => !!v))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rmAsync(path: string): Promise<void> {
|
||||||
|
let rmReq = this.allocSystem(path.length + 1, 0x9c)
|
||||||
|
U.memcpy(rmReq, 6, U.stringToUint8Array(path))
|
||||||
|
|
||||||
|
return this.talkAsync(rmReq)
|
||||||
|
.then(resp => { })
|
||||||
|
}
|
||||||
|
|
||||||
private initAsync() {
|
private initAsync() {
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,10 @@ Button *getButton(int id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void target_init() {
|
void target_init() {
|
||||||
InitEV3();
|
OutputInit();
|
||||||
|
ButtonLedInit();
|
||||||
|
SoundInit();
|
||||||
|
|
||||||
getWButtons(); // always on - handles ESCAPE key
|
getWButtons(); // always on - handles ESCAPE key
|
||||||
DMESG("runtime started [%s]", HardwareVersionString());
|
DMESG("runtime started [%s]", HardwareVersionString());
|
||||||
}
|
}
|
||||||
|
@ -262,6 +262,7 @@ void dumpDmesg() {
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void screen_init();
|
||||||
void initRuntime() {
|
void initRuntime() {
|
||||||
daemon(1, 1);
|
daemon(1, 1);
|
||||||
startTime = currTime();
|
startTime = currTime();
|
||||||
@ -270,6 +271,7 @@ void initRuntime() {
|
|||||||
pthread_create(&disp, NULL, evtDispatcher, NULL);
|
pthread_create(&disp, NULL, evtDispatcher, NULL);
|
||||||
pthread_detach(disp);
|
pthread_detach(disp);
|
||||||
target_init();
|
target_init();
|
||||||
|
screen_init();
|
||||||
startUser();
|
startUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
"test.ts"
|
"test.ts"
|
||||||
],
|
],
|
||||||
"npmDependencies": {
|
"npmDependencies": {
|
||||||
"ev3api-bin": "1.0.0"
|
"ev3api-bin": "1.1.0"
|
||||||
},
|
},
|
||||||
"public": true,
|
"public": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "pxt.h"
|
#include "pxt.h"
|
||||||
#include "ev3.h"
|
#include "ev3.h"
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Drawing modes
|
* Drawing modes
|
||||||
@ -24,32 +25,19 @@ enum class ScreenFont {
|
|||||||
// We only support up to 4 arguments for C++ functions - need to pack them on the TS side
|
// We only support up to 4 arguments for C++ functions - need to pack them on the TS side
|
||||||
namespace screen {
|
namespace screen {
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
void DisplaySetPixel(byte X, byte Y);
|
|
||||||
void DisplayClrPixel(byte X, byte Y);
|
|
||||||
void DisplayXorPixel(byte X, byte Y);
|
|
||||||
}
|
|
||||||
|
|
||||||
void pokeScreen() {
|
|
||||||
DisplayXorPixel(0, 0);
|
|
||||||
DisplayXorPixel(0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//%
|
//%
|
||||||
void _drawLine(uint32_t p0, uint32_t p1, Draw mode) {
|
void _drawLine(uint32_t p0, uint32_t p1, Draw mode) {
|
||||||
DMESG("line %x %x %x", p0, p1, mode);
|
|
||||||
LineOutEx(XX(p0), YY(p0), XX(p1), YY(p1), (uint32_t)mode);
|
LineOutEx(XX(p0), YY(p0), XX(p1), YY(p1), (uint32_t)mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
//%
|
//%
|
||||||
void _drawRect(uint32_t p0, uint32_t p1, Draw mode) {
|
void _drawRect(uint32_t p0, uint32_t p1, Draw mode) {
|
||||||
DMESG("rect %x %x %x", p0, p1, mode);
|
|
||||||
RectOutEx(XX(p0), YY(p0), XX(p1), YY(p1), (uint32_t)mode);
|
RectOutEx(XX(p0), YY(p0), XX(p1), YY(p1), (uint32_t)mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
//%
|
//%
|
||||||
void _drawEllipse(uint32_t p0, uint32_t p1, Draw mode) {
|
void _drawEllipse(uint32_t p0, uint32_t p1, Draw mode) {
|
||||||
DMESG("ellip %x %x %x", p0, p1, mode);
|
|
||||||
EllipseOutEx(XX(p0), YY(p0), XX(p1), YY(p1), (uint32_t)mode);
|
EllipseOutEx(XX(p0), YY(p0), XX(p1), YY(p1), (uint32_t)mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,8 +57,6 @@ void clear() {
|
|||||||
//%
|
//%
|
||||||
void scroll(int v) {
|
void scroll(int v) {
|
||||||
LcdScroll(v);
|
LcdScroll(v);
|
||||||
pokeScreen(); // missing in ev3-api
|
|
||||||
//LcdUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set font for drawText() */
|
/** Set font for drawText() */
|
||||||
@ -79,3 +65,23 @@ void setFont(ScreenFont font) {
|
|||||||
LcdSelectFont((uint8_t)font);
|
LcdSelectFont((uint8_t)font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace pxt {
|
||||||
|
|
||||||
|
void *screenRefresh(void *dummy) {
|
||||||
|
while (true) {
|
||||||
|
sleep_core_us(30000);
|
||||||
|
LcdUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void screen_init() {
|
||||||
|
LcdInitNoAutoRefresh();
|
||||||
|
LcdClean();
|
||||||
|
|
||||||
|
pthread_t pid;
|
||||||
|
pthread_create(&pid, NULL, screenRefresh, NULL);
|
||||||
|
pthread_detach(pid);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user