Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.

Commit 6edeb56

Browse files
committed
Fix example, add stuff to Readme.
1 parent 5e72992 commit 6edeb56

File tree

4 files changed

+31
-11
lines changed

4 files changed

+31
-11
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,18 @@ This needs tests (sort of hard to test without actual hardware, but I guess I co
5656
the conversion process properly).
5757

5858
It is not handling multiple push devices. Not sure that this is actually a valid usecase for me.
59+
60+
## Contributions
61+
62+
...are welcome. Fork the project, open up a PR, yadda yadda.
63+
64+
## Credits
65+
66+
This uses Tessel's node-usb library and Automattic's libcairo based canvas implementation for the
67+
example.
68+
69+
This library is inspired by an awesome weekend at JSConfEU 2019, and especially by my time spent with the
70+
wonderful people at [live:js](http://livejs.network).
71+
72+
Also, thank you so much, Ableton for [being very open with Push 2 and documenting almost everything
73+
about this](https://github.com/Ableton/push-interface) awesome hardware.

examples/simple-anim.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const USB = require('usb')
12
const Canvas = require('canvas')
23
const path = require('path')
34
const { initPush, sendFrame } = require(path.join(__dirname, '..', 'index.js'))
@@ -27,13 +28,16 @@ let frameNum = 0
2728
function nextFrame() {
2829
drawFrame(ctx, frameNum)
2930
frameNum++
30-
sendFrame(ctx, function() {
31-
process.nextTick(function() {
32-
nextFrame()
33-
})
31+
sendFrame(ctx, function(error) {
32+
// we can ignore any error here, more or less
33+
setTimeout(nextFrame,10) // Do not use nextTick here, as this will not allow USB callbacks to fire.
3434
})
3535
}
3636

37-
initPush(function() {
37+
initPush(function(error) {
38+
if (error) {
39+
console.log(error)
40+
}
41+
// It's ok to continue, as a Push 2 device may appear later
3842
nextFrame()
3943
})

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ function convertImage(image, frame) {
3737
}
3838
}
3939
/* this is thi actual device init */
40-
function _init(push) {
41-
if (push == null) { return; }
42-
push.open()
43-
const pushInterface = push.interface(0)
40+
function _init(device) {
41+
if (device == null) { return; }
42+
device.open()
43+
const pushInterface = device.interface(0)
4444
pushInterface.claim()
4545
endpoint = pushInterface.endpoint(1)
4646
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
2-
"name": "ableton-push-canvas-display",
2+
"name": "@halfbyte/ableton-push-canvas-display",
33
"version": "1.0.0",
44
"description": "send contents of a canvas 2d context to the Ableton Push 2 display",
55
"main": "index.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"example": "node examples/simple-anim.js"
89
},
910
"repository": {
1011
"type": "git",

0 commit comments

Comments
 (0)