Skip to content

Add SSD1305 OLED driver support#413

Open
Kihltech wants to merge 1 commit intorm-hull:mainfrom
Kihltech:feature/ssd1305
Open

Add SSD1305 OLED driver support#413
Kihltech wants to merge 1 commit intorm-hull:mainfrom
Kihltech:feature/ssd1305

Conversation

@Kihltech
Copy link
Contributor

Adds support for the SSD1305 OLED controller.

Changes

  • New ssd1305 device class in luma/oled/device/__init__.py
  • SSD1305 datasheet added to doc/tech-spec/
  • Documentation updated (README, intro.rst, setup.cfg)
  • Full test suite with reference data

Hardware verification

Tested on a Waveshare 2.23inch OLED HAT (128x32, SPI) connected to a Raspberry Pi.
Proof of concept repo: https://github.com/Kihltech/waveshare-2.23inch-oled-hat

Key differences from SSD1306

  • No internal charge pump (CHARGEPUMP set to 0x10, external VCC required)
  • Column offset of 4 for 128x32 mode
  • COM pins config 0x12 for 128x32 mode
  • Supports 128x32 (default) and 128x64 resolutions

Ref #309, ref #412

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces support for the SSD1305 OLED display controller, expanding the luma.oled library's compatibility. It includes the core driver implementation, necessary documentation updates, and a dedicated test suite to ensure proper functionality and integration. The changes enable users to interface with SSD1305-based OLED displays using the existing luma.oled framework.

Highlights

  • New SSD1305 Driver: Implemented a new ssd1305 device class, inheriting from ssd1306, to support the SSD1305 OLED controller.
  • Documentation Updates: Included the SSD1305 datasheet in the doc/tech-spec/ directory and updated documentation files (README.rst, intro.rst, setup.cfg) to reflect the new driver support.
  • Comprehensive Test Suite: Developed a comprehensive test suite (test_ssd1305.py) with reference data (demo_ssd1305.json) to validate the SSD1305 driver's functionality.
  • Hardware Verification: Verified hardware functionality on a Waveshare 2.23inch OLED HAT (128x32, SPI) connected to a Raspberry Pi.
  • SSD1305 Specifics: Addressed key differences of SSD1305 from SSD1306, such as requiring an external VCC (no internal charge pump), specific column offset for 128x32 mode, and support for both 128x32 and 128x64 resolutions.
Changelog
  • README.rst
    • Added "SSD1305" to the list of supported display drivers in the main heading.
    • Included "SSD1305" in the list of supported OLED matrix display controllers in the library description.
  • doc/intro.rst
    • Added "SSD1305" to the list of supported OLED matrix display controllers.
    • Included a download link for the SSD1305 datasheet.
  • luma/oled/device/init.py
    • Introduced the ssd1305 class, inheriting from ssd1306.
    • Implemented specific initialization commands for the SSD1305, including handling external VCC, column offset for 128x32 mode, and support for 128x32 and 128x64 resolutions.
  • setup.cfg
    • Updated the description field to include SSD1305 as a supported chipset.
    • Added ssd1305 to the keywords list.
  • tests/reference/data/demo_ssd1305.json
    • Added a new JSON file containing reference pixel data for SSD1305 display tests.
  • tests/test_ssd1305.py
    • Created a new test file to verify the functionality of the ssd1305 driver.
    • Included tests for 128x32 and 128x64 initialization, invalid dimension handling, hide() and show() methods, and drawing capabilities.
Activity
  • No human activity (comments, reviews, approvals, etc.) has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for the SSD1305 OLED controller, including the driver class, documentation, and a full test suite. The implementation is well-tested and follows the existing structure. My main feedback concerns code duplication in the new ssd1305 class's __init__ method, which is a near-copy of the parent ssd1306's __init__. I've suggested a small change to improve clarity and noted that a larger refactoring of ssd1306 would be beneficial for long-term maintainability.

"""

def __init__(self, serial_interface=None, width=128, height=32, rotate=0, **kwargs):
super(ssd1306, self).__init__(luma.oled.const.ssd1306, serial_interface)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The call super(ssd1306, self).__init__(...) is confusing. It's being used to intentionally skip the parent ssd1306.__init__ and call the grandparent device.__init__. While this works, it's un-idiomatic and hard to follow. For improved clarity, consider calling the grandparent's __init__ method directly.

This is also related to the larger issue of this __init__ method being almost a complete copy of ssd1306.__init__. A future refactor of ssd1306 to make it more extensible would be the ideal solution to avoid this code duplication.

Suggested change
super(ssd1306, self).__init__(luma.oled.const.ssd1306, serial_interface)
device.__init__(self, luma.oled.const.ssd1306, serial_interface)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have used the patterns of other drivers, such as 1309 and 1316, and doing the suggested change would break the consistency.
As for the larger question of code duplication and refactoring, I think that is a question for the maintainers and out of scope for this PR.

represents 270° rotation.
:type rotate: int

.. versionadded:: 3.x.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be 3.15.0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed now!
I had also forgotten to add ssd1305 to the all list.

Adds support for the SSD1305 OLED controller, tested on a
Waveshare 2.23inch OLED HAT (128x32, SPI).

Key differences from SSD1306:
- No internal charge pump (CHARGEPUMP set to 0x10)
- Column offset of 4 for 128x32 mode
- COM pins config 0x12 for 128x32 mode
- Supports 128x32 (default) and 128x64 resolutions

Includes datasheet, documentation updates, and test suite.
Hardware-verified on Raspberry Pi with Waveshare 2.23inch OLED HAT.

Ref rm-hull#309, ref rm-hull#412
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants