Skip to content

RGB speed #40

@garthk

Description

@garthk

I just hooked up 235 pixels using an 8 channel knock-off of the Adafruit 4-channel I2C-safe Bi-directional Logic Level Converter - BSS138. Such overkill for one logic line, but it's keeping the 5V supply to the strip away from the SAO port.

My booting show-off flash in #38 is doing what I'd intended: at boot time, reassure me that I've configured and wired my LEDs correctly. Reckon I might port just the flash to aiko.led for that reason. But, it's sloooow. Writing 243 updates to 7 pixels each time and then calling aiko.led.np.write again is taking 7800ms with a delay of 1ms, 7900ms with the time.sleep_ms code removed—I'm not sure why—and 1990ms even if I do nothing except call aiko.led.np.write() 243 times with 235 pixels. I'll track my work trying to speed it up here until I raise the PR.

Core loop:

def initialise():
  colours = [aiko.led.black] + [gammify(h2c(hex)) for hex in COLOURS] + [aiko.led.black]
  ncolours = len(colours)
  npixels = aiko.led.np.n
  delay = max(1, DURATION_MS // (ncolours + npixels))

  aiko.led.fill(aiko.led.black)
  aiko.led.np.write()

  before = time.ticks_ms()

  for offset in range(0 - ncolours, npixels):
    for index in range(ncolours):
      pixel = offset + index
      if 0 <= pixel < npixels:
        aiko.led.np[pixel] = colours[index]
    aiko.led.np.write()
    time.sleep_ms(delay)

  after = time.ticks_ms()
  print("took {}ms to flash {} times with delay {}ms".format(after-before, npixels+ncolours, delay))
  aiko.led.fill(aiko.led.black)
  aiko.led.np.write()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions