git.s-ol.nu hw/0x33.board/firmware / 5ea0f48
performance: 1MHz SPI, drop fancyled s-ol 2 months ago
4 changed file(s) with 21 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
4646 self.pixels = NeoPixel(board.GP11, 48 + 4, auto_write=False)
4747
4848 displayio.release_displays()
49 i2c = I2C(sda=board.GP14, scl=board.GP15)
49 i2c = I2C(sda=board.GP14, scl=board.GP15, frequency=1000000)
5050 bus = I2CDisplay(i2c, device_address=0x3C)
5151 self.display = SSD1306(bus, width=128, height=32, rotation=180, auto_refresh=False)
5252 self.display.show(displayio.Group())
44 from micropython import const
55 from adafruit_midi.note_on import NoteOn
66 from adafruit_midi.note_off import NoteOff
7 from adafruit_fancyled.adafruit_fancyled import CHSV, clamp_norm
7 from colorsys import hsv_to_rgb
88
99 from .util import ticks_diff
10
11
12 def clamp_norm(v):
13 return max(0, min(v, 1))
1014
1115
1216 class Note:
104108
105109 rest = 1.0 - key_val
106110 value = key_val + value * rest
107 return CHSV(hue, sat, value).pack()
111 return hsv_to_rgb(hue, sat, value)
108112
109113 def on_press(self):
110114 if self.note:
165169 '''
166170 Callback to update RGB LEDs.
167171 '''
168 pixels[0] = CHSV(*self.color).pack()
172 pixels[0] = hsv_to_rgb(*self.color)
169173
170174 def update_display(self):
171175 '''
11
22 from adafruit_display_text import label
33 from adafruit_display_shapes import rect
4 from adafruit_fancyled.adafruit_fancyled import CHSV
4 from colorsys import hsv_to_rgb
55 import displayio
66 import json
77
88 from .util import FONT_10, led_map
99 from .core import Mode, Key
1010
11 BLUE = CHSV(0.48, 1.0, 1.0).pack()
12 BLUE_DIM = CHSV(0.48, 1.0, 0.15).pack()
13
14 CHOICE_NEUTRAL = CHSV(0.0, 0.0, 0.0).pack()
15 RED = CHSV(0.95, 1.0, 1.0).pack()
16 RED_DIM = CHSV(0.95, 1.0, 0.15).pack()
17 GREEN = CHSV(0.27, 1.0, 1.0).pack()
18 GREEN_DIM = CHSV(0.27, 1.0, 0.15).pack()
11 BLUE = hsv_to_rgb(0.48, 1.0, 1.0)
12 BLUE_DIM = hsv_to_rgb(0.48, 1.0, 0.15)
13
14 CHOICE_NEUTRAL = hsv_to_rgb(0.0, 0.0, 0.0)
15 RED = hsv_to_rgb(0.95, 1.0, 1.0)
16 RED_DIM = hsv_to_rgb(0.95, 1.0, 0.15)
17 GREEN = hsv_to_rgb(0.27, 1.0, 1.0)
18 GREEN_DIM = hsv_to_rgb(0.27, 1.0, 0.15)
1919
2020
2121 def _thresh(val, t):
183183 settings: Settings
184184 ui_settings: list[Setting]
185185
186 SETTING_ACTIVE = CHSV(0.12, 1.0, 1.0).pack()
187 SETTING_ACTIVE_DIM = CHSV(0.12, 1.0, 0.15).pack()
186 SETTING_ACTIVE = hsv_to_rgb(0.12, 1.0, 1.0)
187 SETTING_ACTIVE_DIM = hsv_to_rgb(0.12, 1.0, 0.15)
188188
189189 def __init__(self, *args, settings: Settings, ui_settings_ids: list[str]):
190190 super().__init__(*args)
00 adafruit_displayio_ssd1306==1.5.3
11 adafruit_display_shapes==2.4.2
22 adafruit_display_text==2.22.3
3 adafruit_fancyled==1.4.8
43 adafruit_midi==1.4.8
4 neopixel==6.3.0
5 colorsys