micropython / micropython-lib

Core Python libraries ported to MicroPython
Other
2.3k stars 980 forks source link

ssd1306: Add I2C protocol example for SSD1306 display. #852

Open th4ruka opened 1 month ago

th4ruka commented 1 month ago

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

Usage:

1. Install ssd1306 package in your microcontroller.

4. Run the example & see results.

Tests:

th4ruka commented 1 month ago

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.
mattytrentini commented 1 month ago

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

th4ruka commented 1 month ago

Try adding the import:

from micropython import const

Now it works! Thank you @mattytrentini