Skip to content

Commit

Permalink
v0.0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonahss committed May 12, 2023
1 parent e60d8e1 commit e8ba94d
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 70 deletions.
129 changes: 62 additions & 67 deletions napi-rust-drivers/demo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
let fs = require('fs/promises')
let path = require('path')

let { Plinth, imageUtilities } = require('.')

async function main() {
let plinth = new Plinth('devkit')

let erase = function(well) {
console.log('erasing well', well.id)
let buf = Buffer.alloc(4096, ' '.charCodeAt(0))
buf[0] = '{'.charCodeAt(0)
buf[1] = '}'.charCodeAt(0)
well._writeMemory(buf)
console.log('erased well', well.id)
}

//erase(plinth.wells[0])
console.log(plinth.wells[0].getData())
plinth.wells[0].storeData({ hello: 'chukwudi'})
console.log(plinth.wells[0].getData())
plinth.wells[0].storeData({ hello: 'chukwudi', ohyeah: 'coolaid'})
console.log(plinth.wells[0].getData())
}

main()

// let fs = require('fs/promises')
// let path = require('path')

// let { Plinth, imageUtilities } = require('.')
// let { Plinth, imageUtilities } = require('./')

// async function main() {
// let plinth = new Plinth('prototype')
Expand All @@ -15,78 +42,46 @@
// }

// let getData = function(well) {
// return async () => {
// return () => {
// let data = well.getData()
// console.log('data for card in well', well.id, data)
// return data
// }
// }

// plinth.wells.forEach((well, i) => {
// well.onAButtonPress(getData(well))
// well.onBButtonPress(getData(well))
// well.onCButtonPress(getData(well))
// })
// }

// main()

let fs = require('fs/promises')
let path = require('path')

let { Plinth, imageUtilities } = require('./')

async function main() {
let plinth = new Plinth('prototype')


let displayRandomImage = function(well) {
return async () => {
let image = await imageUtilities.randomImage()
plinth.wells[well].displayImage(image)
}
}

let getData = function(well) {
return () => {
let data = well.getData()
return data
}
}

let erase = function(well) {
console.log('erasing well', well.id)
let buf = Buffer.alloc(4096, ' '.charCodeAt(0))
buf[0] = '{'.charCodeAt(0)
buf[1] = '}'.charCodeAt(0)
well._writeMemory(buf)
console.log('erased well', well.id)
}
// let erase = function(well) {
// console.log('erasing well', well.id)
// let buf = Buffer.alloc(4096, ' '.charCodeAt(0))
// buf[0] = '{'.charCodeAt(0)
// buf[1] = '}'.charCodeAt(0)
// well._writeMemory(buf)
// console.log('erased well', well.id)
// }

let logCallbackPress = function(well, buttonId) {
return async () => {
console.log('logging button press by callback: well', well.id, buttonId)
}
}
// let logCallbackPress = function(well, buttonId) {
// return async () => {
// console.log('logging button press by callback: well', well.id, buttonId)
// }
// }

let logEventPress = function(well) {
return (e) => {
console.log('logging button press by event: well', e.well, e.button)
}
}
// let logEventPress = function(well) {
// return (e) => {
// console.log('logging button press by event: well', e.well, e.button)
// }
// }

let logEventChordedPress = function(well) {
return (e) => {
console.log('logging chorded button press by event: well', e.well, e.buttons)
}
}
// let logEventChordedPress = function(well) {
// return (e) => {
// console.log('logging chorded button press by event: well', e.well, e.buttons)
// }
// }

plinth.wells.forEach((well, i) => {
well.onAButtonPress(logCallbackPress(well, 'a'))
well.onBButtonPress(logCallbackPress(well, 'b'))
well.onCButtonPress(logCallbackPress(well, 'c'))
well.on('buttonPress', logEventPress(well))
well.on('chordedButtonPress', logEventChordedPress(well))
})
}
// plinth.wells.forEach((well, i) => {
// well.onAButtonPress(logCallbackPress(well, 'a'))
// well.onBButtonPress(logCallbackPress(well, 'b'))
// well.onCButtonPress(logCallbackPress(well, 'c'))
// well.on('buttonPress', logEventPress(well))
// well.on('chordedButtonPress', logEventChordedPress(well))
// })
// }

main()
//main()
2 changes: 1 addition & 1 deletion napi-rust-drivers/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ export class JsDevkit {
constructor()
displayImage(well: number, image: Buffer): void
setSwitchCallback(well: number, switch: string, callback: (...args: any[]) => any): void
readMemory(well: number, bytes: number): Array<number>
readMemory(well: number, bytes: number): Buffer
writeMemory(well: number, data: Buffer): void
}
2 changes: 1 addition & 1 deletion napi-rust-drivers/npm/linux-arm-gnueabihf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wyldcard/drivers-linux-arm-gnueabihf",
"version": "0.0.13",
"version": "0.0.14",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion napi-rust-drivers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wyldcard/drivers",
"version": "0.0.13",
"version": "0.0.14",
"main": "index.js",
"types": "index.d.ts",
"napi": {
Expand Down
1 change: 1 addition & 0 deletions napi-rust-drivers/plinth.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class Well extends EventEmitter {

getData = function() {
let text = this._readMemory().toString().trim()
console.log('text', text)
return JSON.parse(text)
}

Expand Down

0 comments on commit e8ba94d

Please sign in to comment.