Skip to content

Instantly share code, notes, and snippets.

@alanho
Created May 20, 2018 17:10
Show Gist options
  • Save alanho/1013b6672734a989d296f1e515280e42 to your computer and use it in GitHub Desktop.
Save alanho/1013b6672734a989d296f1e515280e42 to your computer and use it in GitHub Desktop.
General Aircon for Puck.js
var isOn = true;
var commands = {
off: [3.3,1.6,0.4,0.4,0.4,0.4,0.4,1.2,0.4,0.4,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4],
on: [3.3,1.6,0.4,0.4,0.4,0.4,0.4,1.2,0.4,0.4,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,1.2,0.4,0.4,0.4,0.4,0.5,0.3,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,1.2,0.4,1.2,0.4,1.2,0.4,1.2,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,1.2,0.4,0.4,0.4,0.4,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,1.2,0.4,1.2,0.4,1.2,0.4,0.4,0.4,1.2,0.4,1.2,0.4,0.4,0.4]
};
setWatch(function() {
if (isOn) {
console.log('turning off');
Puck.IR(commands.off);
} else {
console.log('turning on');
Puck.IR(commands.on);
}
isOn = !isOn;
}, BTN, {edge:"rising", debounce:50, repeat:true});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment