Starting on screen impl
This commit is contained in:
parent
7671a75dbc
commit
02d8cf7056
16
libs/core/dal.d.ts
vendored
16
libs/core/dal.d.ts
vendored
@ -344,6 +344,22 @@ declare const enum DAL {
|
|||||||
DISPLAY_ERASE_LINE = 0x05,
|
DISPLAY_ERASE_LINE = 0x05,
|
||||||
DISPLAY_FILL_REGION = 0x06,
|
DISPLAY_FILL_REGION = 0x06,
|
||||||
DISPLAY_FRAME = 0x07,
|
DISPLAY_FRAME = 0x07,
|
||||||
|
DRAW_OPT_NORMAL = (0x0000),
|
||||||
|
DRAW_OPT_CLEAR_WHOLE_SCREEN = (0x0001),
|
||||||
|
DRAW_OPT_CLEAR_EXCEPT_STATUS_SCREEN = (0x0002),
|
||||||
|
DRAW_OPT_CLEAR_PIXELS = (0x0004),
|
||||||
|
DRAW_OPT_CLEAR = (0x0004),
|
||||||
|
DRAW_OPT_INVERT = (0x0004),
|
||||||
|
DRAW_OPT_LOGICAL_COPY = (0x0000),
|
||||||
|
DRAW_OPT_LOGICAL_AND = (0x0008),
|
||||||
|
DRAW_OPT_LOGICAL_OR = (0x0010),
|
||||||
|
DRAW_OPT_LOGICAL_XOR = (0x0018),
|
||||||
|
DRAW_OPT_FILL_SHAPE = (0x0020),
|
||||||
|
DRAW_OPT_CLEAR_SCREEN_MODES = (0x0003),
|
||||||
|
DRAW_OPT_LOGICAL_OPERATIONS = (0x0018),
|
||||||
|
DRAW_OPT_POLYGON_POLYLINE = (0x0400),
|
||||||
|
DRAW_OPT_CLEAR_LINE = (0x0800),
|
||||||
|
DRAW_OPT_CLEAR_EOL = (0x1000),
|
||||||
CS_TIMER_1 = 0,
|
CS_TIMER_1 = 0,
|
||||||
CS_TIMER_2 = 1,
|
CS_TIMER_2 = 1,
|
||||||
CS_TIMER_3 = 2,
|
CS_TIMER_3 = 2,
|
||||||
|
12
libs/core/enums.d.ts
vendored
12
libs/core/enums.d.ts
vendored
@ -34,4 +34,16 @@
|
|||||||
OrangePulse = 9, // LED_ORANGE_PULSE
|
OrangePulse = 9, // LED_ORANGE_PULSE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drawing modes
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare enum Draw {
|
||||||
|
Normal = (0x0000), // DRAW_OPT_NORMAL
|
||||||
|
Clear = (0x0004), // DRAW_OPT_CLEAR_PIXELS
|
||||||
|
Xor = (0x0018), // DRAW_OPT_LOGICAL_XOR
|
||||||
|
Fill = (0x0020), // DRAW_OPT_FILL_SHAPE
|
||||||
|
}
|
||||||
|
|
||||||
// Auto-generated. Do not edit. Really.
|
// Auto-generated. Do not edit. Really.
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
"pxtcore.h",
|
"pxtcore.h",
|
||||||
"linux.cpp",
|
"linux.cpp",
|
||||||
"buttons.cpp",
|
"buttons.cpp",
|
||||||
|
"screen.cpp",
|
||||||
|
"screen.ts",
|
||||||
"shims.d.ts",
|
"shims.d.ts",
|
||||||
"enums.d.ts",
|
"enums.d.ts",
|
||||||
"dal.d.ts",
|
"dal.d.ts",
|
||||||
@ -17,10 +19,10 @@
|
|||||||
"test.ts"
|
"test.ts"
|
||||||
],
|
],
|
||||||
"npmDependencies": {
|
"npmDependencies": {
|
||||||
"ev3api-bin": "1.0.0"
|
"ev3api-bin": "1.0.0"
|
||||||
},
|
},
|
||||||
"public": true,
|
"public": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"base": "file:../base"
|
"base": "file:../base"
|
||||||
}
|
}
|
||||||
}
|
}
|
39
libs/core/screen.cpp
Normal file
39
libs/core/screen.cpp
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#include "pxt.h"
|
||||||
|
#include "ev3.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drawing modes
|
||||||
|
*/
|
||||||
|
enum class Draw {
|
||||||
|
Normal = DRAW_OPT_NORMAL, // set pixels to black, no fill
|
||||||
|
Clear = DRAW_OPT_CLEAR_PIXELS,
|
||||||
|
Xor = DRAW_OPT_LOGICAL_XOR,
|
||||||
|
Fill = DRAW_OPT_FILL_SHAPE,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define XX(v) ((uint32_t)(v)&0xffff)
|
||||||
|
#define YY(v) ((uint32_t)(v) >> 16)
|
||||||
|
|
||||||
|
// We only support up to 4 arguments for C++ functions - need to pack them on the TS side
|
||||||
|
namespace screen {
|
||||||
|
//%
|
||||||
|
void _drawLine(uint32_t p0, uint32_t p1, Draw mode) {
|
||||||
|
LineOutEx(XX(p0), YY(p0), XX(p1), YY(p1), (uint32_t)mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
//%
|
||||||
|
void _drawRect(uint32_t p0, uint32_t p1, Draw mode) {
|
||||||
|
RectOutEx(XX(p0), YY(p0), XX(p1), YY(p1), (uint32_t)mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
//%
|
||||||
|
void _drawEllipse(uint32_t p0, uint32_t p1, Draw mode) {
|
||||||
|
EllipseOutEx(XX(p0), YY(p0), XX(p1), YY(p1), (uint32_t)mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Draw text. */
|
||||||
|
//%
|
||||||
|
void drawText(int x, int y, String text, Draw mode) {
|
||||||
|
LcdText((int)mode & (int)Draw::Clear ? 0 : 1, x, y, text->data);
|
||||||
|
}
|
||||||
|
}
|
11
libs/core/screen.ts
Normal file
11
libs/core/screen.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace screen {
|
||||||
|
//% shim=screen::_drawLine
|
||||||
|
function _drawLine(p0: uint32, p1: uint32, mode: Draw): void {}
|
||||||
|
|
||||||
|
//% shim=screen::_drawRect
|
||||||
|
function _drawRect(p0: uint32, p1: uint32, mode: Draw): void {}
|
||||||
|
|
||||||
|
//% shim=screen::_drawEllipse
|
||||||
|
function _drawEllipse(p0: uint32, p1: uint32, mode: Draw): void {}
|
||||||
|
|
||||||
|
}
|
14
libs/core/shims.d.ts
vendored
14
libs/core/shims.d.ts
vendored
@ -38,6 +38,14 @@ declare namespace input {
|
|||||||
//% block="button exit" weight=95 fixedInstance shim=pxt::getButton(5)
|
//% block="button exit" weight=95 fixedInstance shim=pxt::getButton(5)
|
||||||
const buttonExit: Button;
|
const buttonExit: Button;
|
||||||
}
|
}
|
||||||
|
declare namespace control {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine the version of system software currently running.
|
||||||
|
*/
|
||||||
|
//% shim=control::deviceFirmwareVersion
|
||||||
|
function deviceFirmwareVersion(): string;
|
||||||
|
}
|
||||||
declare namespace output {
|
declare namespace output {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,5 +103,11 @@ declare interface Button {
|
|||||||
//% button.fieldOptions.columns=3 shim=ButtonMethods::wasPressed
|
//% button.fieldOptions.columns=3 shim=ButtonMethods::wasPressed
|
||||||
wasPressed(): boolean;
|
wasPressed(): boolean;
|
||||||
}
|
}
|
||||||
|
declare namespace screen {
|
||||||
|
|
||||||
|
/** Draw text. */
|
||||||
|
//% shim=screen::drawText
|
||||||
|
function drawText(x: int32, y: int32, text: string, mode: Draw): void;
|
||||||
|
}
|
||||||
|
|
||||||
// Auto-generated. Do not edit. Really.
|
// Auto-generated. Do not edit. Really.
|
||||||
|
9
libs/core/tsconfig.json
Normal file
9
libs/core/tsconfig.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"outDir": "built",
|
||||||
|
"rootDir": "."
|
||||||
|
},
|
||||||
|
"exclude": ["pxt_modules/**/*test.ts"]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user