Skip to content

Commit

Permalink
small cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
todbot committed Aug 30, 2016
1 parent 6b28a94 commit 03dcbd2
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 36 deletions.
2 changes: 1 addition & 1 deletion NOTES.md
Expand Up @@ -64,7 +64,7 @@ Random notes / documentation while developing the app
- `~off` -- Turn blink(1) off completely (stop patterns, set to dark)
- `~blink:color-count` -- blink color-dark-color-dark, count times. e.g. `~blink:white-3`, `~blink:#ff0000-5`
- `~blink:color-count-time` -- blink color-dark-color-dark, count times, blink time in secs e.g. `~blink:white-3-1.3`, `~blink:#ff0000-5-0.1`
- `~pattern:<patternstr>` -- Play a pattern in string form. e.g. `~pattern:3,#ff00ff,0.5,0,#00ff00,1.3,0`
- `~pattern:<name>:<patternstr>` -- Play a pattern in string form. e.g. `~pattern:bob:3,#ff00ff,0.5,0,#00ff00,1.3,0`

### URL / Script / Tool color & pattern matching
- In general, try to match previous behavior at https://github.com/todbot/blink1/blob/master/docs/blink1control-file-script-url-format.md
Expand Down
11 changes: 0 additions & 11 deletions app/components/gui/bigButtonSet.js
Expand Up @@ -172,17 +172,6 @@ var BigButtonSet = React.createClass({
log.msg("bigButtonSet.playBigButtonSys: no button ", buttonname);
}
},
// playBigButton: function(buttontype, buttonindex) {
// log.msg("bigButtonSet.playBigButton:", buttontype, buttonindex);
// PatternsService.stopAllPatterns();
// var button = this.state.buttonsUser[buttonindex];
// if( buttontype === 'sys' ) {
// button = this.state.buttonsSys[buttonindex];
// }
// else {
// this.playBigButtonUser( buttonindex );
// }
// },

render: function() {
var patterns = PatternsService.getAllPatterns();
Expand Down
2 changes: 1 addition & 1 deletion app/components/gui/preferencesModal.js
Expand Up @@ -105,7 +105,7 @@ var PreferencesModal = React.createClass({
handleBlink1SerialChange: function(serial) {
log.msg("handleBlink1NonComputerChange: ",serial);
// if( serial )
PatternsService.playPattern( '~blink-#888888-3', serial);
PatternsService.playPattern( '~blink:#888888-3', serial);
this.setState({blink1ToUse: serial});
},
handleBlink1NonComputerChoice: function(e) {
Expand Down
7 changes: 7 additions & 0 deletions app/server/apiServer.js
Expand Up @@ -35,6 +35,13 @@ app.get('/blink1/off', function(req,res) {
status: "blink1 off"
});
});
app.get('/blink1/on', function(req,res) {
PatternsService.stopAllPatterns();
Blink1Service.fadeToColor(0.1, '#ffffff'); // turn off everyone
res.json({
status: "blink1 on"
});
});
app.get('/blink1/fadeToRGB', function(req, res) {
var color = tinycolor(req.query.rgb);
var secs = Number(req.query.time) || 0.1;
Expand Down
31 changes: 16 additions & 15 deletions app/server/blink1Service.js
Expand Up @@ -163,7 +163,7 @@ var Blink1Service = {
});
blink1s = [ ]; //{serial: '', device: null } ]; // startup state
log.msg("Blink1Service._removeAllDevices: done");
// FIXME: notify?
// FIXME: notify? nah, because scanForDevices always called after
},

/**
Expand Down Expand Up @@ -256,20 +256,22 @@ var Blink1Service = {
getCurrentBlink1Id() {
return currentBlink1Id;
},
// FIXME: support multiple blink1s
setCurrentLedN: function(n) {
currentState[0].ledn = n;

setCurrentLedN: function(n,blink1id) {
var blink1idx = this.idToBlink1Index(blink1id);
currentState[blink1idx].ledn = n;
this.notifyChange();
},
// FIXME: support multiple blink1s

getCurrentLedN: function(blink1id) {
var blink1idx = this.idToBlink1Index(blink1id);
// blink1idx = blink1idx || 0;
return currentState[blink1idx].ledn;
},
// FIXME: support multiple blink1s
setCurrentMillis: function(m) {
currentState[0].millis = m;

setCurrentMillis: function(m,blink1id) {
var blink1idx = this.idToBlink1Index(blink1id);
currentState[blink1idx].millis = m;
this.notifyChange();
},
getCurrentMillis: function(blink1id) {
Expand All @@ -290,7 +292,7 @@ var Blink1Service = {
return currentState[blink1idx].colors;
},
/**
* Lookup blink1id and map to an index in blink1s array
* Lookup blink1id (blink1 serial number) and map to an index in blink1s array
* If 'blink1ToUse' is set, and blink1id is undefined or 0, use blink1ToUse
* FIXME: Should use conf.blink1Service.blink1ToUse
* FIXME: should convert serial to index
Expand All @@ -301,12 +303,11 @@ var Blink1Service = {
if( blink1id === undefined || blink1id === '' ) {
if( this.conf.blink1ToUse ) {
blink1id = this.conf.blink1ToUse;
}
else {
} else {
blink1id = currentBlink1Id;
}
}
// it's an array index
// it's an array index (NOTE: SHOULD NEVER HIT THIS, BUT JUST IN CASE)
if( blink1id >= 0 && blink1id < blink1s.length ) {
return blink1id;
}
Expand All @@ -323,9 +324,9 @@ var Blink1Service = {
// debug only
dumpCurrentState: function() {
var str = '';
currentState.map( function(s, i) {
var colorsstr = s.colors.reduce( function(prev,curr) { return prev +','+ curr.toHexString(); });
str += 'blink1Idx:'+i+ ': ledn:'+s.ledn+ ', millis:'+s.millis+ ', colors:'+colorsstr + ';\n';
currentState.map( function(b1state, i) {
var colorsstr = b1state.colors.reduce( function(prev,curr) { return prev +','+ curr.toHexString(); });
str += 'blink1Idx:'+i+ ': ledn:'+b1state.ledn+ ', millis:'+b1state.millis+ ', colors:'+colorsstr + ';\n';
});
return str;
},
Expand Down
16 changes: 8 additions & 8 deletions docs/patterns.md
Expand Up @@ -2,14 +2,14 @@


Allowed patterns to play/stop:
* - {patternname}
* - {existing patternname}
* - ~off
* - ~blink-{color}-{count}
* - ~blink-{color}-{count}-{on/off time}
* - ~blink-white-3
* - ~blink-#ff00ff-5
* - ~blink-green-3-0.5
* - ~pattern:3,#ff00ff,0.5,0,#00ff00,1.3,0
* - ~pattern:1,#00f300,0.5,0,#000000,0.5,0
* - ~blink:{color}-{count}
* - ~blink:{color}-{count}-{on/off time}
* - ~blink:white-3
* - ~blink:#ff00ff-5
* - ~blink:green-3-0.5
* - ~pattern:bob:3,#ff00ff,0.5,0,#00ff00,1.3,0
* - ~pattern:good to go:1,#00f300,0.5,0,#000000,0.5,0
* - ~pattern-stop:pattname
* - #hexcolor

0 comments on commit 03dcbd2

Please sign in to comment.