import time
import _thread
import neopixel
from machine import Pin
rainbow = [
(126 , 1 , 0),(114 , 13 , 0),(102 , 25 , 0),(90 , 37 , 0),(78 , 49 , 0),(66 , 61 , 0),(54 , 73 , 0),(42 , 85 , 0),
(30 , 97 , 0),(18 , 109 , 0),(6 , 121 , 0),(0 , 122 , 5),(0 , 110 , 17),(0 , 98 , 29),(0 , 86 , 41),(0 , 74 , 53),
(0 , 62 , 65),(0 , 50 , 77),(0 , 38 , 89),(0 , 26 , 101),(0 , 14 , 113),(0 , 2 , 125),(9 , 0 , 118),(21 , 0 , 106),
(33 , 0 , 94),(45 , 0 , 82),(57 , 0 , 70),(69 , 0 , 58),(81 , 0 , 46),(93 , 0 , 34),(105 , 0 , 22),(117 , 0 , 10)]
pixels = neopixel.NeoPixel(Pin(23), 16)
rqs_to_show =False
to_show = ""
def input_thread():
global rqs_to_show
global to_show
while True:
user_input = input('Some text: ')
to_show = user_input
rqs_to_show = True
print("in input_thread() => ", user_input)
def rgb_thread():
global rainbow
while True:
rainbow = rainbow[-1:] + rainbow[:-1]
for i in range(16):
pixels[i] = rainbow[i]
pixels.write()
time.sleep(0.1)
_thread.start_new_thread(input_thread, ())
# _thread.start_new_thread(rgb_thread, ())
while True:
rgb_thread()
if rqs_to_show:
rqs_to_show = False
print("in main thread: rqs_to_show -> ", to_show)