Add supportedTargets (#24)
* use format * updated monolight * adding supported targets * removing most jacdac in blocks * surviver
This commit is contained in:
Родитель
097f239374
Коммит
6cfeb917f2
|
@ -42,7 +42,7 @@ namespace modules {
|
||||||
* Reads a value of the sensor
|
* Reads a value of the sensor
|
||||||
* @param dimension which channel to read
|
* @param dimension which channel to read
|
||||||
*/
|
*/
|
||||||
//% blockId=jacdacaccget block="jacdac %accelerometer %dimension"
|
//% blockId=jacdacaccget block="%accelerometer %dimension"
|
||||||
//% group="Accelerometer" weight=5
|
//% group="Accelerometer" weight=5
|
||||||
get(dimension: JDDimension): number {
|
get(dimension: JDDimension): number {
|
||||||
const s = this.state;
|
const s = this.state;
|
||||||
|
@ -67,7 +67,7 @@ namespace modules {
|
||||||
* @param gesture
|
* @param gesture
|
||||||
* @param handler
|
* @param handler
|
||||||
*/
|
*/
|
||||||
//% blockId=jacadacacconevent block="jacdac %accelerometer on %gesture"
|
//% blockId=jacadacacconevent block="%accelerometer on %gesture"
|
||||||
//% group="Accelerometer"
|
//% group="Accelerometer"
|
||||||
onEvent(gesture: jacdac.AccelerometerEvent, handler: () => void) {
|
onEvent(gesture: jacdac.AccelerometerEvent, handler: () => void) {
|
||||||
this.registerEvent(gesture, handler);
|
this.registerEvent(gesture, handler);
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
"constants.ts",
|
"constants.ts",
|
||||||
"client.ts"
|
"client.ts"
|
||||||
],
|
],
|
||||||
|
"supportedTargets": [
|
||||||
|
"arcade",
|
||||||
|
"maker",
|
||||||
|
"microbit"
|
||||||
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core": "*",
|
"core": "*",
|
||||||
"jacdac": "github:microsoft/pxt-jacdac"
|
"jacdac": "github:microsoft/pxt-jacdac"
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace modules {
|
||||||
/**
|
/**
|
||||||
* Reads the current x value from the sensor
|
* Reads the current x value from the sensor
|
||||||
*/
|
*/
|
||||||
//% blockId=jacadacbtispressed block="jacdac %button is pressed"
|
//% blockId=jacadacbtispressed block="%button is pressed"
|
||||||
//% group="Buttons"
|
//% group="Buttons"
|
||||||
isPressed(): boolean {
|
isPressed(): boolean {
|
||||||
const s = this.state;
|
const s = this.state;
|
||||||
|
@ -32,7 +32,7 @@ namespace modules {
|
||||||
* @param gesture
|
* @param gesture
|
||||||
* @param handler
|
* @param handler
|
||||||
*/
|
*/
|
||||||
//% blockId=jacadacbtnonevent block="jacdac %button on %event"
|
//% blockId=jacadacbtnonevent block="%button on %event"
|
||||||
//% group="Buttons"
|
//% group="Buttons"
|
||||||
onEvent(event: jacdac.ButtonEvent, handler: () => void) {
|
onEvent(event: jacdac.ButtonEvent, handler: () => void) {
|
||||||
this.registerEvent(event, handler);
|
this.registerEvent(event, handler);
|
||||||
|
|
|
@ -34,4 +34,4 @@ namespace jacdac {
|
||||||
LongClick = 0x4,
|
LongClick = 0x4,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
"constants.ts",
|
"constants.ts",
|
||||||
"client.ts"
|
"client.ts"
|
||||||
],
|
],
|
||||||
|
"supportedTargets": [
|
||||||
|
"arcade",
|
||||||
|
"maker",
|
||||||
|
"microbit"
|
||||||
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core": "*",
|
"core": "*",
|
||||||
"jacdac": "github:microsoft/pxt-jacdac"
|
"jacdac": "github:microsoft/pxt-jacdac"
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
"constants.ts",
|
"constants.ts",
|
||||||
"client.ts"
|
"client.ts"
|
||||||
],
|
],
|
||||||
|
"supportedTargets": [
|
||||||
|
"arcade",
|
||||||
|
"maker"
|
||||||
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core": "*",
|
"core": "*",
|
||||||
"mixer": "*",
|
"mixer": "*",
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
"files": [
|
"files": [
|
||||||
"controllerclient.ts"
|
"controllerclient.ts"
|
||||||
],
|
],
|
||||||
|
"supportedTargets": [
|
||||||
|
"arcade"
|
||||||
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core": "*",
|
"core": "*",
|
||||||
"jacdac": "github:microsoft/pxt-jacdac"
|
"jacdac": "github:microsoft/pxt-jacdac"
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
"constants.ts",
|
"constants.ts",
|
||||||
"client.ts"
|
"client.ts"
|
||||||
],
|
],
|
||||||
|
"supportedTargets": [
|
||||||
|
"arcade"
|
||||||
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core": "*",
|
"core": "*",
|
||||||
"jacdac": "github:microsoft/pxt-jacdac"
|
"jacdac": "github:microsoft/pxt-jacdac"
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace jacdac {
|
||||||
* Shows a string on the LCD screen
|
* Shows a string on the LCD screen
|
||||||
* @param text the text to show
|
* @param text the text to show
|
||||||
*/
|
*/
|
||||||
//% blockId=jdlcdshowstring block="jacdac %client show string %text"
|
//% blockId=jdlcdshowstring block="%client show string %text"
|
||||||
//% group="LCD" blockGap=8
|
//% group="LCD" blockGap=8
|
||||||
showString(text: string) {
|
showString(text: string) {
|
||||||
// test for change
|
// test for change
|
||||||
|
@ -36,7 +36,7 @@ namespace jacdac {
|
||||||
* Shows a number on the LCD screen
|
* Shows a number on the LCD screen
|
||||||
* @param value the number to show
|
* @param value the number to show
|
||||||
*/
|
*/
|
||||||
//% blockId=jdlcdshownumber block="jacdac %client show number %value"
|
//% blockId=jdlcdshownumber block="%client show number %value"
|
||||||
//% group="LCD" blockGap=8
|
//% group="LCD" blockGap=8
|
||||||
showNumber(value: number) {
|
showNumber(value: number) {
|
||||||
this.showString(value.toString());
|
this.showString(value.toString());
|
||||||
|
@ -45,7 +45,7 @@ namespace jacdac {
|
||||||
/**
|
/**
|
||||||
* Clears the screen
|
* Clears the screen
|
||||||
*/
|
*/
|
||||||
//% blockId=jdlcdclear block="jacdac clear %client"
|
//% blockId=jdlcdclear block="clear %client"
|
||||||
//% group="LCD" blockGap=8
|
//% group="LCD" blockGap=8
|
||||||
clear() {
|
clear() {
|
||||||
this.showString("");
|
this.showString("");
|
||||||
|
@ -64,7 +64,7 @@ namespace jacdac {
|
||||||
* Enables or disables display
|
* Enables or disables display
|
||||||
* @param enabled true to turn the display on; false otherwise
|
* @param enabled true to turn the display on; false otherwise
|
||||||
*/
|
*/
|
||||||
//% blockId=jdlcdsetdisplay block="jacdac set %client display %enabled"
|
//% blockId=jdlcdsetdisplay block="set %client display %enabled"
|
||||||
//% enabled.shadow=toggleOnOff
|
//% enabled.shadow=toggleOnOff
|
||||||
//% group="LCD" blockGap=8
|
//% group="LCD" blockGap=8
|
||||||
setDisplay(enabled: boolean) {
|
setDisplay(enabled: boolean) {
|
||||||
|
@ -75,7 +75,7 @@ namespace jacdac {
|
||||||
* Enables or disables blinking
|
* Enables or disables blinking
|
||||||
* @param enabled true to blink
|
* @param enabled true to blink
|
||||||
*/
|
*/
|
||||||
//% blockId=jdlcdsetblink block="jacdac set %client blink %enabled"
|
//% blockId=jdlcdsetblink block="set %client blink %enabled"
|
||||||
//% enabled.shadow=toggleOnOff
|
//% enabled.shadow=toggleOnOff
|
||||||
//% group="LCD" blockGap=8
|
//% group="LCD" blockGap=8
|
||||||
setBlink(enabled: boolean) {
|
setBlink(enabled: boolean) {
|
||||||
|
@ -86,7 +86,7 @@ namespace jacdac {
|
||||||
* Show or hide cursor
|
* Show or hide cursor
|
||||||
* @param enabled true to display cursor, false otherwise
|
* @param enabled true to display cursor, false otherwise
|
||||||
*/
|
*/
|
||||||
//% blockId=jdlcdsetcursor block="jacdac set %client cursor %enabled"
|
//% blockId=jdlcdsetcursor block="set %client cursor %enabled"
|
||||||
//% enabled.shadow=toggleOnOff
|
//% enabled.shadow=toggleOnOff
|
||||||
//% group="LCD" blockGap=8
|
//% group="LCD" blockGap=8
|
||||||
setCursor(enabled: boolean) {
|
setCursor(enabled: boolean) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace jacdac {
|
||||||
/**
|
/**
|
||||||
* Reads the current x value from the sensor
|
* Reads the current x value from the sensor
|
||||||
*/
|
*/
|
||||||
//% blockId=jacdaclightsensorlevel block="jacdac %lightsensor light level"
|
//% blockId=jacdaclightsensorlevel block="%lightsensor light level"
|
||||||
//% group="Light sensor"
|
//% group="Light sensor"
|
||||||
get lightLevel(): number {
|
get lightLevel(): number {
|
||||||
const s = this.state;
|
const s = this.state;
|
||||||
|
@ -28,7 +28,7 @@ namespace jacdac {
|
||||||
* @param gesture
|
* @param gesture
|
||||||
* @param handler
|
* @param handler
|
||||||
*/
|
*/
|
||||||
//% blockId=jacadaclightsensoronevent block="jacdac %client on %event"
|
//% blockId=jacadaclightsensoronevent block="%client on %event"
|
||||||
//% group="Light sensor"
|
//% group="Light sensor"
|
||||||
onEvent(event: JDLightCondition, handler: () => void) {
|
onEvent(event: JDLightCondition, handler: () => void) {
|
||||||
this.registerEvent(event, handler);
|
this.registerEvent(event, handler);
|
||||||
|
@ -39,7 +39,7 @@ namespace jacdac {
|
||||||
* @param level
|
* @param level
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
//% blockId=jacdaclightsetthrshold block="jacdac %lightsensor set threshold %level to %value"
|
//% blockId=jacdaclightsetthrshold block="%lightsensor set threshold %level to %value"
|
||||||
//% group="Light sensor"
|
//% group="Light sensor"
|
||||||
setLightConditionThreshold(level: JDLightCondition, value: number) {
|
setLightConditionThreshold(level: JDLightCondition, value: number) {
|
||||||
this.setThreshold(level == JDLightCondition.Dark, value);
|
this.setThreshold(level == JDLightCondition.Dark, value);
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace jacdac {
|
||||||
/**
|
/**
|
||||||
* Reads the full spectrum
|
* Reads the full spectrum
|
||||||
*/
|
*/
|
||||||
//% blockId=jdlightspectrumfull block="jacdac %client full"
|
//% blockId=jdlightspectrumfull block="%client full"
|
||||||
//% group="Light spectrum sensor"
|
//% group="Light spectrum sensor"
|
||||||
get full(): number {
|
get full(): number {
|
||||||
const s = this.state;
|
const s = this.state;
|
||||||
|
@ -33,7 +33,7 @@ namespace jacdac {
|
||||||
/**
|
/**
|
||||||
* Reads the full spectrum
|
* Reads the full spectrum
|
||||||
*/
|
*/
|
||||||
//% blockId=jdlightspectruminfrared block="jacdac %client infrared"
|
//% blockId=jdlightspectruminfrared block="%client infrared"
|
||||||
//% group="Light spectrum sensor"
|
//% group="Light spectrum sensor"
|
||||||
get infrared(): number {
|
get infrared(): number {
|
||||||
const s = this.state;
|
const s = this.state;
|
||||||
|
@ -44,7 +44,7 @@ namespace jacdac {
|
||||||
/**
|
/**
|
||||||
* Reads the full spectrum
|
* Reads the full spectrum
|
||||||
*/
|
*/
|
||||||
//% blockId=jdlightspectrumvisible block="jacdac %client visible"
|
//% blockId=jdlightspectrumvisible block="%client visible"
|
||||||
//% group="Light spectrum sensor"
|
//% group="Light spectrum sensor"
|
||||||
get visible(): number {
|
get visible(): number {
|
||||||
const s = this.state;
|
const s = this.state;
|
||||||
|
@ -57,7 +57,7 @@ namespace jacdac {
|
||||||
* @param gesture
|
* @param gesture
|
||||||
* @param handler
|
* @param handler
|
||||||
*/
|
*/
|
||||||
//% blockId=jacadaclightsensorspectrumonevent block="jacdac %client on %event"
|
//% blockId=jacadaclightsensorspectrumonevent block="%client on %event"
|
||||||
//% group="Light sensor"
|
//% group="Light sensor"
|
||||||
onEvent(event: JDLightSpectrumEvent, handler: () => void) {
|
onEvent(event: JDLightSpectrumEvent, handler: () => void) {
|
||||||
this.registerEvent(event, handler);
|
this.registerEvent(event, handler);
|
||||||
|
|
|
@ -77,7 +77,7 @@ namespace jacdac {
|
||||||
* Broadcasts a message over JacDac
|
* Broadcasts a message over JacDac
|
||||||
* @param msg
|
* @param msg
|
||||||
*/
|
*/
|
||||||
//% blockId=jacdacBroadcastMessage block="jacdac send $msg"
|
//% blockId=jacdacBroadcastMessage block="send $msg"
|
||||||
//% msg.shadow=jacdacMessageCode draggableParameters
|
//% msg.shadow=jacdacMessageCode draggableParameters
|
||||||
//% weight=200
|
//% weight=200
|
||||||
//% blockGap=8
|
//% blockGap=8
|
||||||
|
@ -93,7 +93,7 @@ namespace jacdac {
|
||||||
* @param msg
|
* @param msg
|
||||||
* @param handler
|
* @param handler
|
||||||
*/
|
*/
|
||||||
//% blockId=jacdacOnMessageReceived block="on jacdac $msg received"
|
//% blockId=jacdacOnMessageReceived block="on $msg received"
|
||||||
//% msg.shadow=jacdacMessageCode draggableParameters
|
//% msg.shadow=jacdacMessageCode draggableParameters
|
||||||
//% weight=199
|
//% weight=199
|
||||||
//% help=jacdac/on-received-message
|
//% help=jacdac/on-received-message
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace jacdac {
|
||||||
* Set the on-board pixel to a given color.
|
* Set the on-board pixel to a given color.
|
||||||
* @param color RGB color of the LED
|
* @param color RGB color of the LED
|
||||||
*/
|
*/
|
||||||
//% blockId="jadacpixelsetcolor" block="jacdac set %pixel color %rgb=colorNumberPicker"
|
//% blockId="jadacpixelsetcolor" block="set %pixel color %rgb=colorNumberPicker"
|
||||||
//% weight=99
|
//% weight=99
|
||||||
//% blockGap=8
|
//% blockGap=8
|
||||||
//% group="Pixel"
|
//% group="Pixel"
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace jacdac {
|
||||||
/**
|
/**
|
||||||
* Gets the distance measure by the sensor. Negative if missing
|
* Gets the distance measure by the sensor. Negative if missing
|
||||||
*/
|
*/
|
||||||
//% blockId=jdproximtitydistance block="jacdac %client distance"
|
//% blockId=jdproximtitydistance block="%client distance"
|
||||||
//% group="Promixity"
|
//% group="Promixity"
|
||||||
get distance(): number {
|
get distance(): number {
|
||||||
const s = this.state;
|
const s = this.state;
|
||||||
|
@ -26,7 +26,7 @@ namespace jacdac {
|
||||||
* @param gesture
|
* @param gesture
|
||||||
* @param handler
|
* @param handler
|
||||||
*/
|
*/
|
||||||
//% blockId=jdproximityevent block="jacdac %client on %event"
|
//% blockId=jdproximityevent block="%client on %event"
|
||||||
//% group="Promixity"
|
//% group="Promixity"
|
||||||
onEvent(event: JDPromixityEvent, handler: () => void) {
|
onEvent(event: JDPromixityEvent, handler: () => void) {
|
||||||
this.registerEvent(event, handler);
|
this.registerEvent(event, handler);
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace jacdac {
|
||||||
/**
|
/**
|
||||||
* Reads the current x value from the sensor
|
* Reads the current x value from the sensor
|
||||||
*/
|
*/
|
||||||
//% blockId=jacdacswitchright block="jacdac %switch right"
|
//% blockId=jacdacswitchright block="%switch right"
|
||||||
//% group="Switch"
|
//% group="Switch"
|
||||||
right(): boolean {
|
right(): boolean {
|
||||||
const s = this.state;
|
const s = this.state;
|
||||||
|
@ -21,7 +21,7 @@ namespace jacdac {
|
||||||
* @param gesture
|
* @param gesture
|
||||||
* @param handler
|
* @param handler
|
||||||
*/
|
*/
|
||||||
//% blockId=jacdacswitchonevent block="jacdac %switch on %event"
|
//% blockId=jacdacswitchonevent block="%switch on %event"
|
||||||
//% group="Switch"
|
//% group="Switch"
|
||||||
onEvent(event: SwitchDirection, handler: () => void) {
|
onEvent(event: SwitchDirection, handler: () => void) {
|
||||||
this.registerEvent(event, handler);
|
this.registerEvent(event, handler);
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace jacdac {
|
||||||
/**
|
/**
|
||||||
* Reads the current x value from the sensor
|
* Reads the current x value from the sensor
|
||||||
*/
|
*/
|
||||||
//% blockId=jacadactouchispressed block="jacdac %button value"
|
//% blockId=jacadactouchispressed block="%button value"
|
||||||
//% group="Touch"
|
//% group="Touch"
|
||||||
value(): number {
|
value(): number {
|
||||||
const s = this.state;
|
const s = this.state;
|
||||||
|
@ -21,7 +21,7 @@ namespace jacdac {
|
||||||
* @param gesture
|
* @param gesture
|
||||||
* @param handler
|
* @param handler
|
||||||
*/
|
*/
|
||||||
//% blockId=jacadactouchonevent block="jacdac %button on %event"
|
//% blockId=jacadactouchonevent block="%button on %event"
|
||||||
//% group="Touch"
|
//% group="Touch"
|
||||||
onEvent(event: JDButtonEvent, handler: () => void) {
|
onEvent(event: JDButtonEvent, handler: () => void) {
|
||||||
this.registerEvent(event, handler);
|
this.registerEvent(event, handler);
|
||||||
|
@ -42,7 +42,7 @@ namespace jacdac {
|
||||||
/**
|
/**
|
||||||
* Reads the current x value from the sensor
|
* Reads the current x value from the sensor
|
||||||
*/
|
*/
|
||||||
//% blockId=jdtoubhbuttonsvalue block="jacdac %button value"
|
//% blockId=jdtoubhbuttonsvalue block="%button value"
|
||||||
//% group="Touch"
|
//% group="Touch"
|
||||||
value(index: number): number {
|
value(index: number): number {
|
||||||
const s = this.state;
|
const s = this.state;
|
||||||
|
@ -55,7 +55,7 @@ namespace jacdac {
|
||||||
* @param gesture
|
* @param gesture
|
||||||
* @param handler
|
* @param handler
|
||||||
*/
|
*/
|
||||||
//% blockId=jdtouchbuttonsevent block="jacdac %client %index on %event"
|
//% blockId=jdtouchbuttonsevent block="%client %index on %event"
|
||||||
//% group="Touch"
|
//% group="Touch"
|
||||||
onEvent(index: number, event: JDButtonEvent, handler: () => void) {
|
onEvent(index: number, event: JDButtonEvent, handler: () => void) {
|
||||||
const j = jacdac.BUTTON_EVENTS.indexOf(<number>event);
|
const j = jacdac.BUTTON_EVENTS.indexOf(<number>event);
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
"constants.ts",
|
"constants.ts",
|
||||||
"client.ts"
|
"client.ts"
|
||||||
],
|
],
|
||||||
|
"supportedTargets": [
|
||||||
|
"arcade",
|
||||||
|
"maker",
|
||||||
|
"microbit"
|
||||||
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core": "*",
|
"core": "*",
|
||||||
"jacdac": "github:microsoft/pxt-jacdac"
|
"jacdac": "github:microsoft/pxt-jacdac"
|
||||||
|
|
|
@ -7,6 +7,7 @@ namespace jacdac {
|
||||||
Log = 0x1,
|
Log = 0x1,
|
||||||
Warning = 0x2,
|
Warning = 0x2,
|
||||||
Error = 0x3,
|
Error = 0x3,
|
||||||
|
Silent = 0x4,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enum LoggerReg {
|
export const enum LoggerReg {
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace modules {
|
||||||
/**
|
/**
|
||||||
* Reads the current x value from the sensor
|
* Reads the current x value from the sensor
|
||||||
*/
|
*/
|
||||||
//% blockId=jacdacmicrophonevent block="jacdac %microphone sound level"
|
//% blockId=jacdacmicrophonevent block="%microphone sound level"
|
||||||
//% group="Microphone"
|
//% group="Microphone"
|
||||||
get soundLevel(): number {
|
get soundLevel(): number {
|
||||||
const s = this.state;
|
const s = this.state;
|
||||||
|
@ -21,7 +21,7 @@ namespace modules {
|
||||||
* @param gesture
|
* @param gesture
|
||||||
* @param handler
|
* @param handler
|
||||||
*/
|
*/
|
||||||
//% blockId=jacadacmicrophoneonevent block="jacdac %microphone on loud sound"
|
//% blockId=jacadacmicrophoneonevent block="%microphone on loud sound"
|
||||||
//% group="Microphone"
|
//% group="Microphone"
|
||||||
onLoudSound(handler: () => void) {
|
onLoudSound(handler: () => void) {
|
||||||
this.registerEvent(DAL.SENSOR_THRESHOLD_HIGH, handler);
|
this.registerEvent(DAL.SENSOR_THRESHOLD_HIGH, handler);
|
||||||
|
@ -32,7 +32,7 @@ namespace modules {
|
||||||
* @param level
|
* @param level
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
//% blockId=jacdacmicrophonesetthreshold block="jacdac %microphone set loud sound threshold to %value"
|
//% blockId=jacdacmicrophonesetthreshold block="%microphone set loud sound threshold to %value"
|
||||||
//% group="Microphone"
|
//% group="Microphone"
|
||||||
setLoudSoundThreshold(value: number) {
|
setLoudSoundThreshold(value: number) {
|
||||||
this.setThreshold(false, value);
|
this.setThreshold(false, value);
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
"constants.ts",
|
"constants.ts",
|
||||||
"client.ts"
|
"client.ts"
|
||||||
],
|
],
|
||||||
|
"supportedTargets": [
|
||||||
|
"arcade",
|
||||||
|
"maker",
|
||||||
|
"microbit"
|
||||||
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core": "*",
|
"core": "*",
|
||||||
"jacdac": "github:microsoft/pxt-jacdac"
|
"jacdac": "github:microsoft/pxt-jacdac"
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace jacdac {
|
||||||
* Run code when a specific even is detected in input data.
|
* Run code when a specific even is detected in input data.
|
||||||
*/
|
*/
|
||||||
//% group="Machine Learning"
|
//% group="Machine Learning"
|
||||||
//% blockId=jacadacmrundetect block="jacdac %client on ML class %classId detected"
|
//% blockId=jacadacmrundetect block="%client on ML class %classId detected"
|
||||||
onDetection(classId: number, handler: () => void) {
|
onDetection(classId: number, handler: () => void) {
|
||||||
this.autoStart()
|
this.autoStart()
|
||||||
this.registerEvent(classId + 1000, handler);
|
this.registerEvent(classId + 1000, handler);
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
"constants.ts",
|
"constants.ts",
|
||||||
"client.ts"
|
"client.ts"
|
||||||
],
|
],
|
||||||
|
"supportedTargets": [
|
||||||
|
"arcade",
|
||||||
|
"maker",
|
||||||
|
"microbit"
|
||||||
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core": "*",
|
"core": "*",
|
||||||
"jacdac": "github:microsoft/pxt-jacdac"
|
"jacdac": "github:microsoft/pxt-jacdac"
|
||||||
|
|
|
@ -13,17 +13,10 @@ namespace modules {
|
||||||
export const blink = new MonoLightAnimation(hex`ffff f401 ffff 0100 0000 fd01`)
|
export const blink = new MonoLightAnimation(hex`ffff f401 ffff 0100 0000 fd01`)
|
||||||
}
|
}
|
||||||
|
|
||||||
enum PwmReg {
|
|
||||||
CurrIteration = 0x80,
|
|
||||||
MaxIterations = 0x81,
|
|
||||||
Steps = 0x82,
|
|
||||||
MaxSteps = 0x180,
|
|
||||||
}
|
|
||||||
|
|
||||||
//% fixedInstances
|
//% fixedInstances
|
||||||
export class MonoLightClient extends jacdac.Client {
|
export class MonoLightClient extends jacdac.Client {
|
||||||
constructor(requiredDevice: string = null) {
|
constructor(requiredDevice: string = null) {
|
||||||
super("pwml", jacdac.SRV_PWM_LIGHT, requiredDevice);
|
super("pwml", jacdac.SRV_MONO_LIGHT, requiredDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set to negative for infinity
|
// set to negative for infinity
|
||||||
|
@ -31,11 +24,11 @@ namespace modules {
|
||||||
numIters |= 0
|
numIters |= 0
|
||||||
if (numIters < 0 || numIters >= 0xffff) numIters = 0xffffffff
|
if (numIters < 0 || numIters >= 0xffff) numIters = 0xffffffff
|
||||||
else if (numIters) numIters--
|
else if (numIters) numIters--
|
||||||
this.setRegInt(PwmReg.MaxIterations, numIters)
|
this.setRegInt(jacdac.MonoLightReg.MaxIterations, numIters)
|
||||||
}
|
}
|
||||||
|
|
||||||
setBrightness(brightness: number): void {
|
setBrightness(brightness: number): void {
|
||||||
this.setRegInt(jacdac.SystemReg.Intensity, brightness << 8)
|
this.setRegInt(jacdac.MonoLightReg.Brightness, brightness << 8)
|
||||||
}
|
}
|
||||||
|
|
||||||
showAnimation(animation: MonoLightAnimation, speed = 100) {
|
showAnimation(animation: MonoLightAnimation, speed = 100) {
|
||||||
|
@ -48,7 +41,7 @@ namespace modules {
|
||||||
anim.setNumber(NumberFormat.UInt16LE, i + 2, adj)
|
anim.setNumber(NumberFormat.UInt16LE, i + 2, adj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.setRegBuffer(PwmReg.Steps, anim)
|
this.setRegBuffer(jacdac.MonoLightReg.Steps, anim)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
namespace jacdac {
|
namespace jacdac {
|
||||||
// Service: PWM Light
|
// Service: Mono Light
|
||||||
export const SRV_PWM_LIGHT = 0x1fb57453
|
export const SRV_MONO_LIGHT = 0x1fb57453
|
||||||
export const enum PwmLightReg {
|
export const enum MonoLightReg {
|
||||||
/**
|
/**
|
||||||
* Read-write ratio uint16_t. Set the luminosity of the strip. The value is used to scale `start_intensity` in `steps` register.
|
* Read-write ratio uint16_t. Set the luminosity of the strip. The value is used to scale `start_intensity` in `steps` register.
|
||||||
* At `0` the power to the strip is completely shut down.
|
* At `0` the power to the strip is completely shut down.
|
|
@ -6,6 +6,11 @@
|
||||||
"constants.ts",
|
"constants.ts",
|
||||||
"client.ts"
|
"client.ts"
|
||||||
],
|
],
|
||||||
|
"supportedTargets": [
|
||||||
|
"arcade",
|
||||||
|
"maker",
|
||||||
|
"microbit"
|
||||||
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core": "*",
|
"core": "*",
|
||||||
"jacdac": "github:microsoft/pxt-jacdac"
|
"jacdac": "github:microsoft/pxt-jacdac"
|
|
@ -15,7 +15,7 @@ namespace modules {
|
||||||
*/
|
*/
|
||||||
//% group="Servos"
|
//% group="Servos"
|
||||||
//% weight=99
|
//% weight=99
|
||||||
//% blockId=jdmotorrun block="jacdac motor %motor run at %speed=speedPicker \\%"
|
//% blockId=jdmotorrun block="%motor run at %speed=speedPicker \\%"
|
||||||
//% servo.fieldEditor="gridpicker"
|
//% servo.fieldEditor="gridpicker"
|
||||||
//% servo.fieldOptions.width=220
|
//% servo.fieldOptions.width=220
|
||||||
//% servo.fieldOptions.columns=2
|
//% servo.fieldOptions.columns=2
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
"constants.ts",
|
"constants.ts",
|
||||||
"client.ts"
|
"client.ts"
|
||||||
],
|
],
|
||||||
|
"supportedTargets": [
|
||||||
|
"arcade",
|
||||||
|
"maker",
|
||||||
|
"microbit"
|
||||||
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core": "*",
|
"core": "*",
|
||||||
"jacdac": "github:microsoft/pxt-jacdac"
|
"jacdac": "github:microsoft/pxt-jacdac"
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace modules {
|
||||||
/**
|
/**
|
||||||
* Reads the current capacitance
|
* Reads the current capacitance
|
||||||
*/
|
*/
|
||||||
//% blockId=jdmultitouchvalue block="jacdac %button value"
|
//% blockId=jdmultitouchvalue block="%button value"
|
||||||
//% group="Touch"
|
//% group="Touch"
|
||||||
value(index: number): number {
|
value(index: number): number {
|
||||||
const s = this.state;
|
const s = this.state;
|
||||||
|
@ -23,7 +23,7 @@ namespace modules {
|
||||||
* @param gesture
|
* @param gesture
|
||||||
* @param handler
|
* @param handler
|
||||||
*/
|
*/
|
||||||
//% blockId=jdmulittouchevent block="jacdac %client on %event"
|
//% blockId=jdmulittouchevent block="%client on %event"
|
||||||
//% group="Touch"
|
//% group="Touch"
|
||||||
onEvent(event: jacdac.MultitouchEvent, handler: (idx: number) => void) {
|
onEvent(event: jacdac.MultitouchEvent, handler: (idx: number) => void) {
|
||||||
this.registerHandler(event, handler);
|
this.registerHandler(event, handler);
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
"constants.ts",
|
"constants.ts",
|
||||||
"client.ts"
|
"client.ts"
|
||||||
],
|
],
|
||||||
|
"supportedTargets": [
|
||||||
|
"arcade",
|
||||||
|
"maker",
|
||||||
|
"microbit"
|
||||||
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core": "*",
|
"core": "*",
|
||||||
"jacdac": "github:microsoft/pxt-jacdac"
|
"jacdac": "github:microsoft/pxt-jacdac"
|
||||||
|
|
10
pack.ts
10
pack.ts
|
@ -299,4 +299,14 @@ namespace jacdac {
|
||||||
jdpackCore(res, fmt, data, 0)
|
jdpackCore(res, fmt, data, 0)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function jdpackEqual<T extends any[]>(fmt: string, left: T, right: T) {
|
||||||
|
if ((!left) !== (!right))
|
||||||
|
return false;
|
||||||
|
if (!left) return true;
|
||||||
|
|
||||||
|
const leftBuffer = jdpack<T>(fmt, left);
|
||||||
|
const rightBuffer = jdpack<T>(fmt, right);
|
||||||
|
return leftBuffer.equals(rightBuffer);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -22,7 +22,7 @@ namespace modules {
|
||||||
/**
|
/**
|
||||||
* Gets the position of the rotary encoder
|
* Gets the position of the rotary encoder
|
||||||
*/
|
*/
|
||||||
//% blockId=jacdacrotaryencoderposition block="jacdac %encoder position"
|
//% blockId=jacdacrotaryencoderposition block="%encoder position"
|
||||||
//% group="Rotary Encoder"
|
//% group="Rotary Encoder"
|
||||||
get position(): number {
|
get position(): number {
|
||||||
const st = this.state;
|
const st = this.state;
|
||||||
|
@ -46,7 +46,7 @@ namespace modules {
|
||||||
* @param gesture
|
* @param gesture
|
||||||
* @param handler
|
* @param handler
|
||||||
*/
|
*/
|
||||||
//% blockId=jacadacrotaryencoderonevent block="jacdac %client on %event"
|
//% blockId=jacadacrotaryencoderonevent block="%client on %event"
|
||||||
//% group="Light sensor"
|
//% group="Light sensor"
|
||||||
onEvent(event: jacdac.RoleManagerEvent, handler: () => void) {
|
onEvent(event: jacdac.RoleManagerEvent, handler: () => void) {
|
||||||
this.registerEvent(event, handler);
|
this.registerEvent(event, handler);
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
"constants.ts",
|
"constants.ts",
|
||||||
"client.ts"
|
"client.ts"
|
||||||
],
|
],
|
||||||
|
"supportedTargets": [
|
||||||
|
"arcade",
|
||||||
|
"maker",
|
||||||
|
"microbit"
|
||||||
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core": "*",
|
"core": "*",
|
||||||
"jacdac": "github:microsoft/pxt-jacdac"
|
"jacdac": "github:microsoft/pxt-jacdac"
|
||||||
|
|
24
routing.ts
24
routing.ts
|
@ -129,8 +129,30 @@ namespace jacdac {
|
||||||
return current
|
return current
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected handleRegFormat<T extends any[]>(pkt: JDPacket, register: number, fmt: string, current: T): T {
|
||||||
|
const getset = pkt.service_command >> 12
|
||||||
|
if (getset == 0 || getset > 2)
|
||||||
|
return current
|
||||||
|
const reg = pkt.service_command & 0xfff
|
||||||
|
if (reg != register)
|
||||||
|
return current
|
||||||
|
if (getset == 1) {
|
||||||
|
this.sendReport(JDPacket.jdpacked(pkt.service_command, fmt, current))
|
||||||
|
} else {
|
||||||
|
if (register >> 8 == 0x1)
|
||||||
|
return current // read-only
|
||||||
|
const v = pkt.jdunpack<T>(fmt)
|
||||||
|
if (!jdpackEqual<T>(fmt, v, current)) {
|
||||||
|
this.stateUpdated = true
|
||||||
|
current = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return current
|
||||||
|
}
|
||||||
|
|
||||||
protected handleRegBool(pkt: JDPacket, register: number, current: boolean): boolean {
|
protected handleRegBool(pkt: JDPacket, register: number, current: boolean): boolean {
|
||||||
return this.handleRegInt(pkt, register, current ? 1 : 0) != 0
|
const [res] = this.handleRegFormat(pkt, register, "u8", [current ? 1 : 0]);
|
||||||
|
return !!res;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected handleRegInt(pkt: JDPacket, register: number, current: number): number {
|
protected handleRegInt(pkt: JDPacket, register: number, current: number): number {
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
"constants.ts",
|
"constants.ts",
|
||||||
"host.ts"
|
"host.ts"
|
||||||
],
|
],
|
||||||
|
"supportedTargets": [
|
||||||
|
"arcade",
|
||||||
|
"maker",
|
||||||
|
"microbit"
|
||||||
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core": "*",
|
"core": "*",
|
||||||
"jacdac": "github:microsoft/pxt-jacdac"
|
"jacdac": "github:microsoft/pxt-jacdac"
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace modules {
|
||||||
*/
|
*/
|
||||||
//% group="Servos"
|
//% group="Servos"
|
||||||
//% weight=100
|
//% weight=100
|
||||||
//% blockId=jdservoservosetangle block="jacdac set %servo angle to %degrees=protractorPicker °"
|
//% blockId=jdservoservosetangle block="set %servo angle to %degrees=protractorPicker °"
|
||||||
//% degrees.defl=90
|
//% degrees.defl=90
|
||||||
//% servo.fieldEditor="gridpicker"
|
//% servo.fieldEditor="gridpicker"
|
||||||
//% servo.fieldOptions.width=220
|
//% servo.fieldOptions.width=220
|
||||||
|
@ -65,7 +65,7 @@ namespace modules {
|
||||||
*/
|
*/
|
||||||
//% group="Servos"
|
//% group="Servos"
|
||||||
//% weight=99
|
//% weight=99
|
||||||
//% blockId=jdservoservorun block="jacdac continuous %servo run at %speed=speedPicker \\%"
|
//% blockId=jdservoservorun block="continuous %servo run at %speed=speedPicker \\%"
|
||||||
//% servo.fieldEditor="gridpicker"
|
//% servo.fieldEditor="gridpicker"
|
||||||
//% servo.fieldOptions.width=220
|
//% servo.fieldOptions.width=220
|
||||||
//% servo.fieldOptions.columns=2
|
//% servo.fieldOptions.columns=2
|
||||||
|
@ -78,7 +78,7 @@ namespace modules {
|
||||||
*/
|
*/
|
||||||
//% group="Servos"
|
//% group="Servos"
|
||||||
//% weight=10 help=servos/set-pulse
|
//% weight=10 help=servos/set-pulse
|
||||||
//% blockId=jdservoservosetpulse block="jacdac set %servo pulse to %micros μs"
|
//% blockId=jdservoservosetpulse block="set %servo pulse to %micros μs"
|
||||||
//% micros.min=500 micros.max=2500
|
//% micros.min=500 micros.max=2500
|
||||||
//% micros.defl=1500
|
//% micros.defl=1500
|
||||||
//% servo.fieldEditor="gridpicker"
|
//% servo.fieldEditor="gridpicker"
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
"constants.ts",
|
"constants.ts",
|
||||||
"client.ts"
|
"client.ts"
|
||||||
],
|
],
|
||||||
|
"supportedTargets": [
|
||||||
|
"arcade",
|
||||||
|
"maker",
|
||||||
|
"microbit"
|
||||||
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core": "*",
|
"core": "*",
|
||||||
"jacdac": "github:microsoft/pxt-jacdac"
|
"jacdac": "github:microsoft/pxt-jacdac"
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
"files": [
|
"files": [
|
||||||
"constants.ts"
|
"constants.ts"
|
||||||
],
|
],
|
||||||
|
"supportedTargets": [
|
||||||
|
"arcade",
|
||||||
|
"maker",
|
||||||
|
"microbit"
|
||||||
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core": "*",
|
"core": "*",
|
||||||
"jacdac": "github:microsoft/pxt-jacdac"
|
"jacdac": "github:microsoft/pxt-jacdac"
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace modules {
|
||||||
/**
|
/**
|
||||||
* Gets the position of the slider
|
* Gets the position of the slider
|
||||||
*/
|
*/
|
||||||
//% blockId=jacdacsliderposition block="jacdac %slider position"
|
//% blockId=jacdacsliderposition block="%slider position"
|
||||||
//% group="Slider"
|
//% group="Slider"
|
||||||
get position(): number {
|
get position(): number {
|
||||||
if (!this.started) {
|
if (!this.started) {
|
||||||
|
|
|
@ -18,7 +18,9 @@
|
||||||
"targetId": "maker"
|
"targetId": "maker"
|
||||||
},
|
},
|
||||||
"supportedTargets": [
|
"supportedTargets": [
|
||||||
"maker"
|
"arcade",
|
||||||
|
"maker",
|
||||||
|
"microbit"
|
||||||
],
|
],
|
||||||
"preferredEditor": "tsprj"
|
"preferredEditor": "tsprj"
|
||||||
}
|
}
|
|
@ -6,6 +6,11 @@
|
||||||
"constants.ts",
|
"constants.ts",
|
||||||
"client.ts"
|
"client.ts"
|
||||||
],
|
],
|
||||||
|
"supportedTargets": [
|
||||||
|
"arcade",
|
||||||
|
"maker",
|
||||||
|
"microbit"
|
||||||
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core": "*",
|
"core": "*",
|
||||||
"net": "*",
|
"net": "*",
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace modules {
|
||||||
* @param gesture
|
* @param gesture
|
||||||
* @param handler
|
* @param handler
|
||||||
*/
|
*/
|
||||||
//% blockId=jacadacthermoonevent block="jacdac %lightsensor on %lightCondition"
|
//% blockId=jacadacthermoonevent block="$client on $condition at $temperature $unit"
|
||||||
//% group="Thermometer"
|
//% group="Thermometer"
|
||||||
onTemperatureConditionChanged(condition: JDTemperatureCondition, temperature: number, unit: JDTemperatureUnit, handler: () => void): void {
|
onTemperatureConditionChanged(condition: JDTemperatureCondition, temperature: number, unit: JDTemperatureUnit, handler: () => void): void {
|
||||||
if (unit == JDTemperatureUnit.Fahrenheit)
|
if (unit == JDTemperatureUnit.Fahrenheit)
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
"constants.ts",
|
"constants.ts",
|
||||||
"client.ts"
|
"client.ts"
|
||||||
],
|
],
|
||||||
|
"supportedTargets": [
|
||||||
|
"arcade",
|
||||||
|
"maker",
|
||||||
|
"microbit"
|
||||||
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core": "*",
|
"core": "*",
|
||||||
"jacdac": "github:microsoft/pxt-jacdac"
|
"jacdac": "github:microsoft/pxt-jacdac"
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
"constants.ts",
|
"constants.ts",
|
||||||
"client.ts"
|
"client.ts"
|
||||||
],
|
],
|
||||||
|
"supportedTargets": [
|
||||||
|
"arcade",
|
||||||
|
"maker",
|
||||||
|
"microbit"
|
||||||
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core": "*",
|
"core": "*",
|
||||||
"jacdac": "github:microsoft/pxt-jacdac",
|
"jacdac": "github:microsoft/pxt-jacdac",
|
||||||
|
|
Загрузка…
Ссылка в новой задаче