Hello Sara & Rui
Can you suggest whats wrong with the following to get the error shown. I have managed to suceed on my earlier challenges with your guidance I am trying to generate a battery graphic with the following code sent to the SSD1306 but have come to a dead end. I first want to just see if i can fill the ssd1306 with around 6 segment blocks of pixels. If I can achieve this I will code up to check battery volts and extinguish the segments as the battery voltage decays, so pretty easy just struggling a little with OOP
I have managed to create a file called battsegsdh.txt, which is a binary file containing just 0 and 1 for sending to the display, code ( saves me hopefully using masses of .Hline print statements). The code below is made up from some being mine and also googled
#Example of using graphics via framebuf from machine import Pin, I2C, from time import sleep import ssd1306 import framebuf import display #Graphics ESP32 Pin assignment i2c = I2C(-1, scl=Pin(22), sda=Pin(21)) oled_width = 128 oled_height = 64 display = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c) #To display just blit it to the display's framebuffer (note you need to invert, #since ON pixels are dark on a normal screen, light on OLED). with open('battsegsdh.txt','rb') as f: #f.readline() # Magic number # i dont need since i edited it out in imported file #f.readline() # Creator comment # i dont need since i edited it out in imported file #f.readline() # Dimensions # i dont need since i edited it out in imported file data = bytearray(f.read()) #hopefully below i created an instance of framebuf with arguments in parenthesis) fbuf = framebuf.FrameBuffer(data, 128, 64, framebuf.MONO_HLSB) display.invert(0) display.blit(fbuf, 0, 0) display.show() I get >>> Ready to download this file,please wait! ...... download ok exec(open('trying to do bat.py').read(),globals()) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<string>", line 6, in <module> ImportError: no module named 'display' >>>
but I have imported the display module???, others ask similar questions
Your help is appreciated since im a little stuck 🙁
First, I’m sorry for the delay in my response.
Can you tell me which libraries have you uploaded to your board and a link to those libraries?
Can you comment or delete line 6 and see what you get?
Thanks for this I now have something its not right on the screen but I expect its how the data in my imported file is being handled probably a byte boundary where the data in the file is not quite alligned with the 0.96″ display as it wraps the text