Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
drasko committed Feb 4, 2015
2 parents ede95be + afa1b52 commit c24a1de
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 91 deletions.
8 changes: 4 additions & 4 deletions examples/webService/bgColorLEDWEB/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">

<script data-main="weioLibs" src="../require.js"></script>
<script data-main="weioLibs" src="www/libs/require.js"></script>
<script src="gyro.js"></script>

<head>
Expand Down Expand Up @@ -48,9 +48,9 @@

function changeColorFromWeio(data) {
rgb = "rgb("+
String(data.data.red) + "," +
String(data.data.green) + "," +
String(data.data.blue) + ")";
String(data.red) + "," +
String(data.green) + "," +
String(data.blue) + ")";
//console.log(data.data.red);
$("body").css("background-color", rgb);
//console.log(data);
Expand Down
79 changes: 40 additions & 39 deletions examples/webService/bgColorLEDWEB/main.py
Original file line number Diff line number Diff line change
@@ -1,72 +1,73 @@
from weioLib.weio import *

import colorsys
import time


def setup():
# Attaches interrupt from Web client to "message" string
attach.event('message', buttonHandler)
attach.process(potar)
sharedVar[0] = 0

def buttonHandler(dataIn) :
if dataIn is not None :
#print dataIn
#print "FROM BROWSER: ", dataIn["data"], " uuid: ", dataIn["uuid"]
beta = float(dataIn)

# put limiters
if (beta>88):
beta = 88
if (beta<-88):
beta = -88

# map interval between -88 and 88 to 0.0 - 1.0
hue = proportion(beta,-88.0,88.0, 0.0,1.0)
# drive HUE color and transform to rgb for LED
# drive HUE color and transform to rgb for LED
rgb = colorsys.hsv_to_rgb(hue, 1.0, 1.0)


# rgb output is 0.0-1.0 transform to 0-255
red = int(rgb[0]*255.0)
green = int(rgb[1]*255.0)
blue = int(rgb[2]*255.0)
print red, " ", green, " ", blue
red = int(rgb[0]*100.0)
green = int(rgb[1]*100.0)
blue = int(rgb[2]*100.0)

print red, " ", green, " ", blue
# Export color to LED
setColor(red,green,blue)

def setColor(r,g,b):
pwmWrite(19,b)
pwmWrite(20,r)
pwmWrite(21,g)

colorData = {}
colorData["red"] = r
colorData["green"] = g
colorData["blue"] = b

for client in shared.connectedClients :
client.connection.emit("usrMsg", colorData)

pwmWrite(19,b)
pwmWrite(20,r)
pwmWrite(21,g)

colorData = {}
colorData["red"] = r
colorData["green"] = g
colorData["blue"] = b

serverPush("usrMsg", colorData)

def potar() :
val = 0
val_p = 0
while True:
val = analogRead(25)

if (abs(val-val_p)>10):
hue = proportion(val,0,1023, 0.0,1.0)
# drive HUE color and transform to rgb for LED
# drive HUE color and transform to rgb for LED
rgb = colorsys.hsv_to_rgb(hue, 1.0, 1.0)

# rgb output is 0.0-1.0 transform to 0-255
red = int(rgb[0]*255.0)
green = int(rgb[1]*255.0)
blue = int(rgb[2]*255.0)

red = int(rgb[0]*100.0)
green = int(rgb[1]*100.0)
blue = int(rgb[2]*100.0)
setColor(red,green,blue)

val_p = val
time.sleep(0.05)

def proportion(value,istart,istop,ostart,ostop) :
return float(ostart) + (float(ostop) - float(ostart)) * ((float(value) - float(istart)) / (float(istop) - float(istart)))

# Attaches interrupt from Web client to "message" string
attach.event('message', buttonHandler)
attach.process(potar)
return float(ostart) + (float(ostop) - float(ostart)) * ((float(value) - float(istart)) / (float(istop) - float(istart)))
48 changes: 0 additions & 48 deletions openWrt/files/etc/samba/smb.conf

This file was deleted.

0 comments on commit c24a1de

Please sign in to comment.