Skip to content

Commit e8ba94d

Browse files
committed
v0.0.14
1 parent e60d8e1 commit e8ba94d

File tree

5 files changed

+66
-70
lines changed

5 files changed

+66
-70
lines changed

napi-rust-drivers/demo.js

+62-67
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,34 @@
1+
let fs = require('fs/promises')
2+
let path = require('path')
3+
4+
let { Plinth, imageUtilities } = require('.')
5+
6+
async function main() {
7+
let plinth = new Plinth('devkit')
8+
9+
let erase = function(well) {
10+
console.log('erasing well', well.id)
11+
let buf = Buffer.alloc(4096, ' '.charCodeAt(0))
12+
buf[0] = '{'.charCodeAt(0)
13+
buf[1] = '}'.charCodeAt(0)
14+
well._writeMemory(buf)
15+
console.log('erased well', well.id)
16+
}
17+
18+
//erase(plinth.wells[0])
19+
console.log(plinth.wells[0].getData())
20+
plinth.wells[0].storeData({ hello: 'chukwudi'})
21+
console.log(plinth.wells[0].getData())
22+
plinth.wells[0].storeData({ hello: 'chukwudi', ohyeah: 'coolaid'})
23+
console.log(plinth.wells[0].getData())
24+
}
25+
26+
main()
27+
128
// let fs = require('fs/promises')
229
// let path = require('path')
330

4-
// let { Plinth, imageUtilities } = require('.')
31+
// let { Plinth, imageUtilities } = require('./')
532

633
// async function main() {
734
// let plinth = new Plinth('prototype')
@@ -15,78 +42,46 @@
1542
// }
1643

1744
// let getData = function(well) {
18-
// return async () => {
45+
// return () => {
1946
// let data = well.getData()
20-
// console.log('data for card in well', well.id, data)
47+
// return data
2148
// }
2249
// }
2350

24-
// plinth.wells.forEach((well, i) => {
25-
// well.onAButtonPress(getData(well))
26-
// well.onBButtonPress(getData(well))
27-
// well.onCButtonPress(getData(well))
28-
// })
29-
// }
30-
31-
// main()
32-
33-
let fs = require('fs/promises')
34-
let path = require('path')
35-
36-
let { Plinth, imageUtilities } = require('./')
37-
38-
async function main() {
39-
let plinth = new Plinth('prototype')
40-
41-
42-
let displayRandomImage = function(well) {
43-
return async () => {
44-
let image = await imageUtilities.randomImage()
45-
plinth.wells[well].displayImage(image)
46-
}
47-
}
48-
49-
let getData = function(well) {
50-
return () => {
51-
let data = well.getData()
52-
return data
53-
}
54-
}
55-
56-
let erase = function(well) {
57-
console.log('erasing well', well.id)
58-
let buf = Buffer.alloc(4096, ' '.charCodeAt(0))
59-
buf[0] = '{'.charCodeAt(0)
60-
buf[1] = '}'.charCodeAt(0)
61-
well._writeMemory(buf)
62-
console.log('erased well', well.id)
63-
}
51+
// let erase = function(well) {
52+
// console.log('erasing well', well.id)
53+
// let buf = Buffer.alloc(4096, ' '.charCodeAt(0))
54+
// buf[0] = '{'.charCodeAt(0)
55+
// buf[1] = '}'.charCodeAt(0)
56+
// well._writeMemory(buf)
57+
// console.log('erased well', well.id)
58+
// }
6459

65-
let logCallbackPress = function(well, buttonId) {
66-
return async () => {
67-
console.log('logging button press by callback: well', well.id, buttonId)
68-
}
69-
}
60+
// let logCallbackPress = function(well, buttonId) {
61+
// return async () => {
62+
// console.log('logging button press by callback: well', well.id, buttonId)
63+
// }
64+
// }
7065

71-
let logEventPress = function(well) {
72-
return (e) => {
73-
console.log('logging button press by event: well', e.well, e.button)
74-
}
75-
}
66+
// let logEventPress = function(well) {
67+
// return (e) => {
68+
// console.log('logging button press by event: well', e.well, e.button)
69+
// }
70+
// }
7671

77-
let logEventChordedPress = function(well) {
78-
return (e) => {
79-
console.log('logging chorded button press by event: well', e.well, e.buttons)
80-
}
81-
}
72+
// let logEventChordedPress = function(well) {
73+
// return (e) => {
74+
// console.log('logging chorded button press by event: well', e.well, e.buttons)
75+
// }
76+
// }
8277

83-
plinth.wells.forEach((well, i) => {
84-
well.onAButtonPress(logCallbackPress(well, 'a'))
85-
well.onBButtonPress(logCallbackPress(well, 'b'))
86-
well.onCButtonPress(logCallbackPress(well, 'c'))
87-
well.on('buttonPress', logEventPress(well))
88-
well.on('chordedButtonPress', logEventChordedPress(well))
89-
})
90-
}
78+
// plinth.wells.forEach((well, i) => {
79+
// well.onAButtonPress(logCallbackPress(well, 'a'))
80+
// well.onBButtonPress(logCallbackPress(well, 'b'))
81+
// well.onCButtonPress(logCallbackPress(well, 'c'))
82+
// well.on('buttonPress', logEventPress(well))
83+
// well.on('chordedButtonPress', logEventChordedPress(well))
84+
// })
85+
// }
9186

92-
main()
87+
//main()

napi-rust-drivers/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ export class JsDevkit {
1414
constructor()
1515
displayImage(well: number, image: Buffer): void
1616
setSwitchCallback(well: number, switch: string, callback: (...args: any[]) => any): void
17-
readMemory(well: number, bytes: number): Array<number>
17+
readMemory(well: number, bytes: number): Buffer
1818
writeMemory(well: number, data: Buffer): void
1919
}

napi-rust-drivers/npm/linux-arm-gnueabihf/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wyldcard/drivers-linux-arm-gnueabihf",
3-
"version": "0.0.13",
3+
"version": "0.0.14",
44
"os": [
55
"linux"
66
],

napi-rust-drivers/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wyldcard/drivers",
3-
"version": "0.0.13",
3+
"version": "0.0.14",
44
"main": "index.js",
55
"types": "index.d.ts",
66
"napi": {

napi-rust-drivers/plinth.js

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class Well extends EventEmitter {
8181

8282
getData = function() {
8383
let text = this._readMemory().toString().trim()
84+
console.log('text', text)
8485
return JSON.parse(text)
8586
}
8687

0 commit comments

Comments
 (0)