Adding local include with constants; dropping LMS enum

This commit is contained in:
Michal Moskal 2017-07-11 16:18:59 +02:00
parent b60775fa50
commit ad5d5daee5
17 changed files with 169 additions and 718 deletions

View File

@ -22,9 +22,8 @@
"output.createBuffer|param|size": "number of bytes in the buffer",
"output.setLights": "Set lights.",
"screen.clear": "Clear screen and reset font to normal.",
"screen.drawText": "Draw text.",
"screen.scroll": "Scroll screen vertically.",
"screen.setFont": "Set font for drawText()",
"screen.doubleIcon": "Double size of an icon.",
"screen.drawIcon": "Draw an icon on the screen.",
"serial": "Reading and writing data over a serial connection.",
"serial.writeDmesg": "Send DMESG debug buffer over serial."
}

View File

@ -126,7 +126,7 @@ namespace input {
}
function readButtons() {
let sl = btnsMM.slice(0, LMS.NUM_BUTTONS)
let sl = btnsMM.slice(0, DAL.NUM_BUTTONS)
let ret = 0
for (let i = 0; i < sl.length; ++i) {
if (sl[i])
@ -137,11 +137,11 @@ namespace input {
function initBtns() {
if (btnsMM) return
btnsMM = control.mmap("/dev/lms_ui", LMS.NUM_BUTTONS, 0)
btnsMM = control.mmap("/dev/lms_ui", DAL.NUM_BUTTONS, 0)
if (!btnsMM) control.fail("no buttons?")
buttons = []
input.internal.unsafePollForChanges(50, readButtons, (prev, curr) => {
if (curr & LMS.BUTTON_ID_ESCAPE)
if (curr & DAL.BUTTON_ID_ESCAPE)
control.reset()
for (let b of buttons)
b.update(!!(curr & b.mask))
@ -165,31 +165,31 @@ namespace input {
* Left button.
*/
//% whenUsed block="button left" weight=95 fixedInstance
export const buttonLeft: Button = new DevButton(LMS.BUTTON_ID_LEFT)
export const buttonLeft: Button = new DevButton(DAL.BUTTON_ID_LEFT)
/**
* Right button.
*/
//% whenUsed block="button right" weight=94 fixedInstance
export const buttonRight: Button = new DevButton(LMS.BUTTON_ID_RIGHT)
export const buttonRight: Button = new DevButton(DAL.BUTTON_ID_RIGHT)
/**
* Up button.
*/
//% whenUsed block="button up" weight=95 fixedInstance
export const buttonUp: Button = new DevButton(LMS.BUTTON_ID_UP)
export const buttonUp: Button = new DevButton(DAL.BUTTON_ID_UP)
/**
* Down button.
*/
//% whenUsed block="button down" weight=95 fixedInstance
export const buttonDown: Button = new DevButton(LMS.BUTTON_ID_DOWN)
export const buttonDown: Button = new DevButton(DAL.BUTTON_ID_DOWN)
/**
* Enter button.
*/
//% whenUsed block="button enter" weight=95 fixedInstance
export const buttonEnter: Button = new DevButton(LMS.BUTTON_ID_ENTER)
export const buttonEnter: Button = new DevButton(DAL.BUTTON_ID_ENTER)
}

View File

@ -27,7 +27,7 @@ namespace input {
}
_deviceType() {
return LMS.DEVICE_TYPE_COLOR
return DAL.DEVICE_TYPE_COLOR
}
setMode(m: ColorSensorMode) {

View File

@ -16,83 +16,3 @@ namespace control {
}
}
const enum LMS {
NUM_INPUTS = 4,
LCD_WIDTH = 178,
LCD_HEIGHT = 128,
NUM_BUTTONS = 6,
DEVICE_TYPE_NXT_TOUCH = 1,
DEVICE_TYPE_NXT_LIGHT = 2,
DEVICE_TYPE_NXT_SOUND = 3,
DEVICE_TYPE_NXT_COLOR = 4,
DEVICE_TYPE_TACHO = 7,
DEVICE_TYPE_MINITACHO = 8,
DEVICE_TYPE_NEWTACHO = 9,
DEVICE_TYPE_TOUCH = 16,
DEVICE_TYPE_COLOR = 29,
DEVICE_TYPE_ULTRASONIC = 30,
DEVICE_TYPE_GYRO = 32,
DEVICE_TYPE_IR = 33,
DEVICE_TYPE_THIRD_PARTY_START = 50,
DEVICE_TYPE_THIRD_PARTY_END = 99,
DEVICE_TYPE_IIC_UNKNOWN = 100,
DEVICE_TYPE_NXT_TEST = 101,
DEVICE_TYPE_NXT_IIC = 123,
DEVICE_TYPE_TERMINAL = 124,
DEVICE_TYPE_UNKNOWN = 125,
DEVICE_TYPE_NONE = 126,
DEVICE_TYPE_ERROR = 127,
MAX_DEVICE_DATALENGTH = 32,
MAX_DEVICE_MODES = 8,
UART_BUFFER_SIZE = 64,
TYPE_NAME_LENGTH = 11,
SYMBOL_LENGTH = 4,
DEVICE_LOGBUF_SIZE = 300,
IIC_NAME_LENGTH = 8,
CONN_UNKNOWN = 111,
CONN_DAISYCHAIN = 117,
CONN_NXT_COLOR = 118,
CONN_NXT_DUMB = 119,
CONN_NXT_IIC = 120,
CONN_INPUT_DUMB = 121,
CONN_INPUT_UART = 122,
CONN_OUTPUT_DUMB = 123,
CONN_OUTPUT_INTELLIGENT = 124,
CONN_OUTPUT_TACHO = 125,
CONN_NONE = 126,
CONN_ERROR = 127,
opOutputGetType = 0xA0,
opOutputSetType = 0xA1,
opOutputReset = 0xA2,
opOutputStop = 0xA3,
opOutputPower = 0xA4,
opOutputSpeed = 0xA5,
opOutputStart = 0xA6,
opOutputPolarity = 0xA7,
opOutputRead = 0xA8,
opOutputTest = 0xA9,
opOutputReady = 0xAA,
opOutputPosition = 0xAB,
opOutputStepPower = 0xAC,
opOutputTimePower = 0xAD,
opOutputStepSpeed = 0xAE,
opOutputTimeSpeed = 0xAF,
opOutputStepSync = 0xB0,
opOutputTimeSync = 0xB1,
opOutputClearCount = 0xB2,
opOutputGetCount = 0xB3,
opOutputProgramStop = 0xB4,
DEVICE_EVT_ANY = 0,
DEVICE_ID_NOTIFY = 10000,
DEVICE_ID_NOTIFY_ONE = 10001,
BUTTON_ID_UP = 0x01,
BUTTON_ID_ENTER = 0x02,
BUTTON_ID_DOWN = 0x04,
BUTTON_ID_RIGHT = 0x08,
BUTTON_ID_LEFT = 0x10,
BUTTON_ID_ESCAPE = 0x20,
}

616
libs/core/dal.d.ts vendored
View File

@ -1,62 +1,10 @@
// Auto-generated. Do not edit.
declare const enum DAL {
// built/dockermake/node_modules/ev3api-bin/include/analog.h
COLORS = 4,
CALPOINTS = 3,
// built/dockermake/node_modules/ev3api-bin/include/basictypes.h
// built/dockermake/node_modules/ev3api-bin/include/ev3.h
// built/dockermake/node_modules/ev3api-bin/include/ev3_button.h
// built/dockermake/node_modules/ev3api-bin/include/ev3_command.h
// built/dockermake/node_modules/ev3api-bin/include/ev3_constants.h
TRUE = 1,
FALSE = 0,
// built/dockermake/pxtapp/ev3const.h
NUM_INPUTS = 4,
NUM_LEDS = 4,
LCD_WIDTH = 178,
LCD_HEIGHT = 128,
TOPLINE_HEIGHT = 10,
OWNER_NONE = 0x0000,
LAYER_MASTER = 0x00,
LAYER_SLAVE1 = 0x10,
LAYER_SLAVE2 = 0x20,
LAYER_SLAVE3 = 0x40,
LAYER_MASK = 0x70,
OUT_A = 0x01,
OUT_B = 0x02,
OUT_C = 0x04,
OUT_D = 0x08,
OUT_AB = 0x03,
OUT_AC = 0x05,
OUT_AD = 0x09,
OUT_BC = 0x06,
OUT_BD = 0x0a,
OUT_CD = 0x0c,
OUT_ABC = 0x07,
OUT_BCD = 0x0e,
OUT_ABCD = 0x0f,
OUT_ALL = 0x0f,
OUT_MASK = 0x0f,
IN_1 = 0x0,
IN_2 = 0x1,
IN_3 = 0x2,
IN_4 = 0x3,
OUT_FLOAT = 0x00,
OUT_OFF = 0x40,
OUT_ON = 0x80,
OUT_REV = 0x00,
OUT_TOGGLE = 0x40,
OUT_FWD = 0x80,
OUT_POWER_DEFAULT = -127,
OUT_REGMODE_IDLE = 0,
OUT_REGMODE_SPEED = 1,
OUT_REGMODE_SYNC = 2,
RESET_NONE = 0x00,
RESET_COUNT = 0x08,
RESET_BLOCK_COUNT = 0x20,
RESET_ROTATION_COUNT = 0x40,
RESET_BLOCKANDTACHO = 0x28,
RESET_ALL = 0x68,
NUM_OUTPUTS = 4,
NUM_BUTTONS = 6,
DEVICE_TYPE_NXT_TOUCH = 1,
DEVICE_TYPE_NXT_LIGHT = 2,
DEVICE_TYPE_NXT_SOUND = 3,
@ -64,6 +12,11 @@ declare const enum DAL {
DEVICE_TYPE_TACHO = 7,
DEVICE_TYPE_MINITACHO = 8,
DEVICE_TYPE_NEWTACHO = 9,
DEVICE_TYPE_TOUCH = 16,
DEVICE_TYPE_COLOR = 29,
DEVICE_TYPE_ULTRASONIC = 30,
DEVICE_TYPE_GYRO = 32,
DEVICE_TYPE_IR = 33,
DEVICE_TYPE_THIRD_PARTY_START = 50,
DEVICE_TYPE_THIRD_PARTY_END = 99,
DEVICE_TYPE_IIC_UNKNOWN = 100,
@ -92,445 +45,6 @@ declare const enum DAL {
CONN_OUTPUT_TACHO = 125,
CONN_NONE = 126,
CONN_ERROR = 127,
BUTTON_ID_UP = 0x01,
BUTTON_ID_ENTER = 0x02,
BUTTON_ID_DOWN = 0x04,
BUTTON_ID_RIGHT = 0x08,
BUTTON_ID_LEFT = 0x10,
BUTTON_ID_ESCAPE = 0x20,
BUTTON_ID_ALL = 0x3f,
NO_OF_BTNS = 6,
NUM_BUTTONS = 6,
BTNSTATE_PRESSED_EV = 0x01,
BTNSTATE_SHORT_RELEASED_EV = 0x02,
BTNSTATE_LONG_PRESSED_EV = 0x04,
BTNSTATE_LONG_RELEASED_EV = 0x08,
BTNSTATE_PRESSED_STATE = 0x80,
BTNSTATE_NONE = 0x10,
NXTCOLOR_IDX_RED = 0,
NXTCOLOR_IDX_GREEN = 1,
NXTCOLOR_IDX_BLUE = 2,
NXTCOLOR_IDX_BLANK = 3,
NUM_NXTCOLOR_IDX = 4,
NXTCOLOR_CAL_POINT_0 = 0,
NXTCOLOR_CAL_POINT_1 = 1,
NXTCOLOR_CAL_POINT_2 = 2,
NUM_NXTCOLOR_CAL_POINTS = 3,
INPUT_BLACKCOLOR = 1,
INPUT_BLUECOLOR = 2,
INPUT_GREENCOLOR = 3,
INPUT_YELLOWCOLOR = 4,
INPUT_REDCOLOR = 5,
INPUT_WHITECOLOR = 6,
FILETYPE_UNKNOWN = 0x00,
FILETYPE_FOLDER = 0x01,
FILETYPE_SOUND = 0x02,
FILETYPE_BYTECODE = 0x03,
FILETYPE_GRAPHICS = 0x04,
FILETYPE_DATALOG = 0x05,
FILETYPE_PROGRAM = 0x06,
FILETYPE_TEXT = 0x07,
FILETYPE_SDCARD = 0x10,
FILETYPE_USBSTICK = 0x20,
NUM_FILETYPES = 0x21,
FONTTYPE_NORMAL = 0,
FONTTYPE_SMALL = 1,
FONTTYPE_LARGE = 2,
FONTTYPE_TINY = 3,
NUM_FONTTYPES = 4,
ICONTYPE_NORMAL = 0,
ICONTYPE_SMALL = 1,
ICONTYPE_LARGE = 2,
ICONTYPE_MENU = 3,
ICONTYPE_ARROW = 4,
NUM_ICONTYPES = 5,
NICON_NONE = -1,
NICON_RUN = 0,
NICON_FOLDER = 1,
NICON_FOLDER2 = 2,
NICON_USB = 3,
NICON_SD = 4,
NICON_SOUND = 5,
NICON_IMAGE = 6,
NICON_SETTINGS = 7,
NICON_ONOFF = 8,
NICON_SEARCH = 9,
NICON_WIFI = 10,
NICON_CONNECTIONS = 11,
NICON_ADD_HIDDEN = 12,
NICON_TRASHBIN = 13,
NICON_VISIBILITY = 14,
NICON_KEY = 15,
NICON_CONNECT = 16,
NICON_DISCONNECT = 17,
NICON_UP = 18,
NICON_DOWN = 19,
NICON_WAIT1 = 20,
NICON_WAIT2 = 21,
NICON_BLUETOOTH = 22,
NICON_INFO = 23,
NICON_TEXT = 24,
NICON_QUESTIONMARK = 27,
NICON_INFO_FILE = 28,
NICON_DISC = 29,
NICON_CONNECTED = 30,
NICON_OBP = 31,
NICON_OBD = 32,
NICON_OPENFOLDER = 33,
NICON_BRICK1 = 34,
NUM_NICONS = 35,
PATH_SIZE = 84,
NAME_SIZE = 32,
EXT_SIZE = 5,
FILENAME_SIZE = 120,
MAC_SIZE = 18,
IP_SIZE = 16,
BT_SIZE = 13,
LED_BLACK = 0,
LED_GREEN = 1,
LED_RED = 2,
LED_ORANGE = 3,
LED_GREEN_FLASH = 4,
LED_RED_FLASH = 5,
LED_ORANGE_FLASH = 6,
LED_GREEN_PULSE = 7,
LED_RED_PULSE = 8,
LED_ORANGE_PULSE = 9,
NUM_LED_PATTERNS = 10,
MS_1 = 1,
MS_2 = 2,
MS_3 = 3,
MS_4 = 4,
MS_5 = 5,
MS_6 = 6,
MS_7 = 7,
MS_8 = 8,
MS_9 = 9,
MS_10 = 10,
MS_20 = 20,
MS_30 = 30,
MS_40 = 40,
MS_50 = 50,
MS_60 = 60,
MS_70 = 70,
MS_80 = 80,
MS_90 = 90,
MS_100 = 100,
MS_150 = 150,
MS_200 = 200,
MS_250 = 250,
MS_300 = 300,
MS_350 = 350,
MS_400 = 400,
MS_450 = 450,
MS_500 = 500,
MS_600 = 600,
MS_700 = 700,
MS_800 = 800,
MS_900 = 900,
SEC_1 = 1000,
SEC_2 = 2000,
SEC_3 = 3000,
SEC_4 = 4000,
SEC_5 = 5000,
SEC_6 = 6000,
SEC_7 = 7000,
SEC_8 = 8000,
SEC_9 = 9000,
SEC_10 = 10000,
SEC_15 = 15000,
SEC_20 = 20000,
SEC_30 = 30000,
MIN_1 = 60000,
SOUND_STATE_IDLE = 0,
SOUND_STATE_SETUP_FILE = 1,
SOUND_STATE_FILE = 2,
SOUND_STATE_FILE_LOOPING = 3,
SOUND_STATE_TONE = 4,
SOUND_STATE_TONE_LOOPING = 5,
SOUND_STATE_STOP = 6,
SOUND_CLICK = 0,
SOUND_DOUBLE_BEEP = 1,
SOUND_DOWN = 2,
SOUND_UP = 3,
SOUND_LOW_BEEP = 4,
SOUND_FAST_UP = 5,
TONE_C2 = 65,
TONE_CS2 = 69,
TONE_D2 = 73,
TONE_DS2 = 78,
TONE_E2 = 82,
TONE_F2 = 87,
TONE_FS2 = 92,
TONE_G2 = 98,
TONE_GS2 = 104,
TONE_A2 = 110,
TONE_AS2 = 117,
TONE_B2 = 123,
TONE_C3 = 131,
TONE_CS3 = 139,
TONE_D3 = 147,
TONE_DS3 = 156,
TONE_E3 = 165,
TONE_F3 = 175,
TONE_FS3 = 185,
TONE_G3 = 196,
TONE_GS3 = 208,
TONE_A3 = 220,
TONE_AS3 = 233,
TONE_B3 = 247,
TONE_C4 = 262,
TONE_CS4 = 277,
TONE_D4 = 294,
TONE_DS4 = 311,
TONE_E4 = 330,
TONE_F4 = 349,
TONE_FS4 = 370,
TONE_G4 = 392,
TONE_GS4 = 415,
TONE_A4 = 440,
TONE_AS4 = 466,
TONE_B4 = 494,
TONE_C5 = 523,
TONE_CS5 = 554,
TONE_D5 = 587,
TONE_DS5 = 622,
TONE_E5 = 659,
TONE_F5 = 698,
TONE_FS5 = 740,
TONE_G5 = 784,
TONE_GS5 = 831,
TONE_A5 = 880,
TONE_AS5 = 932,
TONE_B5 = 988,
TONE_C6 = 1047,
TONE_CS6 = 1109,
TONE_D6 = 1175,
TONE_DS6 = 1245,
TONE_E6 = 1319,
TONE_F6 = 1397,
TONE_FS6 = 1480,
TONE_G6 = 1568,
TONE_GS6 = 1661,
TONE_A6 = 1760,
TONE_AS6 = 1865,
TONE_B6 = 1976,
TONE_C7 = 2093,
TONE_CS7 = 2217,
TONE_D7 = 2349,
TONE_DS7 = 2489,
TONE_E7 = 2637,
TONE_F7 = 2794,
TONE_FS7 = 2960,
TONE_G7 = 3136,
TONE_GS7 = 3322,
TONE_A7 = 3520,
TONE_AS7 = 3729,
TONE_B7 = 3951,
NOTE_WHOLE = 1000,
LCD_LINE8 = 112,
LCD_LINE7 = 96,
LCD_LINE6 = 80,
LCD_LINE5 = 64,
LCD_LINE4 = 48,
LCD_LINE3 = 32,
LCD_LINE2 = 16,
LCD_LINE1 = 0,
DISPLAY_ERASE_ALL = 0x00,
DISPLAY_PIXEL = 0x01,
DISPLAY_HORIZONTAL_LINE = 0x02,
DISPLAY_VERTICAL_LINE = 0x03,
DISPLAY_CHAR = 0x04,
DISPLAY_ERASE_LINE = 0x05,
DISPLAY_FILL_REGION = 0x06,
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_2 = 1,
CS_TIMER_3 = 2,
CS_TIMER_4 = 3,
NUM_CS_TIMERS = 4,
MS_TIMER_1 = 0,
MS_TIMER_2 = 1,
MS_TIMER_3 = 2,
MS_TIMER_4 = 3,
NUM_MS_TIMERS = 4,
US_TIMER_1 = 0,
US_TIMER_2 = 1,
US_TIMER_3 = 2,
US_TIMER_4 = 3,
NUM_US_TIMERS = 4,
opError = 0x00,
opNop = 0x01,
opProgramStop = 0x02,
opProgramStart = 0x03,
opObjectStop = 0x04,
opObjectStart = 0x05,
opObjectTrigger = 0x06,
opObjectWait = 0x07,
opReturn = 0x08,
opCall = 0x09,
opObjectEnd = 0x0A,
opSleep = 0x0B,
opProgramInfo = 0x0C,
opLabel = 0x0D,
opProbe = 0x0E,
opDo = 0x0F,
opAdd1 = 0x10,
opAdd2 = 0x11,
opAdd4 = 0x12,
opAddF = 0x13,
opSub1 = 0x14,
opSub2 = 0x15,
opSub4 = 0x16,
opSubF = 0x17,
opMul1 = 0x18,
opMul2 = 0x19,
opMul4 = 0x1A,
opMulF = 0x1B,
opDiv1 = 0x1C,
opDiv2 = 0x1D,
opDiv4 = 0x1E,
opDivF = 0x1F,
opOr1 = 0x20,
opOr2 = 0x21,
opOr4 = 0x22,
opAnd1 = 0x24,
opAnd2 = 0x25,
opAnd4 = 0x26,
opXor1 = 0x28,
opXor2 = 0x29,
opXor4 = 0x2A,
opRl1 = 0x2C,
opRl2 = 0x2D,
opRl4 = 0x2E,
opInitBytes = 0x2F,
opMove11 = 0x30,
opMove12 = 0x31,
opMove14 = 0x32,
opMove1F = 0x33,
opMove21 = 0x34,
opMove22 = 0x35,
opMove24 = 0x36,
opMove2F = 0x37,
opMove41 = 0x38,
opMove42 = 0x39,
opMove44 = 0x3A,
opMove4F = 0x3B,
opMoveF1 = 0x3C,
opMoveF2 = 0x3D,
opMoveF4 = 0x3E,
opMoveFF = 0x3F,
opJmp = 0x40,
opJmpFalse = 0x41,
opJmpTrue = 0x42,
opJmpNan = 0x43,
opCmpLT1 = 0x44,
opCmpLT2 = 0x45,
opCmpLT4 = 0x46,
opCmpLTF = 0x47,
opCmpGT1 = 0x48,
opCmpGT2 = 0x49,
opCmpGT4 = 0x4A,
opCmpGTF = 0x4B,
opCmpEQ1 = 0x4C,
opCmpEQ2 = 0x4D,
opCmpEQ4 = 0x4E,
opCmpEQF = 0x4F,
opCmpNEQ1 = 0x50,
opCmpNEQ2 = 0x51,
opCmpNEQ4 = 0x52,
opCmpNEQF = 0x53,
opCmpLTEQ1 = 0x54,
opCmpLTEQ2 = 0x55,
opCmpLTEQ4 = 0x56,
opCmpLTEQF = 0x57,
opCmpGTEQ1 = 0x58,
opCmpGTEQ2 = 0x59,
opCmpGTEQ4 = 0x5A,
opCmpGTEQF = 0x5B,
opSelect1 = 0x5C,
opSelect2 = 0x5D,
opSelect4 = 0x5E,
opSelectF = 0x5F,
opSystem = 0x60,
opPortConvertOutput = 0x61,
opPortConvertInput = 0x62,
opNote2Freq = 0x63,
opJmpLT1 = 0x64,
opJmpLT2 = 0x65,
opJmpLT4 = 0x66,
opJmpLTF = 0x67,
opJmpGT1 = 0x68,
opJmpGT2 = 0x69,
opJmpGT4 = 0x6A,
opJmpGTF = 0x6B,
opJmpEQ1 = 0x6C,
opJmpEQ2 = 0x6D,
opJmpEQ4 = 0x6E,
opJmpEQF = 0x6F,
opJmpNEQ1 = 0x70,
opJmpNEQ2 = 0x71,
opJmpNEQ4 = 0x72,
opJmpNEQF = 0x73,
opJmpLTEQ1 = 0x74,
opJmpLTEQ2 = 0x75,
opJmpLTEQ4 = 0x76,
opJmpLTEQF = 0x77,
opJmpGTEQ1 = 0x78,
opJmpGTEQ2 = 0x79,
opJmpGTEQ4 = 0x7A,
opJmpGTEQF = 0x7B,
opInfo = 0x7C,
opStrings = 0x7D,
opMemoryWrite = 0x7E,
opMemoryRead = 0x7F,
opUIFlush = 0x80,
opUIRead = 0x81,
opUIWrite = 0x82,
opUIButton = 0x83,
opUIDraw = 0x84,
opTimerWait = 0x85,
opTimerReady = 0x86,
opTimerRead = 0x87,
opBreakpoint0 = 0x88,
opBreakpoint1 = 0x89,
opBreakpoint2 = 0x8A,
opBreakpoint3 = 0x8B,
opBreakpointSet = 0x8C,
opMath = 0x8D,
opRandom = 0x8E,
opTimerReadUS = 0x8F,
opKeepAlive = 0x90,
opComRead = 0x91,
opComWrite = 0x92,
opSound = 0x94,
opSoundTest = 0x95,
opSoundReady = 0x96,
opInputSample = 0x97,
opInputDeviceList = 0x98,
opInputDevice = 0x99,
opInputRead = 0x9A,
opInputTest = 0x9B,
opInputReady = 0x9C,
opInputReadSI = 0x9D,
opInputReadext = 0x9E,
opInputWrite = 0x9F,
opOutputGetType = 0xA0,
opOutputSetType = 0xA1,
opOutputReset = 0xA2,
@ -552,101 +66,13 @@ declare const enum DAL {
opOutputClearCount = 0xB2,
opOutputGetCount = 0xB3,
opOutputProgramStop = 0xB4,
opFile = 0xC0,
opArray = 0xC1,
opArrayWrite = 0xC2,
opArrayRead = 0xC3,
opArrayAppend = 0xC4,
opMemoryUsage = 0xC5,
opFilename = 0xC6,
opRead1 = 0xC8,
opRead2 = 0xC9,
opRead4 = 0xCA,
opReadF = 0xCB,
opWrite1 = 0xCC,
opWrite2 = 0xCD,
opWrite4 = 0xCE,
opWriteF = 0xCF,
opComReadY = 0xD0,
opComReadData = 0xD1,
opComWriteData = 0xD2,
opComGet = 0xD3,
opComSet = 0xD4,
opComTest = 0xD5,
opComRemove = 0xD6,
opComWriteFile = 0xD7,
opMailboxOpen = 0xD8,
opMailboxWrite = 0xD9,
opMailboxRead = 0xDA,
opMailboxTest = 0xDB,
opMailboxReady = 0xDC,
opMailboxClose = 0xDD,
opTest = 0xFF,
// built/dockermake/node_modules/ev3api-bin/include/ev3_lcd.h
SCREEN_WIDTH = 178,
SCREEN_HEIGHT = 128,
NOOF_CHARS = 96,
FONT_WIDTH = 10,
FONT_HEIGHT = 16,
ROP_CLEAR = 0x00000000,
ROP_AND = 0xff000000,
ROP_ANDREVERSE = 0xff00ff00,
ROP_COPY = 0x0000ff00,
ROP_ANDINVERTED = 0xffff0000,
ROP_NOOP = 0x00ff0000,
ROP_XOR = 0x00ffff00,
ROP_OR = 0xffffff00,
ROP_NOR = 0xffffffff,
ROP_EQUIV = 0x00ffffff,
ROP_INVERT = 0x00ff00ff,
ROP_ORREVERSE = 0xffff00ff,
ROP_COPYINVERTED = 0x0000ffff,
ROP_ORINVERTED = 0xff00ffff,
ROP_NAND = 0xff0000ff,
ROP_SET = 0x000000ff,
// built/dockermake/node_modules/ev3api-bin/include/ev3_output.h
// built/dockermake/node_modules/ev3api-bin/include/ev3_sound.h
// built/dockermake/node_modules/ev3api-bin/include/ev3_timer.h
// built/dockermake/node_modules/ev3api-bin/include/ev3sensor.h
NO_SEN = -1,
TOUCH_PRESS = 1,
COL_REFLECT = 2,
COL_AMBIENT = 3,
COL_COLOR = 4,
US_DIST_CM = 5,
US_DIST_MM = 6,
US_DIST_IN = 7,
GYRO_ANG = 8,
GYRO_RATE = 9,
IR_PROX = 10,
IR_SEEK = 11,
IR_REMOTE = 12,
NXT_IR_SEEKER = 20,
NXT_TEMP_C = 21,
NXT_TEMP_F = 22,
BEACON_CH_1 = 0,
BEACON_CH_2 = 1,
BEACON_CH_3 = 2,
BEACON_CH_4 = 3,
BEACON_OFF = 0,
BEACON_UP_LEFT = 1,
BEACON_DOWN_LEFT = 2,
BEACON_UP_RIGHT = 3,
BEACON_DOWN_RIGHT = 4,
BEACON_UP = 5,
BEACON_DIAG_UP_LEFT = 6,
BEACON_DIAG_UP_RIGHT = 7,
BEACON_DOWN = 8,
BEACON_ON = 9,
BEACON_LEFT = 10,
BEACON_RIGHT = 11,
// built/dockermake/node_modules/ev3api-bin/include/iic.h
// built/dockermake/node_modules/ev3api-bin/include/typedata.h
INPUTS = 4,
OUTPUTS = 4,
// built/dockermake/node_modules/ev3api-bin/include/uart.h
BUTTON_ID_UP = 0x01,
BUTTON_ID_ENTER = 0x02,
BUTTON_ID_DOWN = 0x04,
BUTTON_ID_RIGHT = 0x08,
BUTTON_ID_LEFT = 0x10,
BUTTON_ID_ESCAPE = 0x20,
// built/dockermake/pxtapp/pxt.h
ID_BUTTON_BASE = 100,
DEVICE_EVT_ANY = 0,
DEVICE_ID_NOTIFY = 10000,
DEVICE_ID_NOTIFY_ONE = 10001,
@ -656,6 +82,22 @@ declare const enum DAL {
PXT_REF_TAG_IMAGE = 3,
PXT_REF_TAG_NUMBER = 32,
PXT_REF_TAG_ACTION = 33,
Int8LE = 1,
UInt8LE = 2,
Int16LE = 3,
UInt16LE = 4,
Int32LE = 5,
Int8BE = 6,
UInt8BE = 7,
Int16BE = 8,
UInt16BE = 9,
Int32BE = 10,
UInt32LE = 11,
UInt32BE = 12,
Float32LE = 13,
Float64LE = 14,
Float32BE = 15,
Float64BE = 16,
Undefined = 0,
Boolean = 1,
Number = 2,

84
libs/core/ev3const.h Normal file
View File

@ -0,0 +1,84 @@
#ifndef __PXT_EV3CONST_H
#define __PXT_EV3CONST_H
#define NUM_INPUTS 4
#define LCD_WIDTH 178
#define LCD_HEIGHT 128
#define NUM_BUTTONS 6
#define DEVICE_TYPE_NXT_TOUCH 1
#define DEVICE_TYPE_NXT_LIGHT 2
#define DEVICE_TYPE_NXT_SOUND 3
#define DEVICE_TYPE_NXT_COLOR 4
#define DEVICE_TYPE_TACHO 7
#define DEVICE_TYPE_MINITACHO 8
#define DEVICE_TYPE_NEWTACHO 9
#define DEVICE_TYPE_TOUCH 16
#define DEVICE_TYPE_COLOR 29
#define DEVICE_TYPE_ULTRASONIC 30
#define DEVICE_TYPE_GYRO 32
#define DEVICE_TYPE_IR 33
#define DEVICE_TYPE_THIRD_PARTY_START 50
#define DEVICE_TYPE_THIRD_PARTY_END 99
#define DEVICE_TYPE_IIC_UNKNOWN 100
#define DEVICE_TYPE_NXT_TEST 101
#define DEVICE_TYPE_NXT_IIC 123
#define DEVICE_TYPE_TERMINAL 124
#define DEVICE_TYPE_UNKNOWN 125
#define DEVICE_TYPE_NONE 126
#define DEVICE_TYPE_ERROR 127
#define MAX_DEVICE_DATALENGTH 32
#define MAX_DEVICE_MODES 8
#define UART_BUFFER_SIZE 64
#define TYPE_NAME_LENGTH 11
#define SYMBOL_LENGTH 4
#define DEVICE_LOGBUF_SIZE 300
#define IIC_NAME_LENGTH 8
#define CONN_UNKNOWN 111
#define CONN_DAISYCHAIN 117
#define CONN_NXT_COLOR 118
#define CONN_NXT_DUMB 119
#define CONN_NXT_IIC 120
#define CONN_INPUT_DUMB 121
#define CONN_INPUT_UART 122
#define CONN_OUTPUT_DUMB 123
#define CONN_OUTPUT_INTELLIGENT 124
#define CONN_OUTPUT_TACHO 125
#define CONN_NONE 126
#define CONN_ERROR 127
#define opOutputGetType 0xA0
#define opOutputSetType 0xA1
#define opOutputReset 0xA2
#define opOutputStop 0xA3
#define opOutputPower 0xA4
#define opOutputSpeed 0xA5
#define opOutputStart 0xA6
#define opOutputPolarity 0xA7
#define opOutputRead 0xA8
#define opOutputTest 0xA9
#define opOutputReady 0xAA
#define opOutputPosition 0xAB
#define opOutputStepPower 0xAC
#define opOutputTimePower 0xAD
#define opOutputStepSpeed 0xAE
#define opOutputTimeSpeed 0xAF
#define opOutputStepSync 0xB0
#define opOutputTimeSync 0xB1
#define opOutputClearCount 0xB2
#define opOutputGetCount 0xB3
#define opOutputProgramStop 0xB4
#define BUTTON_ID_UP 0x01
#define BUTTON_ID_ENTER 0x02
#define BUTTON_ID_DOWN 0x04
#define BUTTON_ID_RIGHT 0x08
#define BUTTON_ID_LEFT 0x10
#define BUTTON_ID_ESCAPE 0x20
#endif

View File

@ -11,7 +11,7 @@ namespace input {
}
_deviceType() {
return LMS.DEVICE_TYPE_GYRO
return DAL.DEVICE_TYPE_GYRO
}
setMode(m: GyroSensorMode) {

View File

@ -39,8 +39,8 @@ namespace input.internal {
constructor(p: number) {
this.port = p
this.connType = LMS.CONN_NONE
this.devType = LMS.DEVICE_TYPE_NONE
this.connType = DAL.CONN_NONE
this.devType = DAL.DEVICE_TYPE_NONE
this.sensor = null
this.manual = false
}
@ -49,7 +49,7 @@ namespace input.internal {
function init() {
if (sensors) return
sensors = []
for (let i = 0; i < LMS.NUM_INPUTS; ++i) sensors.push(new SensorInfo(i))
for (let i = 0; i < DAL.NUM_INPUTS; ++i) sensors.push(new SensorInfo(i))
autoSensors = []
devcon = output.createBuffer(DevConOff.Size)
@ -87,7 +87,7 @@ namespace input.internal {
}
function detectDevices() {
let conns = analogMM.slice(AnalogOff.InConn, LMS.NUM_INPUTS)
let conns = analogMM.slice(AnalogOff.InConn, DAL.NUM_INPUTS)
let numChanged = 0
for (let info of sensors) {
@ -96,18 +96,18 @@ namespace input.internal {
continue
numChanged++
info.connType = newConn
info.devType = LMS.DEVICE_TYPE_NONE
if (newConn == LMS.CONN_INPUT_UART) {
info.devType = DAL.DEVICE_TYPE_NONE
if (newConn == DAL.CONN_INPUT_UART) {
control.dmesg(`new UART connection at ${info.port}`)
setUartMode(info.port, 0)
let uinfo = readUartInfo(info.port, 0)
info.devType = uinfo[TypesOff.Type]
control.dmesg(`UART type ${info.devType}`)
} else if (newConn == LMS.CONN_INPUT_DUMB) {
} else if (newConn == DAL.CONN_INPUT_DUMB) {
control.dmesg(`new DUMB connection at ${info.port}`)
// TODO? for now assume touch
info.devType = LMS.DEVICE_TYPE_TOUCH
} else if (newConn == LMS.CONN_NONE || newConn == 0) {
info.devType = DAL.DEVICE_TYPE_TOUCH
} else if (newConn == DAL.CONN_NONE || newConn == 0) {
control.dmesg(`disconnect at ${info.port}`)
} else {
control.dmesg(`unknown connection type: ${newConn} at ${info.port}`)
@ -121,12 +121,12 @@ namespace input.internal {
// first free up disconnected sensors
for (let info of autos) {
if (info.sensor && info.devType == LMS.DEVICE_TYPE_NONE)
if (info.sensor && info.devType == DAL.DEVICE_TYPE_NONE)
info.sensor._setPort(0)
}
for (let info of autos) {
if (!info.sensor && info.devType != LMS.DEVICE_TYPE_NONE) {
if (!info.sensor && info.devType != DAL.DEVICE_TYPE_NONE) {
let found = false
for (let s of autoSensors) {
if (s.getPort() == 0 && s._deviceType() == info.devType) {
@ -260,7 +260,7 @@ namespace input.internal {
function uartReset(port: number) {
if (port < 0) return
control.dmesg(`UART reset at ${port}`)
devcon.setNumber(NumberFormat.Int8LE, DevConOff.Connection + port, LMS.CONN_NONE)
devcon.setNumber(NumberFormat.Int8LE, DevConOff.Connection + port, DAL.CONN_NONE)
devcon.setNumber(NumberFormat.Int8LE, DevConOff.Type + port, 0)
devcon.setNumber(NumberFormat.Int8LE, DevConOff.Mode + port, 0)
uartMM.ioctl(IO.UART_SET_CONN, devcon)
@ -290,7 +290,7 @@ namespace input.internal {
if ((status & UART_DATA_READY) != 0 && (status & UART_PORT_CHANGED) == 0)
break
devcon.setNumber(NumberFormat.Int8LE, DevConOff.Connection + port, LMS.CONN_INPUT_UART)
devcon.setNumber(NumberFormat.Int8LE, DevConOff.Connection + port, DAL.CONN_INPUT_UART)
devcon.setNumber(NumberFormat.Int8LE, DevConOff.Type + port, 0)
devcon.setNumber(NumberFormat.Int8LE, DevConOff.Mode + port, 0)
@ -307,7 +307,7 @@ namespace input.internal {
while (true) {
if (port < 0) return
control.dmesg(`UART set mode to ${mode} at ${port}`)
devcon.setNumber(NumberFormat.Int8LE, DevConOff.Connection + port, LMS.CONN_INPUT_UART)
devcon.setNumber(NumberFormat.Int8LE, DevConOff.Connection + port, DAL.CONN_INPUT_UART)
devcon.setNumber(NumberFormat.Int8LE, DevConOff.Type + port, 33)
devcon.setNumber(NumberFormat.Int8LE, DevConOff.Mode + port, mode)
uartMM.ioctl(IO.UART_SET_CONN, devcon)
@ -322,18 +322,18 @@ namespace input.internal {
}
function getUartBytes(port: number): Buffer {
if (port < 0) return output.createBuffer(LMS.MAX_DEVICE_DATALENGTH)
if (port < 0) return output.createBuffer(DAL.MAX_DEVICE_DATALENGTH)
let index = uartMM.getNumber(NumberFormat.UInt16LE, UartOff.Actual + port * 2)
return uartMM.slice(
UartOff.Raw + LMS.MAX_DEVICE_DATALENGTH * 300 * port + LMS.MAX_DEVICE_DATALENGTH * index,
LMS.MAX_DEVICE_DATALENGTH)
UartOff.Raw + DAL.MAX_DEVICE_DATALENGTH * 300 * port + DAL.MAX_DEVICE_DATALENGTH * index,
DAL.MAX_DEVICE_DATALENGTH)
}
function getUartNumber(fmt: NumberFormat, off: number, port: number) {
if (port < 0) return 0
let index = uartMM.getNumber(NumberFormat.UInt16LE, UartOff.Actual + port * 2)
return uartMM.getNumber(fmt,
UartOff.Raw + LMS.MAX_DEVICE_DATALENGTH * 300 * port + LMS.MAX_DEVICE_DATALENGTH * index + off)
UartOff.Raw + DAL.MAX_DEVICE_DATALENGTH * 300 * port + DAL.MAX_DEVICE_DATALENGTH * index + off)
}

View File

@ -79,7 +79,7 @@ namespace input {
}
_deviceType() {
return LMS.DEVICE_TYPE_IR
return DAL.DEVICE_TYPE_IR
}
setRemoteChannel(c: IrRemoteChannel) {

View File

@ -24,35 +24,35 @@ namespace output {
}
export function stop(out: Output, useBreak = false) {
let b = mkCmd(out, LMS.opOutputStop, 1)
let b = mkCmd(out, DAL.opOutputStop, 1)
b.setNumber(NumberFormat.UInt8LE, 2, useBreak ? 1 : 0)
writePWM(b)
}
export function start(out: Output) {
let b = mkCmd(out, LMS.opOutputStart, 0)
let b = mkCmd(out, DAL.opOutputStart, 0)
writePWM(b)
}
export function reset(out: Output) {
let b = mkCmd(out, LMS.opOutputReset, 0)
let b = mkCmd(out, DAL.opOutputReset, 0)
writePWM(b)
}
export function setSpeed(out: Output, speed: number) {
let b = mkCmd(out, LMS.opOutputSpeed, 1)
let b = mkCmd(out, DAL.opOutputSpeed, 1)
b.setNumber(NumberFormat.Int8LE, 2, Math.clamp(-100, 100, speed))
writePWM(b)
}
export function setPower(out: Output, power: number) {
let b = mkCmd(out, LMS.opOutputPower, 1)
let b = mkCmd(out, DAL.opOutputPower, 1)
b.setNumber(NumberFormat.Int8LE, 2, Math.clamp(-100, 100, power))
writePWM(b)
}
export function setPolarity(out: Output, polarity: number) {
let b = mkCmd(out, LMS.opOutputPolarity, 1)
let b = mkCmd(out, DAL.opOutputPolarity, 1)
b.setNumber(NumberFormat.Int8LE, 2, Math.clamp(-1, 1, polarity))
writePWM(b)
}
@ -68,11 +68,11 @@ namespace output {
}
export function step(out: Output, opts: StepOptions) {
let op = opts.useSteps ? LMS.opOutputStepSpeed : LMS.opOutputTimeSpeed
let op = opts.useSteps ? DAL.opOutputStepSpeed : DAL.opOutputTimeSpeed
let speed = opts.speed
if (speed == null) {
speed = opts.power
op = opts.useSteps ? LMS.opOutputStepPower : LMS.opOutputTimePower
op = opts.useSteps ? DAL.opOutputStepPower : DAL.opOutputTimePower
if (speed == null)
return
}
@ -90,7 +90,7 @@ namespace output {
const types = [0, 0, 0, 0]
export function setType(out: Output, type: OutputType) {
let b = mkCmd(out, LMS.opOutputSetType, 3)
let b = mkCmd(out, DAL.opOutputSetType, 3)
for (let i = 0; i < 4; ++i) {
if (out & (1 << i)) {
types[i] = type

View File

@ -3,8 +3,6 @@
#include "pxtbase.h"
#define ID_BUTTON_BASE 100
namespace pxt {
void raiseEvent(int id, int event);
int allocateNotifyEvent();

View File

@ -6,6 +6,7 @@
"Makefile",
"pxt.h",
"pxtcore.h",
"ev3const.h",
"linux.cpp",
"mmap.cpp",
"control.cpp",

View File

@ -1,6 +1,14 @@
#include "pxt.h"
#include "ev3.h"
#include "ev3const.h"
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
/**
* Drawing modes

View File

@ -81,7 +81,7 @@ namespace screen {
export function setPixel(x: number, y: number, mode = Draw.Normal) {
x |= 0
y |= 0
if (0 <= x && x < LMS.LCD_WIDTH && 0 <= y && y < LMS.LCD_HEIGHT)
if (0 <= x && x < DAL.LCD_WIDTH && 0 <= y && y < DAL.LCD_HEIGHT)
_setPixel(x, y, mode)
}
@ -131,8 +131,8 @@ namespace screen {
return;
if (h <= 0)
return;
let x1 = Math.min(LMS.LCD_WIDTH, x + w);
let y1 = Math.min(LMS.LCD_HEIGHT, y + h);
let x1 = Math.min(DAL.LCD_WIDTH, x + w);
let y1 = Math.min(DAL.LCD_HEIGHT, y + h);
if (w == 1) {
while (y < y1)
_setPixel(x, y++, mode);

View File

@ -16,7 +16,7 @@ namespace input {
}
_deviceType() {
return LMS.DEVICE_TYPE_TOUCH
return DAL.DEVICE_TYPE_TOUCH
}
}

View File

@ -6,7 +6,7 @@ namespace input {
}
_deviceType() {
return LMS.DEVICE_TYPE_ULTRASONIC
return DAL.DEVICE_TYPE_ULTRASONIC
}
/** Get distance in mm */

View File

@ -10,8 +10,7 @@ namespace pxsim {
new CommonButton(DAL.BUTTON_ID_DOWN),
new CommonButton(DAL.BUTTON_ID_RIGHT),
new CommonButton(DAL.BUTTON_ID_LEFT),
new CommonButton(DAL.BUTTON_ID_ESCAPE),
new CommonButton(DAL.BUTTON_ID_ALL)
new CommonButton(DAL.BUTTON_ID_ESCAPE)
];
let data = new Uint8Array(this.buttons.length)
MMapMethods.register("/dev/lms_ui", {