Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
readeral committed Aug 19, 2018
0 parents commit fec5ad0
Show file tree
Hide file tree
Showing 12 changed files with 929 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

Binary file added config/icons/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions config/nuimo-config.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script type="text/javascript">
RED.nodes.registerType('nuimo-config',{
category: 'config',
defaults: {
name: {value: ""}
}
});
</script>

<script type="text/x-red"
data-template-name="nuimo-config">
<div class="form-row">
<label><i class="icon-tag"></i> Name</label>
<input type="text" id="node-config-input-name">
</div>
</script>
41 changes: 41 additions & 0 deletions config/nuimo-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//Needs to 'hold' the bluetooth connection and expose it to the various 'normal' nodes

var nuimo = require('../nuimo.js')

module.exports = function(RED) {

/*let Nuimo = require('nuimojs'),
nuimo = new Nuimo();
*/
function nuimoConfigNode(n) {
RED.nodes.createNode(this,n);
this.nuimo = nuimo;
/*
this.users = [];
this.configNode = n.configNode
this.name = n.name;
var node = this;
nuimo.on("discover", (device) => {
nuimo.on("connect", () => {
node.warn("connected");
connection = "connected";
});
nuimo.on("disconnect", () => {
node.warn("disconnected");
connection = "disconnected";
});
device.connect();
});
function writeMatrix(instructions) {
node.warn("Writing matrix");
nuimo.setLEDMatrix([instructions.matrix], instructions.brightness, instructions.timeout, instructions.options);
}
nuimo.scan();*/
}

RED.nodes.registerType("nuimo-config",nuimoConfigNode);
}
Binary file added listener/icons/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions listener/nuimo-listener.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<script type="text/javascript">
RED.nodes.registerType('nuimo-listener', {
category: 'advanced',
color: '#C0C0C0',
defaults: {
name: { value: ""},
nuimoConfig: {type: "nuimo-config", required:true}
},
inputs: 0,
outputs: 1,
icon: "apple-touch-icon.png",
label: function() {
return this.name || "Nuimo listener";
},
paletteLabel: "Nuimo listener"
});
</script>

<script type="text/x-red" data-template-name="nuimo-listener">
<div class="form-row">
<label for="node-input-nuimoConfig">Config</label>
<input type="text" id="node-input-nuimoConfig">
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>

<script type="text/x-red" data-help-name="nuimo-listener">
<p>A Node-RED node that uses nuimojs and Noble to interact with nuimo devices</p>
</script>
11 changes: 11 additions & 0 deletions listener/nuimo-listener.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//Needs to access the events of Nuimo object

module.exports = function(RED) {
function nuimoListenerNode(config) {
RED.nodes.createNode(this,config);
this.config = config.nuimoConfig
this.nuimoConfig = RED.nodes.getNode(this.config);
var node = this;
}
RED.nodes.registerType("nuimo-listener",nuimoListenerNode);
}
52 changes: 52 additions & 0 deletions matrix/nuimo-set-matrix.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<script type="text/javascript">
RED.nodes.registerType('nuimo-set-matrix', {
category: 'advanced',
color: '#C0C0C0',
defaults: {
name: { value: "" },
matrix: {value: "0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0"},
brightness: { value: 255, validate:RED.validators.number()},
timeout: { value: 2000, validate:RED.validators.number()},
onionSkinning: { value: true },
nuimoConfig: {type:"nuimo-config", required:true}
},
inputs: 1,
outputs: 1,
icon: "hash.png",
label: function() {
return this.name || "Nuimo matrix";
},
paletteLabel: "Nuimo matrix"
});
</script>

<script type="text/x-red" data-template-name="nuimo-set-matrix">
<div class="form-row">
<label>Config</label>
<input type="text" id="node-input-nuimoConfig">
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name">
</div>
<div class="form-row">
<label for="node-input-matrix"><i class="icon-tag"></i> Matrix</label>
<input type="text" id="node-input-matrix" placeholder="0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0">
</div>
<div class="form-row">
<label for="node-input-brightness"><i class="icon-tag"></i> Brightness (0-255)</label>
<input type="text" id="node-input-brightness" placeholder="255">
</div>
<div class="form-row">
<label for="node-input-timeout"><i class="icon-tag"></i> Timeout</label>
<input type="text" id="node-input-timeout" placeholder="2000">
</div>
<div class="form-row">
<label for="node-input-onionSkinning"><i class="icon-tag"></i> Smooth transition</label>
<input type="checkbox" id="node-input-onionSkinning">
</div>
</script>

<script type="text/x-red" data-help-name="nuimo-set-matrix">
<p>A node for creating a matrix to pass through to the Nuimo output node. The matrix value is passed via msg.setMatrix property</p>
</script>
24 changes: 24 additions & 0 deletions matrix/nuimo-set-matrix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//Needs to access the 'writeMatrix' method of Nuimo object

module.exports = function(RED) {

function nuimoSetMatrixNode(config) {
RED.nodes.createNode(this,config);
//import the config node
this.nuimoConfig = RED.nodes.getNode(config.nuimoConfig);

this.matrix = config.matrix;
this.brightness = config.brightness;
this.timeout = config.timeout;
this.onionSkinning = config.onionSkinning;

var node = this;
this.on('input', function(msg) {
let instructions = { matrix: node.matrix, brightness: node.brightness, timeout: node.timeout, options: {onionSkinning: node.onionSkinning}};
msg.instructions = instructions;
nuimo.writeMatrix(instructions);
node.send(msg);
});
}
RED.nodes.registerType("nuimo-set-matrix",nuimoSetMatrixNode);
}
22 changes: 22 additions & 0 deletions nuimo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
let Nuimo = require('nuimojs'),
nuimo = new Nuimo();

nuimo.on("discover", (device) => {
device.on("connect", () => {
console.log("Nuimo connected");
});
device.on("disconnect", () => {
console.log("Nuimo disconnected");
});
device.on("press", () => {
console.log("Press");
});
function writeMatrix(instructions) {
device.setLEDMatrix([instructions.matrix], instructions.brightness, instructions.timeout, instructions.options);
}
device.connect();
});

nuimo.scan();

module.exports.writeMatrix = writeMatrix;
Loading

0 comments on commit fec5ad0

Please sign in to comment.