Browse Source

use 2 separated lists for row/col

rorist 5 months ago
parent
commit
a0c1d2e8e4
4 changed files with 19 additions and 26 deletions
  1. 0 10
      ips
  2. 4 0
      ips-ew
  3. 6 0
      ips-ns
  4. 9 16
      led_ctrl.py

+ 0 - 10
ips

@@ -1,10 +0,0 @@
-192.168.130.130
-192.168.130.143
-192.168.130.238
-192.168.130.105
-192.168.130.237
-192.168.130.173
-192.168.130.80
-192.168.130.225
-192.168.130.134
-192.168.130.78

+ 4 - 0
ips-ew

@@ -0,0 +1,4 @@
+192.168.130.134
+192.168.130.237
+192.168.130.143
+192.168.130.130

+ 6 - 0
ips-ns

@@ -0,0 +1,6 @@
+192.168.130.105
+192.168.130.80
+192.168.130.78
+192.168.130.173
+192.168.130.238
+192.168.130.225

+ 9 - 16
led_ctrl.py

@@ -21,7 +21,9 @@ import time
 app = Flask(__name__)
 CORS(app)
 
-_ips = []
+_ips_ns = []
+_ips_ew = []
+_ips_all = []
 _auto_scan = False
 _color_current = [0, 0, 0]
 _state = 'on'
@@ -142,7 +144,7 @@ def ctrl():
         return 'Unknown effect'
 
     if _effects_cmd[_effect_current][1]:
-        for ip in _ips:
+        for ip in _ips_all:
             _cmd = _effects_cmd[_effect_current][0]
             _cmd(ip, _color_current)
 
@@ -152,22 +154,13 @@ def ctrl():
 # MAIN
 #
 
-# Get the LEDs ips
-if _auto_scan:
-    scanner = BulbScanner()
-    scanner.scan(timeout=4)
-
-    if len(scanner.found_bulbs) > 0:
-        _ips = [x['ipaddr'] for x in scanner.found_bulbs]
-    else:
-        print('No ledstrip found')
-else:
-    f = open('./ips', 'r')
-    _ips = f.readlines()
-    f.close()
-
 if __name__ == '__main__':
 
+    # Get the LEDs ips
+    _ips_ns = f = [x.rstrip() for x in open('./ips-ns', 'r').readlines()]
+    _ips_ew = f = [x.rstrip() for x in open('./ips-ew', 'r').readlines()]
+    _ips_all = _ips_ns + _ips_ew
+
     # Run the web server
     app.run()