• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

ImportError: no module named ‘display’

Q&A Forum › Category: ESP32 › ImportError: no module named ‘display’
0 Vote Up Vote Down
Damian Hartley asked 5 years ago

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 🙁

Regards

Damian

Question Tags: Battery graphic from imported binary file to send to SSD1306
3 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi Damian.
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?
Regards,
Sara
 

0 Vote Up Vote Down
Damian Hartley answered 5 years ago

Hi Sara

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

0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi Damian.
That’s probably what its happening. Can you send a photo of what you see in the display?
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.