From 7affaf04b1972052ab5738b9fb750e5d3395745e Mon Sep 17 00:00:00 2001 From: lub Date: Mon, 1 Mar 2021 21:40:54 +0100 Subject: [PATCH] implement random_grb() function --- src/blinki.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/blinki.py b/src/blinki.py index cfc6462..3a4fe34 100644 --- a/src/blinki.py +++ b/src/blinki.py @@ -3,6 +3,16 @@ from blinkstick import blinkstick from random import randint, choice from time import sleep +def random_grb(): + """ + Get a random GRB array. + """ + # get a random initial color + return [ + randint(1, 255), + randint(1, 255), + randint(1, 255) + ] def set_all_leds(device, grb=[0,0,0]): """ Takes a GRB color array as input and sets the color on all LEDs. @@ -49,11 +59,7 @@ def morph_grb(grb, steps, mode='single'): device = blinkstick.find_first() # get a random initial color -grb = [ - randint(1, 255), - randint(1, 255), - randint(1, 255) -] +grb = random_grb() while True: set_all_leds(device, grb)