From 416cd8571e973e3702a5979cb4eba078484ea54b Mon Sep 17 00:00:00 2001
From: jkerdreu <jkerdreu@b32b6428-25c9-4566-ad07-03861ab6144f>
Date: Wed, 19 May 2021 13:55:14 +0000
Subject: [PATCH] This is the end for version 0.5

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/tags/release-0.5_final@2630 b32b6428-25c9-4566-ad07-03861ab6144f
---
 .../xaal/dashboard/static/js/site.js          |  3 +-
 scripts/btn_relay.py                          | 39 ++++++++++++++++---
 2 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/apps/dashboard/xaal/dashboard/static/js/site.js b/apps/dashboard/xaal/dashboard/static/js/site.js
index e421ad5b..ce71c031 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 aaf9ef13..488b4d7f 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
-- 
GitLab