diff --git a/apps/dashboard/xaal/dashboard/static/js/site.js b/apps/dashboard/xaal/dashboard/static/js/site.js index e421ad5bc90fe0886b69f1b1bfb705c1733ffaa9..ce71c031c7de319c9595b62e99aeb682f1dd5789 100644 --- a/apps/dashboard/xaal/dashboard/static/js/site.js +++ b/apps/dashboard/xaal/dashboard/static/js/site.js @@ -113,7 +113,8 @@ function run_sio() { }); } - +//================ refresh attributes ======================================= +// the old refresh_attributes blocks the page rendering process. function sio_refresh_attributes_old() { console.log('refresh_attributes'); var addrs = []; diff --git a/scripts/btn_relay.py b/scripts/btn_relay.py index aaf9ef139943832828a885ff2ccf44778df819ab..488b4d7f85bafe8587a2f12ececaf75689f0e89d 100644 --- a/scripts/btn_relay.py +++ b/scripts/btn_relay.py @@ -11,6 +11,13 @@ BTN1 = 'ec069c08-92af-11e8-80cd-408d5c18c800' BTN2 = '6fa87ef2-9975-11e8-b1fa-82ed25e6aa00' BTN3 = '821c6026-92ae-11e8-82af-408d5c18c800' +BTN1 = '63b5ece6-c266-11e8-a0fc-400074bcb601' +BTN4 = '63b5ece6-c266-11e8-a0fc-400074bcb605' +BTN5 = 'c38e3f04-92b1-11e8-85ee-408d5c18c800' +BTN3 = '6fa87ef2-9975-11e8-b1fa-82ed25e6aa00' + +RGB1 = 'b97c687c-d700-11e8-b0df-408d5c18c8f7' + dev = None def send(targets,action,body=None): @@ -18,22 +25,42 @@ def send(targets,action,body=None): engine = dev.engine engine.send_request(dev,targets,action,body) +def rand_color_code(): + import random + r = random.randint(0,255) + g = random.randint(0,255) + b = random.randint(0,255) + color='#%x%x%x' % (r,g,b) + return color + def handle_msg(msg): if not msg.is_notify(): return # search for the buttons + """ if msg.action == 'click': - if msg.source == BTN2: + if msg.source == BTN4: send([REL1,REL2],'toggle') - if msg.source == BTN1: + if msg.source in [BTN1,BTN5]: send([REL1],'toggle') if msg.source == BTN3: - send([REL2,],'toggle') - if msg.action == 'double_click': - if msg.source in [BTN1,BTN3]: - send([REL1,REL2],'off') + send([REL2,],'toggle') + """ + if msg.action == 'click': + send([RGB1,],'toggle') + + if msg.action == 'click': + if msg.source in [BTN1,BTN3,BTN5]: + #send([REL1,REL2],'toggle') + #send([RGB1,],'setWhite',{'target':'5000'}) + send([RGB1,],'toggle') + + if msg.source == '6fa87ef2-9975-11e8-b1fa-82ed25e6aa01': + send([RGB1,],'setRGB',{'target':rand_color_code()}) + if msg.source == '6fa87ef2-9975-11e8-b1fa-82ed25e6aa02': + send([RGB1,],'off') def main(): global dev