RGB Bug fix

fetchIP
E. Almqvist 4 years ago
parent e45191d582
commit f12b6dbd6f
  1. 5
      hue_controller.py
  2. 4
      lib/func.py

@ -82,6 +82,7 @@ class controller:
for key in LIGHTS: for key in LIGHTS:
controller.switchLight(key) controller.switchLight(key)
# Light color
def setLightColor(index:int, r:int, g:int, b:int): def setLightColor(index:int, r:int, g:int, b:int):
if( LIGHTS.get(str(index)) ): if( LIGHTS.get(str(index)) ):
loop.run_until_complete( controller.setLightRGB(index, r, g, b) ) loop.run_until_complete( controller.setLightRGB(index, r, g, b) )
@ -104,6 +105,7 @@ class controller:
global LIGHTS global LIGHTS
LIGHTS = json.loads(jsonLights.text) LIGHTS = json.loads(jsonLights.text)
print(LIGHTS)
def end(): def end():
loop.close() loop.close()
@ -112,6 +114,5 @@ class controller:
def testReq(): def testReq():
controller.init() controller.init()
controller.Power(True) controller.Power(True)
controller.setAllLightsColor( 255, 255, 255 ) controller.setAllLightsColor( 178, 199, 255 )
controller.end() controller.end()

@ -9,13 +9,13 @@ def boolToString(v: bool): # To fix the dumb python syntax
return boolStr[v] return boolStr[v]
def rgbToDecimal( r:int, g:int, b:int ): def rgbToDecimal( r:int, g:int, b:int ):
return round(r/255), round(g/255), round(b/255) return round(r/255, 1), round(g/255, 1), round(b/255, 1)
def svNumFix(n: float): def svNumFix(n: float):
return int(round(n*254, 0)) return int(round(n*254, 0))
def hueNumFix(n: float): def hueNumFix(n: float):
return int(round(n*65535)) return int(round(n*65535, 0))
def rgbToHsv( r:int, g:int, b:int ): def rgbToHsv( r:int, g:int, b:int ):
R, G, B = rgbToDecimal(r, g, b) R, G, B = rgbToDecimal(r, g, b)

Loading…
Cancel
Save