Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: bgColorLEDWEB : Fixed color position and value #252

Merged
merged 2 commits into from
Oct 19, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions examples/webApps/bgColorLEDWEB/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ def buttonHandler(dataIn) :
setColor(red,green,blue)

def setColor(r,g,b):
pwmWrite(19,b)
pwmWrite(20,r)
pwmWrite(21,g)
# LED values are comprised between 0 and 100(%).
# For hardware reasons, LEDs lit when pin is LOW (0V)
# This is why the value is inverted here : 100% - led value
pwmWrite(18,100-r)
pwmWrite(19,100-g)
pwmWrite(20,100-b)

colorData = {}
colorData["red"] = r
Expand Down Expand Up @@ -70,4 +73,4 @@ def potar() :
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)))
return float(ostart) + (float(ostop) - float(ostart)) * ((float(value) - float(istart)) / (float(istop) - float(istart)))