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

[display] Improved SSD1306, Support for SH1106 #627

Merged

Conversation

TomSaw
Copy link
Contributor

@TomSaw TomSaw commented May 4, 2021

Support SH1106

Various SSD1306 Displays sold today do actually integrate the cheaper SH1106. This thing is said to be compatible with SSD1306 what's not 100% the case: SH1106 does only support Page MemoryMode. thus requires a different writeDisplay() routine than actually used for modm::Ssd1306.

Current result using modm::Ssd1306 with SH1106 looks lke this

When sending a frame, one has to alternate between setting the incremented page-address and sending page-data.

However, SSD1306 can also be driven in MemoryMode::PAGE but would result in worse performance vs. transmitting the whole frame at once.

Solutions

  1. Create a class Sh1106 inheriting Ssd1306 and override for the differences.
  2. Pass MemoryMode as template parameter to Ssd1306 and specialize for the differences.
  3. Pass Ssd1306_I2cWriteTransaction as template parameter and handle the differences there.

I've choosen 1. because:

  • SH1106 is a different IC and deserves it's own class. The compatibility to SSD1306 is expressed by the strong inheritance on Ssd1306
  • Solution 3. sounds elegant but results in more complex code cause way more binding is required between SSD1306 and Ssd1306_I2cWriteTransaction.
  • One does not want to drive SSD1306 in MemoryMode::PAGE due to worse performance. This excludes 2. and 3 additionally

Improved SSD1306

Structure

  • Detailed Registers in own header ′ssd1306_register.hpp′
  • Renamed DataTranmissionAdapter -> Ssd1306_I2cWriteTransaction for clarification
  • removed numerous cumbersome WriteData() methods

Performance

  • Bulk data transmissions
    • Much faster Initialize() and slightly faster writeDisplay()
    • Size of commandBuffer could be halfed
  • Simplified Ssd1306_I2cWriteTransaction

Changes on MonochromeGraphicDisplay

  • Flipped buffer[x][y] to buffer[y][x] to be compatible with SH1106
    Current layout of the buffer is not compatible with the memory of SH1106. For SH1106 we need the rows ( x-dimension) being ordered behind each other rather than the columns.
    SH1106 unfortunately offers no other options to adjust the mapping. Kindly Ssd1306 comes to meet these constraints and archieve max performance for both displays. We can switch from MemoryMode::VERTICAL -> MemoryMode::HORIZONTAL so both displays expect the rows in a line and the common ′buffer′s dimensions could be flipped.

@TomSaw
Copy link
Contributor Author

TomSaw commented May 4, 2021

Cool. This think looks fine to me. Could you please review @salkinium !?

src/modm/driver/display/sh1106.hpp Outdated Show resolved Hide resolved
src/modm/driver/display/sh1106.hpp Outdated Show resolved Hide resolved
src/modm/driver/display/sh1106.hpp Show resolved Hide resolved
src/modm/driver/display/ssd1306.hpp Outdated Show resolved Hide resolved
src/modm/driver/display/ssd1306.hpp Outdated Show resolved Hide resolved
src/modm/driver/display/ssd1306_impl.hpp Outdated Show resolved Hide resolved
src/modm/driver/display/ssd1306_impl.hpp Outdated Show resolved Hide resolved
src/modm/driver/display/ssd1306_impl.hpp Outdated Show resolved Hide resolved
src/modm/driver/display/ssd1306_impl.hpp Outdated Show resolved Hide resolved
src/modm/driver/display/ssd1306_impl.hpp Outdated Show resolved Hide resolved
@TomSaw TomSaw force-pushed the support-sh1106-and-improve-ssd1306 branch 2 times, most recently from acc3df5 to 3b5bb94 Compare May 5, 2021 07:16
@TomSaw TomSaw changed the title [display] Improve SSD1306, Support SH1106 [display] Improved MonochromeGraphicDisplay and SSD1306, Support for SH1106 May 5, 2021
@TomSaw TomSaw force-pushed the support-sh1106-and-improve-ssd1306 branch 6 times, most recently from 43e9c14 to 0b0332f Compare May 6, 2021 08:05
@TomSaw TomSaw requested a review from salkinium May 6, 2021 08:29
Copy link
Member

@salkinium salkinium left a comment

Choose a reason for hiding this comment

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

Very nice! Perhaps split into two commits, one for the display changes and one for the driver code.

src/modm/ui/display/monochrome_graphic_display.hpp Outdated Show resolved Hide resolved
@TomSaw TomSaw force-pushed the support-sh1106-and-improve-ssd1306 branch from 0b0332f to beda25a Compare May 7, 2021 09:31
@TomSaw TomSaw changed the title [display] Improved MonochromeGraphicDisplay and SSD1306, Support for SH1106 [display] Improved SSD1306, Support for SH1106 May 7, 2021
@TomSaw
Copy link
Contributor Author

TomSaw commented May 7, 2021

Clean. if you're happy, merge pls!

@TomSaw TomSaw force-pushed the support-sh1106-and-improve-ssd1306 branch 2 times, most recently from e4b0461 to 31d9ba2 Compare May 7, 2021 11:12
@TomSaw
Copy link
Contributor Author

TomSaw commented May 7, 2021

Ready to merge, sir!

@salkinium salkinium force-pushed the support-sh1106-and-improve-ssd1306 branch from 31d9ba2 to 7d7490d Compare May 7, 2021 17:52
@salkinium salkinium added the ci:hal Triggers the exhaustive HAL compile CI jobs label May 7, 2021
@salkinium salkinium merged commit 7d7490d into modm-io:develop May 7, 2021
@salkinium salkinium added this to the 2021q2 milestone Jun 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants