upgrade to latest jacdac
This commit is contained in:
Родитель
25a5f10f67
Коммит
2dd052135f
14
main.ts
14
main.ts
|
@ -1,4 +1,4 @@
|
|||
let dns: jacdac.DeviceNamerClient
|
||||
let dns: jacdac.RoleManagerClient
|
||||
|
||||
function describe(dev: jacdac.Device) {
|
||||
let name = ""
|
||||
|
@ -27,7 +27,7 @@ function identify(d: jacdac.Device) {
|
|||
if (d == jacdac.selfDevice())
|
||||
control.runInBackground(jacdac.onIdentifyRequest)
|
||||
else
|
||||
d.sendCtrlCommand(jacdac.CMD_CTRL_IDENTIFY)
|
||||
d.sendCtrlCommand(jacdac.ControlCmd.Identify)
|
||||
}
|
||||
|
||||
function selectDevice(fun: string, cond: (dev: jacdac.Device) => boolean) {
|
||||
|
@ -48,7 +48,7 @@ function selectDevice(fun: string, cond: (dev: jacdac.Device) => boolean) {
|
|||
}
|
||||
|
||||
function operateDNS(ourDNS: jacdac.Device) {
|
||||
dns = new jacdac.DeviceNamerClient(ourDNS.deviceId);
|
||||
dns = new jacdac.RoleManagerClient(ourDNS.deviceId);
|
||||
dns.scan()
|
||||
|
||||
menu.show({
|
||||
|
@ -72,13 +72,13 @@ function operateDNS(ourDNS: jacdac.Device) {
|
|||
function allDNSes() {
|
||||
return jacdac.devices().filter(hasDNS)
|
||||
function hasDNS(d: jacdac.Device) {
|
||||
return d.hasService(jd_class.DEVICE_NAME_SERVICE)
|
||||
return d.hasService(jacdac.SRV_ROLE_MANAGER)
|
||||
}
|
||||
}
|
||||
|
||||
function resetAll() {
|
||||
jacdac.JDPacket.onlyHeader(jacdac.CMD_CTRL_RESET)
|
||||
.sendAsMultiCommand(jd_class.CTRL)
|
||||
jacdac.JDPacket.onlyHeader(jacdac.ControlCmd.Reset)
|
||||
.sendAsMultiCommand(jacdac.SRV_CONTROL)
|
||||
}
|
||||
|
||||
let consoleClient: jacdac.ConsoleClient
|
||||
|
@ -102,7 +102,7 @@ function hideConsole() {
|
|||
function startConsole() {
|
||||
if (!consoleClient) {
|
||||
consoleClient = new jacdac.ConsoleClient()
|
||||
consoleClient.minPriority = JDConsolePriority.Debug
|
||||
consoleClient.minPriority = jacdac.consolePriority = ConsolePriority.Debug
|
||||
consoleClient.start()
|
||||
}
|
||||
showConsole()
|
||||
|
|
4
pxt.json
4
pxt.json
|
@ -20,7 +20,7 @@
|
|||
"test.ts"
|
||||
],
|
||||
"targetVersions": {
|
||||
"target": "1.2.6",
|
||||
"target": "1.3.20",
|
||||
"targetId": "arcade"
|
||||
},
|
||||
"supportedTargets": [
|
||||
|
@ -29,4 +29,4 @@
|
|||
"preferredEditor": "tsprj",
|
||||
"disableTargetTemplateFiles": true,
|
||||
"binaryonly": true
|
||||
}
|
||||
}
|
||||
|
|
10
services.ts
10
services.ts
|
@ -6,7 +6,8 @@ class ServiceDesc {
|
|||
) { }
|
||||
}
|
||||
|
||||
const serviceDescs = [
|
||||
const serviceDescs: ServiceDesc[] = [
|
||||
/*
|
||||
new ServiceDesc(jd_class.ACCELEROMETER, "acc",
|
||||
num => jacdac.accelerometerClient.setStreaming(num & 1 ? true : false)),
|
||||
new ServiceDesc(jd_class.LIGHT, "light", (num) => {
|
||||
|
@ -67,6 +68,7 @@ const serviceDescs = [
|
|||
num => jacdac.rotaryEncoderClient.setStreaming(num & 1 ? true : false)),
|
||||
new ServiceDesc(jd_class.MUSIC, "music",
|
||||
num => jacdac.musicClient.playMelody(music.jumpDown, 20)),
|
||||
*/
|
||||
]
|
||||
|
||||
class RawSensorClient extends jacdac.SensorClient {
|
||||
|
@ -144,10 +146,10 @@ function deviceView(d: jacdac.Device) {
|
|||
footer: "A = select, -> = test service",
|
||||
update: opts => {
|
||||
opts.elements = []
|
||||
opts.elements.push(menu.item(d.classDescription, noop))
|
||||
//opts.elements.push(menu.item(d..classDescription, noop))
|
||||
opts.elements.push(menu.item(d.firmwareVersion, noop))
|
||||
opts.elements.push(menu.item("Temp: " + (d.temperature || "?") + "C", noop))
|
||||
opts.elements.push(menu.item("Uptime: " + Math.round((d.queryInt(jacdac.REG_CTRL_MICROS_SINCE_BOOT) || 0) / 1000000) + "s", noop))
|
||||
opts.elements.push(menu.item("Temp: " + (d.mcuTemperature || "?") + "C", noop))
|
||||
opts.elements.push(menu.item("Uptime: " + Math.round((d.queryInt(jacdac.ControlReg.Uptime) || 0) / 1000000) + "s", noop))
|
||||
opts.elements.push(menu.item("Identify", () => identify(d)))
|
||||
opts.elements.push(menu.item("---", noop))
|
||||
opts.elements = opts.elements.concat(services.map(s => menu.item(s.name, () => {
|
||||
|
|
3
ui.ts
3
ui.ts
|
@ -92,7 +92,8 @@ namespace menu {
|
|||
|
||||
const x = 10
|
||||
if (opts.elements.length == 0) {
|
||||
screen.print("Nothing here, press B to go back", x, 60, 4, image.font5)
|
||||
screen.print("Nothing here", x, 60, 4, image.font5)
|
||||
screen.print("press B to go back", x, 80, 4, image.font5)
|
||||
return
|
||||
}
|
||||
// if elements changed, cursor could be off limits - move(0) will limit it
|
||||
|
|
Загрузка…
Ссылка в новой задаче