ssd1306: Add I2C protocol example for SSD1306 display.
Description:
This is an example for ssd1306 package using I2C protocol. It displays current date and time unpacked from time.localtime() function on the ssd1306 OLED display.The output will look like,
MicroPython
Time: 8:28:16
Date: 6/5/2024
- The display will update in every second.
Usage:
1. Install ssd1306 package in your microcontroller.
- If your device is connected to internet, run following code in REPL
>>> import mip
>>> mip.install("ssd1306")
- Else you can your mpremote from your PC,
$ mpremote connect /dev/ttyUSB0 mip install ssd1306
2. Copy the example_ssd1306_i2c.py file to your device.
3. Connect the SDA, SCL pins as given in the code,
SDA = Pin(22)
SCL = Pin(21)
- You may alter the pins in the code according to your micro-controller's datasheet.
4. Run the example & see results.
Tests:
- This example has been tested in a ESP32 microcontroller.
Can someone help with this failing checks,
Run ruff check --output-format=github .
Error: micropython/drivers/display/ssd1306/examples/example_ssd1306_i2c.py:31:9: F821 Undefined name `const`
Error: micropython/drivers/display/ssd1306/examples/example_ssd1306_i2c.py:32:10: F821 Undefined name `const`
Error: Process completed with exit code 1.
Can someone help with this failing checks,
Run ruff check --output-format=github . Error: micropython/drivers/display/ssd1306/examples/example_ssd1306_i2c.py:31:9: F821 Undefined name `const` Error: micropython/drivers/display/ssd1306/examples/example_ssd1306_i2c.py:32:10: F821 Undefined name `const` Error: Process completed with exit code 1.
Try adding the import:
from micropython import const
Try adding the import:
from micropython import const
Now it works! Thank you @mattytrentini