diff --git a/pccontroller/constants.ts b/pccontroller/constants.ts new file mode 100644 index 000000000..a19a248ab --- /dev/null +++ b/pccontroller/constants.ts @@ -0,0 +1,63 @@ +namespace jacdac { + // Service PC controller constants + export const SRV_PCCONTROLLER = 0x113d0987 + export const enum PCControllerCmd { + /** + * Argument: url string (bytes). Open a URL in the default browser. + * + * ``` + * const [url] = jdunpack<[string]>(buf, "s") + * ``` + */ + OpenUrl = 0x80, + + /** + * Argument: name string (bytes). Start an app. + * + * ``` + * const [name] = jdunpack<[string]>(buf, "s") + * ``` + */ + StartApp = 0x81, + + /** + * Argument: text string (bytes). Send text to the active window. + * + * ``` + * const [text] = jdunpack<[string]>(buf, "s") + * ``` + */ + SendText = 0x82, + + /** + * Argument: script string (bytes). Run a script. + * + * ``` + * const [script] = jdunpack<[string]>(buf, "s") + * ``` + */ + RunScript = 0x83, + } + + export namespace PCControllerCmdPack { + /** + * Pack format for 'open_url' data. + */ + export const OpenUrl = "s" + + /** + * Pack format for 'start_app' data. + */ + export const StartApp = "s" + + /** + * Pack format for 'send_text' data. + */ + export const SendText = "s" + + /** + * Pack format for 'run_script' data. + */ + export const RunScript = "s" + } +} diff --git a/pccontroller/pxt.g.json b/pccontroller/pxt.g.json new file mode 100644 index 000000000..f9d423923 --- /dev/null +++ b/pccontroller/pxt.g.json @@ -0,0 +1,22 @@ +{ + "name": "jacdac-pccontroller", + "version": "0.0.0", + "description": "Send various events to PC, including opening a URL, start an app, sending text, etc.", + "files": [ + "constants.ts", + "client.g.ts" + ], + "testFiles": [ + "test.ts" + ], + "supportedTargets": [ + "microbit", + "arcade", + "maker", + "calliopemini" + ], + "dependencies": { + "core": "*", + "jacdac": "github:microsoft/pxt-jacdac" + } +} \ No newline at end of file diff --git a/pcmonitor/constants.ts b/pcmonitor/constants.ts new file mode 100644 index 000000000..bc0942b1d --- /dev/null +++ b/pcmonitor/constants.ts @@ -0,0 +1,77 @@ +namespace jacdac { + // Service PC monitor constants + export const SRV_PCMONITOR = 0x18627b15 + export const enum PCMonitorReg { + /** + * Read-only % uint8_t. CPU usage in percent. + * + * ``` + * const [cpuUsage] = jdunpack<[number]>(buf, "u8") + * ``` + */ + CpuUsage = 0x190, + + /** + * Read-only °C uint8_t. CPU temperature in Celsius. + * + * ``` + * const [cpuTemperature] = jdunpack<[number]>(buf, "u8") + * ``` + */ + CpuTemperature = 0x191, + + /** + * Read-only % uint8_t. RAM usage in percent. + * + * ``` + * const [ramUsage] = jdunpack<[number]>(buf, "u8") + * ``` + */ + RamUsage = 0x192, + + /** + * GPU info. + * + * ``` + * const [usage, temperature] = jdunpack<[number, number]>(buf, "u8 u8") + * ``` + */ + GpuInformation = 0x193, + + /** + * Network transmit/receive speed in Kbytes per second. + * + * ``` + * const [tx, rx] = jdunpack<[number, number]>(buf, "u16 u16") + * ``` + */ + NetworkInformation = 0x195, + } + + export namespace PCMonitorRegPack { + /** + * Pack format for 'cpu_usage' data. + */ + export const CpuUsage = "u8" + + /** + * Pack format for 'cpu_temperature' data. + */ + export const CpuTemperature = "u8" + + /** + * Pack format for 'ram_usage' data. + */ + export const RamUsage = "u8" + + /** + * Pack format for 'gpu_information' data. + */ + export const GpuInformation = "u8 u8" + + /** + * Pack format for 'network_information' data. + */ + export const NetworkInformation = "u16 u16" + } +} diff --git a/pcmonitor/pxt.g.json b/pcmonitor/pxt.g.json new file mode 100644 index 000000000..26abe5c4d --- /dev/null +++ b/pcmonitor/pxt.g.json @@ -0,0 +1,22 @@ +{ + "name": "jacdac-pcmonitor", + "version": "0.0.0", + "description": "Measures PC monitor.", + "files": [ + "constants.ts", + "client.g.ts" + ], + "testFiles": [ + "test.ts" + ], + "supportedTargets": [ + "microbit", + "arcade", + "maker", + "calliopemini" + ], + "dependencies": { + "core": "*", + "jacdac": "github:microsoft/pxt-jacdac" + } +} \ No newline at end of file