Skip to content

Commit bff8531

Browse files
Use LED strip for load progress
1 parent 5a95408 commit bff8531

2 files changed

Lines changed: 27 additions & 5 deletions

File tree

CLUE_Light_Painter/bmp2led.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ def process(self, input_filename, output_filename, rows,
216216
# Operation performed later requires a list, not a bytearray.
217217
# Make a copy, keeping the same values.
218218
# dotstar_list = list(dotstar_buffer)
219+
#reorder = [0] * dotstar_row_size
219220

220221
# Output rows are held in RAM and periodically written,
221222
# marginally faster than writing each row separately.
@@ -250,6 +251,7 @@ def process(self, input_filename, output_filename, rows,
250251
# Constrain bytes-to-read to pixel strip length
251252
clipped_width = min(self.bmp_specs.width, self.num_pixels)
252253
row_bytes = 3 * clipped_width
254+
# Compute reorder list here (needs row bytes to work)
253255

254256
# Each output row is interpolated from two BMP rows,
255257
# we'll call them 'a' and 'b' here.
@@ -263,6 +265,7 @@ def process(self, input_filename, output_filename, rows,
263265
# I'm sure there's better ways but have a headache.
264266
# This is ONLY needed if using the first of two
265267
# benchmarked methods later (or something similar to it).
268+
# There's really only six possible orders, I could make a list
266269
# if self.blue_index is 0: # BXX DotStar
267270
# offset_0 = 0 # DotStar byte 0 is BMP byte 0 (B)
268271
# if self.green_index is 1: # BGR
@@ -424,6 +427,17 @@ def process(self, input_filename, output_filename, rows,
424427
# has a negative effect on ulab performance, maybe
425428
# memory-management related?
426429

430+
# And a third, using a reordering table...
431+
# This doesn't actually work yet because the
432+
# reorder table hasn't been computed.
433+
# Two extra items (0 and 255) are appended for
434+
# use by headers/footers/etc. Can't directly append
435+
# to ndarray, so we bytearray-ify it first.
436+
#got = bytearray(got) + bytearray([0, 255])
437+
#output_buffer[output_position:output_position +
438+
# dotstar_row_size] = bytearray(
439+
# got[i] for i in reorder)
440+
427441
time3 += (monotonic() - row_start_time)
428442

429443
# Add converted data to output buffer.

CLUE_Light_Painter/code.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,14 @@ def load_progress(self, amount):
174174
Arguments:
175175
amount (float) : Current 'amount loaded' coefficient; 0.0 to 1.0
176176
"""
177-
self.rect.x = int(board.DISPLAY.width * (amount - 1.0))
177+
#self.rect.x = int(board.DISPLAY.width * (amount - 1.0))
178+
num_on = int(amount * self.bmp2led.num_pixels + 0.5)
179+
num_off = self.bmp2led.num_pixels - num_on
180+
on_pixel = [255, 0, 0, 0]
181+
on_pixel[1 + self.bmp2led.green_index] = 10
182+
self.spi.write(bytearray([0] * 4 + on_pixel * num_on +
183+
[255, 0, 0, 0] * num_off + [255] *
184+
((self.bmp2led.num_pixels + 15) // 16)))
178185

179186

180187
def load_image(self):
@@ -185,10 +192,10 @@ def load_image(self):
185192
"""
186193
# Minimal progress display while image is loaded.
187194
group = displayio.Group()
188-
group.append(centered_label('LOADING...', 30, 3))
189-
self.rect = Rect(-board.DISPLAY.width, 120,
190-
board.DISPLAY.width, 40, fill=0x00B000)
191-
group.append(self.rect)
195+
group.append(centered_label('LOADING...', 40, 3))
196+
#self.rect = Rect(-board.DISPLAY.width, 120,
197+
# board.DISPLAY.width, 40, fill=0x00B000)
198+
#group.append(self.rect)
192199
board.DISPLAY.show(group)
193200

194201
# pylint: disable=eval-used
@@ -213,6 +220,7 @@ def load_image(self):
213220
sleep(4)
214221

215222
board.DISPLAY.show(displayio.Group()) # Clear display
223+
self.clear_strip() # LEDs off
216224

217225

218226
def paint(self):

0 commit comments

Comments
 (0)