From 12eb2ef3c3dc9f53f861232ba8ff8d4289267698 Mon Sep 17 00:00:00 2001 From: William Toohey Date: Wed, 30 Sep 2015 23:11:57 +1000 Subject: [PATCH] Serial interface for flashing LEDs. Uses JUart --- js/HuesCanvas.js | 22 ++++++++ serial.html | 138 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100644 serial.html diff --git a/js/HuesCanvas.js b/js/HuesCanvas.js index c7ffc9f..ece9288 100644 --- a/js/HuesCanvas.js +++ b/js/HuesCanvas.js @@ -59,6 +59,7 @@ function HuesCanvas(element, aContext, core) { this.colourFadeLength=0; this.oldColour=0xFFFFFF; this.newColour=0xFFFFFF; + this.serialColour = 0; this.blendMode = "hard-light"; // Chosen because they look decent @@ -73,6 +74,26 @@ function HuesCanvas(element, aContext, core) { requestAnimationFrame(this.getAnimLoop()); } +HuesCanvas.prototype.sendSerial = function() { + if(!ser) + return; + var col = this.colour; + if(this.blackout) { + bOpacity = (this.aContext.currentTime - this.blackoutStart)*10; + bOpacity = Math.min(1, bOpacity); + col *= 1 - bOpacity; + col = Math.floor(col); + } + if(col == this.serialColour) + return; + this.serialColour = col; + var str = String(col); + for(var i = 0; i < str.length; i++) { + ser.send(str[i]); + } + ser.send("\n".charCodeAt(0)); +} + HuesCanvas.prototype.resizeHandler = function(that) { return function() {that.resize();}; } @@ -224,6 +245,7 @@ HuesCanvas.prototype.animationLoop = function() { if(this.animating) { requestAnimationFrame(this.getAnimLoop()); } + this.sendSerial(); } HuesCanvas.prototype.setImage = function(image) { diff --git a/serial.html b/serial.html new file mode 100644 index 0000000..6c2134e --- /dev/null +++ b/serial.html @@ -0,0 +1,138 @@ + + + + + 0x40 + + + + + + + + + + + + + + + + + + + + + + +
+
+
0x00
+
+
+
+
+
+
x
+
+ + + + + + +
+ +
+
+
+ +
+
+
+
+

0x40 Hues of JS, v0.1

+

Adapted from the 0x40 Flash

+

Web-ified by mon

+

With help from Kepstin

+
+
+
+

Beat glossary

+
    +
  • x Vertical blur (snare)
  • +
  • o Horizontal blur (bass)
  • +
  • - No blur
  • +
  • + Blackout
  • +
  • | Short blackout
  • +
  • : Color only
  • +
  • * Image only
  • +
  • X Vertical blur only
  • +
  • O Horizontal blur only
  • +
  • ~ Fade color
  • +
  • = Fade and change image
  • + +
+
+
+

Keyboard shortcuts

+
    +
  • ↑↓ Change song
  • +
  • ←→ Change image
  • +
  • [SHIFT] Random song
  • +
  • -+ Change volume
  • +
  • [M] Toggle mute
  • +
  • [F] Toggle automode
  • +
  • [H] Toggle UI hide
  • +
  • [C] Character list
  • +
  • [S] Song list
  • +
  • [W] Toggle window
  • +
  • [R] Resource packs
  • +
  • [O] Options
  • +
  • [I] Information
  • +
  • [1-4] Change UI
  • +
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file