Skip to content

Commit

Permalink
Merge pull request #252 from ks156/example
Browse files Browse the repository at this point in the history
examples: bgColorLEDWEB : Fixed color position and value
  • Loading branch information
drasko committed Oct 19, 2015
2 parents aae6425 + dc44d3f commit 41e92d9
Showing 1 changed file with 7 additions and 4 deletions.
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)))

0 comments on commit 41e92d9

Please sign in to comment.