From 6b354fed02e3fb8bd72ce7fc595e75496c13d5af Mon Sep 17 00:00:00 2001 From: Jane Petrovna Date: Tue, 25 May 2021 21:55:56 -0400 Subject: [PATCH] add rpi library --- .gitignore | 3 ++- config.json | 3 +++ index.js | 18 +++++++++++------- lights.js | 7 +++++++ package.json | 5 ++++- pnpm-lock.yaml | 41 +++++++++++++++++++++++++++++++++++++++++ run.sh | 2 +- 7 files changed, 69 insertions(+), 10 deletions(-) create mode 100644 config.json create mode 100644 lights.js create mode 100644 pnpm-lock.yaml diff --git a/.gitignore b/.gitignore index ed8ebf5..631db64 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -__pycache__ \ No newline at end of file +__pycache__ +node_modules/ diff --git a/config.json b/config.json new file mode 100644 index 0000000..077404a --- /dev/null +++ b/config.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/index.js b/index.js index 5f82ab6..211c872 100644 --- a/index.js +++ b/index.js @@ -1,11 +1,15 @@ import * as server from './server.js'; +import * as lights from './lights.js'; + +const cfg = require('./config.json'); + +global.cfg = cfg; -console.log(server) server.recv( - (res) => { - console.log(`callback: ${res}`); - }, - (res) => { - console.log(`error callback: ${res}`); - } + (res) => { + lights.parse_pattern(JSON.parse(res)); + }, + (res) => { + console.log(`error callback: ${res}`); + } ); diff --git a/lights.js b/lights.js new file mode 100644 index 0000000..52389cb --- /dev/null +++ b/lights.js @@ -0,0 +1,7 @@ +import * from 'rpi-ws281x-native' + +const fade_ticks = 10; + +export function parse_pattern(pattern) { + console.log(pattern) +} \ No newline at end of file diff --git a/package.json b/package.json index 2d193ee..dc0441d 100644 --- a/package.json +++ b/package.json @@ -13,5 +13,8 @@ "url": "git@ssh.gitdab.com:jane/leds" }, "author": "jane@j4.pm", - "license": "UNLICENSED" + "license": "UNLICENSED", + "dependencies": { + "rpi-ws281x-native": "^1.0.3" + } } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..a4b18ca --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,41 @@ +dependencies: + eris: 0.15.1 +lockfileVersion: 5.2 +packages: + /eris/0.15.1: + dependencies: + ws: 7.4.6 + dev: false + engines: + node: '>=10.4.0' + optionalDependencies: + opusscript: 0.0.8 + tweetnacl: 1.0.3 + resolution: + integrity: sha512-IQ3BPW6OjgFoqjdh+irPOa1jFlkotk+WNu2GQQ7QAQfbzQEPZgn+F+hpOxfMUXPHOZMX4sPKLkVDkMHAssBYhw== + /opusscript/0.0.8: + dev: false + optional: true + resolution: + integrity: sha512-VSTi1aWFuCkRCVq+tx/BQ5q9fMnQ9pVZ3JU4UHKqTkf0ED3fKEPdr+gKAAl3IA2hj9rrP6iyq3hlcJq3HELtNQ== + /tweetnacl/1.0.3: + dev: false + optional: true + resolution: + integrity: sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw== + /ws/7.4.6: + dev: false + engines: + node: '>=8.3.0' + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + resolution: + integrity: sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A== +specifiers: + eris: ^0.15.1 diff --git a/run.sh b/run.sh index 5da169d..d0c7b85 100644 --- a/run.sh +++ b/run.sh @@ -1,2 +1,2 @@ git pull -python ./leds.py \ No newline at end of file +node index.js \ No newline at end of file