ledstrip ontvangen string omzetten naar hex
This commit is contained in:
parent
aa0382f8c5
commit
f73c20ad3d
4
run.py
4
run.py
@ -201,11 +201,15 @@ def api_ledstrip_set():
|
|||||||
global state_ledstrip
|
global state_ledstrip
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
|
# we ontvangen de volgenende waarde '#XXXXXX' maar de driver ondersteunt allen '0xFFFFFF'
|
||||||
desired_state = request.form['setstate']
|
desired_state = request.form['setstate']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
desired_state = int('0x' + desired_state[1:])
|
||||||
|
|
||||||
hardware.set_strip(desired_state)
|
hardware.set_strip(desired_state)
|
||||||
except:
|
except:
|
||||||
|
|
||||||
return {'request': 'False'}
|
return {'request': 'False'}
|
||||||
|
|
||||||
print(f'Set value for ledstrip {desired_state}')
|
print(f'Set value for ledstrip {desired_state}')
|
||||||
|
Reference in New Issue
Block a user