Integrated Changes from Original repository
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,24 @@
|
||||
The following liscence applies to the inclueded Websocket class which was created by G33kDude (https://github.com/G33kDude/WebSocket.ahk):
|
||||
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 GeekDude
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,418 @@
|
||||
#NoEnv
|
||||
#SingleInstance force ; only lets one run
|
||||
SetBatchLines, -1
|
||||
|
||||
#Persistent ; prevents the script from exiting automatically
|
||||
|
||||
; Register a function to be called on exit:
|
||||
OnExit("ExitFunc")
|
||||
|
||||
; make the notification box
|
||||
notificationEnable := true ; set this to false to disable the notification popups
|
||||
notificationTime := 1 ; seconds the notifications stay
|
||||
|
||||
n := new Notification("Starting led shortcuts!", 200,14, ,notificationTime)
|
||||
|
||||
; make the socket
|
||||
socket := new McLightingServer("ws://192.168.1.33:81") ; replace with the ip address of the mclighting controller
|
||||
|
||||
incrementAmount := 10 ; how finely you adjust the color, speed, and brightness per keypress
|
||||
maxColor := 255
|
||||
maxMode := 56 ; the maximum mode id number
|
||||
|
||||
red := 127
|
||||
green := 127
|
||||
blue := 127
|
||||
|
||||
brightness := 127
|
||||
speed := 127
|
||||
mode := 1
|
||||
|
||||
^#Numpad4:: ; switch modes down
|
||||
mode := mode - 1
|
||||
if(mode < 0)
|
||||
mode := maxMode
|
||||
cmd = /%mode% ; / is the set effect mode command
|
||||
setNotification("Mode: " + mode)
|
||||
sendCmd(cmd)
|
||||
; MsgBox %cmd%
|
||||
return
|
||||
|
||||
|
||||
^#Numpad6:: ; switch modes up
|
||||
mode := mode + 1
|
||||
if(mode > maxMode)
|
||||
mode := 0
|
||||
setNotification("Mode: " + mode)
|
||||
cmd = /%mode%
|
||||
sendCmd(cmd)
|
||||
; MsgBox %cmd%
|
||||
return
|
||||
|
||||
^#Numpad5:: ; turn off
|
||||
setNotification("Leds are off")
|
||||
sendCmd("=off") ; = is the set control command
|
||||
return
|
||||
|
||||
^#Numpad0:: ; turn on to static color
|
||||
setNotification("Leds are on")
|
||||
cmd := "*"+toHexColor(red,green,blue) ; * is the set all command
|
||||
sendCmd(cmd) ; = is the set control command
|
||||
return
|
||||
|
||||
|
||||
^#NumpadSub:: ; decreases brightness
|
||||
brightness := brightness - incrementAmount
|
||||
if(brightness < 0)
|
||||
brightness := 0
|
||||
cmd = `%%brightness% ; % is the set brightness mode command. ` is the escape character
|
||||
setNotification("Brightness: " + brightness)
|
||||
sendCmd(cmd)
|
||||
; MsgBox %cmd%
|
||||
return
|
||||
|
||||
^#NumpadAdd:: ; increases brightness
|
||||
brightness := brightness + incrementAmount
|
||||
if(brightness > maxColor)
|
||||
brightness := maxColor
|
||||
cmd = `%%brightness% ; % is the set brightness mode command
|
||||
setNotification("Brightness: " + brightness)
|
||||
sendCmd(cmd)
|
||||
; MsgBox %cmd%
|
||||
return
|
||||
|
||||
^#NumpadDiv:: ; decreases speed
|
||||
speed := speed - incrementAmount
|
||||
if(speed < 0)
|
||||
speed := 0
|
||||
cmd = ?%speed% ; ? is the set brightness mode command
|
||||
setNotification("Speed: "+ speed)
|
||||
sendCmd(cmd)
|
||||
; MsgBox %cmd%
|
||||
return
|
||||
|
||||
^#NumpadMult:: ; increases speed
|
||||
speed := speed + incrementAmount
|
||||
if(speed > maxColor)
|
||||
speed := maxColor
|
||||
cmd = ?%speed% ; ? is the set brightness mode command
|
||||
setNotification("Speed: "+ speed)
|
||||
sendCmd(cmd)
|
||||
; MsgBox %cmd%
|
||||
return
|
||||
|
||||
|
||||
^#Numpad7:: ; increase red amount
|
||||
red := red + incrementAmount
|
||||
if(red > maxColor)
|
||||
red := maxColor
|
||||
|
||||
cmd := "#"+toHexColor(red,green,blue) ; # is the set main color command
|
||||
; MsgBox %cmd%
|
||||
setNotification("Red: " + red)
|
||||
sendCmd(cmd)
|
||||
|
||||
return
|
||||
|
||||
^#Numpad1:: ; decrease red amount
|
||||
red := red - incrementAmount
|
||||
if(red < 0)
|
||||
red := 0
|
||||
|
||||
cmd := "#"+toHexColor(red,green,blue) ; # is the set main color command
|
||||
; MsgBox %cmd%
|
||||
setNotification("Red: " + red)
|
||||
sendCmd(cmd)
|
||||
|
||||
return
|
||||
|
||||
^#Numpad8:: ; increase green amount
|
||||
green := green + incrementAmount
|
||||
if(green > maxColor)
|
||||
green := maxColor
|
||||
|
||||
cmd := "#"+toHexColor(red,green,blue) ; # is the set main color command
|
||||
; MsgBox %cmd%
|
||||
setNotification("Green: " + green)
|
||||
sendCmd(cmd)
|
||||
|
||||
return
|
||||
|
||||
^#Numpad2:: ; decrease green amount
|
||||
green := green - incrementAmount
|
||||
if(green < 0)
|
||||
green := 0
|
||||
|
||||
cmd := "#"+toHexColor(red,green,blue) ; # is the set main color command
|
||||
; MsgBox %cmd%
|
||||
setNotification("Green: " + green)
|
||||
sendCmd(cmd)
|
||||
|
||||
return
|
||||
|
||||
^#Numpad9:: ; increase blue amount
|
||||
blue := blue + incrementAmount
|
||||
if(blue > maxColor)
|
||||
blue := maxColor
|
||||
|
||||
cmd := "#"+toHexColor(red,green,blue) ; # is the set main color command
|
||||
; MsgBox %cmd%
|
||||
setNotification("Blue: " + blue)
|
||||
sendCmd(cmd)
|
||||
|
||||
return
|
||||
|
||||
^#Numpad3:: ; decrease blue amount
|
||||
blue := blue - incrementAmount
|
||||
if(blue < 0)
|
||||
blue := 0
|
||||
|
||||
cmd := "#"+toHexColor(red,green,blue) ; # is the set main color command
|
||||
; MsgBox %cmd%
|
||||
setNotification("Blue: " + blue)
|
||||
sendCmd(cmd)
|
||||
|
||||
return
|
||||
|
||||
sendCmd(cmd)
|
||||
{
|
||||
global socket
|
||||
; MsgBox connected: %connected%
|
||||
if( socket.connected )
|
||||
{
|
||||
socket.Send(cmd)
|
||||
; MsgBox %cmd%
|
||||
}
|
||||
else
|
||||
setNotification("Not connected to server!")
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
toHexColor(r, g, b)
|
||||
{
|
||||
SetFormat, IntegerFast, hex ; To print values as hexadecimal
|
||||
colorNum := r*65536 + g*256 + b
|
||||
color = 000000%colorNum% ; convert to string and add preceeding zeros
|
||||
color := StrReplace(color, "0x") ; replace the 0x from the middle
|
||||
color := SubStr( color, -5 ) ; get last 6 characters
|
||||
|
||||
SetFormat, IntegerFast, dec ; sets the print mode back to decimal
|
||||
return ""+color ;
|
||||
}
|
||||
|
||||
setNotification(message)
|
||||
{
|
||||
global notificationEnable
|
||||
global n ; the notification class
|
||||
if(notificationEnable)
|
||||
{
|
||||
n.updateMessage(message)
|
||||
n.nshow()
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
ExitFunc(ExitReason, ExitCode)
|
||||
{
|
||||
; MsgBox Exiting
|
||||
global n ; notification class
|
||||
n.ndestroy() ; deletes the notification
|
||||
return 0 ; must return zero to exit
|
||||
}
|
||||
|
||||
class McLightingServer extends WebSocket
|
||||
{
|
||||
OnOpen(Event)
|
||||
{
|
||||
setNotification("Connection established!")
|
||||
; InputBox, Data, WebSocket, Enter some text to send through the websocket.
|
||||
; this.Send(Data)
|
||||
|
||||
; global connected
|
||||
this.connected := 1
|
||||
; MsgBox connection %connected%
|
||||
}
|
||||
|
||||
OnMessage(Event)
|
||||
{
|
||||
; MsgBox, % "Received Data: " Event.data
|
||||
; this.Close()
|
||||
}
|
||||
|
||||
OnClose(Event)
|
||||
{
|
||||
setNotification("Websocket Closed!")
|
||||
; MsgBox closed!
|
||||
this.connected := 0
|
||||
this.Disconnect()
|
||||
ExitApp
|
||||
}
|
||||
|
||||
OnError(Event)
|
||||
{
|
||||
setNotification("Websocket Error")
|
||||
; MsgBox error!
|
||||
this.connected := 0
|
||||
this.Close()
|
||||
}
|
||||
|
||||
__Delete()
|
||||
{
|
||||
; setNotification(" Exiting Led controller ") ; sticks after program closes
|
||||
ExitApp
|
||||
}
|
||||
}
|
||||
|
||||
class WebSocket
|
||||
{
|
||||
__New(WS_URL)
|
||||
{
|
||||
this.connected := false ; flag for connection status
|
||||
static wb
|
||||
|
||||
; Create an IE instance
|
||||
Gui, +hWndhOld
|
||||
Gui, New, +hWndhWnd
|
||||
this.hWnd := hWnd
|
||||
Gui, Add, ActiveX, vWB, Shell.Explorer
|
||||
Gui, %hOld%: Default
|
||||
|
||||
; Write an appropriate document
|
||||
WB.Navigate("about:<!DOCTYPE html><meta http-equiv='X-UA-Compatible'"
|
||||
. "content='IE=edge'><body></body>")
|
||||
while (WB.ReadyState < 4)
|
||||
sleep, 50
|
||||
this.document := WB.document
|
||||
|
||||
; Add our handlers to the JavaScript namespace
|
||||
this.document.parentWindow.ahk_savews := this._SaveWS.Bind(this)
|
||||
this.document.parentWindow.ahk_event := this._Event.Bind(this)
|
||||
this.document.parentWindow.ahk_ws_url := WS_URL
|
||||
|
||||
; Add some JavaScript to the page to open a socket
|
||||
Script := this.document.createElement("script")
|
||||
Script.text := "ws = new WebSocket(ahk_ws_url);`n"
|
||||
. "ws.onopen = function(event){ ahk_event('Open', event); };`n"
|
||||
. "ws.onclose = function(event){ ahk_event('Close', event); };`n"
|
||||
. "ws.onerror = function(event){ ahk_event('Error', event); };`n"
|
||||
. "ws.onmessage = function(event){ ahk_event('Message', event); };"
|
||||
this.document.body.appendChild(Script)
|
||||
}
|
||||
|
||||
; Called by the JS in response to WS events
|
||||
_Event(EventName, Event)
|
||||
{
|
||||
this["On" EventName](Event)
|
||||
}
|
||||
|
||||
; Sends data through the WebSocket
|
||||
Send(Data)
|
||||
{
|
||||
; MsgBox %Data%
|
||||
this.document.parentWindow.ws.send(Data)
|
||||
}
|
||||
|
||||
; Closes the WebSocket connection
|
||||
Close(Code:=1000, Reason:="")
|
||||
{
|
||||
this.document.parentWindow.ws.close(Code, Reason)
|
||||
}
|
||||
|
||||
; Closes and deletes the WebSocket, removing
|
||||
; references so the class can be garbage collected
|
||||
Disconnect()
|
||||
{
|
||||
if this.hWnd
|
||||
{
|
||||
this.Close()
|
||||
Gui, % this.hWnd ": Destroy"
|
||||
this.hWnd := False
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Notification
|
||||
{
|
||||
__New(message, pnW=700, pnH=300, position="b r", time=10000)
|
||||
{
|
||||
this.showTime := time ; time that the notification shows up for
|
||||
|
||||
global pn_msg
|
||||
this.pn_msg := message ; message to display
|
||||
|
||||
Gui, Notify: +AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
|
||||
this.PN_hwnd := WinExist()
|
||||
|
||||
WinSet, ExStyle, +0x20
|
||||
WinSet, Transparent, 0 ; makes the box transparent so that it can fade in and out. 255 -> opaque; 0 -> transparent
|
||||
Gui, Notify: Color, 0x111111 ; background color
|
||||
Gui, Notify: Font, cWhite s10 w500, Terminal ; message color, size, weight, and font
|
||||
Gui, Notify: Add, Text, % " x" 20 " y" 12 " vpn_msg", % this.pn_msg ; add message
|
||||
RealW := pnW + 50
|
||||
RealH := pnH + 20
|
||||
Gui, Notify: Show, W%RealW% H%RealH% NoActivate
|
||||
this.WinMove(this.PN_hwnd, position)
|
||||
global windowID := ("ahk_id "this.PN_hwnd) ; window id
|
||||
this.nshow()
|
||||
}
|
||||
|
||||
ndestroy() {
|
||||
this.winfade(windowID,0,50) ; fades the box out
|
||||
Gui, Notify: Destroy
|
||||
return
|
||||
}
|
||||
|
||||
nhide(){ ; called by the timer
|
||||
showTimer:
|
||||
SetTimer, showTimer, Off ; turn off the timer
|
||||
global windowID
|
||||
winfade(windowID,0,50) ; fades the box out
|
||||
return
|
||||
}
|
||||
|
||||
nshow(){
|
||||
w:= ("ahk_id "+this.PN_hwnd)
|
||||
|
||||
WinGet,s,Transparent,%w% ; makes the notification visible
|
||||
s:=(s="")?255:s ;prevent trans unset bug
|
||||
WinSet,Transparent,210,%w%
|
||||
|
||||
Closetick := this.showTime*1000
|
||||
SetTimer, showTimer, % Closetick ; reset the hide timer
|
||||
return
|
||||
}
|
||||
|
||||
updateMessage(message) {
|
||||
this.pn_msg := message
|
||||
GuiControl, Notify: Text, pn_msg, % this.pn_msg
|
||||
return
|
||||
}
|
||||
|
||||
WinMove(hwnd,position) {
|
||||
SysGet, Mon, MonitorWorkArea
|
||||
WinGetPos,ix,iy,w,h, ahk_id %hwnd%
|
||||
x := InStr(position,"l") ? MonLeft : InStr(position,"hc") ? (MonRight-w)/2 : InStr(position,"r") ? MonRight - w : ix
|
||||
y := InStr(position,"t") ? MonTop : InStr(position,"vc") ? (MonBottom-h)/2 : InStr(position,"b") ? MonBottom - h : iy
|
||||
WinMove, ahk_id %hwnd%,,x,y
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
; winfade must be global for the timer to use it
|
||||
winfade(w:="",t:=128,i:=1,d:=10) {
|
||||
w:=(w="")?("ahk_id " WinActive("A")):w
|
||||
t:=(t>255)?255:(t<0)?0:t
|
||||
WinGet,s,Transparent,%w%
|
||||
s:=(s="")?255:s ;prevent trans unset bug
|
||||
WinSet,Transparent,%s%,%w%
|
||||
i:=(s<t)?abs(i):-1*abs(i)
|
||||
while(k:=(i<0)?(s>t):(s<t)&&WinExist(w)) {
|
||||
WinGet,s,Transparent,%w%
|
||||
s+=i
|
||||
WinSet,Transparent,%s%,%w%
|
||||
sleep %d%
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
!!! Make sure that the ip address is edited to match the ip address of your McLighting server !!!
|
||||
|
||||
If you are not familiar with AutoHotKey, this tutorial will get you started: https://autohotkey.com/docs/Tutorial.htm
|
||||
Once you have AutoHotKey installed, double click it to start the script.
|
||||
|
||||
If the Mclighting server goes down for some reason, a socket error notification will appear and you will have to restart the script to reconnect.
|
||||
|
||||
The script is not aware of the current state of the McLighting server and will override what is currently being displayed with its own internal values.
|
||||
|
||||
This has been tested on windows 7 and windows 10.
|
||||
Set the notificationTime variable to the time in seconds that you want the notification to stay on the screen.
|
||||
You can prevent notifications from appearing by setting the notificationEnable variable to false.
|
||||
|
||||
|
||||
The shortcuts only work on the numberpad and only when num lock is on! If you don't have a numberpad you must change the shortcuts to something else. Just be aware that you might be overrriding previously existing shortcuts! Here is the list of windows shortcuts: https://support.microsoft.com/en-us/help/12445/windows-keyboard-shortcuts
|
||||
|
||||
The shortcuts are as follows:
|
||||
|
||||
ctrl+windows+numpad4 decrements the animation mode
|
||||
|
||||
ctrl+windows+numpad6 increments the animation mode
|
||||
|
||||
ctrl+windows+numpad5 turns off the lights
|
||||
|
||||
ctrl+windows+numpad0 turns on all of the lights to the current color
|
||||
|
||||
ctrl+windows+numpadPlus increases the brightness
|
||||
|
||||
ctrl+windows+numpadSubtract decreases the brightness
|
||||
|
||||
ctrl+windows+numpadMultiply increases the speed
|
||||
|
||||
ctrl+windows+numpadDivide decreases the speed
|
||||
|
||||
ctrl+windows+numpad7 increments the red component of the current color
|
||||
|
||||
ctrl+windows+numpad1 decrements the red component of the current color
|
||||
|
||||
ctrl+windows+numpad8 increments the green component of the current color
|
||||
|
||||
ctrl+windows+numpad2 decrements the green component of the current color
|
||||
|
||||
ctrl+windows+numpad9 increments the blue component of the current color
|
||||
|
||||
ctrl+windows+numpad3 decrements the blue component of the current color
|
||||
@@ -7,6 +7,7 @@ light:
|
||||
effect: true
|
||||
effect_list:
|
||||
######
|
||||
- "Static"
|
||||
- "Blink"
|
||||
- "Breath"
|
||||
- "Color Wipe"
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<!--Let browser know website is optimized for mobile-->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<title>McLighting (RGBW) v2</title>
|
||||
</head>
|
||||
|
||||
|
||||
+11
-14
@@ -9,13 +9,14 @@
|
||||
<!--Let browser know website is optimized for mobile-->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
|
||||
<meta charset="utf-8"/>
|
||||
<title>McLighting v2</title>
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<title>McLighting (RGBW) v2</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<nav class="blue light-blueXXX lighten-1XXX" role="navigation" id="mc-nav">
|
||||
<div class="nav-wrapper container">
|
||||
<a id="logo-container" href="#" class="brand-logo">Mc Lighting v2</a>
|
||||
<a id="logo-container" href="#" class="brand-logo">McLighting (RGBW) v2</a>
|
||||
|
||||
<ul class="right hide-on-med-and-down">
|
||||
<li><a href="#" class="mc-navlink" data-pane="pane1">Wheel</a></li>
|
||||
@@ -101,6 +102,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="input-field col s12">
|
||||
<label for="txt_white">White</label><br/>
|
||||
<p class="range-field"><input type="range" id="rng_white" min="0" max="255" class="update_colors" /></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="input-field col s12">
|
||||
<label for="txt_delay">Speed</label><br/>
|
||||
@@ -118,18 +126,6 @@
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col s12 m6 l6 btn_grid">
|
||||
<a class="btn waves-effect waves-light btn_mode_static blue" name="action" data-mode="off">OFF
|
||||
<i class="material-icons right">send</i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col s12 m6 l6 btn_grid">
|
||||
<a class="btn waves-effect waves-light btn_mode_static blue" name="action" data-mode="tv">TV
|
||||
<i class="material-icons right">send</i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div id="modes">
|
||||
<div class="input-field col s12">
|
||||
Loading animations...
|
||||
@@ -158,4 +154,5 @@
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>
|
||||
<script type="text/javascript">@@include('js/script.js')</script>
|
||||
</body>
|
||||
\ No newline at end of file
|
||||
</html>
|
||||
@@ -25,9 +25,9 @@ $(function(){
|
||||
$('#' + pane).removeClass('hide');
|
||||
$('.button-collapse').sideNav('hide');
|
||||
|
||||
if (pane == "pane2") {
|
||||
setMainColor();
|
||||
}
|
||||
//if (pane == "pane2") {
|
||||
// setMainColor();
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,16 +37,60 @@ $(function(){
|
||||
function init() {
|
||||
console.log("Connection websockets to:", ws_url);
|
||||
connection = new WebSocket(ws_url, ['arduino']);
|
||||
|
||||
var mode = 0;
|
||||
var ws2812fx_mode = 0;
|
||||
$.getJSON("http://" + host + "/status", function(data) {
|
||||
console.log("status", data);
|
||||
mode = data.mode;
|
||||
ws2812fx_mode = data.ws2812fx_mode;
|
||||
$("#rng_brightness").val(data.brightness);
|
||||
$("#rng_white").val(data.color[0]);
|
||||
$("#rng_red").val(data.color[1]);
|
||||
$("#rng_green").val(data.color[2]);
|
||||
$("#rng_blue").val(data.color[3]);
|
||||
$("#rng_delay").val(data.speed);
|
||||
var statusColor = "#" + componentToHex(data.color[1]) + componentToHex(data.color[2]) + componentToHex(data.color[3]);
|
||||
$('#status').css("backgroundColor", statusColor);
|
||||
$('#status_color').text(statusColor + "- R=" + data.color[1] + ", G=" + data.color[2] + ", B=" + data.color[3]);
|
||||
});
|
||||
|
||||
// Load modes async
|
||||
// List of all color modes
|
||||
// enum MODE { SET_MODE, HOLD, OFF, ALL, WIPE, RAINBOW, RAINBOWCYCLE, THEATERCHASE, TWINKLERANDOM, THEATERCHASERAINBOW, TV, CUSTOM, AUTO };
|
||||
$.getJSON("http://" + host + "/get_modes", function(data) {
|
||||
//console.log("modes", data);
|
||||
|
||||
console.log("modes", data);
|
||||
var modes_html = "";
|
||||
modes_html += '<div class="col s12 m6 l6 btn_grid">';
|
||||
if (mode == 2) {
|
||||
modes_html += '<a class="btn waves-effect waves-light btn_mode_static red" name="action" data-mode="off">OFF';
|
||||
} else {
|
||||
modes_html += '<a class="btn waves-effect waves-light btn_mode_static blue" name="action" data-mode="off">OFF';
|
||||
}
|
||||
modes_html += '<i class="material-icons right">send</i>';
|
||||
modes_html += '</a>';
|
||||
modes_html += '</div>'
|
||||
modes_html += '<div class="col s12 m6 l6 btn_grid">';
|
||||
if (mode == 10) {
|
||||
modes_html += '<a class="btn waves-effect waves-light btn_mode_static red" name="action" data-mode="tv">TV';
|
||||
} else {
|
||||
modes_html += '<a class="btn waves-effect waves-light btn_mode_static blue" name="action" data-mode="tv">TV';
|
||||
}
|
||||
modes_html += '<i class="material-icons right">send</i>';
|
||||
modes_html += '</a>';
|
||||
modes_html += '</div>';
|
||||
|
||||
|
||||
|
||||
|
||||
data.forEach(function(current_mode){
|
||||
if (current_mode.mode !== undefined) {
|
||||
modes_html += '<div class="col s12 m6 l6 btn_grid">';
|
||||
modes_html += '<a class="btn waves-effect waves-light btn_mode blue" name="action" data-mode="' + current_mode.mode + '">(' + current_mode.mode +') '+ current_mode.name;
|
||||
if (mode == 1 && current_mode.mode == ws2812fx_mode) {
|
||||
modes_html += '<a class="btn waves-effect waves-light btn_mode red" name="action" data-mode="' + current_mode.mode + '">(' + current_mode.mode +') '+ current_mode.name;
|
||||
|
||||
} else {
|
||||
modes_html += '<a class="btn waves-effect waves-light btn_mode blue" name="action" data-mode="' + current_mode.mode + '">(' + current_mode.mode +') '+ current_mode.name;
|
||||
}
|
||||
modes_html += '<i class="material-icons right">send</i>';
|
||||
modes_html += '</a>';
|
||||
modes_html += '</div>';
|
||||
@@ -55,7 +99,7 @@ $(function(){
|
||||
|
||||
$('#modes').html(modes_html);
|
||||
});
|
||||
|
||||
|
||||
// When the connection is open, send some data to the server
|
||||
connection.onopen = function () {
|
||||
//connection.send('Ping'); // Send the message 'Ping' to the server
|
||||
@@ -130,12 +174,16 @@ $(function(){
|
||||
}
|
||||
|
||||
function setMainColor() {
|
||||
var white = $("#rng_white").val();
|
||||
var red = $("#rng_red").val();
|
||||
var green = $("#rng_green").val();
|
||||
var blue = $("#rng_blue").val();
|
||||
var blue = $("#rng_blue").val();
|
||||
|
||||
var mainColorHex = componentToHex(red) + componentToHex(green) + componentToHex(blue);
|
||||
wsSetMainColor(mainColorHex);
|
||||
var hexColor = componentToHex(white) + componentToHex(red) + componentToHex(green) + componentToHex(blue);
|
||||
var statusColor = "#" + componentToHex(red) + componentToHex(green) + componentToHex(blue);
|
||||
wsSetMainColor(hexColor);
|
||||
$('#status').css("backgroundColor", statusColor);
|
||||
$('#status_color').text(statusColor + "- R=" + red + ", G=" + green + ", B=" + blue);
|
||||
}
|
||||
|
||||
|
||||
@@ -253,15 +301,18 @@ $(function(){
|
||||
|
||||
//display the touch/click position and color info
|
||||
function updateStatus(pos, color) {
|
||||
var hexColor = rgbToHex(color);
|
||||
wsSetAll(hexColor);
|
||||
//var hexColor = rgbToHex(color);
|
||||
//wsSetAll(hexColor);
|
||||
var hexColor = componentToHex(color[0]) + componentToHex(color[1]) + componentToHex(color[2]);
|
||||
wsSetMainColor(hexColor);
|
||||
|
||||
hexColor = "#" + hexColor;
|
||||
|
||||
$('#status').css("backgroundColor", hexColor);
|
||||
$('#status_color').text(hexColor + " - R=" + color[0] + ", G=" + color[1] + ", B=" + color[2]);
|
||||
$('#status_color').text(hexColor + "- R=" + color[0] + ", G=" + color[1] + ", B=" + color[2]);
|
||||
$('#status_pos').text("x: " + pos.x + " - y: " + pos.y);
|
||||
|
||||
$("#rng_white").val(0);
|
||||
$("#rng_red").val(color[0]);
|
||||
$("#rng_green").val(color[1]);
|
||||
$("#rng_blue").val(color[2]);
|
||||
|
||||
Reference in New Issue
Block a user