Content

tekton » optimised oled

the upright bars should have been in place on my arrival, that was the pre-requisite for me being able build the installation. as things were, the now partially pre-assembled units were only going up two days later, with only two days to go. this wasn’t good, but it did at least force some pleasant down-time where i got to do some things i’d wanted to do for ages, but motor issues had kept me from. so here is the oled finally looking nice, and not impairing the machine running at 60fps. drawing any text using python’s imaging system was way too slow, but with a little inspection of the adafruit driver library, i saw i could swap out the image buffer and flush that to the screen, which would be near-instantaneous. so with a little pre-rendering, the oled could now update while the controller waits for the next frame’s start time. controller code, now at ~9th revision

pre-render before starting the animation sequence, capturing each rendered buffer instead of sending the buffer:

def render_buffer_cache(prefix):
  for i in range(10):
    draw.rectangle((0,0,oled.width, oled.height), outline=0, fill=0)
    draw.text((0, 0), prefix + str(i),  font=font, fill=255)
    if host_upsidedown: 
      oled.image(image.rotate(180))
    else:
      oled.image(image)
    buffer_cache[i] = list(oled._buffer)

for each frame of animation, point the buffer at the next pre-rendered one and send the contents to the display:

oled._buffer = buffer_cache[frame_index % 10]  
oled.display() 

diary | 08 jul 2015 | tagged: dfuse · tekton · embedded