W55RP20-EVB-PICO ssd1306 example
This example uses MicroPython to control an SSD1306 OLED over I2C. It draws shapes and displays text, with adjustable update frequency for balanced performance.
various company - ssd1306
x 1
Environment Used
- Hardware: Used with an embedded device like Raspberry Pi.
- Display: SSD1306 OLED display module (I2C interface).
- Processor: ARM-based microcontroller.
- Programming Language: MicroPython.
- Other Components: GPIO pins supporting I2C communication (SCL = Pin 9, SDA = Pin 8).
Technologies Used
- MicroPython and Machine Module: This library allows direct communication with hardware, setting up GPIO pins, and managing I2C communication.
- SSD1306 Library: Used to communicate with the SSD1306 display over I2C, displaying text and drawing various shapes.
- OOP Approach: Managed the OLED display in an object-oriented manner by creating an instance of the
OLED_Display
class. - Performance Optimization: Optimized performance using
pixel_threshold
andshow_delay
to control the frequency of screen updates.
How to Use
Initialization:
- Initialize the display module using the
OLED_Display()
class. - Set up the connection with the SSD1306 display using I2C.
Display Text:
- Call
print_oled(text)
to display text at a specific position. - After displaying, the Y-coordinate automatically updates to prepare for the next line of text.
Drawing Shapes:
- Use
draw_shapes(show_delay)
ordraw_shape(shape, show_delay)
to draw different shapes like rectangles, circles, and triangles on the OLED screen. show_delay
parameter allows you to control the delay during drawing, which can be useful for adjusting the drawing speed.
Performance Tuning:
- The
pixel_threshold
value determines how frequently theoled.show()
function is called after updating pixels. show_delay
controls the delay between pixel rendering, allowing fine-tuned control over rendering performance.
Test:
- detailed pinmap of w55rp20 - https://docs.wiznet.io/Product/ioNIC/W55RP20/overview
- w55rp20 datasheet - refere attached in the link below.
- jumper cable connection:
- w55rp2040's GP9 to ssd1306's SCL
- w55rp2040's GP8 to ssd1306's SDA
- w55rp2040's 3V3 to ssd1306's VCC
- w55rp2040's GND to ssd1306's GND
- Install the MicroPython uf2 binary provided by wiznet (https://github.com/WIZnet-ioNIC/WIZnet-ioNIC-micropython/releases) in boot mode.(please refer this link for detailed installation instructions:W55RP20-EVB-PICO Redis example, ) Then, in Thonny, add ssd1306.py and ssd1306_test.py files. You can verify the operation by running the ssd1306_test.py file.
Reference: