From d12e59cab3f53c988c6426f2085f0f24795c587f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Sat, 17 Feb 2024 15:18:22 +0100 Subject: [PATCH] test if updater works MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ebbe Baß --- client/main.py | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/client/main.py b/client/main.py index d18719b..ff1d101 100644 --- a/client/main.py +++ b/client/main.py @@ -62,26 +62,9 @@ def update_led_strip(rgb_values, pixel, strip): strip[int(pixel)] = rgb_values def on_message(mqttc, obj, msg): + global rgb_values_list rgb_values_list = eval(msg.payload.decode()) - for pixel in range(LEDS_PER_PIXEL): - update_led_strip(tuple(eval(rgb_values_list[0])), pixel, strip) - - for pixel in range(LEDS_PER_PIXEL, LEDS_PER_PIXEL*2): - update_led_strip(tuple(eval(rgb_values_list[1])), pixel, strip) - - for pixel in range(LEDS_PER_PIXEL*2, LEDS_PER_PIXEL*3): - update_led_strip(tuple(eval(rgb_values_list[2])), pixel, strip) - - for pixel in range(LEDS_PER_PIXEL*3, LEDS_PER_PIXEL*4): - update_led_strip(tuple(eval(rgb_values_list[3])), pixel, strip) - - for pixel in range(LEDS_PER_PIXEL*4, LEDS_PER_PIXEL*5): - update_led_strip(tuple(eval(rgb_values_list[4])), pixel, strip) - - for pixel in range(LEDS_PER_PIXEL*5, LEDS_PER_PIXEL*6): - update_led_strip(tuple(eval(rgb_values_list[5])), pixel, strip) - # strip.show() if __name__ == "__main__": @@ -96,4 +79,23 @@ if __name__ == "__main__": mqttc.on_message = on_message mqttc.subscribe("tube-"+str(wlan_mac_address)+"/pixel_colors", 0) - mqttc.loop_forever() \ No newline at end of file + mqttc.loop_forever() + + while True: + for pixel in range(LEDS_PER_PIXEL): + update_led_strip(tuple(eval(rgb_values_list[0])), pixel, strip) + + for pixel in range(LEDS_PER_PIXEL, LEDS_PER_PIXEL*2): + update_led_strip(tuple(eval(rgb_values_list[1])), pixel, strip) + + for pixel in range(LEDS_PER_PIXEL*2, LEDS_PER_PIXEL*3): + update_led_strip(tuple(eval(rgb_values_list[2])), pixel, strip) + + for pixel in range(LEDS_PER_PIXEL*3, LEDS_PER_PIXEL*4): + update_led_strip(tuple(eval(rgb_values_list[3])), pixel, strip) + + for pixel in range(LEDS_PER_PIXEL*4, LEDS_PER_PIXEL*5): + update_led_strip(tuple(eval(rgb_values_list[4])), pixel, strip) + + for pixel in range(LEDS_PER_PIXEL*5, LEDS_PER_PIXEL*6): + update_led_strip(tuple(eval(rgb_values_list[5])), pixel, strip) \ No newline at end of file