refresh constants (#98)
* updating all constants * fix build * don't target arcade beta
This commit is contained in:
Родитель
8dac8fadd0
Коммит
d533b4b871
|
@ -13,8 +13,8 @@ This project contains [Jacdac](https://aka.ms/jacdac) host and client services f
|
|||
### Supported editors
|
||||
|
||||
- micro:bit V2, https://makecode.microbit.org/
|
||||
- Arcade, https://arcade.makecode.com/beta
|
||||
- Maker, https://maker.makecode.com/beta
|
||||
- Arcade, https://arcade.makecode.com/
|
||||
- Maker, https://maker.makecode.com/
|
||||
|
||||
## Developer section
|
||||
|
||||
|
|
|
@ -42,22 +42,22 @@ namespace jacdac {
|
|||
|
||||
export namespace AccelerometerRegPack {
|
||||
/**
|
||||
* Pack format for 'forces' register data.
|
||||
* Pack format for 'forces' data.
|
||||
*/
|
||||
export const Forces = "i12.20 i12.20 i12.20"
|
||||
|
||||
/**
|
||||
* Pack format for 'forces_error' register data.
|
||||
* Pack format for 'forces_error' data.
|
||||
*/
|
||||
export const ForcesError = "u12.20"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_force' register data.
|
||||
* Pack format for 'max_force' data.
|
||||
*/
|
||||
export const MaxForce = "u12.20"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_forces_supported' register data.
|
||||
* Pack format for 'max_forces_supported' data.
|
||||
*/
|
||||
export const MaxForcesSupported = "r: u12.20"
|
||||
}
|
||||
|
|
|
@ -41,22 +41,22 @@ namespace jacdac {
|
|||
|
||||
export namespace AcidityRegPack {
|
||||
/**
|
||||
* Pack format for 'acidity' register data.
|
||||
* Pack format for 'acidity' data.
|
||||
*/
|
||||
export const Acidity = "u4.12"
|
||||
|
||||
/**
|
||||
* Pack format for 'acidity_error' register data.
|
||||
* Pack format for 'acidity_error' data.
|
||||
*/
|
||||
export const AcidityError = "u4.12"
|
||||
|
||||
/**
|
||||
* Pack format for 'min_acidity' register data.
|
||||
* Pack format for 'min_acidity' data.
|
||||
*/
|
||||
export const MinAcidity = "u4.12"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_humidity' register data.
|
||||
* Pack format for 'max_humidity' data.
|
||||
*/
|
||||
export const MaxHumidity = "u4.12"
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ namespace modules {
|
|||
//% fixedInstances blockGap=8
|
||||
export class AirPressureClient extends jacdac.SimpleSensorClient {
|
||||
private readonly _pressureError: jacdac.RegisterClient<[number]>
|
||||
private readonly _minPressure: jacdac.RegisterClient<[number]>
|
||||
private readonly _maxPressure: jacdac.RegisterClient<[number]>
|
||||
|
||||
constructor(role: string) {
|
||||
super(
|
||||
|
@ -18,6 +20,18 @@ namespace modules {
|
|||
jacdac.AirPressureRegPack.PressureError,
|
||||
jacdac.RegisterClientFlags.Optional
|
||||
)
|
||||
this._minPressure = this.addRegister<[number]>(
|
||||
jacdac.AirPressureReg.MinPressure,
|
||||
jacdac.AirPressureRegPack.MinPressure,
|
||||
jacdac.RegisterClientFlags.Optional |
|
||||
jacdac.RegisterClientFlags.Const
|
||||
)
|
||||
this._maxPressure = this.addRegister<[number]>(
|
||||
jacdac.AirPressureReg.MaxPressure,
|
||||
jacdac.AirPressureRegPack.MaxPressure,
|
||||
jacdac.RegisterClientFlags.Optional |
|
||||
jacdac.RegisterClientFlags.Const
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,15 +58,39 @@ namespace modules {
|
|||
return values[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Lowest air pressure that can be reported.
|
||||
*/
|
||||
//% callInDebugger
|
||||
//% group="Environment"
|
||||
//% weight=98
|
||||
minPressure(): number {
|
||||
this.start()
|
||||
const values = this._minPressure.pauseUntilValues() as any[]
|
||||
return values[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Highest air pressure that can be reported.
|
||||
*/
|
||||
//% callInDebugger
|
||||
//% group="Environment"
|
||||
//% weight=97
|
||||
maxPressure(): number {
|
||||
this.start()
|
||||
const values = this._maxPressure.pauseUntilValues() as any[]
|
||||
return values[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Run code when the pressure changes by the given threshold value.
|
||||
*/
|
||||
//% group="Environment"
|
||||
//% blockId=jacdac_airpressure_on_pressure_change
|
||||
//% block="on %airpressure pressure changed by %threshold (hPa)"
|
||||
//% weight=98
|
||||
//% weight=96
|
||||
//% threshold.min=0
|
||||
//% threshold.max=1040
|
||||
//% threshold.max=1150
|
||||
//% threshold.defl=1
|
||||
onPressureChangedBy(threshold: number, handler: () => void): void {
|
||||
this.onReadingChangedBy(threshold, handler)
|
||||
|
|
|
@ -19,17 +19,45 @@ namespace jacdac {
|
|||
* ```
|
||||
*/
|
||||
PressureError = 0x106,
|
||||
|
||||
/**
|
||||
* Constant hPa u22.10 (uint32_t). Lowest air pressure that can be reported.
|
||||
*
|
||||
* ```
|
||||
* const [minPressure] = jdunpack<[number]>(buf, "u22.10")
|
||||
* ```
|
||||
*/
|
||||
MinPressure = 0x104,
|
||||
|
||||
/**
|
||||
* Constant hPa u22.10 (uint32_t). Highest air pressure that can be reported.
|
||||
*
|
||||
* ```
|
||||
* const [maxPressure] = jdunpack<[number]>(buf, "u22.10")
|
||||
* ```
|
||||
*/
|
||||
MaxPressure = 0x105,
|
||||
}
|
||||
|
||||
export namespace AirPressureRegPack {
|
||||
/**
|
||||
* Pack format for 'pressure' register data.
|
||||
* Pack format for 'pressure' data.
|
||||
*/
|
||||
export const Pressure = "u22.10"
|
||||
|
||||
/**
|
||||
* Pack format for 'pressure_error' register data.
|
||||
* Pack format for 'pressure_error' data.
|
||||
*/
|
||||
export const PressureError = "u22.10"
|
||||
|
||||
/**
|
||||
* Pack format for 'min_pressure' data.
|
||||
*/
|
||||
export const MinPressure = "u22.10"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_pressure' data.
|
||||
*/
|
||||
export const MaxPressure = "u22.10"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,22 +41,22 @@ namespace jacdac {
|
|||
|
||||
export namespace AirQualityIndexRegPack {
|
||||
/**
|
||||
* Pack format for 'aqi_index' register data.
|
||||
* Pack format for 'aqi_index' data.
|
||||
*/
|
||||
export const AqiIndex = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'aqi_index_error' register data.
|
||||
* Pack format for 'aqi_index_error' data.
|
||||
*/
|
||||
export const AqiIndexError = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'min_aqi_index' register data.
|
||||
* Pack format for 'min_aqi_index' data.
|
||||
*/
|
||||
export const MinAqiIndex = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_aqi_index' register data.
|
||||
* Pack format for 'max_aqi_index' data.
|
||||
*/
|
||||
export const MaxAqiIndex = "u16.16"
|
||||
}
|
||||
|
|
|
@ -49,12 +49,12 @@ namespace jacdac {
|
|||
|
||||
export namespace ArcadeGamepadRegPack {
|
||||
/**
|
||||
* Pack format for 'buttons' register data.
|
||||
* Pack format for 'buttons' data.
|
||||
*/
|
||||
export const Buttons = "r: u8 u0.8"
|
||||
|
||||
/**
|
||||
* Pack format for 'available_buttons' register data.
|
||||
* Pack format for 'available_buttons' data.
|
||||
*/
|
||||
export const AvailableButtons = "r: u8"
|
||||
}
|
||||
|
@ -83,12 +83,12 @@ namespace jacdac {
|
|||
|
||||
export namespace ArcadeGamepadEventPack {
|
||||
/**
|
||||
* Pack format for 'down' register data.
|
||||
* Pack format for 'down' data.
|
||||
*/
|
||||
export const Down = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'up' register data.
|
||||
* Pack format for 'up' data.
|
||||
*/
|
||||
export const Up = "u8"
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace jacdac {
|
|||
|
||||
export namespace ArcadeSoundCmdPack {
|
||||
/**
|
||||
* Pack format for 'play' register data.
|
||||
* Pack format for 'play' data.
|
||||
*/
|
||||
export const Play = "b"
|
||||
}
|
||||
|
@ -54,17 +54,17 @@ namespace jacdac {
|
|||
|
||||
export namespace ArcadeSoundRegPack {
|
||||
/**
|
||||
* Pack format for 'sample_rate' register data.
|
||||
* Pack format for 'sample_rate' data.
|
||||
*/
|
||||
export const SampleRate = "u22.10"
|
||||
|
||||
/**
|
||||
* Pack format for 'buffer_size' register data.
|
||||
* Pack format for 'buffer_size' data.
|
||||
*/
|
||||
export const BufferSize = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'buffer_pending' register data.
|
||||
* Pack format for 'buffer_pending' data.
|
||||
*/
|
||||
export const BufferPending = "u32"
|
||||
}
|
||||
|
|
|
@ -53,12 +53,12 @@ namespace jacdac {
|
|||
|
||||
export namespace BarcodeReaderRegPack {
|
||||
/**
|
||||
* Pack format for 'enabled' register data.
|
||||
* Pack format for 'enabled' data.
|
||||
*/
|
||||
export const Enabled = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'formats' register data.
|
||||
* Pack format for 'formats' data.
|
||||
*/
|
||||
export const Formats = "r: u8"
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ namespace jacdac {
|
|||
|
||||
export namespace BarcodeReaderEventPack {
|
||||
/**
|
||||
* Pack format for 'detect' register data.
|
||||
* Pack format for 'detect' data.
|
||||
*/
|
||||
export const Detect = "u8 s"
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace jacdac {
|
|||
|
||||
export namespace BaseCmdPack {
|
||||
/**
|
||||
* Pack format for 'command_not_implemented' register data.
|
||||
* Pack format for 'command_not_implemented' data.
|
||||
*/
|
||||
export const CommandNotImplemented = "u16 u16"
|
||||
}
|
||||
|
@ -50,12 +50,12 @@ namespace jacdac {
|
|||
|
||||
export namespace BaseRegPack {
|
||||
/**
|
||||
* Pack format for 'instance_name' register data.
|
||||
* Pack format for 'instance_name' data.
|
||||
*/
|
||||
export const InstanceName = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'status_code' register data.
|
||||
* Pack format for 'status_code' data.
|
||||
*/
|
||||
export const StatusCode = "u16 u16"
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ namespace jacdac {
|
|||
|
||||
export namespace BaseEventPack {
|
||||
/**
|
||||
* Pack format for 'status_code_changed' register data.
|
||||
* Pack format for 'status_code_changed' data.
|
||||
*/
|
||||
export const StatusCodeChanged = "u16 u16"
|
||||
}
|
||||
|
|
|
@ -41,22 +41,22 @@ namespace jacdac {
|
|||
|
||||
export namespace BitRadioRegPack {
|
||||
/**
|
||||
* Pack format for 'enabled' register data.
|
||||
* Pack format for 'enabled' data.
|
||||
*/
|
||||
export const Enabled = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'group' register data.
|
||||
* Pack format for 'group' data.
|
||||
*/
|
||||
export const Group = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'transmission_power' register data.
|
||||
* Pack format for 'transmission_power' data.
|
||||
*/
|
||||
export const TransmissionPower = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'frequency_band' register data.
|
||||
* Pack format for 'frequency_band' data.
|
||||
*/
|
||||
export const FrequencyBand = "u8"
|
||||
}
|
||||
|
@ -128,37 +128,37 @@ namespace jacdac {
|
|||
|
||||
export namespace BitRadioCmdPack {
|
||||
/**
|
||||
* Pack format for 'send_string' register data.
|
||||
* Pack format for 'send_string' data.
|
||||
*/
|
||||
export const SendString = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'send_number' register data.
|
||||
* Pack format for 'send_number' data.
|
||||
*/
|
||||
export const SendNumber = "f64"
|
||||
|
||||
/**
|
||||
* Pack format for 'send_value' register data.
|
||||
* Pack format for 'send_value' data.
|
||||
*/
|
||||
export const SendValue = "f64 s"
|
||||
|
||||
/**
|
||||
* Pack format for 'send_buffer' register data.
|
||||
* Pack format for 'send_buffer' data.
|
||||
*/
|
||||
export const SendBuffer = "b"
|
||||
|
||||
/**
|
||||
* Pack format for 'string_received' register data.
|
||||
* Pack format for 'string_received' data.
|
||||
*/
|
||||
export const StringReceived = "u32 u32 i8 b[1] s"
|
||||
|
||||
/**
|
||||
* Pack format for 'number_received' register data.
|
||||
* Pack format for 'number_received' data.
|
||||
*/
|
||||
export const NumberReceived = "u32 u32 i8 b[3] f64 s"
|
||||
|
||||
/**
|
||||
* Pack format for 'buffer_received' register data.
|
||||
* Pack format for 'buffer_received' data.
|
||||
*/
|
||||
export const BufferReceived = "u32 u32 i8 b[1] b"
|
||||
}
|
||||
|
|
|
@ -67,27 +67,27 @@ namespace jacdac {
|
|||
|
||||
export namespace BootloaderCmdPack {
|
||||
/**
|
||||
* Pack format for 'info' register data.
|
||||
* Pack format for 'info' data.
|
||||
*/
|
||||
export const InfoReport = "u32 u32 u32 u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'set_session' register data.
|
||||
* Pack format for 'set_session' data.
|
||||
*/
|
||||
export const SetSession = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'set_session' register data.
|
||||
* Pack format for 'set_session' data.
|
||||
*/
|
||||
export const SetSessionReport = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'page_data' register data.
|
||||
* Pack format for 'page_data' data.
|
||||
*/
|
||||
export const PageData = "u32 u16 u8 u8 u32 u32 u32 u32 u32 b[208]"
|
||||
|
||||
/**
|
||||
* Pack format for 'page_data' register data.
|
||||
* Pack format for 'page_data' data.
|
||||
*/
|
||||
export const PageDataReport = "u32 u32 u32"
|
||||
}
|
||||
|
|
|
@ -32,17 +32,17 @@ namespace jacdac {
|
|||
|
||||
export namespace BrailleDisplayRegPack {
|
||||
/**
|
||||
* Pack format for 'enabled' register data.
|
||||
* Pack format for 'enabled' data.
|
||||
*/
|
||||
export const Enabled = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'patterns' register data.
|
||||
* Pack format for 'patterns' data.
|
||||
*/
|
||||
export const Patterns = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'length' register data.
|
||||
* Pack format for 'length' data.
|
||||
*/
|
||||
export const Length = "u8"
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace jacdac {
|
|||
|
||||
export namespace BridgeRegPack {
|
||||
/**
|
||||
* Pack format for 'enabled' register data.
|
||||
* Pack format for 'enabled' data.
|
||||
*/
|
||||
export const Enabled = "u8"
|
||||
}
|
||||
|
|
|
@ -28,17 +28,17 @@ namespace jacdac {
|
|||
|
||||
export namespace ButtonRegPack {
|
||||
/**
|
||||
* Pack format for 'pressure' register data.
|
||||
* Pack format for 'pressure' data.
|
||||
*/
|
||||
export const Pressure = "u0.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'analog' register data.
|
||||
* Pack format for 'analog' data.
|
||||
*/
|
||||
export const Analog = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'pressed' register data.
|
||||
* Pack format for 'pressed' data.
|
||||
*/
|
||||
export const Pressed = "u8"
|
||||
}
|
||||
|
@ -76,12 +76,12 @@ namespace jacdac {
|
|||
|
||||
export namespace ButtonEventPack {
|
||||
/**
|
||||
* Pack format for 'up' register data.
|
||||
* Pack format for 'up' data.
|
||||
*/
|
||||
export const Up = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'hold' register data.
|
||||
* Pack format for 'hold' data.
|
||||
*/
|
||||
export const Hold = "u32"
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace jacdac {
|
|||
|
||||
export namespace BuzzerRegPack {
|
||||
/**
|
||||
* Pack format for 'volume' register data.
|
||||
* Pack format for 'volume' data.
|
||||
*/
|
||||
export const Volume = "u0.8"
|
||||
}
|
||||
|
@ -40,12 +40,12 @@ namespace jacdac {
|
|||
|
||||
export namespace BuzzerCmdPack {
|
||||
/**
|
||||
* Pack format for 'play_tone' register data.
|
||||
* Pack format for 'play_tone' data.
|
||||
*/
|
||||
export const PlayTone = "u16 u16 u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'play_note' register data.
|
||||
* Pack format for 'play_note' data.
|
||||
*/
|
||||
export const PlayNote = "u16 u0.16 u16"
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace jacdac {
|
|||
|
||||
export namespace CapacitiveButtonRegPack {
|
||||
/**
|
||||
* Pack format for 'threshold' register data.
|
||||
* Pack format for 'threshold' data.
|
||||
*/
|
||||
export const Threshold = "u0.16"
|
||||
}
|
||||
|
|
|
@ -76,32 +76,32 @@ namespace jacdac {
|
|||
|
||||
export namespace CharacterScreenRegPack {
|
||||
/**
|
||||
* Pack format for 'message' register data.
|
||||
* Pack format for 'message' data.
|
||||
*/
|
||||
export const Message = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'brightness' register data.
|
||||
* Pack format for 'brightness' data.
|
||||
*/
|
||||
export const Brightness = "u0.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'text_direction' register data.
|
||||
* Pack format for 'text_direction' data.
|
||||
*/
|
||||
export const TextDirection = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'rows' register data.
|
||||
* Pack format for 'rows' data.
|
||||
*/
|
||||
export const Rows = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'columns' register data.
|
||||
* Pack format for 'columns' data.
|
||||
*/
|
||||
export const Columns = "u8"
|
||||
}
|
||||
|
|
|
@ -31,57 +31,6 @@ namespace modules {
|
|||
jacdac.CloudAdapterReg.ConnectionName,
|
||||
jacdac.CloudAdapterRegPack.ConnectionName
|
||||
)
|
||||
|
||||
this.on(jacdac.EVENT, pkt => this.handleCloudCommandEvent(pkt))
|
||||
}
|
||||
|
||||
private handleCloudCommandEvent(pkt: jacdac.JDPacket) {
|
||||
if (pkt.eventCode != jacdac.CloudAdapterEvent.CloudCommand) return
|
||||
|
||||
try {
|
||||
// decode message
|
||||
const [seqno, label, values] = pkt.jdunpack<
|
||||
[number, string, number[][]]
|
||||
>(jacdac.CloudAdapterEventPack.CloudCommand)
|
||||
|
||||
// find handler
|
||||
const handler = this._messageHandlers.find(
|
||||
h => h.label == label
|
||||
)
|
||||
|
||||
// send ack
|
||||
const busy = this._messages.length > MAX_QUEUE
|
||||
const status = busy
|
||||
? jacdac.CloudAdapterCommandStatus.Busy
|
||||
: !handler
|
||||
? jacdac.CloudAdapterCommandStatus.NotFound
|
||||
: jacdac.CloudAdapterCommandStatus.OK
|
||||
const resValues: number[][] = []
|
||||
const data = jacdac.jdpack(
|
||||
jacdac.CloudAdapterCmdPack.AckCloudCommand,
|
||||
[seqno, status, resValues]
|
||||
)
|
||||
this.sendCommand(
|
||||
jacdac.JDPacket.from(
|
||||
jacdac.CloudAdapterCmd.AckCloudCommand,
|
||||
data
|
||||
)
|
||||
)
|
||||
|
||||
// queue message
|
||||
if (!busy) {
|
||||
const msg = new CloudMessage()
|
||||
msg.label = label
|
||||
const res = []
|
||||
for (const v of values || []) {
|
||||
res.push(v.shift())
|
||||
}
|
||||
msg.values = res
|
||||
this._messages.push(msg)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(`invalid cloud command ${e}`)
|
||||
}
|
||||
}
|
||||
|
||||
private handleConsumeCloudMessages() {
|
||||
|
@ -121,51 +70,6 @@ namespace modules {
|
|||
return values[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads a label and numberical value.
|
||||
*/
|
||||
//% group="IoT"
|
||||
//% blockId=jacdac_jacscriptcloud_upload_number_cmd
|
||||
//% block="%jacscriptcloud upload number $label $value||$value2 $value3 $value4"
|
||||
//% weight=92
|
||||
//% inlineInputMode=inline
|
||||
uploadNumber(
|
||||
label: string,
|
||||
value: number,
|
||||
value2?: number,
|
||||
value3?: number,
|
||||
value4?: number
|
||||
): void {
|
||||
if (!label || isNaN(value)) return
|
||||
const values: number[] = [value]
|
||||
if (!isNaN(value2)) {
|
||||
values.push(value2)
|
||||
if (!isNaN(value3)) {
|
||||
values.push(value3)
|
||||
if (!isNaN(value4)) {
|
||||
values.push(value4)
|
||||
}
|
||||
}
|
||||
}
|
||||
this.upload(label, values)
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads a labelled payload of values.
|
||||
*/
|
||||
//% group="IoT"
|
||||
//% weight=92
|
||||
upload(label: string, values: number[]): void {
|
||||
this.start()
|
||||
this.sendCommand(
|
||||
jacdac.JDPacket.jdpacked(
|
||||
jacdac.CloudAdapterCmd.Upload,
|
||||
jacdac.CloudAdapterCmdPack.Upload,
|
||||
[label, values.map(v => [v])]
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted when we connect or disconnect from the cloud.
|
||||
*/
|
||||
|
@ -174,36 +78,6 @@ namespace modules {
|
|||
onChange(handler: () => void): void {
|
||||
this.registerEvent(jacdac.CloudAdapterEvent.Change, handler)
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a handler for a given cloud command
|
||||
* @param label command name
|
||||
* @param handler
|
||||
* @returns
|
||||
*/
|
||||
//% draggableParameters=reporter
|
||||
//% blockId=jacdac_cloudadapter_on_cloud_command block="on %cloudadapter command $label"
|
||||
//% group="IoT"
|
||||
//% weight=96
|
||||
onCloudCommand(
|
||||
label: string,
|
||||
handler: (value: number, values: number[]) => void
|
||||
) {
|
||||
if (!label) return
|
||||
let h = this._messageHandlers.find(h => h.label == label)
|
||||
if (!h) {
|
||||
h = new CloudMessageHandler()
|
||||
h.label = label
|
||||
h.handler = (msg: CloudMessage) => {
|
||||
const values = msg.values || []
|
||||
handler(values[0], values)
|
||||
}
|
||||
this._messageHandlers.push(h)
|
||||
}
|
||||
this.registerEvent(jacdac.CloudAdapterEvent.CloudCommand, () =>
|
||||
this.handleConsumeCloudMessages()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
//% fixedInstance whenUsed weight=1 block="cloud adapter1"
|
||||
|
|
|
@ -1,67 +1,42 @@
|
|||
namespace jacdac {
|
||||
// Service Cloud Adapter constants
|
||||
export const SRV_CLOUD_ADAPTER = 0x14606e9c
|
||||
|
||||
export const enum CloudAdapterCommandStatus { // uint32_t
|
||||
//% block="ok"
|
||||
OK = 0xc8,
|
||||
//% block="not found"
|
||||
NotFound = 0x194,
|
||||
//% block="busy"
|
||||
Busy = 0x1ad,
|
||||
}
|
||||
|
||||
export const enum CloudAdapterCmd {
|
||||
/**
|
||||
* Upload a labelled tuple of values to the cloud.
|
||||
* The tuple will be automatically tagged with timestamp and originating device.
|
||||
* Upload a JSON-encoded message to the cloud.
|
||||
*
|
||||
* ```
|
||||
* const [label, value] = jdunpack<[string, number[]]>(buf, "z f64[]")
|
||||
* const [topic, json] = jdunpack<[string, string]>(buf, "z s")
|
||||
* ```
|
||||
*/
|
||||
Upload = 0x80,
|
||||
UploadJson = 0x80,
|
||||
|
||||
/**
|
||||
* Argument: payload bytes. Upload a binary message to the cloud.
|
||||
* Upload a binary message to the cloud.
|
||||
*
|
||||
* ```
|
||||
* const [payload] = jdunpack<[Buffer]>(buf, "b")
|
||||
* const [topic, payload] = jdunpack<[string, Buffer]>(buf, "z b")
|
||||
* ```
|
||||
*/
|
||||
UploadBin = 0x81,
|
||||
|
||||
/**
|
||||
* Should be called when it finishes handling a `cloud_command`.
|
||||
*
|
||||
* ```
|
||||
* const [seqNo, status, result] = jdunpack<[number, jacdac.CloudAdapterCommandStatus, number[]]>(buf, "u32 u32 f64[]")
|
||||
* ```
|
||||
*/
|
||||
AckCloudCommand = 0x83,
|
||||
UploadBinary = 0x81,
|
||||
}
|
||||
|
||||
export namespace CloudAdapterCmdPack {
|
||||
/**
|
||||
* Pack format for 'upload' register data.
|
||||
* Pack format for 'upload_json' data.
|
||||
*/
|
||||
export const Upload = "z r: f64"
|
||||
export const UploadJson = "z s"
|
||||
|
||||
/**
|
||||
* Pack format for 'upload_bin' register data.
|
||||
* Pack format for 'upload_binary' data.
|
||||
*/
|
||||
export const UploadBin = "b"
|
||||
|
||||
/**
|
||||
* Pack format for 'ack_cloud_command' register data.
|
||||
*/
|
||||
export const AckCloudCommand = "u32 u32 r: f64"
|
||||
export const UploadBinary = "z b"
|
||||
}
|
||||
|
||||
export const enum CloudAdapterReg {
|
||||
/**
|
||||
* Read-only bool (uint8_t). Indicate whether we're currently connected to the cloud server.
|
||||
* When offline, `upload` commands are queued, and `get_twin` respond with cached values.
|
||||
* When offline, `upload` commands are queued.
|
||||
*
|
||||
* ```
|
||||
* const [connected] = jdunpack<[number]>(buf, "u8")
|
||||
|
@ -82,26 +57,36 @@ namespace jacdac {
|
|||
|
||||
export namespace CloudAdapterRegPack {
|
||||
/**
|
||||
* Pack format for 'connected' register data.
|
||||
* Pack format for 'connected' data.
|
||||
*/
|
||||
export const Connected = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'connection_name' register data.
|
||||
* Pack format for 'connection_name' data.
|
||||
*/
|
||||
export const ConnectionName = "s"
|
||||
}
|
||||
|
||||
export const enum CloudAdapterEvent {
|
||||
/**
|
||||
* Emitted when cloud requests to run some action.
|
||||
* Emitted when cloud send us a JSON message.
|
||||
*
|
||||
* ```
|
||||
* const [seqNo, command, argument] = jdunpack<[number, string, number[]]>(buf, "u32 z f64[]")
|
||||
* const [topic, json] = jdunpack<[string, string]>(buf, "z s")
|
||||
* ```
|
||||
*/
|
||||
//% block="cloud command"
|
||||
CloudCommand = 0x81,
|
||||
//% block="on json"
|
||||
OnJson = 0x80,
|
||||
|
||||
/**
|
||||
* Emitted when cloud send us a binary message.
|
||||
*
|
||||
* ```
|
||||
* const [topic, payload] = jdunpack<[string, Buffer]>(buf, "z b")
|
||||
* ```
|
||||
*/
|
||||
//% block="on binary"
|
||||
OnBinary = 0x81,
|
||||
|
||||
/**
|
||||
* Emitted when we connect or disconnect from the cloud.
|
||||
|
@ -112,8 +97,13 @@ namespace jacdac {
|
|||
|
||||
export namespace CloudAdapterEventPack {
|
||||
/**
|
||||
* Pack format for 'cloud_command' register data.
|
||||
* Pack format for 'on_json' data.
|
||||
*/
|
||||
export const CloudCommand = "u32 z r: f64"
|
||||
export const OnJson = "z s"
|
||||
|
||||
/**
|
||||
* Pack format for 'on_binary' data.
|
||||
*/
|
||||
export const OnBinary = "z b"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,10 @@
|
|||
{
|
||||
"name": "jacdac-cloud-adapter",
|
||||
"version": "1.8.41",
|
||||
"description": "Supports cloud connections to upload and download data.\nNote that `f64` values following a label are not necessarily aligned.",
|
||||
"files": [
|
||||
"constants.ts",
|
||||
"client.ts"
|
||||
],
|
||||
"testFiles": [
|
||||
"test.ts"
|
||||
],
|
||||
"supportedTargets": [
|
||||
"microbit",
|
||||
"arcade",
|
||||
"maker"
|
||||
],
|
||||
"description": "Supports cloud connections.",
|
||||
"files": ["constants.ts", "client.ts"],
|
||||
"testFiles": ["test.ts"],
|
||||
"supportedTargets": ["maker"],
|
||||
"dependencies": {
|
||||
"core": "*",
|
||||
"jacdac": "github:microsoft/pxt-jacdac"
|
||||
|
|
|
@ -1,9 +1 @@
|
|||
modules.cloudAdapter1.onCloudCommand("test", (value, values) => {
|
||||
console.log(
|
||||
"cloud command received: test " + value + " / " + values.join(",")
|
||||
)
|
||||
})
|
||||
forever(() => {
|
||||
modules.cloudAdapter1.uploadNumber("rnd", Math.random(), Math.random())
|
||||
pause(5000)
|
||||
})
|
||||
// TODO
|
|
@ -0,0 +1,159 @@
|
|||
namespace jacdac {
|
||||
// Service Cloud Configuration constants
|
||||
export const SRV_CLOUD_CONFIGURATION = 0x1462eefc
|
||||
|
||||
export const enum CloudConfigurationConnectionStatus { // uint16_t
|
||||
//% block="connected"
|
||||
Connected = 0x1,
|
||||
//% block="disconnected"
|
||||
Disconnected = 0x2,
|
||||
//% block="connecting"
|
||||
Connecting = 0x3,
|
||||
//% block="disconnecting"
|
||||
Disconnecting = 0x4,
|
||||
}
|
||||
|
||||
export const enum CloudConfigurationReg {
|
||||
/**
|
||||
* Read-only string (bytes). Something like `my-iot-hub.azure-devices.net` if available.
|
||||
*
|
||||
* ```
|
||||
* const [serverName] = jdunpack<[string]>(buf, "s")
|
||||
* ```
|
||||
*/
|
||||
ServerName = 0x180,
|
||||
|
||||
/**
|
||||
* Read-only string (bytes). Device identifier for the device in the cloud if available.
|
||||
*
|
||||
* ```
|
||||
* const [cloudDeviceId] = jdunpack<[string]>(buf, "s")
|
||||
* ```
|
||||
*/
|
||||
CloudDeviceId = 0x181,
|
||||
|
||||
/**
|
||||
* Constant string (bytes). Cloud provider identifier.
|
||||
*
|
||||
* ```
|
||||
* const [cloudType] = jdunpack<[string]>(buf, "s")
|
||||
* ```
|
||||
*/
|
||||
CloudType = 0x183,
|
||||
|
||||
/**
|
||||
* Read-only ConnectionStatus (uint16_t). Indicates the status of connection. A message beyond the [0..3] range represents an HTTP error code.
|
||||
*
|
||||
* ```
|
||||
* const [connectionStatus] = jdunpack<[jacdac.CloudConfigurationConnectionStatus]>(buf, "u16")
|
||||
* ```
|
||||
*/
|
||||
ConnectionStatus = 0x182,
|
||||
|
||||
/**
|
||||
* Read-write ms uint32_t. How often to push data to the cloud.
|
||||
*
|
||||
* ```
|
||||
* const [pushPeriod] = jdunpack<[number]>(buf, "u32")
|
||||
* ```
|
||||
*/
|
||||
PushPeriod = 0x80,
|
||||
|
||||
/**
|
||||
* Read-write ms uint32_t. If no message is published within given period, the device resets.
|
||||
* This can be due to connectivity problems or due to the device having nothing to publish.
|
||||
* Forced to be at least `2 * flush_period`.
|
||||
* Set to `0` to disable (default).
|
||||
*
|
||||
* ```
|
||||
* const [pushWatchdogPeriod] = jdunpack<[number]>(buf, "u32")
|
||||
* ```
|
||||
*/
|
||||
PushWatchdogPeriod = 0x81,
|
||||
}
|
||||
|
||||
export namespace CloudConfigurationRegPack {
|
||||
/**
|
||||
* Pack format for 'server_name' data.
|
||||
*/
|
||||
export const ServerName = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'cloud_device_id' data.
|
||||
*/
|
||||
export const CloudDeviceId = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'cloud_type' data.
|
||||
*/
|
||||
export const CloudType = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'connection_status' data.
|
||||
*/
|
||||
export const ConnectionStatus = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'push_period' data.
|
||||
*/
|
||||
export const PushPeriod = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'push_watchdog_period' data.
|
||||
*/
|
||||
export const PushWatchdogPeriod = "u32"
|
||||
}
|
||||
|
||||
export const enum CloudConfigurationCmd {
|
||||
/**
|
||||
* No args. Starts a connection to the cloud service
|
||||
*/
|
||||
Connect = 0x81,
|
||||
|
||||
/**
|
||||
* No args. Starts disconnecting from the cloud service
|
||||
*/
|
||||
Disconnect = 0x82,
|
||||
|
||||
/**
|
||||
* Argument: connection_string string (bytes). Restricted command to override the existing connection string to cloud.
|
||||
*
|
||||
* ```
|
||||
* const [connectionString] = jdunpack<[string]>(buf, "s")
|
||||
* ```
|
||||
*/
|
||||
SetConnectionString = 0x86,
|
||||
}
|
||||
|
||||
export namespace CloudConfigurationCmdPack {
|
||||
/**
|
||||
* Pack format for 'set_connection_string' data.
|
||||
*/
|
||||
export const SetConnectionString = "s"
|
||||
}
|
||||
|
||||
export const enum CloudConfigurationEvent {
|
||||
/**
|
||||
* Argument: connection_status ConnectionStatus (uint16_t). Raised when the connection status changes
|
||||
*
|
||||
* ```
|
||||
* const [connectionStatus] = jdunpack<[jacdac.CloudConfigurationConnectionStatus]>(buf, "u16")
|
||||
* ```
|
||||
*/
|
||||
//% block="connection status change"
|
||||
ConnectionStatusChange = 0x3,
|
||||
|
||||
/**
|
||||
* Raised when a message has been sent to the hub.
|
||||
*/
|
||||
//% block="message sent"
|
||||
MessageSent = 0x80,
|
||||
}
|
||||
|
||||
export namespace CloudConfigurationEventPack {
|
||||
/**
|
||||
* Pack format for 'connection_status_change' data.
|
||||
*/
|
||||
export const ConnectionStatusChange = "u16"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "jacdac-cloud-configuration",
|
||||
"version": "0.0.0",
|
||||
"description": "Connection and diagnostics information about the cloud connection.",
|
||||
"files": [
|
||||
"constants.ts",
|
||||
"client.g.ts"
|
||||
],
|
||||
"testFiles": [
|
||||
"test.ts"
|
||||
],
|
||||
"supportedTargets": [
|
||||
"microbit",
|
||||
"arcade",
|
||||
"maker"
|
||||
],
|
||||
"dependencies": {
|
||||
"core": "*",
|
||||
"jacdac": "github:microsoft/pxt-jacdac"
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ namespace jacdac {
|
|||
|
||||
export namespace CodalMessageBusCmdPack {
|
||||
/**
|
||||
* Pack format for 'send' register data.
|
||||
* Pack format for 'send' data.
|
||||
*/
|
||||
export const Send = "u16 u16"
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace jacdac {
|
|||
|
||||
export namespace CodalMessageBusEventPack {
|
||||
/**
|
||||
* Pack format for 'message' register data.
|
||||
* Pack format for 'message' data.
|
||||
*/
|
||||
export const Message = "u16 u16"
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace jacdac {
|
|||
|
||||
export namespace ColorRegPack {
|
||||
/**
|
||||
* Pack format for 'color' register data.
|
||||
* Pack format for 'color' data.
|
||||
*/
|
||||
export const Color = "u0.16 u0.16 u0.16"
|
||||
}
|
||||
|
|
|
@ -32,17 +32,17 @@ namespace jacdac {
|
|||
|
||||
export namespace CompassRegPack {
|
||||
/**
|
||||
* Pack format for 'heading' register data.
|
||||
* Pack format for 'heading' data.
|
||||
*/
|
||||
export const Heading = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'enabled' register data.
|
||||
* Pack format for 'enabled' data.
|
||||
*/
|
||||
export const Enabled = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'heading_error' register data.
|
||||
* Pack format for 'heading_error' data.
|
||||
*/
|
||||
export const HeadingError = "u16.16"
|
||||
}
|
||||
|
|
|
@ -134,36 +134,37 @@ namespace jacdac {
|
|||
|
||||
export namespace ControlCmdPack {
|
||||
/**
|
||||
* Pack format for 'services' register data.
|
||||
* Pack format for 'services' data.
|
||||
*/
|
||||
export const ServicesReport = "u16 u8 u8 r: u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'flood_ping' register data.
|
||||
* Pack format for 'flood_ping' data.
|
||||
*/
|
||||
export const FloodPing = "u32 u32 u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'flood_ping' register data.
|
||||
* Pack format for 'flood_ping' data.
|
||||
*/
|
||||
export const FloodPingReport = "u32 b"
|
||||
|
||||
/**
|
||||
* Pack format for 'set_status_light' register data.
|
||||
* Pack format for 'set_status_light' data.
|
||||
*/
|
||||
export const SetStatusLight = "u8 u8 u8 u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'reliable_commands' register data.
|
||||
* Pack format for 'reliable_commands' data.
|
||||
*/
|
||||
export const ReliableCommands = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'reliable_commands' register data.
|
||||
* Pack format for 'reliable_commands' data.
|
||||
*/
|
||||
export const ReliableCommandsReport = "b[12]"
|
||||
}
|
||||
|
||||
export const enum ControlPipe {}
|
||||
/**
|
||||
* pipe_command WrappedCommand
|
||||
* ```
|
||||
|
@ -171,9 +172,9 @@ namespace jacdac {
|
|||
* ```
|
||||
*/
|
||||
|
||||
export namespace ControlinfoPack {
|
||||
export namespace ControlPipePack {
|
||||
/**
|
||||
* Pack format for 'wrapped_command' register data.
|
||||
* Pack format for 'wrapped_command' data.
|
||||
*/
|
||||
export const WrappedCommand = "u8 u8 u16 b"
|
||||
}
|
||||
|
@ -247,37 +248,37 @@ namespace jacdac {
|
|||
|
||||
export namespace ControlRegPack {
|
||||
/**
|
||||
* Pack format for 'reset_in' register data.
|
||||
* Pack format for 'reset_in' data.
|
||||
*/
|
||||
export const ResetIn = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'device_description' register data.
|
||||
* Pack format for 'device_description' data.
|
||||
*/
|
||||
export const DeviceDescription = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'product_identifier' register data.
|
||||
* Pack format for 'product_identifier' data.
|
||||
*/
|
||||
export const ProductIdentifier = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'bootloader_product_identifier' register data.
|
||||
* Pack format for 'bootloader_product_identifier' data.
|
||||
*/
|
||||
export const BootloaderProductIdentifier = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'firmware_version' register data.
|
||||
* Pack format for 'firmware_version' data.
|
||||
*/
|
||||
export const FirmwareVersion = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'mcu_temperature' register data.
|
||||
* Pack format for 'mcu_temperature' data.
|
||||
*/
|
||||
export const McuTemperature = "i16"
|
||||
|
||||
/**
|
||||
* Pack format for 'uptime' register data.
|
||||
* Pack format for 'uptime' data.
|
||||
*/
|
||||
export const Uptime = "u64"
|
||||
}
|
||||
|
|
|
@ -50,27 +50,27 @@ namespace jacdac {
|
|||
|
||||
export namespace DcCurrentMeasurementRegPack {
|
||||
/**
|
||||
* Pack format for 'measurement_name' register data.
|
||||
* Pack format for 'measurement_name' data.
|
||||
*/
|
||||
export const MeasurementName = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'measurement' register data.
|
||||
* Pack format for 'measurement' data.
|
||||
*/
|
||||
export const Measurement = "f64"
|
||||
|
||||
/**
|
||||
* Pack format for 'measurement_error' register data.
|
||||
* Pack format for 'measurement_error' data.
|
||||
*/
|
||||
export const MeasurementError = "f64"
|
||||
|
||||
/**
|
||||
* Pack format for 'min_measurement' register data.
|
||||
* Pack format for 'min_measurement' data.
|
||||
*/
|
||||
export const MinMeasurement = "f64"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_measurement' register data.
|
||||
* Pack format for 'max_measurement' data.
|
||||
*/
|
||||
export const MaxMeasurement = "f64"
|
||||
}
|
||||
|
|
|
@ -67,32 +67,32 @@ namespace jacdac {
|
|||
|
||||
export namespace DcVoltageMeasurementRegPack {
|
||||
/**
|
||||
* Pack format for 'measurement_type' register data.
|
||||
* Pack format for 'measurement_type' data.
|
||||
*/
|
||||
export const MeasurementType = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'measurement_name' register data.
|
||||
* Pack format for 'measurement_name' data.
|
||||
*/
|
||||
export const MeasurementName = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'measurement' register data.
|
||||
* Pack format for 'measurement' data.
|
||||
*/
|
||||
export const Measurement = "f64"
|
||||
|
||||
/**
|
||||
* Pack format for 'measurement_error' register data.
|
||||
* Pack format for 'measurement_error' data.
|
||||
*/
|
||||
export const MeasurementError = "f64"
|
||||
|
||||
/**
|
||||
* Pack format for 'min_measurement' register data.
|
||||
* Pack format for 'min_measurement' data.
|
||||
*/
|
||||
export const MinMeasurement = "f64"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_measurement' register data.
|
||||
* Pack format for 'max_measurement' data.
|
||||
*/
|
||||
export const MaxMeasurement = "f64"
|
||||
}
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
namespace jacdac {
|
||||
// Service DeviceScript Manager constants
|
||||
export const SRV_DEVICE_SCRIPT_MANAGER = 0x1134ea2b
|
||||
|
||||
export const enum DeviceScriptManagerMessageFlags { // uint8_t
|
||||
//% block="to be continued"
|
||||
ToBeContinued = 0x1,
|
||||
}
|
||||
|
||||
export const enum DeviceScriptManagerCmd {
|
||||
/**
|
||||
* Argument: bytecode_size B uint32_t. Open pipe for streaming in the bytecode of the program. The size of the bytecode has to be declared upfront.
|
||||
|
@ -38,45 +32,26 @@ namespace jacdac {
|
|||
* ```
|
||||
*/
|
||||
ReadBytecode = 0x81,
|
||||
|
||||
/**
|
||||
* Generated by `console.log()` calls from DeviceScript program.
|
||||
* The counter starts at `0`, increments by `1` for each packet and wraps around.
|
||||
* It can be used to detect if some messages are missing.
|
||||
* If message is too long to fit in a single packet, it will be fragmented (this is not implemented yet).
|
||||
* In a fragmented message, all packets except for the last one have `ToBeContinued` flag set.
|
||||
* Note that `counter` field will increase in each fragment.
|
||||
* `log_message` reports are only sent when `logging == true`.
|
||||
*
|
||||
* ```
|
||||
* const [counter, flags, message] = jdunpack<[number, jacdac.DeviceScriptManagerMessageFlags, string]>(buf, "u8 u8 s")
|
||||
* ```
|
||||
*/
|
||||
LogMessage = 0x82,
|
||||
}
|
||||
|
||||
export namespace DeviceScriptManagerCmdPack {
|
||||
/**
|
||||
* Pack format for 'deploy_bytecode' register data.
|
||||
* Pack format for 'deploy_bytecode' data.
|
||||
*/
|
||||
export const DeployBytecode = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'deploy_bytecode' register data.
|
||||
* Pack format for 'deploy_bytecode' data.
|
||||
*/
|
||||
export const DeployBytecodeReport = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'read_bytecode' register data.
|
||||
* Pack format for 'read_bytecode' data.
|
||||
*/
|
||||
export const ReadBytecode = "b[12]"
|
||||
|
||||
/**
|
||||
* Pack format for 'log_message' register data.
|
||||
*/
|
||||
export const LogMessage = "u8 u8 s"
|
||||
}
|
||||
|
||||
export const enum DeviceScriptManagerPipe {}
|
||||
/**
|
||||
* pipe_report Bytecode
|
||||
* ```
|
||||
|
@ -84,9 +59,9 @@ namespace jacdac {
|
|||
* ```
|
||||
*/
|
||||
|
||||
export namespace DeviceScriptManagerinfoPack {
|
||||
export namespace DeviceScriptManagerPipePack {
|
||||
/**
|
||||
* Pack format for 'bytecode' register data.
|
||||
* Pack format for 'bytecode' data.
|
||||
*/
|
||||
export const Bytecode = "b"
|
||||
}
|
||||
|
@ -113,16 +88,6 @@ namespace jacdac {
|
|||
*/
|
||||
Autostart = 0x81,
|
||||
|
||||
/**
|
||||
* Read-write bool (uint8_t). `log_message` reports are only sent when this is `true`.
|
||||
* It defaults to `false`.
|
||||
*
|
||||
* ```
|
||||
* const [logging] = jdunpack<[number]>(buf, "u8")
|
||||
* ```
|
||||
*/
|
||||
Logging = 0x82,
|
||||
|
||||
/**
|
||||
* Read-only uint32_t. The size of current program.
|
||||
*
|
||||
|
@ -149,38 +114,77 @@ namespace jacdac {
|
|||
* ```
|
||||
*/
|
||||
ProgramSha256 = 0x182,
|
||||
|
||||
/**
|
||||
* Returns the runtime version number compatible with [Semver](https://semver.org/).
|
||||
* When read as 32-bit little endian integer a version `7.15.500` would be `0x07_0F_01F4`.
|
||||
*
|
||||
* ```
|
||||
* const [patch, minor, major] = jdunpack<[number, number, number]>(buf, "u16 u8 u8")
|
||||
* ```
|
||||
*/
|
||||
RuntimeVersion = 0x183,
|
||||
|
||||
/**
|
||||
* Read-only string (bytes). The name of currently running program. The compiler takes is from `package.json`.
|
||||
*
|
||||
* ```
|
||||
* const [programName] = jdunpack<[string]>(buf, "s")
|
||||
* ```
|
||||
*/
|
||||
ProgramName = 0x184,
|
||||
|
||||
/**
|
||||
* Read-only string (bytes). The version number of currently running program. The compiler takes is from `package.json`
|
||||
* and `git`.
|
||||
*
|
||||
* ```
|
||||
* const [programVersion] = jdunpack<[string]>(buf, "s")
|
||||
* ```
|
||||
*/
|
||||
ProgramVersion = 0x185,
|
||||
}
|
||||
|
||||
export namespace DeviceScriptManagerRegPack {
|
||||
/**
|
||||
* Pack format for 'running' register data.
|
||||
* Pack format for 'running' data.
|
||||
*/
|
||||
export const Running = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'autostart' register data.
|
||||
* Pack format for 'autostart' data.
|
||||
*/
|
||||
export const Autostart = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'logging' register data.
|
||||
*/
|
||||
export const Logging = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'program_size' register data.
|
||||
* Pack format for 'program_size' data.
|
||||
*/
|
||||
export const ProgramSize = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'program_hash' register data.
|
||||
* Pack format for 'program_hash' data.
|
||||
*/
|
||||
export const ProgramHash = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'program_sha256' register data.
|
||||
* Pack format for 'program_sha256' data.
|
||||
*/
|
||||
export const ProgramSha256 = "b[32]"
|
||||
|
||||
/**
|
||||
* Pack format for 'runtime_version' data.
|
||||
*/
|
||||
export const RuntimeVersion = "u16 u8 u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'program_name' data.
|
||||
*/
|
||||
export const ProgramName = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'program_version' data.
|
||||
*/
|
||||
export const ProgramVersion = "s"
|
||||
}
|
||||
|
||||
export const enum DeviceScriptManagerEvent {
|
||||
|
@ -205,7 +209,7 @@ namespace jacdac {
|
|||
|
||||
export namespace DeviceScriptManagerEventPack {
|
||||
/**
|
||||
* Pack format for 'program_panic' register data.
|
||||
* Pack format for 'program_panic' data.
|
||||
*/
|
||||
export const ProgramPanic = "u32 u32"
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "jacdac-device-script-manager",
|
||||
"version": "0.0.0",
|
||||
"description": "Allows for deployment and control over DeviceScript virtual machine.\n\nPrograms start automatically after device restart or uploading of new program.\nYou can stop programs until next reset by setting the `running` register to `0`.\n\nTODO - debug interface:\n* read-globals command/register\n* globals-changed pipe\n* breakpoint command\n* some performance monitoring?",
|
||||
"description": "Allows for deployment and control over DeviceScript virtual machine.\n\nPrograms start automatically after device restart or uploading of new program.\nYou can stop programs until next reset by setting the `running` register to `0`.",
|
||||
"files": [
|
||||
"constants.ts",
|
||||
"client.g.ts"
|
||||
|
|
|
@ -42,22 +42,22 @@ namespace jacdac {
|
|||
|
||||
export namespace AccelerometerRegPack {
|
||||
/**
|
||||
* Pack format for 'forces' register data.
|
||||
* Pack format for 'forces' data.
|
||||
*/
|
||||
export const Forces = "i12.20 i12.20 i12.20"
|
||||
|
||||
/**
|
||||
* Pack format for 'forces_error' register data.
|
||||
* Pack format for 'forces_error' data.
|
||||
*/
|
||||
export const ForcesError = "u12.20"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_force' register data.
|
||||
* Pack format for 'max_force' data.
|
||||
*/
|
||||
export const MaxForce = "u12.20"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_forces_supported' register data.
|
||||
* Pack format for 'max_forces_supported' data.
|
||||
*/
|
||||
export const MaxForcesSupported = "r: u12.20"
|
||||
}
|
||||
|
|
|
@ -41,22 +41,22 @@ namespace jacdac {
|
|||
|
||||
export namespace BitRadioRegPack {
|
||||
/**
|
||||
* Pack format for 'enabled' register data.
|
||||
* Pack format for 'enabled' data.
|
||||
*/
|
||||
export const Enabled = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'group' register data.
|
||||
* Pack format for 'group' data.
|
||||
*/
|
||||
export const Group = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'transmission_power' register data.
|
||||
* Pack format for 'transmission_power' data.
|
||||
*/
|
||||
export const TransmissionPower = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'frequency_band' register data.
|
||||
* Pack format for 'frequency_band' data.
|
||||
*/
|
||||
export const FrequencyBand = "u8"
|
||||
}
|
||||
|
@ -128,37 +128,37 @@ namespace jacdac {
|
|||
|
||||
export namespace BitRadioCmdPack {
|
||||
/**
|
||||
* Pack format for 'send_string' register data.
|
||||
* Pack format for 'send_string' data.
|
||||
*/
|
||||
export const SendString = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'send_number' register data.
|
||||
* Pack format for 'send_number' data.
|
||||
*/
|
||||
export const SendNumber = "f64"
|
||||
|
||||
/**
|
||||
* Pack format for 'send_value' register data.
|
||||
* Pack format for 'send_value' data.
|
||||
*/
|
||||
export const SendValue = "f64 s"
|
||||
|
||||
/**
|
||||
* Pack format for 'send_buffer' register data.
|
||||
* Pack format for 'send_buffer' data.
|
||||
*/
|
||||
export const SendBuffer = "b"
|
||||
|
||||
/**
|
||||
* Pack format for 'string_received' register data.
|
||||
* Pack format for 'string_received' data.
|
||||
*/
|
||||
export const StringReceived = "u32 u32 i8 b[1] s"
|
||||
|
||||
/**
|
||||
* Pack format for 'number_received' register data.
|
||||
* Pack format for 'number_received' data.
|
||||
*/
|
||||
export const NumberReceived = "u32 u32 i8 b[3] f64 s"
|
||||
|
||||
/**
|
||||
* Pack format for 'buffer_received' register data.
|
||||
* Pack format for 'buffer_received' data.
|
||||
*/
|
||||
export const BufferReceived = "u32 u32 i8 b[1] b"
|
||||
}
|
||||
|
|
|
@ -28,17 +28,17 @@ namespace jacdac {
|
|||
|
||||
export namespace ButtonRegPack {
|
||||
/**
|
||||
* Pack format for 'pressure' register data.
|
||||
* Pack format for 'pressure' data.
|
||||
*/
|
||||
export const Pressure = "u0.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'analog' register data.
|
||||
* Pack format for 'analog' data.
|
||||
*/
|
||||
export const Analog = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'pressed' register data.
|
||||
* Pack format for 'pressed' data.
|
||||
*/
|
||||
export const Pressed = "u8"
|
||||
}
|
||||
|
@ -76,12 +76,12 @@ namespace jacdac {
|
|||
|
||||
export namespace ButtonEventPack {
|
||||
/**
|
||||
* Pack format for 'up' register data.
|
||||
* Pack format for 'up' data.
|
||||
*/
|
||||
export const Up = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'hold' register data.
|
||||
* Pack format for 'hold' data.
|
||||
*/
|
||||
export const Hold = "u32"
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace jacdac {
|
|||
|
||||
export namespace BuzzerRegPack {
|
||||
/**
|
||||
* Pack format for 'volume' register data.
|
||||
* Pack format for 'volume' data.
|
||||
*/
|
||||
export const Volume = "u0.8"
|
||||
}
|
||||
|
@ -40,12 +40,12 @@ namespace jacdac {
|
|||
|
||||
export namespace BuzzerCmdPack {
|
||||
/**
|
||||
* Pack format for 'play_tone' register data.
|
||||
* Pack format for 'play_tone' data.
|
||||
*/
|
||||
export const PlayTone = "u16 u16 u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'play_note' register data.
|
||||
* Pack format for 'play_note' data.
|
||||
*/
|
||||
export const PlayNote = "u16 u0.16 u16"
|
||||
}
|
||||
|
|
|
@ -32,17 +32,17 @@ namespace jacdac {
|
|||
|
||||
export namespace CompassRegPack {
|
||||
/**
|
||||
* Pack format for 'heading' register data.
|
||||
* Pack format for 'heading' data.
|
||||
*/
|
||||
export const Heading = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'enabled' register data.
|
||||
* Pack format for 'enabled' data.
|
||||
*/
|
||||
export const Enabled = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'heading_error' register data.
|
||||
* Pack format for 'heading_error' data.
|
||||
*/
|
||||
export const HeadingError = "u16.16"
|
||||
}
|
||||
|
|
|
@ -59,27 +59,27 @@ namespace jacdac {
|
|||
|
||||
export namespace DotMatrixRegPack {
|
||||
/**
|
||||
* Pack format for 'dots' register data.
|
||||
* Pack format for 'dots' data.
|
||||
*/
|
||||
export const Dots = "b"
|
||||
|
||||
/**
|
||||
* Pack format for 'brightness' register data.
|
||||
* Pack format for 'brightness' data.
|
||||
*/
|
||||
export const Brightness = "u0.8"
|
||||
|
||||
/**
|
||||
* Pack format for 'rows' register data.
|
||||
* Pack format for 'rows' data.
|
||||
*/
|
||||
export const Rows = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'columns' register data.
|
||||
* Pack format for 'columns' data.
|
||||
*/
|
||||
export const Columns = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
}
|
||||
|
|
|
@ -40,17 +40,17 @@ namespace jacdac {
|
|||
|
||||
export namespace LightLevelRegPack {
|
||||
/**
|
||||
* Pack format for 'light_level' register data.
|
||||
* Pack format for 'light_level' data.
|
||||
*/
|
||||
export const LightLevel = "u0.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'light_level_error' register data.
|
||||
* Pack format for 'light_level_error' data.
|
||||
*/
|
||||
export const LightLevelError = "u0.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
}
|
||||
|
|
|
@ -41,22 +41,22 @@ namespace jacdac {
|
|||
|
||||
export namespace SoundLevelRegPack {
|
||||
/**
|
||||
* Pack format for 'sound_level' register data.
|
||||
* Pack format for 'sound_level' data.
|
||||
*/
|
||||
export const SoundLevel = "u0.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'enabled' register data.
|
||||
* Pack format for 'enabled' data.
|
||||
*/
|
||||
export const Enabled = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'loud_threshold' register data.
|
||||
* Pack format for 'loud_threshold' data.
|
||||
*/
|
||||
export const LoudThreshold = "u0.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'quiet_threshold' register data.
|
||||
* Pack format for 'quiet_threshold' data.
|
||||
*/
|
||||
export const QuietThreshold = "u0.16"
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace jacdac {
|
|||
|
||||
export namespace SoundPlayerRegPack {
|
||||
/**
|
||||
* Pack format for 'volume' register data.
|
||||
* Pack format for 'volume' data.
|
||||
*/
|
||||
export const Volume = "u0.16"
|
||||
}
|
||||
|
@ -46,16 +46,17 @@ namespace jacdac {
|
|||
|
||||
export namespace SoundPlayerCmdPack {
|
||||
/**
|
||||
* Pack format for 'play' register data.
|
||||
* Pack format for 'play' data.
|
||||
*/
|
||||
export const Play = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'list_sounds' register data.
|
||||
* Pack format for 'list_sounds' data.
|
||||
*/
|
||||
export const ListSounds = "b[12]"
|
||||
}
|
||||
|
||||
export const enum SoundPlayerPipe {}
|
||||
/**
|
||||
* pipe_report ListSoundsPipe
|
||||
* ```
|
||||
|
@ -63,9 +64,9 @@ namespace jacdac {
|
|||
* ```
|
||||
*/
|
||||
|
||||
export namespace SoundPlayerinfoPack {
|
||||
export namespace SoundPlayerPipePack {
|
||||
/**
|
||||
* Pack format for 'list_sounds_pipe' register data.
|
||||
* Pack format for 'list_sounds_pipe' data.
|
||||
*/
|
||||
export const ListSoundsPipe = "u32 s"
|
||||
}
|
||||
|
|
|
@ -60,27 +60,27 @@ namespace jacdac {
|
|||
|
||||
export namespace TemperatureRegPack {
|
||||
/**
|
||||
* Pack format for 'temperature' register data.
|
||||
* Pack format for 'temperature' data.
|
||||
*/
|
||||
export const Temperature = "i22.10"
|
||||
|
||||
/**
|
||||
* Pack format for 'min_temperature' register data.
|
||||
* Pack format for 'min_temperature' data.
|
||||
*/
|
||||
export const MinTemperature = "i22.10"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_temperature' register data.
|
||||
* Pack format for 'max_temperature' data.
|
||||
*/
|
||||
export const MaxTemperature = "i22.10"
|
||||
|
||||
/**
|
||||
* Pack format for 'temperature_error' register data.
|
||||
* Pack format for 'temperature_error' data.
|
||||
*/
|
||||
export const TemperatureError = "u22.10"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,444 @@
|
|||
namespace jacdac {
|
||||
// Service DeviceScript Debugger constants
|
||||
export const SRV_DEVS_DBG = 0x155b5b40
|
||||
|
||||
export const enum DevsDbgValueTag { // uint8_t
|
||||
//% block="number"
|
||||
Number = 0x1,
|
||||
//% block="special"
|
||||
Special = 0x2,
|
||||
//% block="fiber"
|
||||
Fiber = 0x3,
|
||||
//% block="builtin object"
|
||||
BuiltinObject = 0x5,
|
||||
//% block="exotic"
|
||||
Exotic = 0x6,
|
||||
//% block="unhandled"
|
||||
Unhandled = 0x7,
|
||||
//% block="img buffer"
|
||||
ImgBuffer = 0x20,
|
||||
//% block="img string builtin"
|
||||
ImgStringBuiltin = 0x21,
|
||||
//% block="img string ascii"
|
||||
ImgStringAscii = 0x22,
|
||||
//% block="img string utf8"
|
||||
ImgStringUTF8 = 0x23,
|
||||
//% block="img role"
|
||||
ImgRole = 0x30,
|
||||
//% block="img function"
|
||||
ImgFunction = 0x31,
|
||||
//% block="img role member"
|
||||
ImgRoleMember = 0x32,
|
||||
//% block="obj array"
|
||||
ObjArray = 0x51,
|
||||
//% block="obj map"
|
||||
ObjMap = 0x52,
|
||||
//% block="obj buffer"
|
||||
ObjBuffer = 0x53,
|
||||
//% block="obj string"
|
||||
ObjString = 0x54,
|
||||
//% block="obj stack frame"
|
||||
ObjStackFrame = 0x55,
|
||||
//% block="obj packet"
|
||||
ObjPacket = 0x56,
|
||||
//% block="obj bound function"
|
||||
ObjBoundFunction = 0x57,
|
||||
//% block="obj opaque"
|
||||
ObjOpaque = 0x58,
|
||||
//% block="obj any"
|
||||
ObjAny = 0x50,
|
||||
//% block="obj mask"
|
||||
ObjMask = 0xf0,
|
||||
//% block="user1"
|
||||
User1 = 0xf1,
|
||||
//% block="user2"
|
||||
User2 = 0xf2,
|
||||
//% block="user3"
|
||||
User3 = 0xf3,
|
||||
//% block="user4"
|
||||
User4 = 0xf4,
|
||||
}
|
||||
|
||||
export const enum DevsDbgValueSpecial { // uint8_t
|
||||
//% block="undefined"
|
||||
Undefined = 0x0,
|
||||
//% block="true"
|
||||
True = 0x1,
|
||||
//% block="false"
|
||||
False = 0x2,
|
||||
//% block="null"
|
||||
Null = 0x3,
|
||||
//% block="globals"
|
||||
Globals = 0x64,
|
||||
//% block="current exception"
|
||||
CurrentException = 0x65,
|
||||
}
|
||||
|
||||
export const enum DevsDbgFunIdx { // uint16_t
|
||||
//% block="none"
|
||||
None = 0x0,
|
||||
//% block="main"
|
||||
Main = 0xc34f,
|
||||
//% block="first built in"
|
||||
FirstBuiltIn = 0xc350,
|
||||
}
|
||||
|
||||
export const enum DevsDbgFiberHandle { // uint32_t
|
||||
//% block="none"
|
||||
None = 0x0,
|
||||
}
|
||||
|
||||
export const enum DevsDbgProgramCounter {} // uint32_t
|
||||
|
||||
export const enum DevsDbgObjStackFrame { // uint32_t
|
||||
//% block="null"
|
||||
Null = 0x0,
|
||||
}
|
||||
|
||||
export const enum DevsDbgString { // uint32_t
|
||||
//% block="static indicator mask"
|
||||
StaticIndicatorMask = 0x80000001,
|
||||
//% block="static tag mask"
|
||||
StaticTagMask = 0x7f000000,
|
||||
//% block="static index mask"
|
||||
StaticIndexMask = 0xfffffe,
|
||||
//% block="unhandled"
|
||||
Unhandled = 0x0,
|
||||
}
|
||||
|
||||
export const enum DevsDbgStepFlags { // uint16_t
|
||||
//% block="step out"
|
||||
StepOut = 0x1,
|
||||
//% block="step in"
|
||||
StepIn = 0x2,
|
||||
//% block="throw"
|
||||
Throw = 0x4,
|
||||
}
|
||||
|
||||
export const enum DevsDbgSuspensionType { // uint8_t
|
||||
//% block="none"
|
||||
None = 0x0,
|
||||
//% block="breakpoint"
|
||||
Breakpoint = 0x1,
|
||||
//% block="unhandled exception"
|
||||
UnhandledException = 0x2,
|
||||
//% block="handled exception"
|
||||
HandledException = 0x3,
|
||||
//% block="halt"
|
||||
Halt = 0x4,
|
||||
//% block="panic"
|
||||
Panic = 0x5,
|
||||
//% block="restart"
|
||||
Restart = 0x6,
|
||||
//% block="debugger stmt"
|
||||
DebuggerStmt = 0x7,
|
||||
//% block="step"
|
||||
Step = 0x8,
|
||||
}
|
||||
|
||||
export const enum DevsDbgCmd {
|
||||
/**
|
||||
* Argument: results pipe (bytes). List the currently running fibers (threads).
|
||||
*
|
||||
* ```
|
||||
* const [results] = jdunpack<[Buffer]>(buf, "b[12]")
|
||||
* ```
|
||||
*/
|
||||
ReadFibers = 0x80,
|
||||
|
||||
/**
|
||||
* List stack frames in a fiber.
|
||||
*
|
||||
* ```
|
||||
* const [results, fiberHandle] = jdunpack<[Buffer, jacdac.DevsDbgFiberHandle]>(buf, "b[12] u32")
|
||||
* ```
|
||||
*/
|
||||
ReadStack = 0x81,
|
||||
|
||||
/**
|
||||
* Read variable slots in a stack frame, elements of an array, etc.
|
||||
*
|
||||
* ```
|
||||
* const [results, v0, tag, start, length] = jdunpack<[Buffer, number, jacdac.DevsDbgValueTag, number, number]>(buf, "b[12] u32 u8 x[1] u16 u16")
|
||||
* ```
|
||||
*/
|
||||
ReadIndexedValues = 0x82,
|
||||
|
||||
/**
|
||||
* Read variable slots in an object.
|
||||
*
|
||||
* ```
|
||||
* const [results, v0, tag] = jdunpack<[Buffer, number, jacdac.DevsDbgValueTag]>(buf, "b[12] u32 u8")
|
||||
* ```
|
||||
*/
|
||||
ReadNamedValues = 0x83,
|
||||
|
||||
/**
|
||||
* Read a specific value.
|
||||
*
|
||||
* ```
|
||||
* const [v0, tag] = jdunpack<[number, jacdac.DevsDbgValueTag]>(buf, "u32 u8")
|
||||
* ```
|
||||
*/
|
||||
ReadValue = 0x84,
|
||||
|
||||
/**
|
||||
* report ReadValue
|
||||
* ```
|
||||
* const [v0, v1, fnIdx, tag] = jdunpack<[number, number, jacdac.DevsDbgFunIdx, jacdac.DevsDbgValueTag]>(buf, "u32 u32 u16 u8")
|
||||
* ```
|
||||
*/
|
||||
|
||||
/**
|
||||
* Read bytes of a string (UTF8) or buffer value.
|
||||
*
|
||||
* ```
|
||||
* const [results, v0, tag, start, length] = jdunpack<[Buffer, number, jacdac.DevsDbgValueTag, number, number]>(buf, "b[12] u32 u8 x[1] u16 u16")
|
||||
* ```
|
||||
*/
|
||||
ReadBytes = 0x85,
|
||||
|
||||
/**
|
||||
* Set breakpoint(s) at a location(s).
|
||||
*
|
||||
* ```
|
||||
* const [breakPc] = jdunpack<[jacdac.DevsDbgProgramCounter[]]>(buf, "u32[]")
|
||||
* ```
|
||||
*/
|
||||
SetBreakpoints = 0x90,
|
||||
|
||||
/**
|
||||
* Clear breakpoint(s) at a location(s).
|
||||
*
|
||||
* ```
|
||||
* const [breakPc] = jdunpack<[jacdac.DevsDbgProgramCounter[]]>(buf, "u32[]")
|
||||
* ```
|
||||
*/
|
||||
ClearBreakpoints = 0x91,
|
||||
|
||||
/**
|
||||
* No args. Clear all breakpoints.
|
||||
*/
|
||||
ClearAllBreakpoints = 0x92,
|
||||
|
||||
/**
|
||||
* No args. Resume program execution after a breakpoint was hit.
|
||||
*/
|
||||
Resume = 0x93,
|
||||
|
||||
/**
|
||||
* No args. Try suspending current program. Client needs to wait for `suspended` event afterwards.
|
||||
*/
|
||||
Halt = 0x94,
|
||||
|
||||
/**
|
||||
* No args. Run the program from the beginning and halt on first instruction.
|
||||
*/
|
||||
RestartAndHalt = 0x95,
|
||||
|
||||
/**
|
||||
* Set breakpoints that only trigger in the specified stackframe and resume program.
|
||||
* The breakpoints are cleared automatically on next suspension (regardless of the reason).
|
||||
*
|
||||
* ```
|
||||
* const [stackframe, flags, breakPc] = jdunpack<[jacdac.DevsDbgObjStackFrame, jacdac.DevsDbgStepFlags, jacdac.DevsDbgProgramCounter[]]>(buf, "u32 u16 x[2] u32[]")
|
||||
* ```
|
||||
*/
|
||||
Step = 0x96,
|
||||
}
|
||||
|
||||
export namespace DevsDbgCmdPack {
|
||||
/**
|
||||
* Pack format for 'read_fibers' data.
|
||||
*/
|
||||
export const ReadFibers = "b[12]"
|
||||
|
||||
/**
|
||||
* Pack format for 'read_stack' data.
|
||||
*/
|
||||
export const ReadStack = "b[12] u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'read_indexed_values' data.
|
||||
*/
|
||||
export const ReadIndexedValues = "b[12] u32 u8 u8 u16 u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'read_named_values' data.
|
||||
*/
|
||||
export const ReadNamedValues = "b[12] u32 u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'read_value' data.
|
||||
*/
|
||||
export const ReadValue = "u32 u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'read_value' data.
|
||||
*/
|
||||
export const ReadValueReport = "u32 u32 u16 u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'read_bytes' data.
|
||||
*/
|
||||
export const ReadBytes = "b[12] u32 u8 u8 u16 u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'set_breakpoints' data.
|
||||
*/
|
||||
export const SetBreakpoints = "r: u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'clear_breakpoints' data.
|
||||
*/
|
||||
export const ClearBreakpoints = "r: u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'step' data.
|
||||
*/
|
||||
export const Step = "u32 u16 u16 r: u32"
|
||||
}
|
||||
|
||||
export const enum DevsDbgPipe {}
|
||||
/**
|
||||
* pipe_report Fiber
|
||||
* ```
|
||||
* const [handle, initialFn, currFn] = jdunpack<[jacdac.DevsDbgFiberHandle, jacdac.DevsDbgFunIdx, jacdac.DevsDbgFunIdx]>(buf, "u32 u16 u16")
|
||||
* ```
|
||||
*/
|
||||
|
||||
/**
|
||||
* pipe_report Stackframe
|
||||
* ```
|
||||
* const [self, pc, closure, fnIdx] = jdunpack<[jacdac.DevsDbgObjStackFrame, jacdac.DevsDbgProgramCounter, jacdac.DevsDbgObjStackFrame, jacdac.DevsDbgFunIdx]>(buf, "u32 u32 u32 u16 x[2]")
|
||||
* ```
|
||||
*/
|
||||
|
||||
/**
|
||||
* pipe_report Value
|
||||
* ```
|
||||
* const [v0, v1, fnIdx, tag] = jdunpack<[number, number, jacdac.DevsDbgFunIdx, jacdac.DevsDbgValueTag]>(buf, "u32 u32 u16 u8")
|
||||
* ```
|
||||
*/
|
||||
|
||||
/**
|
||||
* pipe_report KeyValue
|
||||
* ```
|
||||
* const [key, v0, v1, fnIdx, tag] = jdunpack<[jacdac.DevsDbgString, number, number, jacdac.DevsDbgFunIdx, jacdac.DevsDbgValueTag]>(buf, "u32 u32 u32 u16 u8")
|
||||
* ```
|
||||
*/
|
||||
|
||||
/**
|
||||
* pipe_report BytesValue
|
||||
* ```
|
||||
* const [data] = jdunpack<[Buffer]>(buf, "b")
|
||||
* ```
|
||||
*/
|
||||
|
||||
export namespace DevsDbgPipePack {
|
||||
/**
|
||||
* Pack format for 'fiber' data.
|
||||
*/
|
||||
export const Fiber = "u32 u16 u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'stackframe' data.
|
||||
*/
|
||||
export const Stackframe = "u32 u32 u32 u16 u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'value' data.
|
||||
*/
|
||||
export const Value = "u32 u32 u16 u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'key_value' data.
|
||||
*/
|
||||
export const KeyValue = "u32 u32 u32 u16 u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'bytes_value' data.
|
||||
*/
|
||||
export const BytesValue = "b"
|
||||
}
|
||||
|
||||
export const enum DevsDbgReg {
|
||||
/**
|
||||
* Read-write bool (uint8_t). Turn on/off the debugger interface.
|
||||
*
|
||||
* ```
|
||||
* const [enabled] = jdunpack<[number]>(buf, "u8")
|
||||
* ```
|
||||
*/
|
||||
Enabled = 0x1,
|
||||
|
||||
/**
|
||||
* Read-write bool (uint8_t). Wheather to place breakpoint at unhandled exception.
|
||||
*
|
||||
* ```
|
||||
* const [breakAtUnhandledExn] = jdunpack<[number]>(buf, "u8")
|
||||
* ```
|
||||
*/
|
||||
BreakAtUnhandledExn = 0x80,
|
||||
|
||||
/**
|
||||
* Read-write bool (uint8_t). Wheather to place breakpoint at handled exception.
|
||||
*
|
||||
* ```
|
||||
* const [breakAtHandledExn] = jdunpack<[number]>(buf, "u8")
|
||||
* ```
|
||||
*/
|
||||
BreakAtHandledExn = 0x81,
|
||||
|
||||
/**
|
||||
* Read-only bool (uint8_t). Indicates if the program is currently suspended.
|
||||
* Most commands can only be executed when the program is suspended.
|
||||
*
|
||||
* ```
|
||||
* const [isSuspended] = jdunpack<[number]>(buf, "u8")
|
||||
* ```
|
||||
*/
|
||||
IsSuspended = 0x180,
|
||||
}
|
||||
|
||||
export namespace DevsDbgRegPack {
|
||||
/**
|
||||
* Pack format for 'enabled' data.
|
||||
*/
|
||||
export const Enabled = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'break_at_unhandled_exn' data.
|
||||
*/
|
||||
export const BreakAtUnhandledExn = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'break_at_handled_exn' data.
|
||||
*/
|
||||
export const BreakAtHandledExn = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'is_suspended' data.
|
||||
*/
|
||||
export const IsSuspended = "u8"
|
||||
}
|
||||
|
||||
export const enum DevsDbgEvent {
|
||||
/**
|
||||
* Emitted when the program hits a breakpoint or similar event in the specified fiber.
|
||||
*
|
||||
* ```
|
||||
* const [fiber, type] = jdunpack<[jacdac.DevsDbgFiberHandle, jacdac.DevsDbgSuspensionType]>(buf, "u32 u8")
|
||||
* ```
|
||||
*/
|
||||
//% block="suspended"
|
||||
Suspended = 0x80,
|
||||
}
|
||||
|
||||
export namespace DevsDbgEventPack {
|
||||
/**
|
||||
* Pack format for 'suspended' data.
|
||||
*/
|
||||
export const Suspended = "u32 u8"
|
||||
}
|
||||
}
|
|
@ -62,27 +62,27 @@ namespace jacdac {
|
|||
|
||||
export namespace DistanceRegPack {
|
||||
/**
|
||||
* Pack format for 'distance' register data.
|
||||
* Pack format for 'distance' data.
|
||||
*/
|
||||
export const Distance = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'distance_error' register data.
|
||||
* Pack format for 'distance_error' data.
|
||||
*/
|
||||
export const DistanceError = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'min_range' register data.
|
||||
* Pack format for 'min_range' data.
|
||||
*/
|
||||
export const MinRange = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_range' register data.
|
||||
* Pack format for 'max_range' data.
|
||||
*/
|
||||
export const MaxRange = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace jacdac {
|
|||
|
||||
export namespace DmxRegPack {
|
||||
/**
|
||||
* Pack format for 'enabled' register data.
|
||||
* Pack format for 'enabled' data.
|
||||
*/
|
||||
export const Enabled = "u8"
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ namespace jacdac {
|
|||
|
||||
export namespace DmxCmdPack {
|
||||
/**
|
||||
* Pack format for 'send' register data.
|
||||
* Pack format for 'send' data.
|
||||
*/
|
||||
export const Send = "b"
|
||||
}
|
||||
|
|
|
@ -59,27 +59,27 @@ namespace jacdac {
|
|||
|
||||
export namespace DotMatrixRegPack {
|
||||
/**
|
||||
* Pack format for 'dots' register data.
|
||||
* Pack format for 'dots' data.
|
||||
*/
|
||||
export const Dots = "b"
|
||||
|
||||
/**
|
||||
* Pack format for 'brightness' register data.
|
||||
* Pack format for 'brightness' data.
|
||||
*/
|
||||
export const Brightness = "u0.8"
|
||||
|
||||
/**
|
||||
* Pack format for 'rows' register data.
|
||||
* Pack format for 'rows' data.
|
||||
*/
|
||||
export const Rows = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'columns' register data.
|
||||
* Pack format for 'columns' data.
|
||||
*/
|
||||
export const Columns = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
}
|
||||
|
|
|
@ -51,27 +51,27 @@ namespace jacdac {
|
|||
|
||||
export namespace DualMotorsRegPack {
|
||||
/**
|
||||
* Pack format for 'speed' register data.
|
||||
* Pack format for 'speed' data.
|
||||
*/
|
||||
export const Speed = "i1.15 i1.15"
|
||||
|
||||
/**
|
||||
* Pack format for 'enabled' register data.
|
||||
* Pack format for 'enabled' data.
|
||||
*/
|
||||
export const Enabled = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'load_torque' register data.
|
||||
* Pack format for 'load_torque' data.
|
||||
*/
|
||||
export const LoadTorque = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'load_rotation_speed' register data.
|
||||
* Pack format for 'load_rotation_speed' data.
|
||||
*/
|
||||
export const LoadRotationSpeed = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'reversible' register data.
|
||||
* Pack format for 'reversible' data.
|
||||
*/
|
||||
export const Reversible = "u8"
|
||||
}
|
||||
|
|
|
@ -58,27 +58,27 @@ namespace jacdac {
|
|||
|
||||
export namespace ECO2RegPack {
|
||||
/**
|
||||
* Pack format for 'e_CO2' register data.
|
||||
* Pack format for 'e_CO2' data.
|
||||
*/
|
||||
export const ECO2 = "u22.10"
|
||||
|
||||
/**
|
||||
* Pack format for 'e_CO2_error' register data.
|
||||
* Pack format for 'e_CO2_error' data.
|
||||
*/
|
||||
export const ECO2Error = "u22.10"
|
||||
|
||||
/**
|
||||
* Pack format for 'min_e_CO2' register data.
|
||||
* Pack format for 'min_e_CO2' data.
|
||||
*/
|
||||
export const MinECO2 = "u22.10"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_e_CO2' register data.
|
||||
* Pack format for 'max_e_CO2' data.
|
||||
*/
|
||||
export const MaxECO2 = "u22.10"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
}
|
||||
|
|
|
@ -23,12 +23,12 @@ namespace jacdac {
|
|||
|
||||
export namespace FlexRegPack {
|
||||
/**
|
||||
* Pack format for 'bending' register data.
|
||||
* Pack format for 'bending' data.
|
||||
*/
|
||||
export const Bending = "i1.15"
|
||||
|
||||
/**
|
||||
* Pack format for 'length' register data.
|
||||
* Pack format for 'length' data.
|
||||
*/
|
||||
export const Length = "u16"
|
||||
}
|
||||
|
|
|
@ -76,17 +76,17 @@ namespace jacdac {
|
|||
|
||||
export namespace GamepadRegPack {
|
||||
/**
|
||||
* Pack format for 'direction' register data.
|
||||
* Pack format for 'direction' data.
|
||||
*/
|
||||
export const Direction = "u32 i1.15 i1.15"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'buttons_available' register data.
|
||||
* Pack format for 'buttons_available' data.
|
||||
*/
|
||||
export const ButtonsAvailable = "u32"
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ namespace jacdac {
|
|||
|
||||
export namespace GamepadEventPack {
|
||||
/**
|
||||
* Pack format for 'buttons_changed' register data.
|
||||
* Pack format for 'buttons_changed' data.
|
||||
*/
|
||||
export const ButtonsChanged = "u32"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,179 @@
|
|||
namespace jacdac {
|
||||
// Service GPIO constants
|
||||
export const SRV_GPIO = 0x10d85a69
|
||||
|
||||
export const enum GPIOMode { // uint8_t
|
||||
//% block="off"
|
||||
Off = 0x0,
|
||||
//% block="off pull up"
|
||||
OffPullUp = 0x10,
|
||||
//% block="off pull down"
|
||||
OffPullDown = 0x20,
|
||||
//% block="input"
|
||||
Input = 0x1,
|
||||
//% block="input pull up"
|
||||
InputPullUp = 0x11,
|
||||
//% block="input pull down"
|
||||
InputPullDown = 0x21,
|
||||
//% block="output"
|
||||
Output = 0x2,
|
||||
//% block="output high"
|
||||
OutputHigh = 0x12,
|
||||
//% block="output low"
|
||||
OutputLow = 0x22,
|
||||
//% block="analog in"
|
||||
AnalogIn = 0x3,
|
||||
//% block="alternative"
|
||||
Alternative = 0x4,
|
||||
//% block="base mode mask"
|
||||
BaseModeMask = 0xf,
|
||||
}
|
||||
|
||||
export const enum GPIOCapabilities { // uint16_t
|
||||
//% block="pull up"
|
||||
PullUp = 0x1,
|
||||
//% block="pull down"
|
||||
PullDown = 0x2,
|
||||
//% block="input"
|
||||
Input = 0x4,
|
||||
//% block="output"
|
||||
Output = 0x8,
|
||||
//% block="analog"
|
||||
Analog = 0x10,
|
||||
}
|
||||
|
||||
export const enum GPIOReg {
|
||||
/**
|
||||
* Read-only digital_values bytes. For every pin set to `Input*` the corresponding **bit** in `digital_values` will be `1` if and only if
|
||||
* the pin is high.
|
||||
* For other pins, the bit is `0`.
|
||||
* This is normally streamed at low-ish speed, but it's also automatically reported whenever
|
||||
* a digital input pin changes value (throttled to ~100Hz).
|
||||
* The analog values can be read with the `ADC` service.
|
||||
*
|
||||
* ```
|
||||
* const [digitalValues] = jdunpack<[Buffer]>(buf, "b")
|
||||
* ```
|
||||
*/
|
||||
State = 0x101,
|
||||
|
||||
/**
|
||||
* Read-only # uint8_t. Number of pins that can be operated through this service.
|
||||
*
|
||||
* ```
|
||||
* const [numPins] = jdunpack<[number]>(buf, "u8")
|
||||
* ```
|
||||
*/
|
||||
NumPins = 0x180,
|
||||
}
|
||||
|
||||
export namespace GPIORegPack {
|
||||
/**
|
||||
* Pack format for 'state' data.
|
||||
*/
|
||||
export const State = "b"
|
||||
|
||||
/**
|
||||
* Pack format for 'num_pins' data.
|
||||
*/
|
||||
export const NumPins = "u8"
|
||||
}
|
||||
|
||||
export const enum GPIOCmd {
|
||||
/**
|
||||
* Configure (including setting the value) zero or more pins.
|
||||
* `Alternative` settings means the pin is controlled by other service (SPI, I2C, UART, PWM, etc.).
|
||||
*
|
||||
* ```
|
||||
* const [rest] = jdunpack<[([number, jacdac.GPIOMode])[]]>(buf, "r: u8 u8")
|
||||
* const [pin, mode] = rest[0]
|
||||
* ```
|
||||
*/
|
||||
Configure = 0x80,
|
||||
|
||||
/**
|
||||
* Argument: pin uint8_t. Report capabilities and name of a pin.
|
||||
*
|
||||
* ```
|
||||
* const [pin] = jdunpack<[number]>(buf, "u8")
|
||||
* ```
|
||||
*/
|
||||
PinInfo = 0x81,
|
||||
|
||||
/**
|
||||
* report PinInfo
|
||||
* ```
|
||||
* const [pin, hwPin, capabilities, mode, label] = jdunpack<[number, number, jacdac.GPIOCapabilities, jacdac.GPIOMode, string]>(buf, "u8 u8 u16 u8 s")
|
||||
* ```
|
||||
*/
|
||||
|
||||
/**
|
||||
* Argument: label string (bytes). This responds with `pin_info` report.
|
||||
*
|
||||
* ```
|
||||
* const [label] = jdunpack<[string]>(buf, "s")
|
||||
* ```
|
||||
*/
|
||||
PinByLabel = 0x83,
|
||||
|
||||
/**
|
||||
* report PinByLabel
|
||||
* ```
|
||||
* const [pin, hwPin, capabilities, mode, label] = jdunpack<[number, number, jacdac.GPIOCapabilities, jacdac.GPIOMode, string]>(buf, "u8 u8 u16 u8 s")
|
||||
* ```
|
||||
*/
|
||||
|
||||
/**
|
||||
* Argument: hw_pin uint8_t. This responds with `pin_info` report.
|
||||
*
|
||||
* ```
|
||||
* const [hwPin] = jdunpack<[number]>(buf, "u8")
|
||||
* ```
|
||||
*/
|
||||
PinByHwPin = 0x84,
|
||||
|
||||
/**
|
||||
* report PinByHwPin
|
||||
* ```
|
||||
* const [pin, hwPin, capabilities, mode, label] = jdunpack<[number, number, jacdac.GPIOCapabilities, jacdac.GPIOMode, string]>(buf, "u8 u8 u16 u8 s")
|
||||
* ```
|
||||
*/
|
||||
}
|
||||
|
||||
export namespace GPIOCmdPack {
|
||||
/**
|
||||
* Pack format for 'configure' data.
|
||||
*/
|
||||
export const Configure = "r: u8 u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'pin_info' data.
|
||||
*/
|
||||
export const PinInfo = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'pin_info' data.
|
||||
*/
|
||||
export const PinInfoReport = "u8 u8 u16 u8 s"
|
||||
|
||||
/**
|
||||
* Pack format for 'pin_by_label' data.
|
||||
*/
|
||||
export const PinByLabel = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'pin_by_label' data.
|
||||
*/
|
||||
export const PinByLabelReport = "u8 u8 u16 u8 s"
|
||||
|
||||
/**
|
||||
* Pack format for 'pin_by_hw_pin' data.
|
||||
*/
|
||||
export const PinByHwPin = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'pin_by_hw_pin' data.
|
||||
*/
|
||||
export const PinByHwPinReport = "u8 u8 u16 u8 s"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "jacdac-gpio",
|
||||
"version": "0.0.0",
|
||||
"description": "Access to General Purpose Input/Output (GPIO) pins on a board.\nThe pins are indexed `0 ... num_pins-1`.\nThe indexing does not correspond to hardware pin names, nor labels on the board (see `get_pin_info` command for that),\nand should **not** be exposed to the user.",
|
||||
"files": [
|
||||
"constants.ts",
|
||||
"client.g.ts"
|
||||
],
|
||||
"testFiles": [
|
||||
"test.ts"
|
||||
],
|
||||
"supportedTargets": [
|
||||
"microbit",
|
||||
"arcade",
|
||||
"maker"
|
||||
],
|
||||
"dependencies": {
|
||||
"core": "*",
|
||||
"jacdac": "github:microsoft/pxt-jacdac"
|
||||
}
|
||||
}
|
|
@ -42,22 +42,22 @@ namespace jacdac {
|
|||
|
||||
export namespace GyroscopeRegPack {
|
||||
/**
|
||||
* Pack format for 'rotation_rates' register data.
|
||||
* Pack format for 'rotation_rates' data.
|
||||
*/
|
||||
export const RotationRates = "i12.20 i12.20 i12.20"
|
||||
|
||||
/**
|
||||
* Pack format for 'rotation_rates_error' register data.
|
||||
* Pack format for 'rotation_rates_error' data.
|
||||
*/
|
||||
export const RotationRatesError = "u12.20"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_rate' register data.
|
||||
* Pack format for 'max_rate' data.
|
||||
*/
|
||||
export const MaxRate = "u12.20"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_rates_supported' register data.
|
||||
* Pack format for 'max_rates_supported' data.
|
||||
*/
|
||||
export const MaxRatesSupported = "r: u12.20"
|
||||
}
|
||||
|
|
|
@ -46,17 +46,17 @@ namespace jacdac {
|
|||
|
||||
export namespace HeartRateRegPack {
|
||||
/**
|
||||
* Pack format for 'heart_rate' register data.
|
||||
* Pack format for 'heart_rate' data.
|
||||
*/
|
||||
export const HeartRate = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'heart_rate_error' register data.
|
||||
* Pack format for 'heart_rate_error' data.
|
||||
*/
|
||||
export const HeartRateError = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
}
|
||||
|
|
|
@ -32,17 +32,17 @@ namespace jacdac {
|
|||
|
||||
export namespace HidJoystickRegPack {
|
||||
/**
|
||||
* Pack format for 'button_count' register data.
|
||||
* Pack format for 'button_count' data.
|
||||
*/
|
||||
export const ButtonCount = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'buttons_analog' register data.
|
||||
* Pack format for 'buttons_analog' data.
|
||||
*/
|
||||
export const ButtonsAnalog = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'axis_count' register data.
|
||||
* Pack format for 'axis_count' data.
|
||||
*/
|
||||
export const AxisCount = "u8"
|
||||
}
|
||||
|
@ -69,12 +69,12 @@ namespace jacdac {
|
|||
|
||||
export namespace HidJoystickCmdPack {
|
||||
/**
|
||||
* Pack format for 'set_buttons' register data.
|
||||
* Pack format for 'set_buttons' data.
|
||||
*/
|
||||
export const SetButtons = "r: u0.8"
|
||||
|
||||
/**
|
||||
* Pack format for 'set_axis' register data.
|
||||
* Pack format for 'set_axis' data.
|
||||
*/
|
||||
export const SetAxis = "r: i1.15"
|
||||
}
|
||||
|
|
|
@ -314,7 +314,7 @@ namespace jacdac {
|
|||
|
||||
export namespace HidKeyboardCmdPack {
|
||||
/**
|
||||
* Pack format for 'key' register data.
|
||||
* Pack format for 'key' data.
|
||||
*/
|
||||
export const Key = "r: u16 u8 u8"
|
||||
}
|
||||
|
|
|
@ -57,17 +57,17 @@ namespace jacdac {
|
|||
|
||||
export namespace HidMouseCmdPack {
|
||||
/**
|
||||
* Pack format for 'set_button' register data.
|
||||
* Pack format for 'set_button' data.
|
||||
*/
|
||||
export const SetButton = "u16 u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'move' register data.
|
||||
* Pack format for 'move' data.
|
||||
*/
|
||||
export const Move = "i16 i16 u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'wheel' register data.
|
||||
* Pack format for 'wheel' data.
|
||||
*/
|
||||
export const Wheel = "i16 u16"
|
||||
}
|
||||
|
|
|
@ -84,6 +84,7 @@ namespace modules {
|
|||
//% block="on %humidity humidity changed by %threshold (%RH)"
|
||||
//% weight=96
|
||||
//% threshold.min=0
|
||||
//% threshold.max=100
|
||||
//% threshold.defl=1
|
||||
onHumidityChangedBy(threshold: number, handler: () => void): void {
|
||||
this.onReadingChangedBy(threshold, handler)
|
||||
|
|
|
@ -41,22 +41,22 @@ namespace jacdac {
|
|||
|
||||
export namespace HumidityRegPack {
|
||||
/**
|
||||
* Pack format for 'humidity' register data.
|
||||
* Pack format for 'humidity' data.
|
||||
*/
|
||||
export const Humidity = "u22.10"
|
||||
|
||||
/**
|
||||
* Pack format for 'humidity_error' register data.
|
||||
* Pack format for 'humidity_error' data.
|
||||
*/
|
||||
export const HumidityError = "u22.10"
|
||||
|
||||
/**
|
||||
* Pack format for 'min_humidity' register data.
|
||||
* Pack format for 'min_humidity' data.
|
||||
*/
|
||||
export const MinHumidity = "u22.10"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_humidity' register data.
|
||||
* Pack format for 'max_humidity' data.
|
||||
*/
|
||||
export const MaxHumidity = "u22.10"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
namespace jacdac {
|
||||
// Service I2C constants
|
||||
export const SRV_I2C = 0x1c18ca43
|
||||
|
||||
export const enum I2CStatus { // uint8_t
|
||||
//% block="ok"
|
||||
OK = 0x0,
|
||||
//% block="nack addr"
|
||||
NAckAddr = 0x1,
|
||||
//% block="nack data"
|
||||
NAckData = 0x2,
|
||||
//% block="no i2c"
|
||||
NoI2C = 0x3,
|
||||
}
|
||||
|
||||
export const enum I2CReg {
|
||||
/**
|
||||
* Read-only bool (uint8_t). Indicates whether the I2C is working.
|
||||
*
|
||||
* ```
|
||||
* const [ok] = jdunpack<[number]>(buf, "u8")
|
||||
* ```
|
||||
*/
|
||||
Ok = 0x180,
|
||||
}
|
||||
|
||||
export namespace I2CRegPack {
|
||||
/**
|
||||
* Pack format for 'ok' data.
|
||||
*/
|
||||
export const Ok = "u8"
|
||||
}
|
||||
|
||||
export const enum I2CCmd {
|
||||
/**
|
||||
* `address` is 7-bit.
|
||||
* `num_read` can be 0 if nothing needs to be read.
|
||||
* The `write_buf` includes the register address if required (first one or two bytes).
|
||||
*
|
||||
* ```
|
||||
* const [address, numRead, writeBuf] = jdunpack<[number, number, Buffer]>(buf, "u8 u8 b")
|
||||
* ```
|
||||
*/
|
||||
Transaction = 0x80,
|
||||
|
||||
/**
|
||||
* report Transaction
|
||||
* ```
|
||||
* const [status, readBuf] = jdunpack<[jacdac.I2CStatus, Buffer]>(buf, "u8 b")
|
||||
* ```
|
||||
*/
|
||||
}
|
||||
|
||||
export namespace I2CCmdPack {
|
||||
/**
|
||||
* Pack format for 'transaction' data.
|
||||
*/
|
||||
export const Transaction = "u8 u8 b"
|
||||
|
||||
/**
|
||||
* Pack format for 'transaction' data.
|
||||
*/
|
||||
export const TransactionReport = "u8 b"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "jacdac-i2c",
|
||||
"version": "0.0.0",
|
||||
"description": "Inter-Integrated Circuit (I2C, I²C, IIC) serial communication bus lets you communicate with\nmany sensors and actuators.",
|
||||
"files": [
|
||||
"constants.ts",
|
||||
"client.g.ts"
|
||||
],
|
||||
"testFiles": [
|
||||
"test.ts"
|
||||
],
|
||||
"supportedTargets": [
|
||||
"microbit",
|
||||
"arcade",
|
||||
"maker"
|
||||
],
|
||||
"dependencies": {
|
||||
"core": "*",
|
||||
"jacdac": "github:microsoft/pxt-jacdac"
|
||||
}
|
||||
}
|
|
@ -23,12 +23,12 @@ namespace jacdac {
|
|||
|
||||
export namespace IlluminanceRegPack {
|
||||
/**
|
||||
* Pack format for 'illuminance' register data.
|
||||
* Pack format for 'illuminance' data.
|
||||
*/
|
||||
export const Illuminance = "u22.10"
|
||||
|
||||
/**
|
||||
* Pack format for 'illuminance_error' register data.
|
||||
* Pack format for 'illuminance_error' data.
|
||||
*/
|
||||
export const IlluminanceError = "u22.10"
|
||||
}
|
||||
|
|
|
@ -24,12 +24,12 @@ namespace jacdac {
|
|||
|
||||
export namespace IndexedScreenCmdPack {
|
||||
/**
|
||||
* Pack format for 'start_update' register data.
|
||||
* Pack format for 'start_update' data.
|
||||
*/
|
||||
export const StartUpdate = "u16 u16 u16 u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'set_pixels' register data.
|
||||
* Pack format for 'set_pixels' data.
|
||||
*/
|
||||
export const SetPixels = "b"
|
||||
}
|
||||
|
@ -124,42 +124,42 @@ namespace jacdac {
|
|||
|
||||
export namespace IndexedScreenRegPack {
|
||||
/**
|
||||
* Pack format for 'brightness' register data.
|
||||
* Pack format for 'brightness' data.
|
||||
*/
|
||||
export const Brightness = "u0.8"
|
||||
|
||||
/**
|
||||
* Pack format for 'palette' register data.
|
||||
* Pack format for 'palette' data.
|
||||
*/
|
||||
export const Palette = "r: u8 u8 u8 u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'bits_per_pixel' register data.
|
||||
* Pack format for 'bits_per_pixel' data.
|
||||
*/
|
||||
export const BitsPerPixel = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'width' register data.
|
||||
* Pack format for 'width' data.
|
||||
*/
|
||||
export const Width = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'height' register data.
|
||||
* Pack format for 'height' data.
|
||||
*/
|
||||
export const Height = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'width_major' register data.
|
||||
* Pack format for 'width_major' data.
|
||||
*/
|
||||
export const WidthMajor = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'up_sampling' register data.
|
||||
* Pack format for 'up_sampling' data.
|
||||
*/
|
||||
export const UpSampling = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'rotation' register data.
|
||||
* Pack format for 'rotation' data.
|
||||
*/
|
||||
export const Rotation = "u16"
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace jacdac {
|
|||
|
||||
export namespace LedSingleCmdPack {
|
||||
/**
|
||||
* Pack format for 'animate' register data.
|
||||
* Pack format for 'animate' data.
|
||||
*/
|
||||
export const Animate = "u8 u8 u8 u8"
|
||||
}
|
||||
|
@ -89,32 +89,32 @@ namespace jacdac {
|
|||
|
||||
export namespace LedSingleRegPack {
|
||||
/**
|
||||
* Pack format for 'color' register data.
|
||||
* Pack format for 'color' data.
|
||||
*/
|
||||
export const Color = "u8 u8 u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_power' register data.
|
||||
* Pack format for 'max_power' data.
|
||||
*/
|
||||
export const MaxPower = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'led_count' register data.
|
||||
* Pack format for 'led_count' data.
|
||||
*/
|
||||
export const LedCount = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'wave_length' register data.
|
||||
* Pack format for 'wave_length' data.
|
||||
*/
|
||||
export const WaveLength = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'luminous_intensity' register data.
|
||||
* Pack format for 'luminous_intensity' data.
|
||||
*/
|
||||
export const LuminousIntensity = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
}
|
||||
|
|
|
@ -120,47 +120,47 @@ namespace jacdac {
|
|||
|
||||
export namespace LedStripRegPack {
|
||||
/**
|
||||
* Pack format for 'brightness' register data.
|
||||
* Pack format for 'brightness' data.
|
||||
*/
|
||||
export const Brightness = "u0.8"
|
||||
|
||||
/**
|
||||
* Pack format for 'actual_brightness' register data.
|
||||
* Pack format for 'actual_brightness' data.
|
||||
*/
|
||||
export const ActualBrightness = "u0.8"
|
||||
|
||||
/**
|
||||
* Pack format for 'light_type' register data.
|
||||
* Pack format for 'light_type' data.
|
||||
*/
|
||||
export const LightType = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'num_pixels' register data.
|
||||
* Pack format for 'num_pixels' data.
|
||||
*/
|
||||
export const NumPixels = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'num_columns' register data.
|
||||
* Pack format for 'num_columns' data.
|
||||
*/
|
||||
export const NumColumns = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_power' register data.
|
||||
* Pack format for 'max_power' data.
|
||||
*/
|
||||
export const MaxPower = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_pixels' register data.
|
||||
* Pack format for 'max_pixels' data.
|
||||
*/
|
||||
export const MaxPixels = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'num_repeats' register data.
|
||||
* Pack format for 'num_repeats' data.
|
||||
*/
|
||||
export const NumRepeats = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ namespace jacdac {
|
|||
|
||||
export namespace LedStripCmdPack {
|
||||
/**
|
||||
* Pack format for 'run' register data.
|
||||
* Pack format for 'run' data.
|
||||
*/
|
||||
export const Run = "b"
|
||||
}
|
||||
|
|
|
@ -117,52 +117,52 @@ namespace jacdac {
|
|||
|
||||
export namespace LedRegPack {
|
||||
/**
|
||||
* Pack format for 'pixels' register data.
|
||||
* Pack format for 'pixels' data.
|
||||
*/
|
||||
export const Pixels = "b"
|
||||
|
||||
/**
|
||||
* Pack format for 'brightness' register data.
|
||||
* Pack format for 'brightness' data.
|
||||
*/
|
||||
export const Brightness = "u0.8"
|
||||
|
||||
/**
|
||||
* Pack format for 'actual_brightness' register data.
|
||||
* Pack format for 'actual_brightness' data.
|
||||
*/
|
||||
export const ActualBrightness = "u0.8"
|
||||
|
||||
/**
|
||||
* Pack format for 'num_pixels' register data.
|
||||
* Pack format for 'num_pixels' data.
|
||||
*/
|
||||
export const NumPixels = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'num_columns' register data.
|
||||
* Pack format for 'num_columns' data.
|
||||
*/
|
||||
export const NumColumns = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_power' register data.
|
||||
* Pack format for 'max_power' data.
|
||||
*/
|
||||
export const MaxPower = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'leds_per_pixel' register data.
|
||||
* Pack format for 'leds_per_pixel' data.
|
||||
*/
|
||||
export const LedsPerPixel = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'wave_length' register data.
|
||||
* Pack format for 'wave_length' data.
|
||||
*/
|
||||
export const WaveLength = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'luminous_intensity' register data.
|
||||
* Pack format for 'luminous_intensity' data.
|
||||
*/
|
||||
export const LuminousIntensity = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
}
|
||||
|
|
|
@ -24,12 +24,12 @@ namespace jacdac {
|
|||
|
||||
export namespace LightBulbRegPack {
|
||||
/**
|
||||
* Pack format for 'brightness' register data.
|
||||
* Pack format for 'brightness' data.
|
||||
*/
|
||||
export const Brightness = "u0.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'dimmable' register data.
|
||||
* Pack format for 'dimmable' data.
|
||||
*/
|
||||
export const Dimmable = "u8"
|
||||
}
|
||||
|
|
|
@ -40,17 +40,17 @@ namespace jacdac {
|
|||
|
||||
export namespace LightLevelRegPack {
|
||||
/**
|
||||
* Pack format for 'light_level' register data.
|
||||
* Pack format for 'light_level' data.
|
||||
*/
|
||||
export const LightLevel = "u0.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'light_level_error' register data.
|
||||
* Pack format for 'light_level_error' data.
|
||||
*/
|
||||
export const LightLevelError = "u0.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace jacdac {
|
|||
|
||||
export namespace LoggerRegPack {
|
||||
/**
|
||||
* Pack format for 'min_priority' register data.
|
||||
* Pack format for 'min_priority' data.
|
||||
*/
|
||||
export const MinPriority = "u8"
|
||||
}
|
||||
|
@ -77,22 +77,22 @@ namespace jacdac {
|
|||
|
||||
export namespace LoggerCmdPack {
|
||||
/**
|
||||
* Pack format for 'debug' register data.
|
||||
* Pack format for 'debug' data.
|
||||
*/
|
||||
export const Debug = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'log' register data.
|
||||
* Pack format for 'log' data.
|
||||
*/
|
||||
export const Log = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'warn' register data.
|
||||
* Pack format for 'warn' data.
|
||||
*/
|
||||
export const Warn = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'error' register data.
|
||||
* Pack format for 'error' data.
|
||||
*/
|
||||
export const Error = "s"
|
||||
}
|
||||
|
|
|
@ -52,17 +52,17 @@ namespace jacdac {
|
|||
|
||||
export namespace MagneticFieldLevelRegPack {
|
||||
/**
|
||||
* Pack format for 'strength' register data.
|
||||
* Pack format for 'strength' data.
|
||||
*/
|
||||
export const Strength = "i1.15"
|
||||
|
||||
/**
|
||||
* Pack format for 'detected' register data.
|
||||
* Pack format for 'detected' data.
|
||||
*/
|
||||
export const Detected = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
}
|
||||
|
|
|
@ -24,12 +24,12 @@ namespace jacdac {
|
|||
|
||||
export namespace MagnetometerRegPack {
|
||||
/**
|
||||
* Pack format for 'forces' register data.
|
||||
* Pack format for 'forces' data.
|
||||
*/
|
||||
export const Forces = "i32 i32 i32"
|
||||
|
||||
/**
|
||||
* Pack format for 'forces_error' register data.
|
||||
* Pack format for 'forces_error' data.
|
||||
*/
|
||||
export const ForcesError = "i32"
|
||||
}
|
||||
|
|
|
@ -65,27 +65,27 @@ namespace jacdac {
|
|||
|
||||
export namespace MatrixKeypadRegPack {
|
||||
/**
|
||||
* Pack format for 'pressed' register data.
|
||||
* Pack format for 'pressed' data.
|
||||
*/
|
||||
export const Pressed = "r: u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'rows' register data.
|
||||
* Pack format for 'rows' data.
|
||||
*/
|
||||
export const Rows = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'columns' register data.
|
||||
* Pack format for 'columns' data.
|
||||
*/
|
||||
export const Columns = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'labels' register data.
|
||||
* Pack format for 'labels' data.
|
||||
*/
|
||||
export const Labels = "r: z"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
}
|
||||
|
@ -134,22 +134,22 @@ namespace jacdac {
|
|||
|
||||
export namespace MatrixKeypadEventPack {
|
||||
/**
|
||||
* Pack format for 'down' register data.
|
||||
* Pack format for 'down' data.
|
||||
*/
|
||||
export const Down = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'up' register data.
|
||||
* Pack format for 'up' data.
|
||||
*/
|
||||
export const Up = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'click' register data.
|
||||
* Pack format for 'click' data.
|
||||
*/
|
||||
export const Click = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'long_click' register data.
|
||||
* Pack format for 'long_click' data.
|
||||
*/
|
||||
export const LongClick = "u8"
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace jacdac {
|
|||
|
||||
export namespace MicrophoneCmdPack {
|
||||
/**
|
||||
* Pack format for 'sample' register data.
|
||||
* Pack format for 'sample' data.
|
||||
*/
|
||||
export const Sample = "b[12] u32"
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ namespace jacdac {
|
|||
|
||||
export namespace MicrophoneRegPack {
|
||||
/**
|
||||
* Pack format for 'sampling_period' register data.
|
||||
* Pack format for 'sampling_period' data.
|
||||
*/
|
||||
export const SamplingPeriod = "u32"
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace jacdac {
|
|||
|
||||
export namespace MidiOutputRegPack {
|
||||
/**
|
||||
* Pack format for 'enabled' register data.
|
||||
* Pack format for 'enabled' data.
|
||||
*/
|
||||
export const Enabled = "u8"
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ namespace jacdac {
|
|||
|
||||
export namespace MidiOutputCmdPack {
|
||||
/**
|
||||
* Pack format for 'send' register data.
|
||||
* Pack format for 'send' data.
|
||||
*/
|
||||
export const Send = "b"
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
{
|
||||
"targetWebsite": "https://arcade.makecode.com/beta",
|
||||
"targetWebsite": "https://arcade.makecode.com/",
|
||||
"overrides": {
|
||||
"testDependencies": {
|
||||
"net": "*",
|
||||
"device": "*"
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"links.json"
|
||||
]
|
||||
}
|
||||
"include": ["links.json"]
|
||||
}
|
||||
|
|
|
@ -51,22 +51,22 @@ namespace jacdac {
|
|||
|
||||
export namespace ModelRunnerCmdPack {
|
||||
/**
|
||||
* Pack format for 'set_model' register data.
|
||||
* Pack format for 'set_model' data.
|
||||
*/
|
||||
export const SetModel = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'set_model' register data.
|
||||
* Pack format for 'set_model' data.
|
||||
*/
|
||||
export const SetModelReport = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'predict' register data.
|
||||
* Pack format for 'predict' data.
|
||||
*/
|
||||
export const Predict = "b[12]"
|
||||
|
||||
/**
|
||||
* Pack format for 'predict' register data.
|
||||
* Pack format for 'predict' data.
|
||||
*/
|
||||
export const PredictReport = "u16"
|
||||
}
|
||||
|
@ -181,57 +181,57 @@ namespace jacdac {
|
|||
|
||||
export namespace ModelRunnerRegPack {
|
||||
/**
|
||||
* Pack format for 'auto_invoke_every' register data.
|
||||
* Pack format for 'auto_invoke_every' data.
|
||||
*/
|
||||
export const AutoInvokeEvery = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'outputs' register data.
|
||||
* Pack format for 'outputs' data.
|
||||
*/
|
||||
export const Outputs = "r: f32"
|
||||
|
||||
/**
|
||||
* Pack format for 'input_shape' register data.
|
||||
* Pack format for 'input_shape' data.
|
||||
*/
|
||||
export const InputShape = "r: u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'output_shape' register data.
|
||||
* Pack format for 'output_shape' data.
|
||||
*/
|
||||
export const OutputShape = "r: u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'last_run_time' register data.
|
||||
* Pack format for 'last_run_time' data.
|
||||
*/
|
||||
export const LastRunTime = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'allocated_arena_size' register data.
|
||||
* Pack format for 'allocated_arena_size' data.
|
||||
*/
|
||||
export const AllocatedArenaSize = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'model_size' register data.
|
||||
* Pack format for 'model_size' data.
|
||||
*/
|
||||
export const ModelSize = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'last_error' register data.
|
||||
* Pack format for 'last_error' data.
|
||||
*/
|
||||
export const LastError = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'format' register data.
|
||||
* Pack format for 'format' data.
|
||||
*/
|
||||
export const Format = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'format_version' register data.
|
||||
* Pack format for 'format_version' data.
|
||||
*/
|
||||
export const FormatVersion = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'parallel' register data.
|
||||
* Pack format for 'parallel' data.
|
||||
*/
|
||||
export const Parallel = "u8"
|
||||
}
|
||||
|
|
|
@ -47,22 +47,22 @@ namespace jacdac {
|
|||
|
||||
export namespace MotionRegPack {
|
||||
/**
|
||||
* Pack format for 'moving' register data.
|
||||
* Pack format for 'moving' data.
|
||||
*/
|
||||
export const Moving = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_distance' register data.
|
||||
* Pack format for 'max_distance' data.
|
||||
*/
|
||||
export const MaxDistance = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'angle' register data.
|
||||
* Pack format for 'angle' data.
|
||||
*/
|
||||
export const Angle = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
}
|
||||
|
|
|
@ -52,27 +52,27 @@ namespace jacdac {
|
|||
|
||||
export namespace MotorRegPack {
|
||||
/**
|
||||
* Pack format for 'speed' register data.
|
||||
* Pack format for 'speed' data.
|
||||
*/
|
||||
export const Speed = "i1.15"
|
||||
|
||||
/**
|
||||
* Pack format for 'enabled' register data.
|
||||
* Pack format for 'enabled' data.
|
||||
*/
|
||||
export const Enabled = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'load_torque' register data.
|
||||
* Pack format for 'load_torque' data.
|
||||
*/
|
||||
export const LoadTorque = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'load_rotation_speed' register data.
|
||||
* Pack format for 'load_rotation_speed' data.
|
||||
*/
|
||||
export const LoadRotationSpeed = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'reversible' register data.
|
||||
* Pack format for 'reversible' data.
|
||||
*/
|
||||
export const Reversible = "u8"
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace jacdac {
|
|||
|
||||
export namespace MultitouchRegPack {
|
||||
/**
|
||||
* Pack format for 'capacity' register data.
|
||||
* Pack format for 'capacity' data.
|
||||
*/
|
||||
export const Capacity = "r: i16"
|
||||
}
|
||||
|
@ -85,32 +85,32 @@ namespace jacdac {
|
|||
|
||||
export namespace MultitouchEventPack {
|
||||
/**
|
||||
* Pack format for 'touch' register data.
|
||||
* Pack format for 'touch' data.
|
||||
*/
|
||||
export const Touch = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'release' register data.
|
||||
* Pack format for 'release' data.
|
||||
*/
|
||||
export const Release = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'tap' register data.
|
||||
* Pack format for 'tap' data.
|
||||
*/
|
||||
export const Tap = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'long_press' register data.
|
||||
* Pack format for 'long_press' data.
|
||||
*/
|
||||
export const LongPress = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'swipe_pos' register data.
|
||||
* Pack format for 'swipe_pos' data.
|
||||
*/
|
||||
export const SwipePos = "u16 u8 u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'swipe_neg' register data.
|
||||
* Pack format for 'swipe_neg' data.
|
||||
*/
|
||||
export const SwipeNeg = "u16 u8 u8"
|
||||
}
|
||||
|
|
|
@ -29,12 +29,12 @@ namespace jacdac {
|
|||
|
||||
export namespace PlanarPositionRegPack {
|
||||
/**
|
||||
* Pack format for 'position' register data.
|
||||
* Pack format for 'position' data.
|
||||
*/
|
||||
export const Position = "i22.10 i22.10"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
}
|
||||
|
|
|
@ -31,12 +31,12 @@ namespace jacdac {
|
|||
|
||||
export namespace PotentiometerRegPack {
|
||||
/**
|
||||
* Pack format for 'position' register data.
|
||||
* Pack format for 'position' data.
|
||||
*/
|
||||
export const Position = "u0.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
}
|
||||
|
|
|
@ -41,22 +41,22 @@ namespace jacdac {
|
|||
|
||||
export namespace PowerSupplyRegPack {
|
||||
/**
|
||||
* Pack format for 'enabled' register data.
|
||||
* Pack format for 'enabled' data.
|
||||
*/
|
||||
export const Enabled = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'output_voltage' register data.
|
||||
* Pack format for 'output_voltage' data.
|
||||
*/
|
||||
export const OutputVoltage = "f64"
|
||||
|
||||
/**
|
||||
* Pack format for 'minimum_voltage' register data.
|
||||
* Pack format for 'minimum_voltage' data.
|
||||
*/
|
||||
export const MinimumVoltage = "f64"
|
||||
|
||||
/**
|
||||
* Pack format for 'maximum_voltage' register data.
|
||||
* Pack format for 'maximum_voltage' data.
|
||||
*/
|
||||
export const MaximumVoltage = "f64"
|
||||
}
|
||||
|
|
|
@ -107,47 +107,47 @@ namespace jacdac {
|
|||
|
||||
export namespace PowerRegPack {
|
||||
/**
|
||||
* Pack format for 'allowed' register data.
|
||||
* Pack format for 'allowed' data.
|
||||
*/
|
||||
export const Allowed = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_power' register data.
|
||||
* Pack format for 'max_power' data.
|
||||
*/
|
||||
export const MaxPower = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'power_status' register data.
|
||||
* Pack format for 'power_status' data.
|
||||
*/
|
||||
export const PowerStatus = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'current_draw' register data.
|
||||
* Pack format for 'current_draw' data.
|
||||
*/
|
||||
export const CurrentDraw = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'battery_voltage' register data.
|
||||
* Pack format for 'battery_voltage' data.
|
||||
*/
|
||||
export const BatteryVoltage = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'battery_charge' register data.
|
||||
* Pack format for 'battery_charge' data.
|
||||
*/
|
||||
export const BatteryCharge = "u0.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'battery_capacity' register data.
|
||||
* Pack format for 'battery_capacity' data.
|
||||
*/
|
||||
export const BatteryCapacity = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'keep_on_pulse_duration' register data.
|
||||
* Pack format for 'keep_on_pulse_duration' data.
|
||||
*/
|
||||
export const KeepOnPulseDuration = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'keep_on_pulse_period' register data.
|
||||
* Pack format for 'keep_on_pulse_period' data.
|
||||
*/
|
||||
export const KeepOnPulsePeriod = "u16"
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ namespace jacdac {
|
|||
|
||||
export namespace PowerEventPack {
|
||||
/**
|
||||
* Pack format for 'power_status_changed' register data.
|
||||
* Pack format for 'power_status_changed' data.
|
||||
*/
|
||||
export const PowerStatusChanged = "u8"
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace jacdac {
|
|||
|
||||
export namespace PressureButtonRegPack {
|
||||
/**
|
||||
* Pack format for 'threshold' register data.
|
||||
* Pack format for 'threshold' data.
|
||||
*/
|
||||
export const Threshold = "u0.16"
|
||||
}
|
||||
|
|
|
@ -131,72 +131,72 @@ namespace jacdac {
|
|||
|
||||
export namespace ProtoTestRegPack {
|
||||
/**
|
||||
* Pack format for 'rw_bool' register data.
|
||||
* Pack format for 'rw_bool' data.
|
||||
*/
|
||||
export const RwBool = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'ro_bool' register data.
|
||||
* Pack format for 'ro_bool' data.
|
||||
*/
|
||||
export const RoBool = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'rw_u32' register data.
|
||||
* Pack format for 'rw_u32' data.
|
||||
*/
|
||||
export const RwU32 = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'ro_u32' register data.
|
||||
* Pack format for 'ro_u32' data.
|
||||
*/
|
||||
export const RoU32 = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'rw_i32' register data.
|
||||
* Pack format for 'rw_i32' data.
|
||||
*/
|
||||
export const RwI32 = "i32"
|
||||
|
||||
/**
|
||||
* Pack format for 'ro_i32' register data.
|
||||
* Pack format for 'ro_i32' data.
|
||||
*/
|
||||
export const RoI32 = "i32"
|
||||
|
||||
/**
|
||||
* Pack format for 'rw_string' register data.
|
||||
* Pack format for 'rw_string' data.
|
||||
*/
|
||||
export const RwString = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'ro_string' register data.
|
||||
* Pack format for 'ro_string' data.
|
||||
*/
|
||||
export const RoString = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'rw_bytes' register data.
|
||||
* Pack format for 'rw_bytes' data.
|
||||
*/
|
||||
export const RwBytes = "b"
|
||||
|
||||
/**
|
||||
* Pack format for 'ro_bytes' register data.
|
||||
* Pack format for 'ro_bytes' data.
|
||||
*/
|
||||
export const RoBytes = "b"
|
||||
|
||||
/**
|
||||
* Pack format for 'rw_i8_u8_u16_i32' register data.
|
||||
* Pack format for 'rw_i8_u8_u16_i32' data.
|
||||
*/
|
||||
export const RwI8U8U16I32 = "i8 u8 u16 i32"
|
||||
|
||||
/**
|
||||
* Pack format for 'ro_i8_u8_u16_i32' register data.
|
||||
* Pack format for 'ro_i8_u8_u16_i32' data.
|
||||
*/
|
||||
export const RoI8U8U16I32 = "i8 u8 u16 i32"
|
||||
|
||||
/**
|
||||
* Pack format for 'rw_u8_string' register data.
|
||||
* Pack format for 'rw_u8_string' data.
|
||||
*/
|
||||
export const RwU8String = "u8 s"
|
||||
|
||||
/**
|
||||
* Pack format for 'ro_u8_string' register data.
|
||||
* Pack format for 'ro_u8_string' data.
|
||||
*/
|
||||
export const RoU8String = "u8 s"
|
||||
}
|
||||
|
@ -275,37 +275,37 @@ namespace jacdac {
|
|||
|
||||
export namespace ProtoTestEventPack {
|
||||
/**
|
||||
* Pack format for 'e_bool' register data.
|
||||
* Pack format for 'e_bool' data.
|
||||
*/
|
||||
export const EBool = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'e_u32' register data.
|
||||
* Pack format for 'e_u32' data.
|
||||
*/
|
||||
export const EU32 = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'e_i32' register data.
|
||||
* Pack format for 'e_i32' data.
|
||||
*/
|
||||
export const EI32 = "i32"
|
||||
|
||||
/**
|
||||
* Pack format for 'e_string' register data.
|
||||
* Pack format for 'e_string' data.
|
||||
*/
|
||||
export const EString = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'e_bytes' register data.
|
||||
* Pack format for 'e_bytes' data.
|
||||
*/
|
||||
export const EBytes = "b"
|
||||
|
||||
/**
|
||||
* Pack format for 'e_i8_u8_u16_i32' register data.
|
||||
* Pack format for 'e_i8_u8_u16_i32' data.
|
||||
*/
|
||||
export const EI8U8U16I32 = "i8 u8 u16 i32"
|
||||
|
||||
/**
|
||||
* Pack format for 'e_u8_string' register data.
|
||||
* Pack format for 'e_u8_string' data.
|
||||
*/
|
||||
export const EU8String = "u8 s"
|
||||
}
|
||||
|
@ -386,46 +386,47 @@ namespace jacdac {
|
|||
|
||||
export namespace ProtoTestCmdPack {
|
||||
/**
|
||||
* Pack format for 'c_bool' register data.
|
||||
* Pack format for 'c_bool' data.
|
||||
*/
|
||||
export const CBool = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'c_u32' register data.
|
||||
* Pack format for 'c_u32' data.
|
||||
*/
|
||||
export const CU32 = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'c_i32' register data.
|
||||
* Pack format for 'c_i32' data.
|
||||
*/
|
||||
export const CI32 = "i32"
|
||||
|
||||
/**
|
||||
* Pack format for 'c_string' register data.
|
||||
* Pack format for 'c_string' data.
|
||||
*/
|
||||
export const CString = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'c_bytes' register data.
|
||||
* Pack format for 'c_bytes' data.
|
||||
*/
|
||||
export const CBytes = "b"
|
||||
|
||||
/**
|
||||
* Pack format for 'c_i8_u8_u16_i32' register data.
|
||||
* Pack format for 'c_i8_u8_u16_i32' data.
|
||||
*/
|
||||
export const CI8U8U16I32 = "i8 u8 u16 i32"
|
||||
|
||||
/**
|
||||
* Pack format for 'c_u8_string' register data.
|
||||
* Pack format for 'c_u8_string' data.
|
||||
*/
|
||||
export const CU8String = "u8 s"
|
||||
|
||||
/**
|
||||
* Pack format for 'c_report_pipe' register data.
|
||||
* Pack format for 'c_report_pipe' data.
|
||||
*/
|
||||
export const CReportPipe = "b[12]"
|
||||
}
|
||||
|
||||
export const enum ProtoTestPipe {}
|
||||
/**
|
||||
* pipe_report PBytes
|
||||
* ```
|
||||
|
@ -433,9 +434,9 @@ namespace jacdac {
|
|||
* ```
|
||||
*/
|
||||
|
||||
export namespace ProtoTestinfoPack {
|
||||
export namespace ProtoTestPipePack {
|
||||
/**
|
||||
* Pack format for 'p_bytes' register data.
|
||||
* Pack format for 'p_bytes' data.
|
||||
*/
|
||||
export const PBytes = "u8"
|
||||
}
|
||||
|
|
|
@ -23,12 +23,12 @@ namespace jacdac {
|
|||
|
||||
export namespace PulseOximeterRegPack {
|
||||
/**
|
||||
* Pack format for 'oxygen' register data.
|
||||
* Pack format for 'oxygen' data.
|
||||
*/
|
||||
export const Oxygen = "u8.8"
|
||||
|
||||
/**
|
||||
* Pack format for 'oxygen_error' register data.
|
||||
* Pack format for 'oxygen_error' data.
|
||||
*/
|
||||
export const OxygenError = "u8.8"
|
||||
}
|
||||
|
|
|
@ -23,12 +23,12 @@ namespace jacdac {
|
|||
|
||||
export namespace RainGaugeRegPack {
|
||||
/**
|
||||
* Pack format for 'precipitation' register data.
|
||||
* Pack format for 'precipitation' data.
|
||||
*/
|
||||
export const Precipitation = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'precipitation_precision' register data.
|
||||
* Pack format for 'precipitation_precision' data.
|
||||
*/
|
||||
export const PrecipitationPrecision = "u16.16"
|
||||
}
|
||||
|
|
|
@ -51,22 +51,22 @@ namespace jacdac {
|
|||
|
||||
export namespace RealTimeClockRegPack {
|
||||
/**
|
||||
* Pack format for 'local_time' register data.
|
||||
* Pack format for 'local_time' data.
|
||||
*/
|
||||
export const LocalTime = "u16 u8 u8 u8 u8 u8 u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'drift' register data.
|
||||
* Pack format for 'drift' data.
|
||||
*/
|
||||
export const Drift = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'precision' register data.
|
||||
* Pack format for 'precision' data.
|
||||
*/
|
||||
export const Precision = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ namespace jacdac {
|
|||
|
||||
export namespace RealTimeClockCmdPack {
|
||||
/**
|
||||
* Pack format for 'set_time' register data.
|
||||
* Pack format for 'set_time' data.
|
||||
*/
|
||||
export const SetTime = "u16 u8 u8 u8 u8 u8 u8"
|
||||
}
|
||||
|
|
|
@ -31,12 +31,12 @@ namespace jacdac {
|
|||
|
||||
export namespace ReflectedLightRegPack {
|
||||
/**
|
||||
* Pack format for 'brightness' register data.
|
||||
* Pack format for 'brightness' data.
|
||||
*/
|
||||
export const Brightness = "u0.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
}
|
||||
|
|
|
@ -42,17 +42,17 @@ namespace jacdac {
|
|||
|
||||
export namespace RelayRegPack {
|
||||
/**
|
||||
* Pack format for 'active' register data.
|
||||
* Pack format for 'active' data.
|
||||
*/
|
||||
export const Active = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_switching_current' register data.
|
||||
* Pack format for 'max_switching_current' data.
|
||||
*/
|
||||
export const MaxSwitchingCurrent = "u32"
|
||||
}
|
||||
|
|
|
@ -37,12 +37,12 @@ namespace jacdac {
|
|||
|
||||
export namespace RngRegPack {
|
||||
/**
|
||||
* Pack format for 'random' register data.
|
||||
* Pack format for 'random' data.
|
||||
*/
|
||||
export const Random = "b"
|
||||
|
||||
/**
|
||||
* Pack format for 'variant' register data.
|
||||
* Pack format for 'variant' data.
|
||||
*/
|
||||
export const Variant = "u8"
|
||||
}
|
||||
|
|
|
@ -28,12 +28,12 @@ namespace jacdac {
|
|||
|
||||
export namespace RoleManagerRegPack {
|
||||
/**
|
||||
* Pack format for 'auto_bind' register data.
|
||||
* Pack format for 'auto_bind' data.
|
||||
*/
|
||||
export const AutoBind = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'all_roles_allocated' register data.
|
||||
* Pack format for 'all_roles_allocated' data.
|
||||
*/
|
||||
export const AllRolesAllocated = "u8"
|
||||
}
|
||||
|
@ -65,16 +65,17 @@ namespace jacdac {
|
|||
|
||||
export namespace RoleManagerCmdPack {
|
||||
/**
|
||||
* Pack format for 'set_role' register data.
|
||||
* Pack format for 'set_role' data.
|
||||
*/
|
||||
export const SetRole = "b[8] u8 s"
|
||||
|
||||
/**
|
||||
* Pack format for 'list_roles' register data.
|
||||
* Pack format for 'list_roles' data.
|
||||
*/
|
||||
export const ListRoles = "b[12]"
|
||||
}
|
||||
|
||||
export const enum RoleManagerPipe {}
|
||||
/**
|
||||
* pipe_report Roles
|
||||
* ```
|
||||
|
@ -82,9 +83,9 @@ namespace jacdac {
|
|||
* ```
|
||||
*/
|
||||
|
||||
export namespace RoleManagerinfoPack {
|
||||
export namespace RoleManagerPipePack {
|
||||
/**
|
||||
* Pack format for 'roles' register data.
|
||||
* Pack format for 'roles' data.
|
||||
*/
|
||||
export const Roles = "b[8] u32 u8 s"
|
||||
}
|
||||
|
|
|
@ -34,17 +34,17 @@ namespace jacdac {
|
|||
|
||||
export namespace RotaryEncoderRegPack {
|
||||
/**
|
||||
* Pack format for 'position' register data.
|
||||
* Pack format for 'position' data.
|
||||
*/
|
||||
export const Position = "i32"
|
||||
|
||||
/**
|
||||
* Pack format for 'clicks_per_turn' register data.
|
||||
* Pack format for 'clicks_per_turn' data.
|
||||
*/
|
||||
export const ClicksPerTurn = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'clicker' register data.
|
||||
* Pack format for 'clicker' data.
|
||||
*/
|
||||
export const Clicker = "u8"
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace jacdac {
|
|||
|
||||
export namespace RoverRegPack {
|
||||
/**
|
||||
* Pack format for 'kinematics' register data.
|
||||
* Pack format for 'kinematics' data.
|
||||
*/
|
||||
export const Kinematics = "i16.16 i16.16 i16.16 i16.16 i16.16"
|
||||
}
|
||||
|
|
|
@ -23,12 +23,12 @@ namespace jacdac {
|
|||
|
||||
export namespace SatNavRegPack {
|
||||
/**
|
||||
* Pack format for 'position' register data.
|
||||
* Pack format for 'position' data.
|
||||
*/
|
||||
export const Position = "u64 i9.23 i9.23 u16.16 i26.6 u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'enabled' register data.
|
||||
* Pack format for 'enabled' data.
|
||||
*/
|
||||
export const Enabled = "u8"
|
||||
}
|
||||
|
|
|
@ -68,27 +68,27 @@ namespace jacdac {
|
|||
|
||||
export namespace SensorAggregatorRegPack {
|
||||
/**
|
||||
* Pack format for 'inputs' register data.
|
||||
* Pack format for 'inputs' data.
|
||||
*/
|
||||
export const Inputs = "u16 u16 u32 r: b[8] u32 u8 u8 u8 i8"
|
||||
|
||||
/**
|
||||
* Pack format for 'num_samples' register data.
|
||||
* Pack format for 'num_samples' data.
|
||||
*/
|
||||
export const NumSamples = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'sample_size' register data.
|
||||
* Pack format for 'sample_size' data.
|
||||
*/
|
||||
export const SampleSize = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'streaming_samples' register data.
|
||||
* Pack format for 'streaming_samples' data.
|
||||
*/
|
||||
export const StreamingSamples = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'current_sample' register data.
|
||||
* Pack format for 'current_sample' data.
|
||||
*/
|
||||
export const CurrentSample = "b"
|
||||
}
|
||||
|
|
|
@ -32,17 +32,17 @@ namespace jacdac {
|
|||
|
||||
export namespace SensorRegPack {
|
||||
/**
|
||||
* Pack format for 'streaming_samples' register data.
|
||||
* Pack format for 'streaming_samples' data.
|
||||
*/
|
||||
export const StreamingSamples = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'streaming_interval' register data.
|
||||
* Pack format for 'streaming_interval' data.
|
||||
*/
|
||||
export const StreamingInterval = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'streaming_preferred_interval' register data.
|
||||
* Pack format for 'streaming_preferred_interval' data.
|
||||
*/
|
||||
export const StreamingPreferredInterval = "u32"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,147 @@
|
|||
namespace jacdac {
|
||||
// Service Serial constants
|
||||
export const SRV_SERIAL = 0x11bae5c4
|
||||
|
||||
export const enum SerialParityType { // uint8_t
|
||||
//% block="none"
|
||||
None = 0x0,
|
||||
//% block="even"
|
||||
Even = 0x1,
|
||||
//% block="odd"
|
||||
Odd = 0x2,
|
||||
}
|
||||
|
||||
export const enum SerialReg {
|
||||
/**
|
||||
* Read-write bool (uint8_t). Indicates if the serial connection is active.
|
||||
*
|
||||
* ```
|
||||
* const [connected] = jdunpack<[number]>(buf, "u8")
|
||||
* ```
|
||||
*/
|
||||
Connected = 0x1,
|
||||
|
||||
/**
|
||||
* Read-only string (bytes). User-friendly name of the connection.
|
||||
*
|
||||
* ```
|
||||
* const [connectionName] = jdunpack<[string]>(buf, "s")
|
||||
* ```
|
||||
*/
|
||||
ConnectionName = 0x181,
|
||||
|
||||
/**
|
||||
* Read-write baud uint32_t. A positive, non-zero value indicating the baud rate at which serial communication is be established.
|
||||
*
|
||||
* ```
|
||||
* const [baudRate] = jdunpack<[number]>(buf, "u32")
|
||||
* ```
|
||||
*/
|
||||
BaudRate = 0x80,
|
||||
|
||||
/**
|
||||
* Read-write uint8_t. The number of data bits per frame. Either 7 or 8.
|
||||
*
|
||||
* ```
|
||||
* const [dataBits] = jdunpack<[number]>(buf, "u8")
|
||||
* ```
|
||||
*/
|
||||
DataBits = 0x81,
|
||||
|
||||
/**
|
||||
* Read-write # uint8_t. The number of stop bits at the end of a frame. Either 1 or 2.
|
||||
*
|
||||
* ```
|
||||
* const [stopBits] = jdunpack<[number]>(buf, "u8")
|
||||
* ```
|
||||
*/
|
||||
StopBits = 0x82,
|
||||
|
||||
/**
|
||||
* Read-write ParityType (uint8_t). The parity mode.
|
||||
*
|
||||
* ```
|
||||
* const [parityMode] = jdunpack<[jacdac.SerialParityType]>(buf, "u8")
|
||||
* ```
|
||||
*/
|
||||
ParityMode = 0x83,
|
||||
|
||||
/**
|
||||
* Read-write # uint8_t. A positive, non-zero value indicating the size of the read and write buffers that should be created.
|
||||
*
|
||||
* ```
|
||||
* const [bufferSize] = jdunpack<[number]>(buf, "u8")
|
||||
* ```
|
||||
*/
|
||||
BufferSize = 0x84,
|
||||
}
|
||||
|
||||
export namespace SerialRegPack {
|
||||
/**
|
||||
* Pack format for 'connected' data.
|
||||
*/
|
||||
export const Connected = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'connection_name' data.
|
||||
*/
|
||||
export const ConnectionName = "s"
|
||||
|
||||
/**
|
||||
* Pack format for 'baud_rate' data.
|
||||
*/
|
||||
export const BaudRate = "u32"
|
||||
|
||||
/**
|
||||
* Pack format for 'data_bits' data.
|
||||
*/
|
||||
export const DataBits = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'stop_bits' data.
|
||||
*/
|
||||
export const StopBits = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'parity_mode' data.
|
||||
*/
|
||||
export const ParityMode = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'buffer_size' data.
|
||||
*/
|
||||
export const BufferSize = "u8"
|
||||
}
|
||||
|
||||
export const enum SerialCmd {
|
||||
/**
|
||||
* Argument: data bytes. Send a buffer of data over the serial transport.
|
||||
*
|
||||
* ```
|
||||
* const [data] = jdunpack<[Buffer]>(buf, "b")
|
||||
* ```
|
||||
*/
|
||||
Send = 0x80,
|
||||
|
||||
/**
|
||||
* Argument: data bytes. Raised when a buffer of data is received.
|
||||
*
|
||||
* ```
|
||||
* const [data] = jdunpack<[Buffer]>(buf, "b")
|
||||
* ```
|
||||
*/
|
||||
Received = 0x80,
|
||||
}
|
||||
|
||||
export namespace SerialCmdPack {
|
||||
/**
|
||||
* Pack format for 'send' data.
|
||||
*/
|
||||
export const Send = "b"
|
||||
|
||||
/**
|
||||
* Pack format for 'received' data.
|
||||
*/
|
||||
export const Received = "b"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "jacdac-serial",
|
||||
"version": "0.0.0",
|
||||
"description": "An asynchronous serial communication service capable of sending and receiving buffers of data.\nSettings default to 115200 baud 8N1.",
|
||||
"files": [
|
||||
"constants.ts",
|
||||
"client.g.ts"
|
||||
],
|
||||
"testFiles": [
|
||||
"test.ts"
|
||||
],
|
||||
"supportedTargets": [
|
||||
"microbit",
|
||||
"arcade",
|
||||
"maker"
|
||||
],
|
||||
"dependencies": {
|
||||
"core": "*",
|
||||
"jacdac": "github:microsoft/pxt-jacdac"
|
||||
}
|
||||
}
|
|
@ -95,52 +95,52 @@ namespace jacdac {
|
|||
|
||||
export namespace ServoRegPack {
|
||||
/**
|
||||
* Pack format for 'angle' register data.
|
||||
* Pack format for 'angle' data.
|
||||
*/
|
||||
export const Angle = "i16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'enabled' register data.
|
||||
* Pack format for 'enabled' data.
|
||||
*/
|
||||
export const Enabled = "u8"
|
||||
|
||||
/**
|
||||
* Pack format for 'offset' register data.
|
||||
* Pack format for 'offset' data.
|
||||
*/
|
||||
export const Offset = "i16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'min_angle' register data.
|
||||
* Pack format for 'min_angle' data.
|
||||
*/
|
||||
export const MinAngle = "i16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'min_pulse' register data.
|
||||
* Pack format for 'min_pulse' data.
|
||||
*/
|
||||
export const MinPulse = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_angle' register data.
|
||||
* Pack format for 'max_angle' data.
|
||||
*/
|
||||
export const MaxAngle = "i16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'max_pulse' register data.
|
||||
* Pack format for 'max_pulse' data.
|
||||
*/
|
||||
export const MaxPulse = "u16"
|
||||
|
||||
/**
|
||||
* Pack format for 'stall_torque' register data.
|
||||
* Pack format for 'stall_torque' data.
|
||||
*/
|
||||
export const StallTorque = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'response_speed' register data.
|
||||
* Pack format for 'response_speed' data.
|
||||
*/
|
||||
export const ResponseSpeed = "u16.16"
|
||||
|
||||
/**
|
||||
* Pack format for 'actual_angle' register data.
|
||||
* Pack format for 'actual_angle' data.
|
||||
*/
|
||||
export const ActualAngle = "i16.16"
|
||||
}
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче