Add custom impl of output; drop ev3-api
This commit is contained in:
parent
02e45762b4
commit
340d5e5cbf
2
libs/core/dal.d.ts
vendored
2
libs/core/dal.d.ts
vendored
@ -2,6 +2,7 @@
|
||||
declare const enum DAL {
|
||||
// built/dockermake/pxtapp/ev3const.h
|
||||
NUM_INPUTS = 4,
|
||||
NUM_OUTPUTS = 4,
|
||||
LCD_WIDTH = 178,
|
||||
LCD_HEIGHT = 128,
|
||||
NUM_BUTTONS = 6,
|
||||
@ -45,6 +46,7 @@ declare const enum DAL {
|
||||
CONN_OUTPUT_TACHO = 125,
|
||||
CONN_NONE = 126,
|
||||
CONN_ERROR = 127,
|
||||
opProgramStart = 0x03,
|
||||
opOutputGetType = 0xA0,
|
||||
opOutputSetType = 0xA1,
|
||||
opOutputReset = 0xA2,
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define __PXT_EV3CONST_H
|
||||
|
||||
#define NUM_INPUTS 4
|
||||
#define NUM_OUTPUTS 4
|
||||
#define LCD_WIDTH 178
|
||||
#define LCD_HEIGHT 128
|
||||
#define NUM_BUTTONS 6
|
||||
@ -52,6 +53,7 @@
|
||||
#define CONN_NONE 126
|
||||
#define CONN_ERROR 127
|
||||
|
||||
#define opProgramStart 0x03
|
||||
#define opOutputGetType 0xA0
|
||||
#define opOutputSetType 0xA1
|
||||
#define opOutputReset 0xA2
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "pxt.h"
|
||||
#include "ev3.h"
|
||||
#include "ev3const.h"
|
||||
|
||||
namespace output {
|
||||
|
||||
@ -12,18 +12,11 @@ Buffer createBuffer(int size) {
|
||||
return mkBuffer(NULL, size);
|
||||
}
|
||||
|
||||
extern "C" int WriteToPWMDevice(char *bytes, int num_bytes);
|
||||
|
||||
//%
|
||||
void writePWM(Buffer buf) {
|
||||
WriteToPWMDevice((char *)buf->data, buf->length);
|
||||
}
|
||||
}
|
||||
|
||||
namespace pxt {
|
||||
|
||||
void target_init() {
|
||||
OutputInit();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,8 +13,34 @@ enum OutputType {
|
||||
}
|
||||
|
||||
namespace output {
|
||||
//% shim=output::writePWM
|
||||
function writePWM(buf: Buffer): void { }
|
||||
let pwmMM: MMap
|
||||
let motorMM: MMap
|
||||
|
||||
const enum MotorDataOff {
|
||||
TachoCounts = 0, // int32
|
||||
Speed = 4, // int8
|
||||
Padding = 5, // int8[3]
|
||||
TachoSensor = 8, // int32
|
||||
Size = 12
|
||||
}
|
||||
|
||||
function init() {
|
||||
if (pwmMM) return
|
||||
pwmMM = control.mmap("/dev/lms_pwm", 0, 0)
|
||||
if (!pwmMM) control.fail("no PWM file")
|
||||
motorMM = control.mmap("/dev/lms_motor", MotorDataOff.Size * DAL.NUM_OUTPUTS, 0)
|
||||
|
||||
stop(Output.ALL)
|
||||
|
||||
let buf = output.createBuffer(1)
|
||||
buf[0] = DAL.opProgramStart
|
||||
writePWM(buf)
|
||||
}
|
||||
|
||||
function writePWM(buf: Buffer): void {
|
||||
init()
|
||||
pwmMM.write(buf)
|
||||
}
|
||||
|
||||
function mkCmd(out: Output, cmd: number, addSize: number) {
|
||||
let b = createBuffer(2 + addSize)
|
||||
|
@ -30,9 +30,7 @@
|
||||
"testFiles": [
|
||||
"test.ts"
|
||||
],
|
||||
"npmDependencies": {
|
||||
"ev3api-bin": "1.1.0"
|
||||
},
|
||||
"npmDependencies": {},
|
||||
"public": true,
|
||||
"dependencies": {
|
||||
"base": "file:../base"
|
||||
|
Loading…
Reference in New Issue
Block a user