Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

th4ruka
Copy link

@th4ruka th4ruka commented May 6, 2024

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.

@th4ruka
Copy link
Author

th4ruka commented May 6, 2024

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
Copy link
Contributor

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

Signed-off-by: tharuka-pavith <tharukapavith2@gmail.com>
@th4ruka
Copy link
Author

th4ruka commented May 6, 2024

Try adding the import:

from micropython import const

Now it works! Thank you @mattytrentini

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants