led-matrix-controllers 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# LED Matrix Controllers
|
|
2
2
|
|
|
3
|
-
Cross-firmware controllers
|
|
3
|
+
Cross-firmware controllers for the [Framework Laptop 16 LED matrix module](https://frame.work/products/16-led-matrix) using WebHID and Web Serial APIs
|
|
4
4
|
|
|
5
5
|
## Supported Firmwares
|
|
6
6
|
|
|
@@ -14,11 +14,51 @@ If you maintain another firmware or a fork, please open an issue or submit a PR!
|
|
|
14
14
|
|
|
15
15
|
### Installation
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
#### Browser
|
|
18
|
+
|
|
19
|
+
```html
|
|
20
|
+
<script type="module">
|
|
21
|
+
import { DefaultController } from 'https://esm.sh/led-matrix-controllers@latest';
|
|
22
|
+
const controller = new DefaultController();
|
|
23
|
+
await controller.connect();
|
|
24
|
+
// ...
|
|
25
|
+
</script>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
#### Node.js
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install led-matrix-controllers
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Also see [examples/webpack/](examples/webpack/)
|
|
18
35
|
|
|
19
36
|
### Usage
|
|
20
37
|
|
|
21
|
-
|
|
38
|
+
#### For specific firmware
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
// Controllers for specific firmware
|
|
42
|
+
import { DefaultController, SigrootController, SparkleController } from 'led-matrix-controllers';
|
|
43
|
+
|
|
44
|
+
const controller = new DefaultController();
|
|
45
|
+
await controller.connect();
|
|
46
|
+
await controller.draw( /* 34x9 matrix array */ );
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Also see [examples/sparkle.html](examples/sparkle.html)
|
|
50
|
+
|
|
51
|
+
#### For specific interface
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
import { HardwareControllerFactory } from 'led-matrix-controllers';
|
|
55
|
+
|
|
56
|
+
// connect to device
|
|
57
|
+
const foo = HardwareControllerFactory.detectSerial();
|
|
58
|
+
const bar = HardwareControllerFactory.detectHID();
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Also see [examples/detect-firmware.html](examples/detect-firmware.html)
|
|
22
62
|
|
|
23
63
|
## Development
|
|
24
64
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=9,t=34,a=12972,r=[50,172],i=32,n=[0,32],s=Object.freeze([0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,5,5,5,5,6,6,6,6,6,7,7,7,7,8,8,8,9,9,9,10,10,10,11,11,11,12,12,12,13,13,14,14,14,15,15,16,16,17,17,17,18,18,19,19,20,20,21,22,22,23,23,24,24,25,26,26,27,27,28,29,29,30,31,32,32,33,34,34,35,36,37,38,38,39,40,41,42,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,66,67,68,69,70,71,73,74,75,76,78,79,80,82,83,84,86,87,88,90,91,93,94,96,97,99,100,102,103,105,106,108,110,111,113,115,116,118,120,121,123,125,127,128,130,132,134,136,138,140,141,143,145,147,149,151,153,155,157,159,161,164,166,168,170,172,174,177,179,181,183,186,188,190,193,195,197,200,202,205,207,210,212,215,217,220,222,225,228,230,233,236,238,241,244,247,249,252,255]),o=[],c=[{usbVendorId:a,usbProductId:32}];class l extends Error{constructor(){super("User cancelled port selection."),this.name=this.constructor.name,this.date=new Date}}class d extends Error{constructor(){super("Selected port already in use."),this.name=this.constructor.name,this.date=new Date}}async function u(){try{if(o&&o.length>0)return o.pop();if(o.push(...await navigator.serial.getPorts()),o&&o.length>0)return o.pop();if(o.push(...await navigator.serial.requestPort({filters:c})),o&&o.length>0)return o.pop()}catch(e){throw"NotFoundError"==e.name?new l:"InvalidStateError"==e.name?new d:e}}async function w(e){try{await e.close()}catch(e){if("InvalidStateError"!=e.name&&"Failed to execute 'close' on 'SerialPort': The port is already closed."!=e.message)throw e}}class h{constructor(e){this.#e=`port-mutex-${Math.random().toString()}`,this.#t=new Map,this.#a=e}async acquire(e){const t=new Error("created bad cb").stack;await this.#r(async()=>{try{await e(this.#a)}catch(e){console.error("Error occured in anonymous callback."),console.error("Original error:",e),console.error("--- This callback was created at ---\n",t)}})}async acquireIdempotent(e,t){const a=new Error("created bad cb").stack;this.#t.has(e)&&console.info(`"${e}" request coalesced.`),this.#t.set(e,async()=>{try{await t(this.#a)}catch(e){console.error("Error occured in anonymous callback."),console.error("Original error:",e),console.error("--- This callback was created at ---\n",a)}}),await this.#r(()=>this.#i(e))}async#r(e){return navigator.locks.request(this.#e,e)}async#i(e){if(this.#t.has(e)){const t=this.#t.get(e);this.#t.delete(e),await t()}}#e;#t;#a}class p{constructor(e){this.#n=e}async rx(e,t=3e3){if(null===this.#n)throw new Error("attempted RX before port initialization.");if(this.#n.readable.locked)throw new Error("attempted RX while port locked.");const a=[],r=this.#n.readable.getReader(),i=setTimeout(()=>r.cancel(),t);try{for(;a.length<e;){const{value:e,done:t}=await r.read();if(a.push(...e??[]),t||!e)break}}finally{clearTimeout(i),r.releaseLock()}return a}async tx(e){if(null===this.#n)throw new Error("attempted TX before port initialization.");if(this.#n.writable.locked)throw new Error("attempted TX while port locked.");const t=this.#n.writable.getWriter();try{await t.write(new Uint8Array(e))}finally{await t.close()}}#n}const y=Object.freeze({ANIMATE:4,BRIGHTNESS:0,BOOTLOADER:2,DRAW:6,DRAW_GREY_COL_BUFFER:8,GAME_CTRL:17,GAME_STATUS:18,PANIC:5,PATTERN:1,SLEEP:3,STAGE_GREY_COL:7,START_GAME:16,VERSION:32});let _=class{constructor(e=null){this.portMutex=e}async bootloader(){await this.portMutex.acquire(async e=>{await e.tx([...r,y.BOOTLOADER])})}async draw(e){let t=0,a=new Uint8Array(39).fill(0);for(let r=0;r<34;r++)for(let i=0;i<9;i++)e[r][i]&&(a[t>>3]|=1<<t%8),t++;await this.portMutex.acquireIdempotent("drawMatrix",async e=>{await e.tx([...r,y.DRAW,...a])})}async drawGrayscale(e){const t=Array.from({length:9},(t,a)=>new Array({length:34},(t,r)=>GAMMA[Math.floor(255*(e[r][a]??0))]));await this.portMutex.acquireIdempotent("drawMatrix",async e=>{for(let a=0;a<9;a++)await e.tx([y.STAGE_GREY_COL,a,...t[a]]);await e.tx([y.DRAW_GREY_COL_BUFFER])})}async version(){let e={};return await this.portMutex.acquire(async t=>{await t.tx([...r,y.VERSION]);const a=await t.rx(32);e.major=a[0],e.minor=a[1]>>4,e.patch=15&a[1],e.preRelease=1==a[2]}),e}};class A extends _{async bootloader(){return super.bootloader()}async connect(){const e=await u();e?.connected&&(await w(e),await e.open({baudRate:115200}),this.portMutex=new h(new p(e)))}async draw(e){switch(this.#s){case BitDepth.GRAY_8BIT:super.drawGrayscale(e);break;case BitDepth.MONO_1BIT:super.draw(e)}}async verifyFirmware(){try{const e=await super.version();return e&&null!=e.major&&null!=e.minor&&null!=e.patch&&null!=e.preRelease}catch{return!1}}async version(){return super.version()}#s}const m=Object.freeze({NOOP:0,ANIMATION_DIAMOND:100,ANIMATION_FIRE:98,ANIMATION_FIREPLACE:102,ANIMATION_GEAR:103,ANIMATION_RING:114,ANIMATION_STARTUP:97,ANIMATION_STARTUP_ONCE:65,BOOTLOADER:101,DRAW_PWM:109,DRAW_PWM_BLOCKING:77,DRAW_SCALE:110,DRAW_SCALE_BLOCKING:78,FLUSH_CMD_QUEUE:99,TEST_PATTERN:116,SET_CONST_PWM:119,SET_CONST_SCALE:115,SET_PX_PWM:112,SET_PX_SCALE:113,IDENTITY_STRING:127}),
|
|
1
|
+
const e=9,t=34,a=12972,r=[50,172],i=32,n=[0,32],s=Object.freeze([0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,5,5,5,5,6,6,6,6,6,7,7,7,7,8,8,8,9,9,9,10,10,10,11,11,11,12,12,12,13,13,14,14,14,15,15,16,16,17,17,17,18,18,19,19,20,20,21,22,22,23,23,24,24,25,26,26,27,27,28,29,29,30,31,32,32,33,34,34,35,36,37,38,38,39,40,41,42,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,66,67,68,69,70,71,73,74,75,76,78,79,80,82,83,84,86,87,88,90,91,93,94,96,97,99,100,102,103,105,106,108,110,111,113,115,116,118,120,121,123,125,127,128,130,132,134,136,138,140,141,143,145,147,149,151,153,155,157,159,161,164,166,168,170,172,174,177,179,181,183,186,188,190,193,195,197,200,202,205,207,210,212,215,217,220,222,225,228,230,233,236,238,241,244,247,249,252,255]),o=[],c=[{usbVendorId:a,usbProductId:32}];class l extends Error{constructor(){super("User cancelled port selection."),this.name=this.constructor.name,this.date=new Date}}class d extends Error{constructor(){super("Selected port already in use."),this.name=this.constructor.name,this.date=new Date}}async function u(){try{if(o&&o.length>0)return o.pop();if(o.push(...await navigator.serial.getPorts()),o&&o.length>0)return o.pop();if(o.push(...await navigator.serial.requestPort({filters:c})),o&&o.length>0)return o.pop()}catch(e){throw"NotFoundError"==e.name?new l:"InvalidStateError"==e.name?new d:e}}async function w(e){try{await e.close()}catch(e){if("InvalidStateError"!=e.name&&"Failed to execute 'close' on 'SerialPort': The port is already closed."!=e.message)throw e}}class h{constructor(e){this.#e=`port-mutex-${Math.random().toString()}`,this.#t=new Map,this.#a=e}async acquire(e){const t=new Error("created bad cb").stack;await this.#r(async()=>{try{await e(this.#a)}catch(e){console.error("Error occured in anonymous callback."),console.error("Original error:",e),console.error("--- This callback was created at ---\n",t)}})}async acquireIdempotent(e,t){const a=new Error("created bad cb").stack;this.#t.has(e)&&console.info(`"${e}" request coalesced.`),this.#t.set(e,async()=>{try{await t(this.#a)}catch(e){console.error("Error occured in anonymous callback."),console.error("Original error:",e),console.error("--- This callback was created at ---\n",a)}}),await this.#r(()=>this.#i(e))}async#r(e){return navigator.locks.request(this.#e,e)}async#i(e){if(this.#t.has(e)){const t=this.#t.get(e);this.#t.delete(e),await t()}}#e;#t;#a}class p{constructor(e){this.#n=e}async rx(e,t=3e3){if(null===this.#n)throw new Error("attempted RX before port initialization.");if(this.#n.readable.locked)throw new Error("attempted RX while port locked.");const a=[],r=this.#n.readable.getReader(),i=setTimeout(()=>r.cancel(),t);try{for(;a.length<e;){const{value:e,done:t}=await r.read();if(a.push(...e??[]),t||!e)break}}finally{clearTimeout(i),r.releaseLock()}return a}async tx(e){if(null===this.#n)throw new Error("attempted TX before port initialization.");if(this.#n.writable.locked)throw new Error("attempted TX while port locked.");const t=this.#n.writable.getWriter();try{await t.write(new Uint8Array(e))}finally{await t.close()}}#n}const y=Object.freeze({ANIMATE:4,BRIGHTNESS:0,BOOTLOADER:2,DRAW:6,DRAW_GREY_COL_BUFFER:8,GAME_CTRL:17,GAME_STATUS:18,PANIC:5,PATTERN:1,SLEEP:3,STAGE_GREY_COL:7,START_GAME:16,VERSION:32});let _=class{constructor(e=null){this.portMutex=e}async bootloader(){await this.portMutex.acquire(async e=>{await e.tx([...r,y.BOOTLOADER])})}async draw(e){let t=0,a=new Uint8Array(39).fill(0);for(let r=0;r<34;r++)for(let i=0;i<9;i++)e[r][i]&&(a[t>>3]|=1<<t%8),t++;await this.portMutex.acquireIdempotent("drawMatrix",async e=>{await e.tx([...r,y.DRAW,...a])})}async drawGrayscale(e){const t=Array.from({length:9},(t,a)=>new Array({length:34},(t,r)=>GAMMA[Math.floor(255*(e[r][a]??0))]));await this.portMutex.acquireIdempotent("drawMatrix",async e=>{for(let a=0;a<9;a++)await e.tx([y.STAGE_GREY_COL,a,...t[a]]);await e.tx([y.DRAW_GREY_COL_BUFFER])})}async version(){let e={};return await this.portMutex.acquire(async t=>{await t.tx([...r,y.VERSION]);const a=await t.rx(32);e.major=a[0],e.minor=a[1]>>4,e.patch=15&a[1],e.preRelease=1==a[2]}),e}};class A extends _{async bootloader(){return super.bootloader()}async connect(){const e=await u();e?.connected&&(await w(e),await e.open({baudRate:115200}),this.portMutex=new h(new p(e)))}async draw(e){switch(this.#s){case BitDepth.GRAY_8BIT:super.drawGrayscale(e);break;case BitDepth.MONO_1BIT:super.draw(e)}}async verifyFirmware(){try{const e=await super.version();return e&&null!=e.major&&null!=e.minor&&null!=e.patch&&null!=e.preRelease}catch{return!1}}async version(){return super.version()}#s}const m=Object.freeze({NOOP:0,ANIMATION_DIAMOND:100,ANIMATION_FIRE:98,ANIMATION_FIREPLACE:102,ANIMATION_GEAR:103,ANIMATION_RING:114,ANIMATION_STARTUP:97,ANIMATION_STARTUP_ONCE:65,BOOTLOADER:101,DRAW_PWM:109,DRAW_PWM_BLOCKING:77,DRAW_SCALE:110,DRAW_SCALE_BLOCKING:78,FLUSH_CMD_QUEUE:99,TEST_PATTERN:116,SET_CONST_PWM:119,SET_CONST_SCALE:115,SET_PX_PWM:112,SET_PX_SCALE:113,IDENTITY_STRING:127}),f=/^Sig\sFW\sLED\sMatrix\sFW\sV(\d+)\.(\d+)$/;class E{constructor(e=null){this.portMutex=e}async bootloader(){await this.portMutex.acquire(async e=>{await e.tx([m.BOOTLOADER])})}async identityString(){let e=null;return await this.portMutex.acquire(async t=>{await t.tx([m.IDENTITY_STRING]),e=await t.rx(25)}),String.fromCharCode(...e)}async setPixelPwm(e,t,a){await this.portMutex.acquire(async r=>{await r.tx([m.SET_PX_PWM,t,e,a])})}async setGlobalPwm(e){await this.portMutex.acquire(async t=>{await t.tx([m.SET_CONST_PWM,e])})}async setMatrixPwm(e){await this.portMutex.acquireIdempotent("drawMatrix",async t=>{await t.tx([m.DRAW_PWM].concat(e.flat().map(e=>s[Math.floor(255*(e??0))])))})}async setPixelAnalog(e,t,a){await this.portMutex.acquire(async r=>{await r.tx([m.SET_PX_SCALE,t,e,a])})}async setGlobalAnalog(e){await this.portMutex.acquire(async t=>{await t.tx([m.SET_CONST_SCALE,e])})}async setMatrixAnalog(e){await this.portMutex.acquireIdempotent("drawMatrix",async t=>{await t.tx([m.DRAW_SCALE].concat(e.flat().map(e=>s[Math.floor(255*(e??0))])))})}}class g extends E{async bootloader(){await super.bootloader()}async connect(){const e=await u();e?.connected&&(await w(e),await e.open({baudRate:115200}),this.portMutex=new h(new p(e)))}async draw(e){this.#o||(await super.setGlobalAnalog(32),this.#o=!0),await super.setMatrixPwm(e)}async verifyFirmware(){return null!=await this.version()}async version(){const e=(await super.identityString()).match(f);return e&&3==e.length?{major:e[1],minor:e[2]}:null}#o}const T=[],b=[{vendorId:a,productId:32}];class x extends Error{constructor(){super("User cancelled device selection."),this.name=this.constructor.name,this.date=new Date}}class M{constructor(e){this.#c=e}async send(e,t){if(t.length<e.bytes)t=function(e,t,a=0){return e.concat(new Array(t-e.length).fill(a))}(t,e.bytes);else if(t.length>e.bytes)throw new Error("Unable to send report: too many bytes");const a=new Uint8Array(t).buffer;e.feature?await this.#c.sendFeatureReport(e.id,a):await this.#c.sendReport(e.id,a)}async request(e){let t=[];if(!e.feature)throw new Error("Invalid operation");if(t=await this.#c.receiveFeatureReport(e.id),t.byteLength!=e.bytes){const a=e.bytes,r=t.byteLength;console.error(`reply length=${r} (expected ${a})`)}return t}#c}const v={id:1,bytes:307,feature:!0},I={id:2,bytes:16,feature:!0},S={id:4,bytes:306,feature:!0},O=0,R=1,N=2,D=3,P=5,U=0;class L{constructor(e=null){this.device=e}async info(){const e=await this.device.request(v);return{sleep_pin:e.getUint8(1),dip1_pin:e.getUint8(2),intb_pin:e.getUint8(3),state_flags:e.getUint8(4),id_reg:e.getUint8(5),config_reg:e.getUint8(6),global_brightness:e.getUint8(7),display_width:e.getUint8(8),display_height:e.getUint8(9),timeout_ms:e.getUint32(10),version_major:e.getUint8(14),version_minor:e.getUint8(15)}}async wake(){await this.device.send(I,[R,!1])}async sleep(){await this.device.send(I,[R,!0])}async disableSleep(){await this.device.send(I,[D,255,255,255,255])}async disableDeepSleep(){await this.device.send(I,[N,1])}async disableSleepTimer(){await this.device.send(I,[D,0,0,0,0])}async enableDeepSleep(){await this.device.send(I,[N,0])}async enableSleepTimer(e){const t=new DataView(new ArrayBuffer(4));t.setInt32(0,e,!1),await this.device.send(I,[D,t.getUint8(0),t.getUint8(1),t.getUint8(2),t.getUint8(3)])}async reboot(e){await this.device.send(I,[O,e])}async drawMatrix(e){await this.device.send(S,e.flat().map(e=>s[Math.floor(255*(e??0))]))}async drawPixel(e,t,a){await this.device.send(I,[P,t,e,a])}async drawLine({r1:e,c1:t},{r2:a,c2:r},i){await this.device.send(I,[P,e,t,a,r,i])}device}class C extends L{async bootloader(){await super.reboot(U)}async connect(){const e=await async function(){if(T&&T.length>0)return T.pop();if(T.push(...await navigator.hid.getDevices()),T&&T.length>0)return T.pop();if(T.push(...await navigator.hid.requestDevice({filters:b})),T&&T.length>0)return T.pop();throw new x}();e&&(await e.open(),this.device=new M(e))}async draw(e){await super.drawMatrix(e)}async verifyFirmware(){try{const e=await super.info();return 34==e.display_height&&9==e.display_width}catch{return!1}}async version(){const e=await super.info();return null!=e.version_major&&null!=e.version_minor&&(e.version_major>0||e.version_minor>0)?{major:e.version_major,minor:e.version_minor}:{major:1,minor:0}}}class G{static async detectSerial(){const e=new A,t=new g;return await e.connect(),await e.verifyFirmware()?e:(await t.connect(),await t.verifyFirmware()?t:null)}static async detectHID(){const e=new C;return await e.connect(),await e.verifyFirmware()?e:null}}export{A as DefaultController,s as GAMMA,t as HEIGHT,G as HardwareControllerFactory,i as PID,n as PID_ARR,g as SigrootController,C as SparkleController,a as VID,r as VID_ARR,e as WIDTH};
|
|
2
2
|
//# sourceMappingURL=led-matrix-controllers.browser.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"led-matrix-controllers.browser.mjs","sources":["../src/hardware-constants.js","../src/web-serial/port.js","../src/web-serial/PortMutex.js","../src/web-serial/PortOperations.js","../src/supported-firmware/FrameworkComputer/inputmodule-rs/commands.js","../src/supported-firmware/FrameworkComputer/inputmodule-rs/CommandAbstractionLayer.js","../src/supported-firmware/FrameworkComputer/inputmodule-rs/DefaultController.js","../src/supported-firmware/sigroot/FW_LED_Matrix_Firmware/commands.js","../src/supported-firmware/sigroot/FW_LED_Matrix_Firmware/CommandAbstractionLayer.js","../src/supported-firmware/sigroot/FW_LED_Matrix_Firmware/SigrootController.js","../src/web-hid/device.js","../src/web-hid/HIDOperations.js","../src/web-hid/util.js","../src/supported-firmware/vddCore/sparkle-fw16/reports.js","../src/supported-firmware/vddCore/sparkle-fw16/ReportAbstractionLayer.js","../src/supported-firmware/vddCore/sparkle-fw16/SparkleController.js","../src/HardwareControllerFactory.js"],"sourcesContent":["export const WIDTH = 9;\r\nexport const HEIGHT = 34;\r\nexport const VID = 0x32AC;\r\nexport const VID_ARR = [0x32, 0xAC];\r\nexport const PID = 0x0020;\r\nexport const PID_ARR = [0x00, 0x20];\r\n\r\nexport const GAMMA = Object.freeze([\r\n 0, 0, 0, 0, 0, 0, 0, 1, \r\n 1, 1, 1, 1, 1, 1, 1, 1, \r\n 1, 1, 1, 1, 1, 1, 1, 1, \r\n 1, 1, 1, 1, 1, 1, 1, 1, \r\n 1, 1, 1, 2, 2, 2, 2, 2, \r\n 2, 2, 2, 2, 3, 3, 3, 3, \r\n 3, 3, 3, 4, 4, 4, 4, 4, \r\n 4, 5, 5, 5, 5, 6, 6, 6, \r\n 6, 6, 7, 7, 7, 7, 8, 8, \r\n 8, 9, 9, 9, 10, 10, 10, 11, \r\n 11, 11, 12, 12, 12, 13, 13, 14, \r\n 14, 14, 15, 15, 16, 16, 17, 17, \r\n 17, 18, 18, 19, 19, 20, 20, 21, \r\n 22, 22, 23, 23, 24, 24, 25, 26, \r\n 26, 27, 27, 28, 29, 29, 30, 31, \r\n 32, 32, 33, 34, 34, 35, 36, 37, \r\n 38, 38, 39, 40, 41, 42, 42, 43, \r\n 44, 45, 46, 47, 48, 49, 50, 51, \r\n 52, 53, 54, 55, 56, 57, 58, 59, \r\n 60, 61, 62, 63, 64, 66, 67, 68, \r\n 69, 70, 71, 73, 74, 75, 76, 78, \r\n 79, 80, 82, 83, 84, 86, 87, 88, \r\n 90, 91, 93, 94, 96, 97, 99, 100, \r\n 102, 103, 105, 106, 108, 110, 111, 113, \r\n 115, 116, 118, 120, 121, 123, 125, 127, \r\n 128, 130, 132, 134, 136, 138, 140, 141, \r\n 143, 145, 147, 149, 151, 153, 155, 157, \r\n 159, 161, 164, 166, 168, 170, 172, 174, \r\n 177, 179, 181, 183, 186, 188, 190, 193, \r\n 195, 197, 200, 202, 205, 207, 210, 212, \r\n 215, 217, 220, 222, 225, 228, 230, 233, \r\n 236, 238, 241, 244, 247, 249, 252, 255\r\n]);\r\n","import { PID, VID } from '../hardware-constants.js';\r\n\r\nconst extraPorts = [];\r\n\r\nconst filters = [\r\n {\r\n usbVendorId: VID,\r\n usbProductId: PID,\r\n }\r\n];\r\n\r\nexport class PortSelectionCancelled extends Error {\r\n constructor() {\r\n super('User cancelled port selection.');\r\n this.name = this.constructor.name;\r\n this.date = new Date();\r\n }\r\n}\r\n\r\nexport class PortUnavailable extends Error {\r\n constructor() {\r\n super('Selected port already in use.');\r\n this.name = this.constructor.name;\r\n this.date = new Date();\r\n }\r\n}\r\n\r\nexport async function getPort() {\r\n try {\r\n if (extraPorts && extraPorts.length > 0) {\r\n return extraPorts.pop();\r\n }\r\n\r\n extraPorts.push(...await navigator.serial.getPorts());\r\n if (extraPorts && extraPorts.length > 0) {\r\n return extraPorts.pop();\r\n }\r\n\r\n extraPorts.push(...await navigator.serial.requestPort({ filters }));\r\n if (extraPorts && extraPorts.length > 0) {\r\n return extraPorts.pop();\r\n }\r\n\r\n } catch (e) {\r\n if (e.name == 'NotFoundError') {\r\n throw new PortSelectionCancelled();\r\n } else if (e.name == 'InvalidStateError') {\r\n throw new PortUnavailable();\r\n } else {\r\n throw e;\r\n }\r\n }\r\n}\r\n\r\nexport async function close(port) {\r\n try {\r\n await port.close();\r\n } catch(e) {\r\n if (e.name != 'InvalidStateError') {\r\n if (e.message != \"Failed to execute 'close' on 'SerialPort': The port is already closed.\") {\r\n throw e;\r\n }\r\n }\r\n }\r\n}\r\n","export class PortMutex {\r\n constructor(portOperations) {\r\n this.#lockName = `port-mutex-${Math.random().toString()}`;\r\n this.#deduper = new Map();\r\n this.#portOps = portOperations;\r\n }\r\n\r\n async acquire(fn) {\r\n const trace = new Error('created bad cb').stack;\r\n\r\n await this.#enqueue(async () => {\r\n try {\r\n await fn(this.#portOps);\r\n } catch (e) {\r\n console.error('Error occured in anonymous callback.');\r\n console.error('Original error:', e);\r\n console.error('--- This callback was created at ---\\n', trace);\r\n }\r\n });\r\n }\r\n\r\n async acquireIdempotent(key, fn) {\r\n const trace = new Error('created bad cb').stack;\r\n\r\n if (this.#deduper.has(key)) {\r\n console.info(`\"${key}\" request coalesced.`);\r\n }\r\n\r\n this.#deduper.set(key, async () => {\r\n try {\r\n await fn(this.#portOps);\r\n } catch (e) {\r\n console.error('Error occured in anonymous callback.');\r\n console.error('Original error:', e);\r\n console.error('--- This callback was created at ---\\n', trace);\r\n }\r\n });\r\n\r\n await this.#enqueue(() => this.#execDedupedOp(key));\r\n }\r\n\r\n async #enqueue(fn) {\r\n // `navigator.locks` maintains queue and provides mutual exclusion.\r\n return navigator.locks.request(this.#lockName, fn);\r\n }\r\n\r\n async #execDedupedOp(key) {\r\n if (this.#deduper.has(key)) {\r\n const fn = this.#deduper.get(key);\r\n this.#deduper.delete(key);\r\n await fn();\r\n }\r\n }\r\n\r\n #lockName;\r\n #deduper;\r\n #portOps;\r\n}\r\n","export class PortOperations {\r\n constructor(port) {\r\n this.#port = port;\r\n }\r\n\r\n async rx(length, timeout=3000) {\r\n if (this.#port === null) {\r\n throw new Error('attempted RX before port initialization.');\r\n }\r\n\r\n /*\r\n * ReadableStream's built-in locking mechanism cannot be awaited or otherwise\r\n * asynchronously acquired. A PortMutex must be used.\r\n */\r\n if (this.#port.readable.locked) {\r\n throw new Error('attempted RX while port locked.');\r\n }\r\n\r\n const response = [];\r\n const reader = this.#port.readable.getReader();\r\n const timeoutHandle = setTimeout(() => reader.cancel(), timeout);\r\n\r\n try {\r\n // Response may be divided across multiple reads\r\n while (response.length < length) {\r\n const { value, done } = await reader.read();\r\n response.push(...(value ?? []));\r\n if (done || !value) break;\r\n }\r\n } finally {\r\n clearTimeout(timeoutHandle);\r\n reader.releaseLock();\r\n }\r\n\r\n return response;\r\n }\r\n\r\n async tx(buffer) {\r\n if (this.#port === null) {\r\n throw new Error('attempted TX before port initialization.');\r\n }\r\n \r\n /*\r\n * WritableStream's built-in locking mechanism cannot be awaited or otherwise\r\n * asynchronously acquired. A PortMutex must be used.\r\n */\r\n if (this.#port.writable.locked) {\r\n throw new Error('attempted TX while port locked.');\r\n }\r\n\r\n const writer = this.#port.writable.getWriter();\r\n\r\n try {\r\n await writer.write(new Uint8Array(buffer));\r\n } finally {\r\n /* \r\n * The writer must be completely torn down between every single write.\r\n * Many parsers can't handle delayed flushing and write coalescing.\r\n * Command sequences will fail if `releaseLock()` is used here.\r\n */\r\n await writer.close();\r\n }\r\n }\r\n\r\n #port;\r\n}\r\n","// All replies to all commands are 32 bytes\r\nexport const RX_PACKET_SZ = 32;\r\n\r\nexport const Command = Object.freeze({\r\n ANIMATE: 0x04,\r\n BRIGHTNESS: 0x00,\r\n BOOTLOADER: 0x02,\r\n DRAW: 0x06,\r\n DRAW_GREY_COL_BUFFER: 0x08,\r\n GAME_CTRL: 0x11,\r\n GAME_STATUS: 0x12,\r\n PANIC: 0x05,\r\n PATTERN: 0x01,\r\n SLEEP: 0x03,\r\n STAGE_GREY_COL: 0x07,\r\n START_GAME: 0x10,\r\n VERSION: 0x20,\r\n});\r\n\r\n// Used with Command.PATTERN\r\nexport const Pattern = Object.freeze({\r\n DISPLAY_LOTUS_HORIZONTAL: 0x03,\r\n DISPLAY_LOTUS_VERTICAL: 0x07,\r\n DISPLAY_PANIC: 0x06,\r\n DOUBLE_GRADIENT: 0x02,\r\n FULL_BRIGHTNESS: 0x05,\r\n GRADIENT: 0x01,\r\n PERCENTAGE: 0x00,\r\n ZIG_ZAG: 0x04,\r\n});\r\n\r\n// DRAW or DRAW_GREY_COL_BUFFER\r\nexport const BitDepth = Object.freeze({\r\n GRAY_8BIT: '8-bit',\r\n MONO_1BIT: '1-bit',\r\n})\r\n","import { HEIGHT, VID_ARR, WIDTH } from '../../../hardware-constants.js';\r\nimport { Command, RX_PACKET_SZ } from './commands.js';\r\n\r\nexport class CommandAbstractionLayer {\r\n constructor(portMutex = null) {\r\n this.portMutex = portMutex;\r\n }\r\n\r\n async bootloader() {\r\n await this.portMutex.acquire(async p => {\r\n await p.tx([...VID_ARR, Command.BOOTLOADER]);\r\n });\r\n }\r\n\r\n async draw(matrix) {\r\n let index = 0;\r\n let output = new Uint8Array(39).fill(0);\r\n\r\n // Pack cells into bits\r\n for (let r = 0; r < HEIGHT; r++) {\r\n for (let c = 0; c < WIDTH; c++) {\r\n if (matrix[r][c]) {\r\n output[index >> 3] |= 1 << index % 8;\r\n }\r\n index++;\r\n }\r\n }\r\n\r\n await this.portMutex.acquireIdempotent(\r\n 'drawMatrix', \r\n async p => {\r\n await p.tx([...VID_ARR, Command.DRAW, ...output]);\r\n }\r\n );\r\n }\r\n\r\n async drawGrayscale(matrix) {\r\n // Transpose & Gamma Correction\r\n const buffers = Array.from(\r\n { length: WIDTH }, \r\n (_, c) => new Array(\r\n { length: HEIGHT }, \r\n (_, r) => GAMMA[Math.floor((matrix[r][c] ?? 0) * 255)]\r\n )\r\n );\r\n\r\n // Only execute the most recent call \r\n await this.portMutex.acquireIdempotent(\r\n 'drawMatrix', \r\n async p => {\r\n for (let i = 0; i < WIDTH; i++) {\r\n await p.tx([Command.STAGE_GREY_COL, i, ...buffers[i]]);\r\n }\r\n await p.tx([Command.DRAW_GREY_COL_BUFFER]);\r\n }\r\n );\r\n }\r\n\r\n async version() {\r\n let ver = {};\r\n\r\n await this.portMutex.acquire(async p => {\r\n await p.tx([...VID_ARR, Command.VERSION]);\r\n const response = await p.rx(RX_PACKET_SZ);\r\n\r\n // MMMMMMMM mmmmPPPP 0000000p\r\n ver.major = response[0];\r\n ver.minor = response[1] >> 4;\r\n ver.patch = response[1] & 0x0F;\r\n ver.preRelease = response[2] == 1;\r\n });\r\n\r\n return ver;\r\n }\r\n}\r\n","import { close, getPort } from '../../../web-serial/port.js';\r\nimport { PortMutex } from '../../../web-serial/PortMutex.js';\r\nimport { PortOperations } from '../../../web-serial/PortOperations.js';\r\nimport { CommandAbstractionLayer } from './CommandAbstractionLayer.js';\r\n\r\nexport class DefaultController extends CommandAbstractionLayer {\r\n async bootloader() {\r\n return super.bootloader();\r\n }\r\n\r\n async connect() {\r\n const port = await getPort();\r\n\r\n if (port?.connected) {\r\n await close(port);\r\n await port.open({ baudRate: 115200 });\r\n this.portMutex = new PortMutex(new PortOperations(port));\r\n }\r\n }\r\n\r\n async draw(matrix) {\r\n switch (this.#bitDepth) {\r\n\r\n case BitDepth.GRAY_8BIT:\r\n super.drawGrayscale(matrix);\r\n break;\r\n\r\n case BitDepth.MONO_1BIT:\r\n super.draw(matrix);\r\n break;\r\n }\r\n }\r\n\r\n async verifyFirmware() {\r\n try {\r\n const version = await super.version();\r\n\r\n return version\r\n && version.major != undefined\r\n && version.minor != undefined\r\n && version.patch != undefined\r\n && version.preRelease != undefined;\r\n \r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n async version() {\r\n return super.version();\r\n }\r\n\r\n #bitDepth;\r\n}\r\n","export const Command = Object.freeze({\r\n /* 000 */ NOOP: 0x00,\r\n /* 'd' */ ANIMATION_DIAMOND: 0x64,\r\n /* 'b' */ ANIMATION_FIRE: 0x62,\r\n /* 'f' */ ANIMATION_FIREPLACE: 0x66,\r\n /* 'g' */ ANIMATION_GEAR: 0x67,\r\n /* 'r' */ ANIMATION_RING: 0x72,\r\n /* 'a' */ ANIMATION_STARTUP: 0x61,\r\n /* 'A' */ ANIMATION_STARTUP_ONCE: 0x41,\r\n /* 'e' */ BOOTLOADER: 0x65,\r\n /* 'm' */ DRAW_PWM: 0x6D,\r\n /* 'M' */ DRAW_PWM_BLOCKING: 0x4D,\r\n /* 'n' */ DRAW_SCALE: 0x6E,\r\n /* 'N' */ DRAW_SCALE_BLOCKING: 0x4E,\r\n /* 'c' */ FLUSH_CMD_QUEUE: 0x63,\r\n /* 't' */ TEST_PATTERN: 0x74,\r\n /* 'w' */ SET_CONST_PWM: 0x77,\r\n /* 's' */ SET_CONST_SCALE: 0x73,\r\n /* 'p' */ SET_PX_PWM: 0x70,\r\n /* 'q' */ SET_PX_SCALE: 0x71,\r\n /* 127 */ IDENTITY_STRING: 0x7F,\r\n});\r\n\r\nexport const IDENTITY_STR_LEN = 25;\r\n\r\nexport const IDENTITY_STR_REGEX = /^Sig\\sFW\\sLED\\sMatrix\\sFW\\sV(\\d+)\\.(\\d+)$/;\r\n","import { GAMMA } from '../../../hardware-constants.js';\r\nimport { Command, IDENTITY_STR_LEN } from './commands.js';\r\n\r\nexport class CommandAbstractionLayer {\r\n constructor(portMutex = null) {\r\n this.portMutex = portMutex;\r\n }\r\n\r\n async bootloader() {\r\n await this.portMutex.acquire(async p => {\r\n await p.tx([Command.BOOTLOADER]);\r\n });\r\n }\r\n\r\n async identityString() {\r\n let ident = null;\r\n\r\n await this.portMutex.acquire(async p => {\r\n await p.tx([Command.IDENTITY_STRING]);\r\n ident = await p.rx(IDENTITY_STR_LEN);\r\n });\r\n\r\n return String.fromCharCode(...ident);\r\n }\r\n\r\n async setPixelPwm(r, c, brightness) {\r\n await this.portMutex.acquire(\r\n async p => {\r\n await p.tx([Command.SET_PX_PWM, c, r, brightness]);\r\n }\r\n );\r\n }\r\n\r\n async setGlobalPwm(brightness) {\r\n await this.portMutex.acquire(\r\n async p => {\r\n await p.tx([Command.SET_CONST_PWM, brightness]);\r\n }\r\n );\r\n }\r\n\r\n async setMatrixPwm(matrix) {\r\n // Only execute the most recent call \r\n await this.portMutex.acquireIdempotent(\r\n 'drawMatrix', \r\n async p => {\r\n await p.tx(\r\n [Command.DRAW_PWM].concat(\r\n matrix.flat().map(v => \r\n GAMMA[Math.floor((v ?? 0) * 255)]\r\n )\r\n )\r\n );\r\n }\r\n );\r\n }\r\n\r\n async setPixelAnalog(r, c, brightness) {\r\n await this.portMutex.acquire(\r\n async p => {\r\n await p.tx([Command.SET_PX_SCALE, c, r, brightness]);\r\n }\r\n );\r\n }\r\n\r\n async setGlobalAnalog(brightness) {\r\n await this.portMutex.acquire(\r\n async p => {\r\n await p.tx([Command.SET_CONST_SCALE, brightness]);\r\n }\r\n );\r\n }\r\n\r\n async setMatrixAnalog(matrix) {\r\n // Only execute the most recent call \r\n await this.portMutex.acquireIdempotent(\r\n 'drawMatrix', \r\n async p => {\r\n await p.tx(\r\n [Command.DRAW_SCALE].concat(\r\n matrix.flat().map(v => \r\n GAMMA[Math.floor((v ?? 0) * 255)]\r\n )\r\n )\r\n );\r\n }\r\n );\r\n }\r\n}\r\n","import { close, getPort } from '../../../web-serial/port.js';\r\nimport { PortMutex } from '../../../web-serial/PortMutex.js';\r\nimport { PortOperations } from '../../../web-serial/PortOperations.js';\r\nimport { CommandAbstractionLayer } from './CommandAbstractionLayer.js';\r\nimport { IDENTITY_STR_REGEX } from './commands.js';\r\n\r\nexport class SigrootController extends CommandAbstractionLayer {\r\n async bootloader() {\r\n await super.bootloader();\r\n }\r\n\r\n async connect() {\r\n const port = await getPort();\r\n\r\n if (port?.connected) {\r\n await close(port);\r\n await port.open({ baudRate: 115200 });\r\n this.portMutex = new PortMutex(new PortOperations(port));\r\n }\r\n }\r\n\r\n async draw(matrix) {\r\n if (!this.#scaleInitialized) {\r\n await super.setGlobalAnalog(0x20);\r\n this.#scaleInitialized = true;\r\n }\r\n\r\n await super.setMatrixPwm(matrix);\r\n }\r\n\r\n async verifyFirmware() { \r\n return await this.version() != null;\r\n }\r\n\r\n async version() {\r\n const ident = await super.identityString();\r\n const match = ident.match(IDENTITY_STR_REGEX);\r\n\r\n if (match && match.length == 3) {\r\n return {\r\n major: match[1],\r\n minor: match[2]\r\n }\r\n } else {\r\n return null;\r\n }\r\n }\r\n\r\n #scaleInitialized;\r\n}\r\n","import { PID, VID } from '../hardware-constants.js';\r\n\r\nconst extraDevices = [];\r\n\r\nconst filters = [\r\n {\r\n vendorId: VID,\r\n productId: PID,\r\n }\r\n];\r\n\r\nexport class DeviceSelectionCancelled extends Error {\r\n constructor() {\r\n super('User cancelled device selection.');\r\n this.name = this.constructor.name;\r\n this.date = new Date();\r\n }\r\n}\r\n\r\nexport async function getDevice() {\r\n if (extraDevices && extraDevices.length > 0) {\r\n return extraDevices.pop();\r\n }\r\n\r\n extraDevices.push(...(await navigator.hid.getDevices()));\r\n if (extraDevices && extraDevices.length > 0) {\r\n return extraDevices.pop();\r\n }\r\n\r\n extraDevices.push(...(await navigator.hid.requestDevice({ filters })));\r\n if (extraDevices && extraDevices.length > 0) {\r\n return extraDevices.pop();\r\n }\r\n\r\n throw new DeviceSelectionCancelled();\r\n}\r\n","import { pad } from './util.js';\r\n\r\nexport class HIDOperations {\r\n constructor(device) {\r\n this.#device = device;\r\n }\r\n\r\n async send(report, data) {\r\n if (data.length < report.bytes) {\r\n data = pad(data, report.bytes);\r\n } else if (data.length > report.bytes) {\r\n throw new Error('Unable to send report: too many bytes');\r\n }\r\n\r\n const buffer = new Uint8Array(data).buffer;\r\n\r\n if (report.feature) {\r\n await this.#device.sendFeatureReport(report.id, buffer);\r\n } else {\r\n await this.#device.sendReport(report.id, buffer);\r\n }\r\n }\r\n\r\n async request(report) {\r\n let reply = [];\r\n\r\n if (report.feature) {\r\n reply = await this.#device.receiveFeatureReport(report.id);\r\n } else {\r\n /* \r\n * HID input reports are used for unprompted data.\r\n * See WebHID `HIDInputReportEvent`\r\n */\r\n throw new Error('Invalid operation');\r\n }\r\n\r\n if (reply.byteLength != report.bytes) {\r\n const exp = report.bytes;\r\n const act = reply.byteLength;\r\n console.error(`reply length=${act} (expected ${exp})`);\r\n }\r\n\r\n return reply;\r\n }\r\n\r\n #device;\r\n}\r\n","export function pad(arr, len, val=0x00) {\r\n return arr.concat(new Array(len - arr.length).fill(val));\r\n}\r\n","export const Reports = {\r\n GLITTER_DEVICE_INFO: {\r\n id: 0x01,\r\n bytes: 307,\r\n feature: true,\r\n },\r\n GLITTER_BASIC_CMD: {\r\n id: 0x02,\r\n bytes: 16,\r\n feature: true,\r\n },\r\n GLITTER_GRID_PWM_CNTL: {\r\n id: 0x03,\r\n bytes: 306,\r\n feature: true,\r\n },\r\n GLITTER_GRID_PWM_CNTL: {\r\n id: 0x04,\r\n bytes: 306,\r\n feature: true,\r\n }\r\n}\r\n\r\nexport const Commands = {\r\n GLITTER_CMD_REBOOT: 0x00,\r\n GLITTER_CMD_SLEEP: 0x01,\r\n GLITTER_CMD_WAKE_ON_COMMAND: 0x02,\r\n GLITTER_CMD_SET_SLEEP_TIMEOUT: 0x03,\r\n GLITTER_CMD_SET_GLOBAL_BRIGHTNESS: 0x04,\r\n GLITTER_CMD_DRAW_PIXEL: 0x05,\r\n GLITTER_CMD_DRAW_LINE: 0x06\r\n}\r\n\r\nexport const BootMode = {\r\n BOOTSEL: 0x00,\r\n NORMAL: 0x01,\r\n}\r\n","import { GAMMA } from '../../../hardware-constants.js';\r\nimport { Commands, Reports } from './reports.js';\r\n\r\nexport class ReportAbstractionLayer {\r\n constructor(device = null) {\r\n this.device = device;\r\n }\r\n\r\n async info() {\r\n const infoRaw = await this.device.request(Reports.GLITTER_DEVICE_INFO);\r\n\r\n return {\r\n sleep_pin: infoRaw.getUint8(1),\r\n dip1_pin: infoRaw.getUint8(2),\r\n intb_pin: infoRaw.getUint8(3),\r\n state_flags: infoRaw.getUint8(4),\r\n id_reg: infoRaw.getUint8(5),\r\n config_reg: infoRaw.getUint8(6),\r\n global_brightness: infoRaw.getUint8(7),\r\n display_width: infoRaw.getUint8(8),\r\n display_height: infoRaw.getUint8(9),\r\n timeout_ms: infoRaw.getUint32(10),\r\n version_major: infoRaw.getUint8(14),\r\n version_minor: infoRaw.getUint8(15),\r\n };\r\n }\r\n\r\n async wake() {\r\n await this.device.send(\r\n Reports.GLITTER_BASIC_CMD,\r\n [Commands.GLITTER_CMD_SLEEP, false]\r\n );\r\n }\r\n\r\n async sleep() {\r\n await this.device.send(\r\n Reports.GLITTER_BASIC_CMD,\r\n [Commands.GLITTER_CMD_SLEEP, true]\r\n );\r\n }\r\n\r\n async disableSleep() {\r\n await this.device.send(\r\n Reports.GLITTER_BASIC_CMD, \r\n [Commands.GLITTER_CMD_SET_SLEEP_TIMEOUT, 0xff, 0xff, 0xff, 0xff]\r\n );\r\n }\r\n\r\n async disableDeepSleep() {\r\n await this.device.send(\r\n Reports.GLITTER_BASIC_CMD, \r\n [Commands.GLITTER_CMD_WAKE_ON_COMMAND, 0x01]\r\n );\r\n }\r\n\r\n async disableSleepTimer() {\r\n await this.device.send(\r\n Reports.GLITTER_BASIC_CMD, \r\n [Commands.GLITTER_CMD_SET_SLEEP_TIMEOUT, 0x00, 0x00, 0x00, 0x00]\r\n );\r\n }\r\n \r\n async enableDeepSleep() {\r\n await this.device.send(\r\n Reports.GLITTER_BASIC_CMD, \r\n [Commands.GLITTER_CMD_WAKE_ON_COMMAND, 0x00]\r\n );\r\n }\r\n\r\n async enableSleepTimer(milliseconds) {\r\n const view = new DataView(new ArrayBuffer(4));\r\n const littleEndian = false;\r\n view.setInt32(0, milliseconds, littleEndian);\r\n await this.device.send(\r\n Reports.GLITTER_BASIC_CMD, \r\n [\r\n Commands.GLITTER_CMD_SET_SLEEP_TIMEOUT, \r\n view.getUint8(0), \r\n view.getUint8(1), \r\n view.getUint8(2), \r\n view.getUint8(3),\r\n ]\r\n );\r\n }\r\n\r\n async reboot(mode) {\r\n await this.device.send(\r\n Reports.GLITTER_BASIC_CMD, \r\n [Commands.GLITTER_CMD_REBOOT, mode]\r\n );\r\n }\r\n\r\n async drawMatrix(matrix) {\r\n await this.device.send(\r\n Reports.GLITTER_GRID_PWM_CNTL,\r\n matrix.flat().map(v => GAMMA[Math.floor((v ?? 0) * 255)])\r\n );\r\n }\r\n\r\n async drawPixel(r, c, brightness) {\r\n await this.device.send(\r\n Reports.GLITTER_BASIC_CMD,\r\n [Commands.GLITTER_CMD_DRAW_PIXEL, c, r, brightness]\r\n );\r\n }\r\n\r\n async drawLine({r1, c1}, {r2, c2}, brightness) {\r\n await this.device.send(\r\n Reports.GLITTER_BASIC_CMD,\r\n [Commands.GLITTER_CMD_DRAW_PIXEL, r1, c1, r2, c2, brightness]\r\n );\r\n }\r\n\r\n device;\r\n}\r\n","import { getDevice } from '../../../web-hid/device.js';\r\nimport { HIDOperations } from '../../../web-hid/HIDOperations.js';\r\nimport { ReportAbstractionLayer } from './ReportAbstractionLayer.js';\r\nimport { BootMode } from './reports.js';\r\n\r\nexport class SparkleController extends ReportAbstractionLayer {\r\n async bootloader() {\r\n await super.reboot(BootMode.BOOTSEL);\r\n }\r\n\r\n async connect() {\r\n const device = await getDevice();\r\n if (device) {\r\n await device.open();\r\n this.device = new HIDOperations(device);\r\n }\r\n }\r\n \r\n async draw(matrix) {\r\n await super.drawMatrix(matrix);\r\n }\r\n\r\n async verifyFirmware() {\r\n try {\r\n const info = await super.info();\r\n return (\r\n info.display_height == HEIGHT &&\r\n info.display_width == WIDTH\r\n );\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n async version() {\r\n const info = await super.info();\r\n if (info.version_major != undefined \r\n && info.version_minor != undefined\r\n && (info.version_major > 0 || info.version_minor > 0)) {\r\n return {\r\n major: info.version_major,\r\n minor: info.version_minor\r\n }\r\n } else {\r\n // Sparkle <=1.1.1: Glitter version unavailable \r\n return { major: 1, minor: 0 };\r\n }\r\n }\r\n}\r\n","import { DefaultController } from './supported-firmware/FrameworkComputer/inputmodule-rs/DefaultController.js';\r\nimport { SigrootController } from './supported-firmware/sigroot/FW_LED_Matrix_Firmware/SigrootController.js';\r\nimport { SparkleController } from './supported-firmware/vddCore/sparkle-fw16/SparkleController.js';\r\n\r\nexport class HardwareControllerFactory {\r\n static async detectSerial() {\r\n const c1 = new DefaultController();\r\n const c2 = new SigrootController();\r\n\r\n await c1.connect();\r\n if (await c1.verifyFirmware()) {\r\n return c1;\r\n }\r\n \r\n await c2.connect()\r\n if (await c2.verifyFirmware()) {\r\n return c2;\r\n } \r\n \r\n return null;\r\n }\r\n\r\n static async detectHID() {\r\n const c1 = new SparkleController();\r\n \r\n await c1.connect();\r\n if (await c1.verifyFirmware()) {\r\n return c1;\r\n } \r\n \r\n return null;\r\n }\r\n}\r\n"],"names":["WIDTH","HEIGHT","VID","VID_ARR","PID","PID_ARR","GAMMA","Object","freeze","extraPorts","filters","usbVendorId","usbProductId","PortSelectionCancelled","Error","constructor","super","this","name","date","Date","PortUnavailable","async","getPort","length","pop","push","navigator","serial","getPorts","requestPort","e","close","port","message","PortMutex","portOperations","lockName","Math","random","toString","deduper","Map","portOps","acquire","fn","trace","stack","enqueue","console","error","acquireIdempotent","key","has","info","set","execDedupedOp","locks","request","get","delete","PortOperations","rx","timeout","readable","locked","response","reader","getReader","timeoutHandle","setTimeout","cancel","value","done","read","clearTimeout","releaseLock","tx","buffer","writable","writer","getWriter","write","Uint8Array","Command","ANIMATE","BRIGHTNESS","BOOTLOADER","DRAW","DRAW_GREY_COL_BUFFER","GAME_CTRL","GAME_STATUS","PANIC","PATTERN","SLEEP","STAGE_GREY_COL","START_GAME","VERSION","CommandAbstractionLayer$1","portMutex","bootloader","p","draw","matrix","index","output","fill","r","c","drawGrayscale","buffers","Array","from","_","floor","i","version","ver","major","minor","patch","preRelease","DefaultController","CommandAbstractionLayer","connect","connected","open","baudRate","bitDepth","BitDepth","GRAY_8BIT","MONO_1BIT","verifyFirmware","undefined","NOOP","ANIMATION_DIAMOND","ANIMATION_FIRE","ANIMATION_FIREPLACE","ANIMATION_GEAR","ANIMATION_RING","ANIMATION_STARTUP","ANIMATION_STARTUP_ONCE","DRAW_PWM","DRAW_PWM_BLOCKING","DRAW_SCALE","DRAW_SCALE_BLOCKING","FLUSH_CMD_QUEUE","TEST_PATTERN","SET_CONST_PWM","SET_CONST_SCALE","SET_PX_PWM","SET_PX_SCALE","IDENTITY_STRING","IDENTITY_STR_REGEX","identityString","ident","String","fromCharCode","setPixelPwm","brightness","setGlobalPwm","setMatrixPwm","concat","flat","map","v","setPixelAnalog","setGlobalAnalog","setMatrixAnalog","SigrootController","scaleInitialized","match","extraDevices","vendorId","productId","DeviceSelectionCancelled","HIDOperations","device","send","report","data","bytes","arr","len","val","pad","feature","sendFeatureReport","id","sendReport","reply","receiveFeatureReport","byteLength","exp","act","Reports","Commands","BootMode","ReportAbstractionLayer","infoRaw","sleep_pin","getUint8","dip1_pin","intb_pin","state_flags","id_reg","config_reg","global_brightness","display_width","display_height","timeout_ms","getUint32","version_major","version_minor","wake","sleep","disableSleep","disableDeepSleep","disableSleepTimer","enableDeepSleep","enableSleepTimer","milliseconds","view","DataView","ArrayBuffer","setInt32","reboot","mode","drawMatrix","drawPixel","drawLine","r1","c1","r2","c2","SparkleController","hid","getDevices","requestDevice","getDevice","HardwareControllerFactory","detectSerial","detectHID"],"mappings":"AAAY,MAACA,EAAQ,EACRC,EAAS,GACTC,EAAM,MACNC,EAAU,CAAC,GAAM,KACjBC,EAAM,GACNC,EAAU,CAAC,EAAM,IAEjBC,EAAQC,OAAOC,OAAO,CACjC,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EACrB,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EACrB,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EACrB,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EACrB,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EACrB,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EACrB,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,E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J,MAAMqD,QLQH3J,iBACL,GAAIsJ,GAAgBA,EAAapJ,OAAS,EACxC,OAAOoJ,EAAanJ,MAItB,GADAmJ,EAAalJ,cAAeC,UAAUiN,IAAIC,cACtCjE,GAAgBA,EAAapJ,OAAS,EACxC,OAAOoJ,EAAanJ,MAItB,GADAmJ,EAAalJ,cAAeC,UAAUiN,IAAIE,cAAc,CAAEpO,aACtDkK,GAAgBA,EAAapJ,OAAS,EACxC,OAAOoJ,EAAanJ,MAGtB,MAAM,IAAIsJ,CACZ,CKxByBgE,GACjB9D,UACIA,EAAOnD,OACb7G,KAAKgK,OAAS,IAAID,EAAcC,GAEpC,CAEA,UAAM3E,CAAKC,SACHvF,MAAMoN,WAAW7H,EACzB,CAEA,oBAAM6B,GACJ,IACE,MAAM9E,QAAatC,MAAMsC,OACzB,OACEA,EAAK2J,gBAAkBhN,QACvBqD,EAAK0J,eAAiBhN,KAE1B,CAAE,MACA,OAAO,CACT,CACF,CAEA,aAAMoH,GACJ,MAAM9D,QAAatC,MAAMsC,OACzB,OAA0B+E,MAAtB/E,EAAK8J,eACkB/E,MAAtB/E,EAAK+J,gBACJ/J,EAAK8J,cAAgB,GAAK9J,EAAK+J,cAAgB,GAC5C,CACL/F,MAAOhE,EAAK8J,cACZ7F,MAAOjE,EAAK+J,eAIP,CAAE/F,MAAO,EAAGC,MAAO,EAE9B,EC3CK,MAAMyH,EACX,yBAAaC,GACX,MAAMT,EAAK,IAAI9G,EACTgH,EAAK,IAAIjE,EAGf,aADM+D,EAAG5G,gBACC4G,EAAGpG,iBACJoG,SAGHE,EAAG9G,gBACC8G,EAAGtG,iBACJsG,EAGF,KACT,CAEA,sBAAaQ,GACX,MAAMV,EAAK,IAAIG,EAGf,aADMH,EAAG5G,gBACC4G,EAAGpG,iBACJoG,EAGF,IACT"}
|
|
1
|
+
{"version":3,"file":"led-matrix-controllers.browser.mjs","sources":["../src/hardware-constants.js","../src/web-serial/port.js","../src/web-serial/PortMutex.js","../src/web-serial/PortOperations.js","../src/supported-firmware/FrameworkComputer/inputmodule-rs/commands.js","../src/supported-firmware/FrameworkComputer/inputmodule-rs/CommandAbstractionLayer.js","../src/supported-firmware/FrameworkComputer/inputmodule-rs/DefaultController.js","../src/supported-firmware/sigroot/FW_LED_Matrix_Firmware/commands.js","../src/supported-firmware/sigroot/FW_LED_Matrix_Firmware/CommandAbstractionLayer.js","../src/supported-firmware/sigroot/FW_LED_Matrix_Firmware/SigrootController.js","../src/web-hid/device.js","../src/web-hid/HIDOperations.js","../src/web-hid/util.js","../src/supported-firmware/vddCore/sparkle-fw16/reports.js","../src/supported-firmware/vddCore/sparkle-fw16/ReportAbstractionLayer.js","../src/supported-firmware/vddCore/sparkle-fw16/SparkleController.js","../src/HardwareControllerFactory.js"],"sourcesContent":["export const WIDTH = 9;\r\nexport const HEIGHT = 34;\r\nexport const VID = 0x32AC;\r\nexport const VID_ARR = [0x32, 0xAC];\r\nexport const PID = 0x0020;\r\nexport const PID_ARR = [0x00, 0x20];\r\n\r\nexport const GAMMA = Object.freeze([\r\n 0, 0, 0, 0, 0, 0, 0, 1, \r\n 1, 1, 1, 1, 1, 1, 1, 1, \r\n 1, 1, 1, 1, 1, 1, 1, 1, \r\n 1, 1, 1, 1, 1, 1, 1, 1, \r\n 1, 1, 1, 2, 2, 2, 2, 2, \r\n 2, 2, 2, 2, 3, 3, 3, 3, \r\n 3, 3, 3, 4, 4, 4, 4, 4, \r\n 4, 5, 5, 5, 5, 6, 6, 6, \r\n 6, 6, 7, 7, 7, 7, 8, 8, \r\n 8, 9, 9, 9, 10, 10, 10, 11, \r\n 11, 11, 12, 12, 12, 13, 13, 14, \r\n 14, 14, 15, 15, 16, 16, 17, 17, \r\n 17, 18, 18, 19, 19, 20, 20, 21, \r\n 22, 22, 23, 23, 24, 24, 25, 26, \r\n 26, 27, 27, 28, 29, 29, 30, 31, \r\n 32, 32, 33, 34, 34, 35, 36, 37, \r\n 38, 38, 39, 40, 41, 42, 42, 43, \r\n 44, 45, 46, 47, 48, 49, 50, 51, \r\n 52, 53, 54, 55, 56, 57, 58, 59, \r\n 60, 61, 62, 63, 64, 66, 67, 68, \r\n 69, 70, 71, 73, 74, 75, 76, 78, \r\n 79, 80, 82, 83, 84, 86, 87, 88, \r\n 90, 91, 93, 94, 96, 97, 99, 100, \r\n 102, 103, 105, 106, 108, 110, 111, 113, \r\n 115, 116, 118, 120, 121, 123, 125, 127, \r\n 128, 130, 132, 134, 136, 138, 140, 141, \r\n 143, 145, 147, 149, 151, 153, 155, 157, \r\n 159, 161, 164, 166, 168, 170, 172, 174, \r\n 177, 179, 181, 183, 186, 188, 190, 193, \r\n 195, 197, 200, 202, 205, 207, 210, 212, \r\n 215, 217, 220, 222, 225, 228, 230, 233, \r\n 236, 238, 241, 244, 247, 249, 252, 255\r\n]);\r\n","import { PID, VID } from '../hardware-constants.js';\r\n\r\nconst extraPorts = [];\r\n\r\nconst filters = [\r\n {\r\n usbVendorId: VID,\r\n usbProductId: PID,\r\n }\r\n];\r\n\r\nexport class PortSelectionCancelled extends Error {\r\n constructor() {\r\n super('User cancelled port selection.');\r\n this.name = this.constructor.name;\r\n this.date = new Date();\r\n }\r\n}\r\n\r\nexport class PortUnavailable extends Error {\r\n constructor() {\r\n super('Selected port already in use.');\r\n this.name = this.constructor.name;\r\n this.date = new Date();\r\n }\r\n}\r\n\r\nexport async function getPort() {\r\n try {\r\n if (extraPorts && extraPorts.length > 0) {\r\n return extraPorts.pop();\r\n }\r\n\r\n extraPorts.push(...await navigator.serial.getPorts());\r\n if (extraPorts && extraPorts.length > 0) {\r\n return extraPorts.pop();\r\n }\r\n\r\n extraPorts.push(...await navigator.serial.requestPort({ filters }));\r\n if (extraPorts && extraPorts.length > 0) {\r\n return extraPorts.pop();\r\n }\r\n\r\n } catch (e) {\r\n if (e.name == 'NotFoundError') {\r\n throw new PortSelectionCancelled();\r\n } else if (e.name == 'InvalidStateError') {\r\n throw new PortUnavailable();\r\n } else {\r\n throw e;\r\n }\r\n }\r\n}\r\n\r\nexport async function close(port) {\r\n try {\r\n await port.close();\r\n } catch(e) {\r\n if (e.name != 'InvalidStateError') {\r\n if (e.message != \"Failed to execute 'close' on 'SerialPort': The port is already closed.\") {\r\n throw e;\r\n }\r\n }\r\n }\r\n}\r\n","export class PortMutex {\r\n constructor(portOperations) {\r\n this.#lockName = `port-mutex-${Math.random().toString()}`;\r\n this.#deduper = new Map();\r\n this.#portOps = portOperations;\r\n }\r\n\r\n async acquire(fn) {\r\n const trace = new Error('created bad cb').stack;\r\n\r\n await this.#enqueue(async () => {\r\n try {\r\n await fn(this.#portOps);\r\n } catch (e) {\r\n console.error('Error occured in anonymous callback.');\r\n console.error('Original error:', e);\r\n console.error('--- This callback was created at ---\\n', trace);\r\n }\r\n });\r\n }\r\n\r\n async acquireIdempotent(key, fn) {\r\n const trace = new Error('created bad cb').stack;\r\n\r\n if (this.#deduper.has(key)) {\r\n console.info(`\"${key}\" request coalesced.`);\r\n }\r\n\r\n this.#deduper.set(key, async () => {\r\n try {\r\n await fn(this.#portOps);\r\n } catch (e) {\r\n console.error('Error occured in anonymous callback.');\r\n console.error('Original error:', e);\r\n console.error('--- This callback was created at ---\\n', trace);\r\n }\r\n });\r\n\r\n await this.#enqueue(() => this.#execDedupedOp(key));\r\n }\r\n\r\n async #enqueue(fn) {\r\n // `navigator.locks` maintains queue and provides mutual exclusion.\r\n return navigator.locks.request(this.#lockName, fn);\r\n }\r\n\r\n async #execDedupedOp(key) {\r\n if (this.#deduper.has(key)) {\r\n const fn = this.#deduper.get(key);\r\n this.#deduper.delete(key);\r\n await fn();\r\n }\r\n }\r\n\r\n #lockName;\r\n #deduper;\r\n #portOps;\r\n}\r\n","export class PortOperations {\r\n constructor(port) {\r\n this.#port = port;\r\n }\r\n\r\n async rx(length, timeout=3000) {\r\n if (this.#port === null) {\r\n throw new Error('attempted RX before port initialization.');\r\n }\r\n\r\n /*\r\n * ReadableStream's built-in locking mechanism cannot be awaited or otherwise\r\n * asynchronously acquired. A PortMutex must be used.\r\n */\r\n if (this.#port.readable.locked) {\r\n throw new Error('attempted RX while port locked.');\r\n }\r\n\r\n const response = [];\r\n const reader = this.#port.readable.getReader();\r\n const timeoutHandle = setTimeout(() => reader.cancel(), timeout);\r\n\r\n try {\r\n // Response may be divided across multiple reads\r\n while (response.length < length) {\r\n const { value, done } = await reader.read();\r\n response.push(...(value ?? []));\r\n if (done || !value) break;\r\n }\r\n } finally {\r\n clearTimeout(timeoutHandle);\r\n reader.releaseLock();\r\n }\r\n\r\n return response;\r\n }\r\n\r\n async tx(buffer) {\r\n if (this.#port === null) {\r\n throw new Error('attempted TX before port initialization.');\r\n }\r\n \r\n /*\r\n * WritableStream's built-in locking mechanism cannot be awaited or otherwise\r\n * asynchronously acquired. A PortMutex must be used.\r\n */\r\n if (this.#port.writable.locked) {\r\n throw new Error('attempted TX while port locked.');\r\n }\r\n\r\n const writer = this.#port.writable.getWriter();\r\n\r\n try {\r\n await writer.write(new Uint8Array(buffer));\r\n } finally {\r\n /* \r\n * The writer must be completely torn down between every single write.\r\n * Many parsers can't handle delayed flushing and write coalescing.\r\n * Command sequences will fail if `releaseLock()` is used here.\r\n */\r\n await writer.close();\r\n }\r\n }\r\n\r\n #port;\r\n}\r\n","// All replies to all commands are 32 bytes\r\nexport const RX_PACKET_SZ = 32;\r\n\r\nexport const Command = Object.freeze({\r\n ANIMATE: 0x04,\r\n BRIGHTNESS: 0x00,\r\n BOOTLOADER: 0x02,\r\n DRAW: 0x06,\r\n DRAW_GREY_COL_BUFFER: 0x08,\r\n GAME_CTRL: 0x11,\r\n GAME_STATUS: 0x12,\r\n PANIC: 0x05,\r\n PATTERN: 0x01,\r\n SLEEP: 0x03,\r\n STAGE_GREY_COL: 0x07,\r\n START_GAME: 0x10,\r\n VERSION: 0x20,\r\n});\r\n\r\n// Used with Command.PATTERN\r\nexport const Pattern = Object.freeze({\r\n DISPLAY_LOTUS_HORIZONTAL: 0x03,\r\n DISPLAY_LOTUS_VERTICAL: 0x07,\r\n DISPLAY_PANIC: 0x06,\r\n DOUBLE_GRADIENT: 0x02,\r\n FULL_BRIGHTNESS: 0x05,\r\n GRADIENT: 0x01,\r\n PERCENTAGE: 0x00,\r\n ZIG_ZAG: 0x04,\r\n});\r\n\r\n// DRAW or DRAW_GREY_COL_BUFFER\r\nexport const BitDepth = Object.freeze({\r\n GRAY_8BIT: '8-bit',\r\n MONO_1BIT: '1-bit',\r\n})\r\n","import { HEIGHT, VID_ARR, WIDTH } from '../../../hardware-constants.js';\r\nimport { Command, RX_PACKET_SZ } from './commands.js';\r\n\r\nexport class CommandAbstractionLayer {\r\n constructor(portMutex = null) {\r\n this.portMutex = portMutex;\r\n }\r\n\r\n async bootloader() {\r\n await this.portMutex.acquire(async p => {\r\n await p.tx([...VID_ARR, Command.BOOTLOADER]);\r\n });\r\n }\r\n\r\n async draw(matrix) {\r\n let index = 0;\r\n let output = new Uint8Array(39).fill(0);\r\n\r\n // Pack cells into bits\r\n for (let r = 0; r < HEIGHT; r++) {\r\n for (let c = 0; c < WIDTH; c++) {\r\n if (matrix[r][c]) {\r\n output[index >> 3] |= 1 << index % 8;\r\n }\r\n index++;\r\n }\r\n }\r\n\r\n await this.portMutex.acquireIdempotent(\r\n 'drawMatrix', \r\n async p => {\r\n await p.tx([...VID_ARR, Command.DRAW, ...output]);\r\n }\r\n );\r\n }\r\n\r\n async drawGrayscale(matrix) {\r\n // Transpose & Gamma Correction\r\n const buffers = Array.from(\r\n { length: WIDTH }, \r\n (_, c) => new Array(\r\n { length: HEIGHT }, \r\n (_, r) => GAMMA[Math.floor((matrix[r][c] ?? 0) * 255)]\r\n )\r\n );\r\n\r\n // Only execute the most recent call \r\n await this.portMutex.acquireIdempotent(\r\n 'drawMatrix', \r\n async p => {\r\n for (let i = 0; i < WIDTH; i++) {\r\n await p.tx([Command.STAGE_GREY_COL, i, ...buffers[i]]);\r\n }\r\n await p.tx([Command.DRAW_GREY_COL_BUFFER]);\r\n }\r\n );\r\n }\r\n\r\n async version() {\r\n let ver = {};\r\n\r\n await this.portMutex.acquire(async p => {\r\n await p.tx([...VID_ARR, Command.VERSION]);\r\n const response = await p.rx(RX_PACKET_SZ);\r\n\r\n // MMMMMMMM mmmmPPPP 0000000p\r\n ver.major = response[0];\r\n ver.minor = response[1] >> 4;\r\n ver.patch = response[1] & 0x0F;\r\n ver.preRelease = response[2] == 1;\r\n });\r\n\r\n return ver;\r\n }\r\n}\r\n","import { close, getPort } from '../../../web-serial/port.js';\r\nimport { PortMutex } from '../../../web-serial/PortMutex.js';\r\nimport { PortOperations } from '../../../web-serial/PortOperations.js';\r\nimport { CommandAbstractionLayer } from './CommandAbstractionLayer.js';\r\n\r\nexport class DefaultController extends CommandAbstractionLayer {\r\n async bootloader() {\r\n return super.bootloader();\r\n }\r\n\r\n async connect() {\r\n const port = await getPort();\r\n\r\n if (port?.connected) {\r\n await close(port);\r\n await port.open({ baudRate: 115200 });\r\n this.portMutex = new PortMutex(new PortOperations(port));\r\n }\r\n }\r\n\r\n async draw(matrix) {\r\n switch (this.#bitDepth) {\r\n\r\n case BitDepth.GRAY_8BIT:\r\n super.drawGrayscale(matrix);\r\n break;\r\n\r\n case BitDepth.MONO_1BIT:\r\n super.draw(matrix);\r\n break;\r\n }\r\n }\r\n\r\n async verifyFirmware() {\r\n try {\r\n const version = await super.version();\r\n\r\n return version\r\n && version.major != undefined\r\n && version.minor != undefined\r\n && version.patch != undefined\r\n && version.preRelease != undefined;\r\n \r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n async version() {\r\n return super.version();\r\n }\r\n\r\n #bitDepth;\r\n}\r\n","export const Command = Object.freeze({\r\n /* 000 */ NOOP: 0x00,\r\n /* 'd' */ ANIMATION_DIAMOND: 0x64,\r\n /* 'b' */ ANIMATION_FIRE: 0x62,\r\n /* 'f' */ ANIMATION_FIREPLACE: 0x66,\r\n /* 'g' */ ANIMATION_GEAR: 0x67,\r\n /* 'r' */ ANIMATION_RING: 0x72,\r\n /* 'a' */ ANIMATION_STARTUP: 0x61,\r\n /* 'A' */ ANIMATION_STARTUP_ONCE: 0x41,\r\n /* 'e' */ BOOTLOADER: 0x65,\r\n /* 'm' */ DRAW_PWM: 0x6D,\r\n /* 'M' */ DRAW_PWM_BLOCKING: 0x4D,\r\n /* 'n' */ DRAW_SCALE: 0x6E,\r\n /* 'N' */ DRAW_SCALE_BLOCKING: 0x4E,\r\n /* 'c' */ FLUSH_CMD_QUEUE: 0x63,\r\n /* 't' */ TEST_PATTERN: 0x74,\r\n /* 'w' */ SET_CONST_PWM: 0x77,\r\n /* 's' */ SET_CONST_SCALE: 0x73,\r\n /* 'p' */ SET_PX_PWM: 0x70,\r\n /* 'q' */ SET_PX_SCALE: 0x71,\r\n /* 127 */ IDENTITY_STRING: 0x7F,\r\n});\r\n\r\nexport const IDENTITY_STR_LEN = 25;\r\n\r\nexport const IDENTITY_STR_REGEX = /^Sig\\sFW\\sLED\\sMatrix\\sFW\\sV(\\d+)\\.(\\d+)$/;\r\n","import { GAMMA } from '../../../hardware-constants.js';\r\nimport { Command, IDENTITY_STR_LEN } from './commands.js';\r\n\r\nexport class CommandAbstractionLayer {\r\n constructor(portMutex = null) {\r\n this.portMutex = portMutex;\r\n }\r\n\r\n async bootloader() {\r\n await this.portMutex.acquire(async p => {\r\n await p.tx([Command.BOOTLOADER]);\r\n });\r\n }\r\n\r\n async identityString() {\r\n let ident = null;\r\n\r\n await this.portMutex.acquire(async p => {\r\n await p.tx([Command.IDENTITY_STRING]);\r\n ident = await p.rx(IDENTITY_STR_LEN);\r\n });\r\n\r\n return String.fromCharCode(...ident);\r\n }\r\n\r\n async setPixelPwm(r, c, brightness) {\r\n await this.portMutex.acquire(\r\n async p => {\r\n await p.tx([Command.SET_PX_PWM, c, r, brightness]);\r\n }\r\n );\r\n }\r\n\r\n async setGlobalPwm(brightness) {\r\n await this.portMutex.acquire(\r\n async p => {\r\n await p.tx([Command.SET_CONST_PWM, brightness]);\r\n }\r\n );\r\n }\r\n\r\n async setMatrixPwm(matrix) {\r\n // Only execute the most recent call \r\n await this.portMutex.acquireIdempotent(\r\n 'drawMatrix', \r\n async p => {\r\n await p.tx(\r\n [Command.DRAW_PWM].concat(\r\n matrix.flat().map(v => \r\n GAMMA[Math.floor((v ?? 0) * 255)]\r\n )\r\n )\r\n );\r\n }\r\n );\r\n }\r\n\r\n async setPixelAnalog(r, c, brightness) {\r\n await this.portMutex.acquire(\r\n async p => {\r\n await p.tx([Command.SET_PX_SCALE, c, r, brightness]);\r\n }\r\n );\r\n }\r\n\r\n async setGlobalAnalog(brightness) {\r\n await this.portMutex.acquire(\r\n async p => {\r\n await p.tx([Command.SET_CONST_SCALE, brightness]);\r\n }\r\n );\r\n }\r\n\r\n async setMatrixAnalog(matrix) {\r\n // Only execute the most recent call \r\n await this.portMutex.acquireIdempotent(\r\n 'drawMatrix', \r\n async p => {\r\n await p.tx(\r\n [Command.DRAW_SCALE].concat(\r\n matrix.flat().map(v => \r\n GAMMA[Math.floor((v ?? 0) * 255)]\r\n )\r\n )\r\n );\r\n }\r\n );\r\n }\r\n}\r\n","import { close, getPort } from '../../../web-serial/port.js';\r\nimport { PortMutex } from '../../../web-serial/PortMutex.js';\r\nimport { PortOperations } from '../../../web-serial/PortOperations.js';\r\nimport { CommandAbstractionLayer } from './CommandAbstractionLayer.js';\r\nimport { IDENTITY_STR_REGEX } from './commands.js';\r\n\r\nexport class SigrootController extends CommandAbstractionLayer {\r\n async bootloader() {\r\n await super.bootloader();\r\n }\r\n\r\n async connect() {\r\n const port = await getPort();\r\n\r\n if (port?.connected) {\r\n await close(port);\r\n await port.open({ baudRate: 115200 });\r\n this.portMutex = new PortMutex(new PortOperations(port));\r\n }\r\n }\r\n\r\n async draw(matrix) {\r\n if (!this.#scaleInitialized) {\r\n await super.setGlobalAnalog(0x20);\r\n this.#scaleInitialized = true;\r\n }\r\n\r\n await super.setMatrixPwm(matrix);\r\n }\r\n\r\n async verifyFirmware() { \r\n return await this.version() != null;\r\n }\r\n\r\n async version() {\r\n const ident = await super.identityString();\r\n const match = ident.match(IDENTITY_STR_REGEX);\r\n\r\n if (match && match.length == 3) {\r\n return {\r\n major: match[1],\r\n minor: match[2]\r\n }\r\n } else {\r\n return null;\r\n }\r\n }\r\n\r\n #scaleInitialized;\r\n}\r\n","import { PID, VID } from '../hardware-constants.js';\r\n\r\nconst extraDevices = [];\r\n\r\nconst filters = [\r\n {\r\n vendorId: VID,\r\n productId: PID,\r\n }\r\n];\r\n\r\nexport class DeviceSelectionCancelled extends Error {\r\n constructor() {\r\n super('User cancelled device selection.');\r\n this.name = this.constructor.name;\r\n this.date = new Date();\r\n }\r\n}\r\n\r\nexport async function getDevice() {\r\n if (extraDevices && extraDevices.length > 0) {\r\n return extraDevices.pop();\r\n }\r\n\r\n extraDevices.push(...(await navigator.hid.getDevices()));\r\n if (extraDevices && extraDevices.length > 0) {\r\n return extraDevices.pop();\r\n }\r\n\r\n extraDevices.push(...(await navigator.hid.requestDevice({ filters })));\r\n if (extraDevices && extraDevices.length > 0) {\r\n return extraDevices.pop();\r\n }\r\n\r\n throw new DeviceSelectionCancelled();\r\n}\r\n","import { pad } from './util.js';\r\n\r\nexport class HIDOperations {\r\n constructor(device) {\r\n this.#device = device;\r\n }\r\n\r\n async send(report, data) {\r\n if (data.length < report.bytes) {\r\n data = pad(data, report.bytes);\r\n } else if (data.length > report.bytes) {\r\n throw new Error('Unable to send report: too many bytes');\r\n }\r\n\r\n const buffer = new Uint8Array(data).buffer;\r\n\r\n if (report.feature) {\r\n await this.#device.sendFeatureReport(report.id, buffer);\r\n } else {\r\n await this.#device.sendReport(report.id, buffer);\r\n }\r\n }\r\n\r\n async request(report) {\r\n let reply = [];\r\n\r\n if (report.feature) {\r\n reply = await this.#device.receiveFeatureReport(report.id);\r\n } else {\r\n /* \r\n * HID input reports are used for unprompted data.\r\n * See WebHID `HIDInputReportEvent`\r\n */\r\n throw new Error('Invalid operation');\r\n }\r\n\r\n if (reply.byteLength != report.bytes) {\r\n const exp = report.bytes;\r\n const act = reply.byteLength;\r\n console.error(`reply length=${act} (expected ${exp})`);\r\n }\r\n\r\n return reply;\r\n }\r\n\r\n #device;\r\n}\r\n","export function pad(arr, len, val=0x00) {\r\n return arr.concat(new Array(len - arr.length).fill(val));\r\n}\r\n","export const Reports = {\r\n GLITTER_DEVICE_INFO: {\r\n id: 0x01,\r\n bytes: 307,\r\n feature: true,\r\n },\r\n GLITTER_BASIC_CMD: {\r\n id: 0x02,\r\n bytes: 16,\r\n feature: true,\r\n },\r\n GLITTER_GRID_PWM_CNTL: {\r\n id: 0x03,\r\n bytes: 306,\r\n feature: true,\r\n },\r\n GLITTER_GRID_PWM_CNTL: {\r\n id: 0x04,\r\n bytes: 306,\r\n feature: true,\r\n }\r\n}\r\n\r\nexport const Commands = {\r\n GLITTER_CMD_REBOOT: 0x00,\r\n GLITTER_CMD_SLEEP: 0x01,\r\n GLITTER_CMD_WAKE_ON_COMMAND: 0x02,\r\n GLITTER_CMD_SET_SLEEP_TIMEOUT: 0x03,\r\n GLITTER_CMD_SET_GLOBAL_BRIGHTNESS: 0x04,\r\n GLITTER_CMD_DRAW_PIXEL: 0x05,\r\n GLITTER_CMD_DRAW_LINE: 0x06\r\n}\r\n\r\nexport const BootMode = {\r\n BOOTSEL: 0x00,\r\n NORMAL: 0x01,\r\n}\r\n","import { GAMMA } from '../../../hardware-constants.js';\r\nimport { Commands, Reports } from './reports.js';\r\n\r\nexport class ReportAbstractionLayer {\r\n constructor(device = null) {\r\n this.device = device;\r\n }\r\n\r\n async info() {\r\n const infoRaw = await this.device.request(Reports.GLITTER_DEVICE_INFO);\r\n\r\n return {\r\n sleep_pin: infoRaw.getUint8(1),\r\n dip1_pin: infoRaw.getUint8(2),\r\n intb_pin: infoRaw.getUint8(3),\r\n state_flags: infoRaw.getUint8(4),\r\n id_reg: infoRaw.getUint8(5),\r\n config_reg: infoRaw.getUint8(6),\r\n global_brightness: infoRaw.getUint8(7),\r\n display_width: infoRaw.getUint8(8),\r\n display_height: infoRaw.getUint8(9),\r\n timeout_ms: infoRaw.getUint32(10),\r\n version_major: infoRaw.getUint8(14),\r\n version_minor: infoRaw.getUint8(15),\r\n };\r\n }\r\n\r\n async wake() {\r\n await this.device.send(\r\n Reports.GLITTER_BASIC_CMD,\r\n [Commands.GLITTER_CMD_SLEEP, false]\r\n );\r\n }\r\n\r\n async sleep() {\r\n await this.device.send(\r\n Reports.GLITTER_BASIC_CMD,\r\n [Commands.GLITTER_CMD_SLEEP, true]\r\n );\r\n }\r\n\r\n async disableSleep() {\r\n await this.device.send(\r\n Reports.GLITTER_BASIC_CMD, \r\n [Commands.GLITTER_CMD_SET_SLEEP_TIMEOUT, 0xff, 0xff, 0xff, 0xff]\r\n );\r\n }\r\n\r\n async disableDeepSleep() {\r\n await this.device.send(\r\n Reports.GLITTER_BASIC_CMD, \r\n [Commands.GLITTER_CMD_WAKE_ON_COMMAND, 0x01]\r\n );\r\n }\r\n\r\n async disableSleepTimer() {\r\n await this.device.send(\r\n Reports.GLITTER_BASIC_CMD, \r\n [Commands.GLITTER_CMD_SET_SLEEP_TIMEOUT, 0x00, 0x00, 0x00, 0x00]\r\n );\r\n }\r\n \r\n async enableDeepSleep() {\r\n await this.device.send(\r\n Reports.GLITTER_BASIC_CMD, \r\n [Commands.GLITTER_CMD_WAKE_ON_COMMAND, 0x00]\r\n );\r\n }\r\n\r\n async enableSleepTimer(milliseconds) {\r\n const view = new DataView(new ArrayBuffer(4));\r\n const littleEndian = false;\r\n view.setInt32(0, milliseconds, littleEndian);\r\n await this.device.send(\r\n Reports.GLITTER_BASIC_CMD, \r\n [\r\n Commands.GLITTER_CMD_SET_SLEEP_TIMEOUT, \r\n view.getUint8(0), \r\n view.getUint8(1), \r\n view.getUint8(2), \r\n view.getUint8(3),\r\n ]\r\n );\r\n }\r\n\r\n async reboot(mode) {\r\n await this.device.send(\r\n Reports.GLITTER_BASIC_CMD, \r\n [Commands.GLITTER_CMD_REBOOT, mode]\r\n );\r\n }\r\n\r\n async drawMatrix(matrix) {\r\n await this.device.send(\r\n Reports.GLITTER_GRID_PWM_CNTL,\r\n matrix.flat().map(v => GAMMA[Math.floor((v ?? 0) * 255)])\r\n );\r\n }\r\n\r\n async drawPixel(r, c, brightness) {\r\n await this.device.send(\r\n Reports.GLITTER_BASIC_CMD,\r\n [Commands.GLITTER_CMD_DRAW_PIXEL, c, r, brightness]\r\n );\r\n }\r\n\r\n async drawLine({r1, c1}, {r2, c2}, brightness) {\r\n await this.device.send(\r\n Reports.GLITTER_BASIC_CMD,\r\n [Commands.GLITTER_CMD_DRAW_PIXEL, r1, c1, r2, c2, brightness]\r\n );\r\n }\r\n\r\n device;\r\n}\r\n","import { HEIGHT, WIDTH } from '../../../hardware-constants.js';\r\nimport { getDevice } from '../../../web-hid/device.js';\r\nimport { HIDOperations } from '../../../web-hid/HIDOperations.js';\r\nimport { ReportAbstractionLayer } from './ReportAbstractionLayer.js';\r\nimport { BootMode } from './reports.js';\r\n\r\nexport class SparkleController extends ReportAbstractionLayer {\r\n async bootloader() {\r\n await super.reboot(BootMode.BOOTSEL);\r\n }\r\n\r\n async connect() {\r\n const device = await getDevice();\r\n if (device) {\r\n await device.open();\r\n this.device = new HIDOperations(device);\r\n }\r\n }\r\n \r\n async draw(matrix) {\r\n await super.drawMatrix(matrix);\r\n }\r\n\r\n async verifyFirmware() {\r\n try {\r\n const info = await super.info();\r\n return (\r\n info.display_height == HEIGHT &&\r\n info.display_width == WIDTH\r\n );\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n async version() {\r\n const info = await super.info();\r\n if (info.version_major != undefined \r\n && info.version_minor != undefined\r\n && (info.version_major > 0 || info.version_minor > 0)) {\r\n return {\r\n major: info.version_major,\r\n minor: info.version_minor\r\n }\r\n } else {\r\n // Sparkle <=1.1.1: Glitter version unavailable \r\n return { major: 1, minor: 0 };\r\n }\r\n }\r\n}\r\n","import { DefaultController } from './supported-firmware/FrameworkComputer/inputmodule-rs/DefaultController.js';\r\nimport { SigrootController } from './supported-firmware/sigroot/FW_LED_Matrix_Firmware/SigrootController.js';\r\nimport { SparkleController } from './supported-firmware/vddCore/sparkle-fw16/SparkleController.js';\r\n\r\nexport class HardwareControllerFactory {\r\n static async detectSerial() {\r\n const c1 = new DefaultController();\r\n const c2 = new SigrootController();\r\n\r\n await c1.connect();\r\n if (await c1.verifyFirmware()) {\r\n return c1;\r\n }\r\n \r\n await c2.connect()\r\n if (await c2.verifyFirmware()) {\r\n return c2;\r\n } \r\n \r\n return null;\r\n }\r\n\r\n static async detectHID() {\r\n const c1 = new SparkleController();\r\n\r\n await c1.connect();\r\n if (await c1.verifyFirmware()) {\r\n return c1;\r\n } \r\n \r\n return null;\r\n }\r\n}\r\n"],"names":["WIDTH","HEIGHT","VID","VID_ARR","PID","PID_ARR","GAMMA","Object","freeze","extraPorts","filters","usbVendorId","usbProductId","PortSelectionCancelled","Error","constructor","super","this","name","date","Date","PortUnavailable","async","getPort","length","pop","push","navigator","serial","getPorts","requestPort","e","close","port","message","PortMutex","portOperations","lockName","Math","random","toString","deduper","Map","portOps","acquire","fn","trace","stack","enqueue","console","error","acquireIdempotent","key","has","info","set","execDedupedOp","locks","request","get","delete","PortOperations","rx","timeout","readable","locked","response","reader","getReader","timeoutHandle","setTimeout","cancel","value","done","read","clearTimeout","releaseLock","tx","buffer","writable","writer","getWriter","write","Uint8Array","Command","ANIMATE","BRIGHTNESS","BOOTLOADER","DRAW","DRAW_GREY_COL_BUFFER","GAME_CTRL","GAME_STATUS","PANIC","PATTERN","SLEEP","STAGE_GREY_COL","START_GAME","VERSION","CommandAbstractionLayer$1","portMutex","bootloader","p","draw","matrix","index","output","fill","r","c","drawGrayscale","buffers","Array","from","_","floor","i","version","ver","major","minor","patch","preRelease","DefaultController","CommandAbstractionLayer","connect","connected","open","baudRate","bitDepth","BitDepth","GRAY_8BIT","MONO_1BIT","verifyFirmware","undefined","NOOP","ANIMATION_DIAMOND","ANIMATION_FIRE","ANIMATION_FIREPLACE","ANIMATION_GEAR","ANIMATION_RING","ANIMATION_STARTUP","ANIMATION_STARTUP_ONCE","DRAW_PWM","DRAW_PWM_BLOCKING","DRAW_SCALE","DRAW_SCALE_BLOCKING","FLUSH_CMD_QUEUE","TEST_PATTERN","SET_CONST_PWM","SET_CONST_SCALE","SET_PX_PWM","SET_PX_SCALE","IDENTITY_STRING","IDENTITY_STR_REGEX","identityString","ident","String","fromCharCode","setPixelPwm","brightness","setGlobalPwm","setMatrixPwm","concat","flat","map","v","setPixelAnalog","setGlobalAnalog","setMatrixAnalog","SigrootController","scaleInitialized","match","extraDevices","vendorId","productId","DeviceSelectionCancelled","HIDOperations","device","send","report","data","bytes","arr","len","val","pad","feature","sendFeatureReport","id","sendReport","reply","receiveFeatureReport","byteLength","exp","act","Reports","Commands","BootMode","ReportAbstractionLayer","infoRaw","sleep_pin","getUint8","dip1_pin","intb_pin","state_flags","id_reg","config_reg","global_brightness","display_width","display_height","timeout_ms","getUint32","version_major","version_minor","wake","sleep","disableSleep","disableDeepSleep","disableSleepTimer","enableDeepSleep","enableSleepTimer","milliseconds","view","DataView","ArrayBuffer","setInt32","reboot","mode","drawMatrix","drawPixel","drawLine","r1","c1","r2","c2","SparkleController","hid","getDevices","requestDevice","getDevice","HardwareControllerFactory","detectSerial","detectHID"],"mappings":"AAAY,MAACA,EAAQ,EACRC,EAAS,GACTC,EAAM,MACNC,EAAU,CAAC,GAAM,KACjBC,EAAM,GACNC,EAAU,CAAC,EAAM,IAEjBC,EAAQC,OAAOC,OAAO,CACjC,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EACrB,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EACrB,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EACrB,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EACrB,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EACrB,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EACrB,EAAG,EAAG,E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