top of page

12.15.22

  • owenmichael12333
  • Dec 15, 2022
  • 1 min read

This week I attempted to create an animation of a spinning sun using the OLED display and Raspberry Pi Pico. Upon recreating a tutorial that I was following a ran into the following error:

Traceback (most recent call last):
  File "<stdin>", line 19, in <module>
MemoryError: memory allocation failed, allocating 5000 bytes

The code:

from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
import framebuf
import time

WIDTH = 128
HEIGHT = 64

i2c = I2C(0, scl = Pin(1), sda = Pin(0), freq=400000)
display = SSD1306_I2C(WIDTH, HEIGHT, i2c)


images = []
for n in range(1, 28):
    with open('/TEMP/image%s.pbm' % n, 'rb') as f:  #open folder and image
        f.readline() # Magic number
        f.readline() # Creator comment
        f.readline() # Dimensions
        data = bytearray(f.read())
    fbuf = framebuf.FrameBuffer(data, 64, 64, framebuf.MONO_HLSB) #adjust accordingly the width and height
    images.append(fbuf)
    


while True:
    for i in images:
        display.blit(i, 32, 0)
        display.show()
        time.sleep(0.01)

I then decided to take up a zen task of taking apart a previous project and putting the parts away as they were no longer in use.

I am currently looking into CircuitPython as Mr. Christy showed it to me and it might be much easier to use than MicroPython which I am currently using.

 
 
 

Recent Posts

See All
5.11.23

This week I did not get much done due to very few class periods this week. I spent the beginning of the week working on cleaning up the...

 
 
 

Comments


bottom of page