output -> motors

This commit is contained in:
Peli de Halleux 2017-10-27 11:01:11 -07:00
parent bcb68d937d
commit 18fefa2a44
7 changed files with 45 additions and 42 deletions

View File

@ -56,24 +56,24 @@
"input.remoteButtonCenter": "Remote beacon (center) button.",
"input.remoteButtonTopLeft": "Remote top-left button.",
"input.remoteButtonTopRight": "Remote top-right button.",
"output.Motor.clearCount": "Clears the motor count",
"output.Motor.count": "Gets motor step count.",
"output.Motor.on": "Power on or off the motor.",
"output.Motor.reset": "Resets the motor.",
"output.Motor.setBrake": "Sets the automatic brake on or off when the motor is off",
"output.Motor.setBrake|param|brake": "a value indicating if the motor should break when off",
"output.Motor.setPower": "Sets the motor power level from ``-100`` to ``100``.",
"output.Motor.setPower|param|power": "the desired speed to use. eg: 50",
"output.Motor.setReversed": "Reverses the motor polarity",
"output.Motor.speed": "Gets motor actual speed.",
"output.Motor.tachoCount": "Gets motor tacho count.",
"motors.Motor.clearCount": "Clears the motor count",
"motors.Motor.count": "Gets motor step count.",
"motors.Motor.on": "Power on or off the motor.",
"motors.Motor.reset": "Resets the motor.",
"motors.Motor.setBrake": "Sets the automatic brake on or off when the motor is off",
"motors.Motor.setBrake|param|brake": "a value indicating if the motor should break when off",
"motors.Motor.setPower": "Sets the motor power level from ``-100`` to ``100``.",
"motors.Motor.setPower|param|power": "the desired speed to use. eg: 50",
"motors.Motor.setReversed": "Reverses the motor polarity",
"motors.Motor.speed": "Gets motor actual speed.",
"motors.Motor.tachoCount": "Gets motor tacho count.",
"motors.pattern": "Pattern block.",
"motors.pattern|param|pattern": "the lights pattern to use. eg: LightsPattern.Green",
"motors.setStatusLight": "Set lights.",
"motors.setStatusLight|param|pattern": "the lights pattern to use.",
"motors.stopAllMotors": "Stops all motors",
"output.createBuffer": "Create a new zero-initialized buffer.",
"output.createBuffer|param|size": "number of bytes in the buffer",
"output.pattern": "Pattern block.",
"output.pattern|param|pattern": "the lights pattern to use. eg: LightsPattern.Green",
"output.setStatusLight": "Set lights.",
"output.setStatusLight|param|pattern": "the lights pattern to use.",
"output.stopAllMotors": "Stops all motors",
"screen.clear": "Clear screen and reset font to normal.",
"screen.doubleIcon": "Double size of an icon.",
"screen.drawIcon": "Draw an icon on the screen.",

View File

@ -82,32 +82,35 @@
"input.ultrasonic3|block": "ultrasonic sensor 3",
"input.ultrasonic4|block": "ultrasonic sensor 4",
"input|block": "input",
"output.Motor.count|block": "%motor|count",
"output.Motor.on|block": "%motor|%onOrOff",
"output.Motor.setBrake|block": "%motor|set brake %brake",
"output.Motor.setPower|block": "%motor|set power to %speed",
"output.Motor.setReversed|block": "%motor|set reversed %reversed",
"output.Motor.speed|block": "%motor|speed",
"output.Motor.tachoCount|block": "%motor|tacho count",
"output.largeMotorA|block": "large motor A",
"output.largeMotorB|block": "large motor B",
"output.largeMotorC|block": "large motor C",
"output.largeMotorD|block": "large motor D",
"output.mediumMotorA|block": "medium motor A",
"output.mediumMotorB|block": "medium motor B",
"output.mediumMotorC|block": "medium motor C",
"output.mediumMotorD|block": "medium motor D",
"output.pattern|block": "%pattern",
"output.setStatusLight|block": "set status light %pattern=led_pattern",
"output.stopAllMotors|block": "stop all motors",
"motors.Motor.count|block": "%motor|count",
"motors.Motor.on|block": "%motor|%onOrOff",
"motors.Motor.setBrake|block": "%motor|set brake %brake",
"motors.Motor.setPower|block": "%motor|set power to %speed",
"motors.Motor.setReversed|block": "%motor|set reversed %reversed",
"motors.Motor.speed|block": "%motor|speed",
"motors.Motor.tachoCount|block": "%motor|tacho count",
"motors.largeMotorA|block": "large motor A",
"motors.largeMotorB|block": "large motor B",
"motors.largeMotorC|block": "large motor C",
"motors.largeMotorD|block": "large motor D",
"motors.mediumMotorA|block": "medium motor A",
"motors.mediumMotorB|block": "medium motor B",
"motors.mediumMotorC|block": "medium motor C",
"motors.mediumMotorD|block": "medium motor D",
"motors.pattern|block": "%pattern",
"motors.setStatusLight|block": "set status light %pattern=led_pattern",
"motors.stopAllMotors|block": "stop all motors",
"motors|block": "motors",
"output|block": "output",
"screen.print|block": "print %text| at x: %x| y: %y",
"screen.setPixel|block": "set pixel %on| at x: %x| y: %y",
"screen|block": "screen",
"serial|block": "serial",
"{id:category}Brick": "Brick",
"{id:category}Control": "Control",
"{id:category}Input": "Input",
"{id:category}MMap": "MMap",
"{id:category}Motors": "Motors",
"{id:category}Output": "Output",
"{id:category}Screen": "Screen",
"{id:category}Serial": "Serial",

View File

@ -226,7 +226,7 @@ namespace control {
}
}
namespace output {
namespace motors {
let currPattern: LightsPattern
/**

View File

@ -17,7 +17,7 @@ enum OutputType {
MiniTacho = 8,
}
namespace output {
namespace motors {
let pwmMM: MMap
let motorMM: MMap
@ -53,7 +53,7 @@ namespace output {
}
function mkCmd(out: Output, cmd: number, addSize: number) {
const b = createBuffer(2 + addSize)
const b = output.createBuffer(2 + addSize)
b.setNumber(NumberFormat.UInt8LE, 0, cmd)
b.setNumber(NumberFormat.UInt8LE, 1, out)
return b

View File

@ -85,7 +85,7 @@ namespace screen {
* @param y the starting position's x coordinate, eg: 0
*/
//% blockId=screen_setpixel block="set pixel %on| at x: %x| y: %y"
//% weight=98 group="Brick" blockNamespace=output
//% weight=98 group="Brick" blockNamespace=brick
//% x.min=0 x.max=178 y.min=0 y.max=128 on.fieldEditor=toggleonoff
export function setPixel(on: boolean, x: number, y: number) {
x |= 0
@ -101,7 +101,7 @@ namespace screen {
* @param y the starting position's x coordinate, eg: 0
*/
//% blockId=screen_print block="print %text| at x: %x| y: %y"
//% weight=99 group="Brick" blockNamespace=output inlineInputMode="inline"
//% weight=99 group="Brick" blockNamespace=brick inlineInputMode="inline"
//% x.min=0 x.max=178 y.min=0 y.max=128
export function print(text: string, x: number, y: number, mode = Draw.Normal) {
x |= 0

View File

@ -2,7 +2,7 @@ screen.clear()
screen.print("PXT!", 10, 30, Draw.Quad)
screen.drawRect(40, 40, 20, 10, Draw.Fill)
output.setStatusLight(LightsPattern.Orange)
motors.setStatusLight(LightsPattern.Orange)
screen.drawIcon(100, 50, screen.doubleIcon(screen.heart), Draw.Double | Draw.Transparent)
@ -12,7 +12,7 @@ input.buttonEnter.onEvent(ButtonEvent.Click, () => {
input.buttonLeft.onEvent(ButtonEvent.Click, () => {
screen.drawRect(10, 70, 20, 10, Draw.Fill)
output.setStatusLight(LightsPattern.Red)
motors.setStatusLight(LightsPattern.Red)
screen.setFont(screen.microbitFont())
})

View File

@ -5,7 +5,7 @@ namespace input {
//% color="#8AC044" weight=90 icon="\uf185"
//% groups='["Motors", "Brick"]'
namespace output {
namespace motors {
}
//% color="#DF5014" weight=80