From bc3239193fc663b21967520f838a4ef9a98abb9a Mon Sep 17 00:00:00 2001 From: Joey Nelson Date: Sat, 2 Nov 2024 12:27:38 -0700 Subject: [PATCH 1/9] fancy light pattern --- software/software/main.py | 99 +++++++++++++++++++++++++++++---------- 1 file changed, 75 insertions(+), 24 deletions(-) diff --git a/software/software/main.py b/software/software/main.py index c0e61f0..7caa4f6 100644 --- a/software/software/main.py +++ b/software/software/main.py @@ -2,21 +2,24 @@ import time counter = 0 +delay_time = 100 +direction = 1 +velocity = 0 +step = 1000 +step_change = -1 +c2 = 0 +tw = 0 +vel_array = [1,2,4,8,16,32,64] +loc_array = [0,0,0,0,0,0,0] +rot_count = 0 + +intensity_regs = [0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00] -## do a quick spiral to test -if petal_bus: - for j in range(8): - which_leds = (1 << (j+1)) - 1 - for i in range(1,9): - print(which_leds) - petal_bus.writeto_mem(PETAL_ADDRESS, i, bytes([which_leds])) - time.sleep_ms(30) - petal_bus.writeto_mem(PETAL_ADDRESS, i, bytes([which_leds])) while True: ## display button status on RGB - if petal_bus: + if False: if not buttonA.value(): petal_bus.writeto_mem(PETAL_ADDRESS, 2, bytes([0x80])) else: @@ -34,24 +37,72 @@ ## see what's going on with the touch wheel if touchwheel_bus: + last_tw = tw tw = touchwheel_read(touchwheel_bus) - - ## display touchwheel on petal - if petal_bus and touchwheel_bus: - if tw > 0: - tw = (128 - tw) % 256 - petal = int(tw/32) + 1 - else: - petal = 999 - for i in range(1,9): - if i == petal: - petal_bus.writeto_mem(0, i, bytes([0x7F])) - else: - petal_bus.writeto_mem(0, i, bytes([0x00])) + print(tw) + if (last_tw - tw) % 256 < (tw - last_tw) % 256: + velocity = (last_tw - tw) % 256 + else: + velocity = -((tw - last_tw) % 256) + + step = step + step_change + if step > 2000 or step < 400: + step_change = -step_change + + + if tw > 0: + delay_time = 10 + tw + + for i in range(7): + loc_array[i] += vel_array[i] + if loc_array[i] >= 1024: + loc_array[i] = loc_array[i] - 1024 + + + + c2 = c2 + (step >> 3) + limit = 1000 + if c2 >= limit: + + #print(velocity) + c2 = c2 - limit + counter = counter + direction + if counter == 18 or counter == 0: + direction = -direction + #print(velocity) + + rot_count = (rot_count + 1) % 8 + for i in range(8): + if (i % 4) == (rot_count % 4): + intensity_regs[i] = 0x0F + elif (i+1 % 4) == (rot_count % 4) or (i-1 % 4) == (rot_count % 4): + intensity_regs[i] = 0x07 + else: + intensity_regs[i] = 0x00 + + ## display touchwheel on petal + if petal_bus and touchwheel_bus: + for i in range(4): + base_addr = 0x10 + #intensity_byte = (intensity_regs[i*2+1] << 4) | intensity_regs[i*2] + intensity = int(15.5 * (step - 400) / (2000 - 400)) + intensity_byte = intensity << 4 | intensity + + petal_bus.writeto_mem(PETAL_ADDRESS, base_addr+i, bytes([intensity_byte])) + + bitmap = 0 + for i in range(counter): + bitmap = ((0x7f << counter) & 0x7f00) >> 8 + for i in range(1,9): + petal_bus.writeto_mem(PETAL_ADDRESS, i, bytes([bitmap])) + #if i == petal: + # petal_bus.writeto_mem(0, i, bytes([0x3F])) + #else: + # petal_bus.writeto_mem(0, i, bytes([0x00])) - time.sleep_ms(100) + time.sleep_ms(5) bootLED.off() From ad81520da05f4def19de142a8c8a328ff9a9d96b Mon Sep 17 00:00:00 2001 From: Joey Nelson Date: Sat, 2 Nov 2024 14:53:00 -0700 Subject: [PATCH 2/9] multi turn thumbwheel tracker --- software/software/main.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/software/software/main.py b/software/software/main.py index 7caa4f6..35e1867 100644 --- a/software/software/main.py +++ b/software/software/main.py @@ -5,10 +5,13 @@ delay_time = 100 direction = 1 velocity = 0 +location = 0 +smoothed_loc = 0 step = 1000 step_change = -1 c2 = 0 tw = 0 +prev_tw = 0 vel_array = [1,2,4,8,16,32,64] loc_array = [0,0,0,0,0,0,0] rot_count = 0 @@ -37,13 +40,20 @@ ## see what's going on with the touch wheel if touchwheel_bus: - last_tw = tw + tw = touchwheel_read(touchwheel_bus) - print(tw) - if (last_tw - tw) % 256 < (tw - last_tw) % 256: - velocity = (last_tw - tw) % 256 - else: - velocity = -((tw - last_tw) % 256) + if tw != 0: + + #temploc = location % 256 + if (prev_tw - tw) % 256 < (tw - prev_tw) % 256: + velocity = (prev_tw - tw) % 256 + else: + velocity = -((tw - prev_tw) % 256) + location = location + velocity + smoothed_loc = (location + smoothed_loc * 3) >> 2 + print(smoothed_loc) + prev_tw = tw + step = step + step_change if step > 2000 or step < 400: @@ -82,7 +92,7 @@ ## display touchwheel on petal if petal_bus and touchwheel_bus: - for i in range(4): + for i in range(4):im base_addr = 0x10 #intensity_byte = (intensity_regs[i*2+1] << 4) | intensity_regs[i*2] intensity = int(15.5 * (step - 400) / (2000 - 400)) @@ -102,7 +112,7 @@ - time.sleep_ms(5) + time.sleep_ms(10) bootLED.off() From cb4d0f04b37d2932547cb0a2524d13b5e040d412 Mon Sep 17 00:00:00 2001 From: Joey Nelson Date: Sat, 2 Nov 2024 15:50:13 -0700 Subject: [PATCH 3/9] adding center led and sin phasing --- software/software/main.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/software/software/main.py b/software/software/main.py index 35e1867..fef19fa 100644 --- a/software/software/main.py +++ b/software/software/main.py @@ -1,7 +1,8 @@ from machine import I2C, Pin import time +import math -counter = 0 +counter = 0.0 delay_time = 100 direction = 1 velocity = 0 @@ -71,15 +72,14 @@ c2 = c2 + (step >> 3) - limit = 1000 + limit = 500 if c2 >= limit: #print(velocity) c2 = c2 - limit - counter = counter + direction - if counter == 18 or counter == 0: - direction = -direction - #print(velocity) + counter = counter + math.pi/16 + if counter > 2 * math.pi: + counter = counter - 2 * math.pi rot_count = (rot_count + 1) % 8 for i in range(8): @@ -92,17 +92,25 @@ ## display touchwheel on petal if petal_bus and touchwheel_bus: - for i in range(4):im + phase = int((math.sin(counter) + 1) * 9) + phase2 = int((math.sin(counter) + 1) * 4) + for i in range(4): base_addr = 0x10 #intensity_byte = (intensity_regs[i*2+1] << 4) | intensity_regs[i*2] intensity = int(15.5 * (step - 400) / (2000 - 400)) - intensity_byte = intensity << 4 | intensity + if phase <= 1: + temp = phase << 4 - 1; + intensity_byte = temp << 4 | temp + else: + intensity_byte = phase2 << 4 | phase2 petal_bus.writeto_mem(PETAL_ADDRESS, base_addr+i, bytes([intensity_byte])) - bitmap = 0 - for i in range(counter): - bitmap = ((0x7f << counter) & 0x7f00) >> 8 + if phase <= 1: + bitmap = ((0x7f << phase) & 0x7f00) >> 8 | 0x80 + else: + bitmap = ((0x7f << phase) & 0x7f00) >> 8 + for i in range(1,9): petal_bus.writeto_mem(PETAL_ADDRESS, i, bytes([bitmap])) #if i == petal: @@ -112,7 +120,7 @@ - time.sleep_ms(10) + time.sleep_ms(5) bootLED.off() From a0e061431ea7fdce7b890797d9a3fd2c02922f16 Mon Sep 17 00:00:00 2001 From: Joey Nelson Date: Sun, 3 Nov 2024 08:14:38 -0800 Subject: [PATCH 4/9] modes ohh modes --- software/software/main.py | 241 ++++++++++++++++++++++++-------------- 1 file changed, 152 insertions(+), 89 deletions(-) diff --git a/software/software/main.py b/software/software/main.py index fef19fa..cf3935b 100644 --- a/software/software/main.py +++ b/software/software/main.py @@ -1,14 +1,18 @@ from machine import I2C, Pin import time import math +import random + +mode = 6 +max_mode = 8 counter = 0.0 delay_time = 100 direction = 1 velocity = 0 location = 0 smoothed_loc = 0 -step = 1000 +step = 1500 step_change = -1 c2 = 0 tw = 0 @@ -16,111 +20,169 @@ vel_array = [1,2,4,8,16,32,64] loc_array = [0,0,0,0,0,0,0] rot_count = 0 +timeout = 5000 +timestep = 5 + +display = bytearray(8) + + +debounce = { buttonA : 0, buttonB : 0 , buttonC : 0 } +clicked = { buttonA : False, buttonB : False , buttonC : False } + +debounce_max = 8 -intensity_regs = [0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00] +intensity_vals = bytearray(8) while True: - ## display button status on RGB - if False: - if not buttonA.value(): - petal_bus.writeto_mem(PETAL_ADDRESS, 2, bytes([0x80])) - else: - petal_bus.writeto_mem(PETAL_ADDRESS, 2, bytes([0x00])) - - if not buttonB.value(): - petal_bus.writeto_mem(PETAL_ADDRESS, 3, bytes([0x80])) - else: - petal_bus.writeto_mem(PETAL_ADDRESS, 3, bytes([0x00])) - - if not buttonC.value(): - petal_bus.writeto_mem(PETAL_ADDRESS, 4, bytes([0x80])) - else: - petal_bus.writeto_mem(PETAL_ADDRESS, 4, bytes([0x00])) - - ## see what's going on with the touch wheel - if touchwheel_bus: + for button in [buttonA, buttonB, buttonC]: + clicked[button] = False + if not button.value() and debounce[button] < debounce_max: + debounce[button] = debounce[button] + 1 + if debounce[button] == 4: + clicked[button] = True + elif debounce[button] > 0: + debounce[button] = debounce[button] - 1 + + if clicked[buttonA]: + mode = (mode + 1) % max_mode + timeout = 5000 + print("mode:", mode) + + timeout = timeout - timestep + if timeout < 0: + mode = random.randint(0,max_mode) + timeout = 5000 - tw = touchwheel_read(touchwheel_bus) - if tw != 0: + if mode == 0: + ## see what's going on with the touch wheel + if touchwheel_bus: - #temploc = location % 256 - if (prev_tw - tw) % 256 < (tw - prev_tw) % 256: - velocity = (prev_tw - tw) % 256 - else: - velocity = -((tw - prev_tw) % 256) - location = location + velocity - smoothed_loc = (location + smoothed_loc * 3) >> 2 - print(smoothed_loc) - prev_tw = tw + tw = touchwheel_read(touchwheel_bus) + if tw != 0: + + #temploc = location % 256 + if (prev_tw - tw) % 256 < (tw - prev_tw) % 256: + velocity = (prev_tw - tw) % 256 + else: + velocity = -((tw - prev_tw) % 256) + location = location + velocity + smoothed_loc = (location + smoothed_loc * 3) >> 2 + print(smoothed_loc) + prev_tw = tw + + + step = step + step_change + if step > 2000 or step < 1000: + step_change = -step_change - - step = step + step_change - if step > 2000 or step < 400: - step_change = -step_change - - if tw > 0: - delay_time = 10 + tw - - for i in range(7): - loc_array[i] += vel_array[i] - if loc_array[i] >= 1024: - loc_array[i] = loc_array[i] - 1024 - + if tw > 0: + delay_time = 10 + tw + + for i in range(7): + loc_array[i] += vel_array[i] + if loc_array[i] >= 1024: + loc_array[i] = loc_array[i] - 1024 + + + + + c2 = c2 + (step >> 3) + limit = 2000 + if c2 >= limit: - - c2 = c2 + (step >> 3) - limit = 500 - if c2 >= limit: + #print(velocity) + c2 = c2 - limit + counter = counter + math.pi/16 + if counter > 2 * math.pi: + counter = counter - 2 * math.pi + + ## display touchwheel on petal + if petal_bus and touchwheel_bus: + phase = int((math.sin(counter) + 1) * 9) + phase2 = int((math.sin(counter) + 1) * 4) + if phase <= 1: + bitmap = ((0x7f << phase) & 0x7f00) >> 8 | 0x80 + else: + bitmap = ((0x7f << phase) & 0x7f00) >> 8 + + for i in range(8): + display[i] = bitmap + intensity_vals[i] = phase2 + #if i == petal: + # petal_bus.writeto_mem(0, i, bytes([0x3F])) + #else: + # petal_bus.writeto_mem(0, i, bytes([0x00])) + elif mode == 1: + + c2 = c2 + 1 - #print(velocity) - c2 = c2 - limit - counter = counter + math.pi/16 - if counter > 2 * math.pi: - counter = counter - 2 * math.pi + intensity = int((math.sin(c2 / 30.0) + 1) * 8) + intensity = min(max(intensity, 0), 15) + for i in range(8): + display[i] = 0x7f + intensity_vals[i] = intensity + + elif mode == 2: - rot_count = (rot_count + 1) % 8 + c2 = c2 + 1 + phase = (c2 >> 4) % 8 for i in range(8): - if (i % 4) == (rot_count % 4): - intensity_regs[i] = 0x0F - elif (i+1 % 4) == (rot_count % 4) or (i-1 % 4) == (rot_count % 4): - intensity_regs[i] = 0x07 - else: - intensity_regs[i] = 0x00 - - ## display touchwheel on petal - if petal_bus and touchwheel_bus: - phase = int((math.sin(counter) + 1) * 9) - phase2 = int((math.sin(counter) + 1) * 4) - for i in range(4): - base_addr = 0x10 - #intensity_byte = (intensity_regs[i*2+1] << 4) | intensity_regs[i*2] - intensity = int(15.5 * (step - 400) / (2000 - 400)) - if phase <= 1: - temp = phase << 4 - 1; - intensity_byte = temp << 4 | temp - else: - intensity_byte = phase2 << 4 | phase2 + pd = (phase - i) % 8 + intensity_vals[i] = min(15,max(0, (7 - pd * 2) * 2)) + if pd <= 4: + display[i] = 0x7f + else: + display[i] = 0x00 + + elif mode == 3: + for i in range(8): + if random.randint(0,1000) < 20: + intensity_vals[i] = max(0,min(15,intensity_vals[i] + random.randint(-1,2))) + for j in range(7): + if random.randint(0,1000) < 10: + display[i] = display[i] ^ 1 << j + elif mode == 4: + c2 = c2 + 1 + phase = (c2 >> 3) % 24 + for i in range(8): + intensity_vals[i] = 9 + if int(phase / 3) == i: + display[i] = 1 << (6 - (phase % 3)) + else: + display[i] = 0x00 - petal_bus.writeto_mem(PETAL_ADDRESS, base_addr+i, bytes([intensity_byte])) + elif mode == 5: + for i in range(8): + display[i] = random.getrandbits(7) + intensity_vals[i] = random.randint(1,10) - if phase <= 1: - bitmap = ((0x7f << phase) & 0x7f00) >> 8 | 0x80 - else: - bitmap = ((0x7f << phase) & 0x7f00) >> 8 - - for i in range(1,9): - petal_bus.writeto_mem(PETAL_ADDRESS, i, bytes([bitmap])) - #if i == petal: - # petal_bus.writeto_mem(0, i, bytes([0x3F])) - #else: - # petal_bus.writeto_mem(0, i, bytes([0x00])) + elif mode == 6: + c2 = c2 + 1 + phase = (c2 >> 4) % (7 * 8 + 1) + for i in range(8): + intensity_vals[i] = 9 + display[i] = 0 + for j in range(7): + idx = i*7 + j + if phase == (idx * (j+i)) % (7 * 8): + display[i] = display[i] | 1 << j + + + for i in range(4): + base_reg = 0x10 + reg_byte = intensity_vals[i*2+1] << 4 | intensity_vals[i*2] + petal_bus.writeto_mem(PETAL_ADDRESS, base_reg + i, bytes([reg_byte])) - - time.sleep_ms(5) + + for i in range(8): + base_reg = 0x01 + petal_bus.writeto_mem(PETAL_ADDRESS, base_reg + i, bytes([display[i]])) + + time.sleep_ms(timestep) bootLED.off() @@ -128,3 +190,4 @@ + From 1156faad315a9bb261b2c0928c1bbf31f9bc466b Mon Sep 17 00:00:00 2001 From: Joey Nelson Date: Sun, 3 Nov 2024 11:39:17 -0800 Subject: [PATCH 5/9] more modes --- software/software/main.py | 128 ++++++++++++++++++++++++++++---------- 1 file changed, 95 insertions(+), 33 deletions(-) diff --git a/software/software/main.py b/software/software/main.py index cf3935b..2b7d1b9 100644 --- a/software/software/main.py +++ b/software/software/main.py @@ -4,23 +4,23 @@ import random -mode = 6 -max_mode = 8 + +max_mode = 12 +mode = max_mode - 1 counter = 0.0 delay_time = 100 direction = 1 velocity = 0 location = 0 smoothed_loc = 0 -step = 1500 -step_change = -1 c2 = 0 tw = 0 prev_tw = 0 vel_array = [1,2,4,8,16,32,64] loc_array = [0,0,0,0,0,0,0] rot_count = 0 -timeout = 5000 +timeout = 8000 +countdown = timeout timestep = 5 display = bytearray(8) @@ -47,13 +47,16 @@ if clicked[buttonA]: mode = (mode + 1) % max_mode - timeout = 5000 + countdown = timeout + c2 = 0 print("mode:", mode) - timeout = timeout - timestep - if timeout < 0: - mode = random.randint(0,max_mode) - timeout = 5000 + countdown = countdown - timestep + if countdown < 0: + mode = random.randint(0,max_mode-1) + c2 = 0 + countdown = timeout + print("mode:", mode) if mode == 0: ## see what's going on with the touch wheel @@ -71,26 +74,15 @@ smoothed_loc = (location + smoothed_loc * 3) >> 2 print(smoothed_loc) prev_tw = tw - - - step = step + step_change - if step > 2000 or step < 1000: - step_change = -step_change - - - if tw > 0: - delay_time = 10 + tw + for i in range(7): loc_array[i] += vel_array[i] if loc_array[i] >= 1024: loc_array[i] = loc_array[i] - 1024 - - - - c2 = c2 + (step >> 3) - limit = 2000 + c2 = c2 + 1 + limit = 10 if c2 >= limit: #print(velocity) @@ -145,32 +137,102 @@ if random.randint(0,1000) < 10: display[i] = display[i] ^ 1 << j elif mode == 4: + for i in range(8): + display[i] = 0 c2 = c2 + 1 phase = (c2 >> 3) % 24 + phase2 = (-c2 >> 5) % 8 for i in range(8): intensity_vals[i] = 9 if int(phase / 3) == i: - display[i] = 1 << (6 - (phase % 3)) - else: - display[i] = 0x00 + display[i] = display[i] | 1 << (6 - (phase % 3)) + for i in range(8): + if phase2 == i: + display[i] = display[i] | 1 + + elif mode == 5: for i in range(8): - display[i] = random.getrandbits(7) - intensity_vals[i] = random.randint(1,10) + display[i] = random.getrandbits(7) & random.getrandbits(7) & random.getrandbits(7) & random.getrandbits(7) & random.getrandbits(7) & random.getrandbits(7) + intensity_vals[i] = random.randint(1,10) elif mode == 6: c2 = c2 + 1 - phase = (c2 >> 4) % (7 * 8 + 1) + phase = (c2 >> 3) % (7+8) for i in range(8): intensity_vals[i] = 9 display[i] = 0 for j in range(7): - idx = i*7 + j - if phase == (idx * (j+i)) % (7 * 8): + if phase == j+i: display[i] = display[i] | 1 << j - + + + elif mode == 7: + c2 = c2 + 1 + t1 = c2 / 30 + t2 = t1 - math.pi / 8 + t3 = t2 - math.pi / 8 + p1 = int((math.sin(t1) + 1) * 4) + p2 = int((math.sin(t2) + 1) * 4) + p3 = int((math.sin(t3) + 1) * 4) + for i in range(8): + if i == p1: + display[i] = 0x7f + intensity_vals[i] = 15 + elif i == p2: + display[i] = 0x78 + intensity_vals[i] = 7 + elif i == p3: + display[i] = 0x60 + intensity_vals[i] = 0 + else: + display[i] = 0x00 + + elif mode == 8: + c2 = c2 + 1 + pattern = 0xff00ff + for i in range(8): + phase = ((c2 >> 4) + i) % 8 + display[i] = (pattern << phase) & 0x7f + intensity_vals[i] = 9 + + elif mode == 9: + step = int((math.sin(c2 / 900) + 2) * 10) + c2 = c2 + step + phase = (c2 >> 8) % 4 + for i in range(8): + pd = (phase - i) % 4 + intensity_vals[i] = min(15,max(0, (4 - pd * 3) * 4)) + if pd < 3: + display[i] = 0x7f + else: + display[i] = 0x00 + + elif mode == 10: + for i in range(8): + pattern = 0 + for j in range(7): + if random.randint(0,1000) < 20 * (8 - j): + pattern = pattern | 1 << j + display[i] = pattern + intensity_vals[i] = random.randint(1,10) + + elif mode == 11: + c2 = c2 + 1 + phase = (c2 * 3 >> 5) % 8 + stepx = (c2 * 5 >> 10) % 16 + 1 + + for i in range(8): + intensity_vals[i] = 9 + display[i] = 0 + for j in range(7): + if (phase + j * 8 + i) % stepx == 0: + display[i] = 1 << j + + + for i in range(4): base_reg = 0x10 From 92897c0a311b7d7a2e44e2b4b4d0be8718f04ee4 Mon Sep 17 00:00:00 2001 From: Joey Nelson Date: Sun, 3 Nov 2024 12:52:29 -0800 Subject: [PATCH 6/9] done for now --- software/software/main.py | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/software/software/main.py b/software/software/main.py index 2b7d1b9..5fc46e2 100644 --- a/software/software/main.py +++ b/software/software/main.py @@ -5,7 +5,7 @@ -max_mode = 12 +max_mode = 13 mode = max_mode - 1 counter = 0.0 delay_time = 100 @@ -53,7 +53,10 @@ countdown = countdown - timestep if countdown < 0: - mode = random.randint(0,max_mode-1) + next_mode = mode + while next_mode == mode: + next_mode = random.randint(0,max_mode-1) + mode = next_mode c2 = 0 countdown = timeout print("mode:", mode) @@ -136,6 +139,7 @@ for j in range(7): if random.randint(0,1000) < 10: display[i] = display[i] ^ 1 << j + elif mode == 4: for i in range(8): display[i] = 0 @@ -173,9 +177,12 @@ t1 = c2 / 30 t2 = t1 - math.pi / 8 t3 = t2 - math.pi / 8 - p1 = int((math.sin(t1) + 1) * 4) - p2 = int((math.sin(t2) + 1) * 4) - p3 = int((math.sin(t3) + 1) * 4) + count = int(t1 / (math.pi * 2)) + + p1 = (count + int((math.sin(t1) + 1) * 4)) % 8 + p2 = (count + int((math.sin(t2) + 1) * 4)) % 8 + p3 = (count + int((math.sin(t3) + 1) * 4)) % 8 + for i in range(8): if i == p1: display[i] = 0x7f @@ -231,7 +238,26 @@ if (phase + j * 8 + i) % stepx == 0: display[i] = 1 << j - + elif mode == 12: + for i in range(8): + display[i] = 0 + c2 = c2 + 1 + phase = (c2 >> 3) % 24 + phase2 = (-c2 >> 5) % 8 + for loc in range(4): + + for i in range(8): + intensity_vals[i] = 9 + if int(phase / 3) == i: + display[i] = display[i] | 1 << (6 - (phase % 3)) + phase = (phase + 1) % 24 + + for i in range(8): + if phase2 == i: + display[i] = display[i] | 1 + if (phase2 + 1) % 8 == i: + display[i] = display[i] | 2 + for i in range(4): From 37e97a1d88c24dcf202efe03d282881d655d1707 Mon Sep 17 00:00:00 2001 From: Joey Nelson Date: Sun, 3 Nov 2024 19:15:33 -0800 Subject: [PATCH 7/9] ble remote --- software/software/main.py | 95 ++++++++++++++++++++++++++++++--------- 1 file changed, 75 insertions(+), 20 deletions(-) diff --git a/software/software/main.py b/software/software/main.py index 5fc46e2..25895fd 100644 --- a/software/software/main.py +++ b/software/software/main.py @@ -2,8 +2,7 @@ import time import math import random - - +from bleradio import BLERadio max_mode = 13 mode = max_mode - 1 @@ -29,10 +28,13 @@ debounce = { buttonA : 0, buttonB : 0 , buttonC : 0 } clicked = { buttonA : False, buttonB : False , buttonC : False } -debounce_max = 8 +debounce_max = 4 intensity_vals = bytearray(8) - +broadcast_channel = 0 +observe_channel = 0 +max_channels = 8 +radio_mode = False while True: @@ -40,17 +42,29 @@ clicked[button] = False if not button.value() and debounce[button] < debounce_max: debounce[button] = debounce[button] + 1 - if debounce[button] == 4: + if debounce[button] == debounce_max >> 1: clicked[button] = True elif debounce[button] > 0: debounce[button] = debounce[button] - 1 if clicked[buttonA]: - mode = (mode + 1) % max_mode - countdown = timeout - c2 = 0 - print("mode:", mode) - + if radio_mode: + broadcast_channel = (broadcast_channel + 1) % max_channels + radio = BLERadio(broadcast_channel=broadcast_channel, observe_channels=list(range(8))) + else: + mode = (mode + 1) % max_mode + countdown = timeout + c2 = 0 + print("mode:", mode) + + if clicked[buttonB]: + observe_channel = (observe_channel + 1) % max_channels + + if clicked[buttonC]: + radio_mode = not radio_mode + if radio_mode: + radio = BLERadio(broadcast_channel=broadcast_channel, observe_channels=list(range(8))) + countdown = countdown - timestep if countdown < 0: next_mode = mode @@ -61,7 +75,48 @@ countdown = timeout print("mode:", mode) - if mode == 0: + + if radio_mode: + c2 = c2 + 1 + if c2 % 20 == 0: + ## see what's going on with the touch wheel + if touchwheel_bus: + tw = touchwheel_read(touchwheel_bus) + + radio.broadcast([tw]) + + ob = radio.observe(observe_channel) + tw_ob = 0 + if ob is not None: + tw_ob = ob[0] + + ## display touchwheel on petal + if petal_bus and touchwheel_bus: + base_addr = 1 + if tw_ob > 0: + tw_ob = (128 - tw_ob) % 256 + petal = int(tw_ob/32) + 1 + for i in range(8): + if i == petal: + petal_bus.writeto_mem(0, base_addr + i, bytes([0x7F])) + else: + petal_bus.writeto_mem(0, base_addr + i, bytes([0x00])) + else: + for i in range(8): + pattern = 0 + if i <= broadcast_channel: + pattern = pattern | 1 + if i <= observe_channel: + pattern = pattern | 0x40 + + + petal_bus.writeto_mem(0, base_addr + i, bytes([pattern])) + + + + + + elif mode == 0: ## see what's going on with the touch wheel if touchwheel_bus: @@ -259,16 +314,16 @@ display[i] = display[i] | 2 - - for i in range(4): - base_reg = 0x10 - reg_byte = intensity_vals[i*2+1] << 4 | intensity_vals[i*2] - petal_bus.writeto_mem(PETAL_ADDRESS, base_reg + i, bytes([reg_byte])) + if not radio_mode: + for i in range(4): + base_reg = 0x10 + reg_byte = intensity_vals[i*2+1] << 4 | intensity_vals[i*2] + petal_bus.writeto_mem(PETAL_ADDRESS, base_reg + i, bytes([reg_byte])) - - for i in range(8): - base_reg = 0x01 - petal_bus.writeto_mem(PETAL_ADDRESS, base_reg + i, bytes([display[i]])) + + for i in range(8): + base_reg = 0x01 + petal_bus.writeto_mem(PETAL_ADDRESS, base_reg + i, bytes([display[i]])) time.sleep_ms(timestep) bootLED.off() From 1d0e96e8369df975def7906ef9b29221e2b3dfbd Mon Sep 17 00:00:00 2001 From: Joey Nelson Date: Sun, 10 Nov 2024 13:21:20 -0800 Subject: [PATCH 8/9] Move changes in main.py to joemain.py. Added documenation --- software/software/joemain.py | 331 ++++++++++++++++++++++++++++++++ software/software/main.py | 359 +++++------------------------------ 2 files changed, 375 insertions(+), 315 deletions(-) create mode 100644 software/software/joemain.py diff --git a/software/software/joemain.py b/software/software/joemain.py new file mode 100644 index 0000000..80383b3 --- /dev/null +++ b/software/software/joemain.py @@ -0,0 +1,331 @@ +from machine import I2C, Pin +import time +import math +import random + +# use `mpremote mep add bleradio` or similar to install +from bleradio import BLERadio + + +def joemain(): + max_mode = 13 + mode = max_mode - 1 + counter = 0.0 + delay_time = 100 + direction = 1 + velocity = 0 + location = 0 + smoothed_loc = 0 + c2 = 0 + tw = 0 + prev_tw = 0 + vel_array = [1,2,4,8,16,32,64] + loc_array = [0,0,0,0,0,0,0] + rot_count = 0 + timeout = 8000 + countdown = timeout + timestep = 5 + + display = bytearray(8) + + debounce = { buttonA : 0, buttonB : 0 , buttonC : 0 } + clicked = { buttonA : False, buttonB : False , buttonC : False } + + debounce_max = 4 + + intensity_vals = bytearray(8) + broadcast_channel = 0 + observe_channel = 0 + max_channels = 8 + radio_mode = False + + while True: + + #Debounce the inputs to ensure only a single click per button press + for button in [buttonA, buttonB, buttonC]: + clicked[button] = False + if not button.value() and debounce[button] < debounce_max: + debounce[button] = debounce[button] + 1 + if debounce[button] == debounce_max >> 1: + clicked[button] = True + elif debounce[button] > 0: + debounce[button] = debounce[button] - 1 + + # button A either changes the BLE broadcast channel of cycles through animations + if clicked[buttonA]: + if radio_mode: + broadcast_channel = (broadcast_channel + 1) % max_channels + radio = BLERadio(broadcast_channel=broadcast_channel, observe_channels=list(range(8))) + else: + mode = (mode + 1) % max_mode + countdown = timeout + c2 = 0 + + # button B changes the BLE observe channel + if clicked[buttonB]: + observe_channel = (observe_channel + 1) % max_channels + + # button C toggle radio vs animation mode + if clicked[buttonC]: + radio_mode = not radio_mode + if radio_mode: + radio = BLERadio(broadcast_channel=broadcast_channel, observe_channels=list(range(8))) + + # every `timeout` ticks change to a random new animation + countdown = countdown - timestep + if countdown < 0: + next_mode = mode + while next_mode == mode: + next_mode = random.randint(0,max_mode-1) + mode = next_mode + c2 = 0 + countdown = timeout + + #radio mode demonstates using bluetooth to have one touchwheel control remote petals + if radio_mode: + c2 = c2 + 1 + if c2 % 20 == 0: + ## see what's going on with the touch wheel + if touchwheel_bus: + tw = touchwheel_read(touchwheel_bus) + + radio.broadcast([tw]) + + ob = radio.observe(observe_channel) + tw_ob = 0 + if ob is not None: + tw_ob = ob[0] + + ## display touchwheel on petal + if petal_bus and touchwheel_bus: + base_addr = 1 + if tw_ob > 0: + tw_ob = (128 - tw_ob) % 256 + petal = int(tw_ob/32) + 1 + for i in range(8): + if i == petal: + petal_bus.writeto_mem(0, base_addr + i, bytes([0x7F])) + else: + petal_bus.writeto_mem(0, base_addr + i, bytes([0x00])) + else: + for i in range(8): + pattern = 0 + if i <= broadcast_channel: + pattern = pattern | 1 + if i <= observe_channel: + pattern = pattern | 0x40 + + + petal_bus.writeto_mem(0, base_addr + i, bytes([pattern])) + + # When no in radio mode do one of the animations + elif mode == 0: + ## see what's going on with the touch wheel + ## currently not used + if touchwheel_bus: + + tw = touchwheel_read(touchwheel_bus) + if tw != 0: + + #temploc = location % 256 + if (prev_tw - tw) % 256 < (tw - prev_tw) % 256: + velocity = (prev_tw - tw) % 256 + else: + velocity = -((tw - prev_tw) % 256) + location = location + velocity + smoothed_loc = (location + smoothed_loc * 3) >> 2 + print(smoothed_loc) + prev_tw = tw + + + for i in range(7): + loc_array[i] += vel_array[i] + if loc_array[i] >= 1024: + loc_array[i] = loc_array[i] - 1024 + + c2 = c2 + 1 + limit = 10 + if c2 >= limit: + + #print(velocity) + c2 = c2 - limit + counter = counter + math.pi/16 + if counter > 2 * math.pi: + counter = counter - 2 * math.pi + + ## display touchwheel on petal + if petal_bus and touchwheel_bus: + phase = int((math.sin(counter) + 1) * 9) + phase2 = int((math.sin(counter) + 1) * 4) + if phase <= 1: + bitmap = ((0x7f << phase) & 0x7f00) >> 8 | 0x80 + else: + bitmap = ((0x7f << phase) & 0x7f00) >> 8 + + for i in range(8): + display[i] = bitmap + intensity_vals[i] = phase2 + + elif mode == 1: + + c2 = c2 + 1 + + intensity = int((math.sin(c2 / 30.0) + 1) * 8) + intensity = min(max(intensity, 0), 15) + for i in range(8): + display[i] = 0x7f + intensity_vals[i] = intensity + + elif mode == 2: + + c2 = c2 + 1 + phase = (c2 >> 4) % 8 + for i in range(8): + pd = (phase - i) % 8 + intensity_vals[i] = min(15,max(0, (7 - pd * 2) * 2)) + if pd <= 4: + display[i] = 0x7f + else: + display[i] = 0x00 + + elif mode == 3: + for i in range(8): + if random.randint(0,1000) < 20: + intensity_vals[i] = max(0,min(15,intensity_vals[i] + random.randint(-1,2))) + for j in range(7): + if random.randint(0,1000) < 10: + display[i] = display[i] ^ 1 << j + + elif mode == 4: + for i in range(8): + display[i] = 0 + c2 = c2 + 1 + phase = (c2 >> 3) % 24 + phase2 = (-c2 >> 5) % 8 + for i in range(8): + intensity_vals[i] = 9 + if int(phase / 3) == i: + display[i] = display[i] | 1 << (6 - (phase % 3)) + for i in range(8): + if phase2 == i: + display[i] = display[i] | 1 + + + + elif mode == 5: + for i in range(8): + display[i] = random.getrandbits(7) & random.getrandbits(7) & random.getrandbits(7) & random.getrandbits(7) & random.getrandbits(7) & random.getrandbits(7) + intensity_vals[i] = random.randint(1,10) + + elif mode == 6: + c2 = c2 + 1 + phase = (c2 >> 3) % (7+8) + for i in range(8): + intensity_vals[i] = 9 + display[i] = 0 + for j in range(7): + if phase == j+i: + display[i] = display[i] | 1 << j + + + elif mode == 7: + c2 = c2 + 1 + t1 = c2 / 30 + t2 = t1 - math.pi / 8 + t3 = t2 - math.pi / 8 + count = int(t1 / (math.pi * 2)) + + p1 = (count + int((math.sin(t1) + 1) * 4)) % 8 + p2 = (count + int((math.sin(t2) + 1) * 4)) % 8 + p3 = (count + int((math.sin(t3) + 1) * 4)) % 8 + + for i in range(8): + if i == p1: + display[i] = 0x7f + intensity_vals[i] = 15 + elif i == p2: + display[i] = 0x78 + intensity_vals[i] = 7 + elif i == p3: + display[i] = 0x60 + intensity_vals[i] = 0 + else: + display[i] = 0x00 + + elif mode == 8: + c2 = c2 + 1 + pattern = 0xff00ff + for i in range(8): + phase = ((c2 >> 4) + i) % 8 + display[i] = (pattern << phase) & 0x7f + intensity_vals[i] = 9 + + elif mode == 9: + step = int((math.sin(c2 / 900) + 2) * 10) + c2 = c2 + step + phase = (c2 >> 8) % 4 + for i in range(8): + pd = (phase - i) % 4 + intensity_vals[i] = min(15,max(0, (4 - pd * 3) * 4)) + if pd < 3: + display[i] = 0x7f + else: + display[i] = 0x00 + + elif mode == 10: + for i in range(8): + pattern = 0 + for j in range(7): + if random.randint(0,1000) < 20 * (8 - j): + pattern = pattern | 1 << j + display[i] = pattern + intensity_vals[i] = random.randint(1,10) + + elif mode == 11: + c2 = c2 + 1 + + phase = (c2 * 3 >> 5) % 8 + stepx = (c2 * 5 >> 10) % 16 + 1 + + for i in range(8): + intensity_vals[i] = 9 + display[i] = 0 + for j in range(7): + if (phase + j * 8 + i) % stepx == 0: + display[i] = 1 << j + + elif mode == 12: + for i in range(8): + display[i] = 0 + c2 = c2 + 1 + phase = (c2 >> 3) % 24 + phase2 = (-c2 >> 5) % 8 + for loc in range(4): + + for i in range(8): + intensity_vals[i] = 9 + if int(phase / 3) == i: + display[i] = display[i] | 1 << (6 - (phase % 3)) + phase = (phase + 1) % 24 + + for i in range(8): + if phase2 == i: + display[i] = display[i] | 1 + if (phase2 + 1) % 8 == i: + display[i] = display[i] | 2 + + + if not radio_mode: + for i in range(4): + base_reg = 0x10 + reg_byte = intensity_vals[i*2+1] << 4 | intensity_vals[i*2] + petal_bus.writeto_mem(PETAL_ADDRESS, base_reg + i, bytes([reg_byte])) + + + for i in range(8): + base_reg = 0x01 + petal_bus.writeto_mem(PETAL_ADDRESS, base_reg + i, bytes([display[i]])) + + time.sleep_ms(timestep) + bootLED.off() + diff --git a/software/software/main.py b/software/software/main.py index 25895fd..18f161f 100644 --- a/software/software/main.py +++ b/software/software/main.py @@ -1,331 +1,61 @@ from machine import I2C, Pin import time -import math -import random -from bleradio import BLERadio +import joemain -max_mode = 13 -mode = max_mode - 1 -counter = 0.0 -delay_time = 100 -direction = 1 -velocity = 0 -location = 0 -smoothed_loc = 0 -c2 = 0 -tw = 0 -prev_tw = 0 -vel_array = [1,2,4,8,16,32,64] -loc_array = [0,0,0,0,0,0,0] -rot_count = 0 -timeout = 8000 -countdown = timeout -timestep = 5 +# uncomment following line to run fancy animation and ble radio hacks in joemain.py +# joemain() -display = bytearray(8) +counter = 0 - -debounce = { buttonA : 0, buttonB : 0 , buttonC : 0 } -clicked = { buttonA : False, buttonB : False , buttonC : False } - -debounce_max = 4 - -intensity_vals = bytearray(8) -broadcast_channel = 0 -observe_channel = 0 -max_channels = 8 -radio_mode = False +## do a quick spiral to test +if petal_bus: + for j in range(8): + which_leds = (1 << (j+1)) - 1 + for i in range(1,9): + print(which_leds) + petal_bus.writeto_mem(PETAL_ADDRESS, i, bytes([which_leds])) + time.sleep_ms(30) + petal_bus.writeto_mem(PETAL_ADDRESS, i, bytes([which_leds])) while True: - for button in [buttonA, buttonB, buttonC]: - clicked[button] = False - if not button.value() and debounce[button] < debounce_max: - debounce[button] = debounce[button] + 1 - if debounce[button] == debounce_max >> 1: - clicked[button] = True - elif debounce[button] > 0: - debounce[button] = debounce[button] - 1 - - if clicked[buttonA]: - if radio_mode: - broadcast_channel = (broadcast_channel + 1) % max_channels - radio = BLERadio(broadcast_channel=broadcast_channel, observe_channels=list(range(8))) + ## display button status on RGB + if petal_bus: + if not buttonA.value(): + petal_bus.writeto_mem(PETAL_ADDRESS, 2, bytes([0x80])) else: - mode = (mode + 1) % max_mode - countdown = timeout - c2 = 0 - print("mode:", mode) - - if clicked[buttonB]: - observe_channel = (observe_channel + 1) % max_channels + petal_bus.writeto_mem(PETAL_ADDRESS, 2, bytes([0x00])) - if clicked[buttonC]: - radio_mode = not radio_mode - if radio_mode: - radio = BLERadio(broadcast_channel=broadcast_channel, observe_channels=list(range(8))) - - countdown = countdown - timestep - if countdown < 0: - next_mode = mode - while next_mode == mode: - next_mode = random.randint(0,max_mode-1) - mode = next_mode - c2 = 0 - countdown = timeout - print("mode:", mode) - - - if radio_mode: - c2 = c2 + 1 - if c2 % 20 == 0: - ## see what's going on with the touch wheel - if touchwheel_bus: - tw = touchwheel_read(touchwheel_bus) - - radio.broadcast([tw]) - - ob = radio.observe(observe_channel) - tw_ob = 0 - if ob is not None: - tw_ob = ob[0] - - ## display touchwheel on petal - if petal_bus and touchwheel_bus: - base_addr = 1 - if tw_ob > 0: - tw_ob = (128 - tw_ob) % 256 - petal = int(tw_ob/32) + 1 - for i in range(8): - if i == petal: - petal_bus.writeto_mem(0, base_addr + i, bytes([0x7F])) - else: - petal_bus.writeto_mem(0, base_addr + i, bytes([0x00])) - else: - for i in range(8): - pattern = 0 - if i <= broadcast_channel: - pattern = pattern | 1 - if i <= observe_channel: - pattern = pattern | 0x40 - - - petal_bus.writeto_mem(0, base_addr + i, bytes([pattern])) - - - - - - elif mode == 0: - ## see what's going on with the touch wheel - if touchwheel_bus: - - tw = touchwheel_read(touchwheel_bus) - if tw != 0: - - #temploc = location % 256 - if (prev_tw - tw) % 256 < (tw - prev_tw) % 256: - velocity = (prev_tw - tw) % 256 - else: - velocity = -((tw - prev_tw) % 256) - location = location + velocity - smoothed_loc = (location + smoothed_loc * 3) >> 2 - print(smoothed_loc) - prev_tw = tw - - - for i in range(7): - loc_array[i] += vel_array[i] - if loc_array[i] >= 1024: - loc_array[i] = loc_array[i] - 1024 - - c2 = c2 + 1 - limit = 10 - if c2 >= limit: - - #print(velocity) - c2 = c2 - limit - counter = counter + math.pi/16 - if counter > 2 * math.pi: - counter = counter - 2 * math.pi - - ## display touchwheel on petal - if petal_bus and touchwheel_bus: - phase = int((math.sin(counter) + 1) * 9) - phase2 = int((math.sin(counter) + 1) * 4) - if phase <= 1: - bitmap = ((0x7f << phase) & 0x7f00) >> 8 | 0x80 - else: - bitmap = ((0x7f << phase) & 0x7f00) >> 8 - - for i in range(8): - display[i] = bitmap - intensity_vals[i] = phase2 - #if i == petal: - # petal_bus.writeto_mem(0, i, bytes([0x3F])) - #else: - # petal_bus.writeto_mem(0, i, bytes([0x00])) - elif mode == 1: - - c2 = c2 + 1 - - intensity = int((math.sin(c2 / 30.0) + 1) * 8) - intensity = min(max(intensity, 0), 15) - for i in range(8): - display[i] = 0x7f - intensity_vals[i] = intensity - - elif mode == 2: - - c2 = c2 + 1 - phase = (c2 >> 4) % 8 - for i in range(8): - pd = (phase - i) % 8 - intensity_vals[i] = min(15,max(0, (7 - pd * 2) * 2)) - if pd <= 4: - display[i] = 0x7f + if not buttonB.value(): + petal_bus.writeto_mem(PETAL_ADDRESS, 3, bytes([0x80])) + else: + petal_bus.writeto_mem(PETAL_ADDRESS, 3, bytes([0x00])) + + if not buttonC.value(): + petal_bus.writeto_mem(PETAL_ADDRESS, 4, bytes([0x80])) + else: + petal_bus.writeto_mem(PETAL_ADDRESS, 4, bytes([0x00])) + + ## see what's going on with the touch wheel + if touchwheel_bus: + tw = touchwheel_read(touchwheel_bus) + + ## display touchwheel on petal + if petal_bus and touchwheel_bus: + if tw > 0: + tw = (128 - tw) % 256 + petal = int(tw/32) + 1 + else: + petal = 999 + for i in range(1,9): + if i == petal: + petal_bus.writeto_mem(0, i, bytes([0x7F])) else: - display[i] = 0x00 - - elif mode == 3: - for i in range(8): - if random.randint(0,1000) < 20: - intensity_vals[i] = max(0,min(15,intensity_vals[i] + random.randint(-1,2))) - for j in range(7): - if random.randint(0,1000) < 10: - display[i] = display[i] ^ 1 << j + petal_bus.writeto_mem(0, i, bytes([0x00])) - elif mode == 4: - for i in range(8): - display[i] = 0 - c2 = c2 + 1 - phase = (c2 >> 3) % 24 - phase2 = (-c2 >> 5) % 8 - for i in range(8): - intensity_vals[i] = 9 - if int(phase / 3) == i: - display[i] = display[i] | 1 << (6 - (phase % 3)) - for i in range(8): - if phase2 == i: - display[i] = display[i] | 1 - - - - elif mode == 5: - for i in range(8): - display[i] = random.getrandbits(7) & random.getrandbits(7) & random.getrandbits(7) & random.getrandbits(7) & random.getrandbits(7) & random.getrandbits(7) - intensity_vals[i] = random.randint(1,10) - - elif mode == 6: - c2 = c2 + 1 - phase = (c2 >> 3) % (7+8) - for i in range(8): - intensity_vals[i] = 9 - display[i] = 0 - for j in range(7): - if phase == j+i: - display[i] = display[i] | 1 << j - - - elif mode == 7: - c2 = c2 + 1 - t1 = c2 / 30 - t2 = t1 - math.pi / 8 - t3 = t2 - math.pi / 8 - count = int(t1 / (math.pi * 2)) - p1 = (count + int((math.sin(t1) + 1) * 4)) % 8 - p2 = (count + int((math.sin(t2) + 1) * 4)) % 8 - p3 = (count + int((math.sin(t3) + 1) * 4)) % 8 - - for i in range(8): - if i == p1: - display[i] = 0x7f - intensity_vals[i] = 15 - elif i == p2: - display[i] = 0x78 - intensity_vals[i] = 7 - elif i == p3: - display[i] = 0x60 - intensity_vals[i] = 0 - else: - display[i] = 0x00 - - elif mode == 8: - c2 = c2 + 1 - pattern = 0xff00ff - for i in range(8): - phase = ((c2 >> 4) + i) % 8 - display[i] = (pattern << phase) & 0x7f - intensity_vals[i] = 9 - - elif mode == 9: - step = int((math.sin(c2 / 900) + 2) * 10) - c2 = c2 + step - phase = (c2 >> 8) % 4 - for i in range(8): - pd = (phase - i) % 4 - intensity_vals[i] = min(15,max(0, (4 - pd * 3) * 4)) - if pd < 3: - display[i] = 0x7f - else: - display[i] = 0x00 - elif mode == 10: - for i in range(8): - pattern = 0 - for j in range(7): - if random.randint(0,1000) < 20 * (8 - j): - pattern = pattern | 1 << j - display[i] = pattern - intensity_vals[i] = random.randint(1,10) - - elif mode == 11: - c2 = c2 + 1 - - phase = (c2 * 3 >> 5) % 8 - stepx = (c2 * 5 >> 10) % 16 + 1 - - for i in range(8): - intensity_vals[i] = 9 - display[i] = 0 - for j in range(7): - if (phase + j * 8 + i) % stepx == 0: - display[i] = 1 << j - - elif mode == 12: - for i in range(8): - display[i] = 0 - c2 = c2 + 1 - phase = (c2 >> 3) % 24 - phase2 = (-c2 >> 5) % 8 - for loc in range(4): - - for i in range(8): - intensity_vals[i] = 9 - if int(phase / 3) == i: - display[i] = display[i] | 1 << (6 - (phase % 3)) - phase = (phase + 1) % 24 - - for i in range(8): - if phase2 == i: - display[i] = display[i] | 1 - if (phase2 + 1) % 8 == i: - display[i] = display[i] | 2 - - - if not radio_mode: - for i in range(4): - base_reg = 0x10 - reg_byte = intensity_vals[i*2+1] << 4 | intensity_vals[i*2] - petal_bus.writeto_mem(PETAL_ADDRESS, base_reg + i, bytes([reg_byte])) - - - for i in range(8): - base_reg = 0x01 - petal_bus.writeto_mem(PETAL_ADDRESS, base_reg + i, bytes([display[i]])) - - time.sleep_ms(timestep) + time.sleep_ms(100) bootLED.off() @@ -333,4 +63,3 @@ - From 569487e54cc93bce589b8b66f288034951ff8907 Mon Sep 17 00:00:00 2001 From: Joey Nelson Date: Sun, 10 Nov 2024 13:24:21 -0800 Subject: [PATCH 9/9] corrected mpremote mip install commmand comment --- software/software/joemain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/software/joemain.py b/software/software/joemain.py index 80383b3..73127b9 100644 --- a/software/software/joemain.py +++ b/software/software/joemain.py @@ -3,7 +3,7 @@ import math import random -# use `mpremote mep add bleradio` or similar to install +# use `mpremote mep add https://raw.githubusercontent.com/pybricks/micropython-bleradio/master/bleradio.py` or similar to install from bleradio import BLERadio