add streaming stuff

This commit is contained in:
2018-10-03 13:32:23 +02:00
parent dff8545d65
commit 9c6ec9b231
12 changed files with 413 additions and 102 deletions

2
test/.gitignore vendored
View File

@@ -1 +1 @@
node_modules/
node_modules/

45
test/package-lock.json generated
View File

@@ -7,11 +7,56 @@
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
"integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg=="
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
"color-string": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/color-string/-/color-string-1.5.3.tgz",
"integrity": "sha512-dC2C5qeWoYkxki5UAXapdjqO672AM4vZuPGRQfO8b5HKuKGBbKWpITyDYN7TOFKvRW7kOgAn3746clDBMDJyQw==",
"dev": true,
"requires": {
"color-name": "1.1.4",
"simple-swizzle": "0.2.2"
}
},
"coolhue": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/coolhue/-/coolhue-1.0.9.tgz",
"integrity": "sha512-4+ctEja6XNJ8GrV+OLbioHWssC8tT/IUSZlS6i/RXc0R+ef7g6jNGmLC4VwhEKCJXTKPQ0FqbwojYLDtpPXs1w=="
},
"is-arrayish": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz",
"integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==",
"dev": true
},
"neopixel-utils": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/neopixel-utils/-/neopixel-utils-1.0.2.tgz",
"integrity": "sha1-e2IJvR3kmEaRu5nR46iv+8h1Zh4=",
"dev": true,
"requires": {
"color-string": "1.5.3"
}
},
"ramda": {
"version": "0.25.0",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.25.0.tgz",
"integrity": "sha512-GXpfrYVPwx3K7RQ6aYT8KPS8XViSXUVJT1ONhoKPE9VAleW42YE+U+8VEyGWt41EnEQW7gwecYJriTI0pKoecQ=="
},
"simple-swizzle": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz",
"integrity": "sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo=",
"dev": true,
"requires": {
"is-arrayish": "0.3.2"
}
},
"ws": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-6.0.0.tgz",

52
test/stream.js Normal file
View File

@@ -0,0 +1,52 @@
const WebSocket = require('ws');
const { times, min, max } = require('ramda');
const cmdWs = new WebSocket('ws://192.168.1.247/stream');
const {Strip} = require('neopixel-utils');
const randomColor = () => Math.floor(Math.random() * 255);
let strip = Strip(8);
//strip.setPixelColor(0, [randomColor(), randomColor(), randomColor()]);
//console.log(strip.getPixelColor(0));
/* const color = (r, g, b) => {
return uint16_t((r & 0xF8) << 8)
| uint16_t((g & 0xFC) << 3)
| uint16_t(b >> 3);
} */
/* const color = (r, g, b) => {
return ((r & 0xF8) << 8)
| ((g & 0xFC) << 3)
| (b >> 3);
}
const createTest = (ws, items) => () => {
console.log(`Items: ${items}`)
let array = new Uint16Array(items);
times(index => {
const r = index === 0 ? 255 : Math.floor(Math.random() * 255)
const g = index === 0 ? 0 : Math.floor(Math.random() * 255)
const b = index === 0 ? 255 : Math.floor(Math.random() * 255)
const number = color(r, g, b)
console.log(`R: ${r} G: ${g} B: ${b}`)
//const number = Math.floor(Math.random() * 65535);
array[index] = number
console.log(number)
}
, items);
ws.send(array);
}
*/
const createTest = (ws, items) => () => {
console.log(`Items: ${items}`)
times(index => {
strip.setPixelColor(index, [randomColor(), randomColor(), randomColor()]);
} , items);
console.log(strip.buffer);
ws.send(strip.buffer);
}
cmdWs.on('message', console.log);
cmdWs.on('open', createTest(cmdWs, 5));