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

[driver] SSD1306 SPI display #1090

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open

[driver] SSD1306 SPI display #1090

wants to merge 5 commits into from

Conversation

rleh
Copy link
Member

@rleh rleh commented Oct 9, 2023

  • Rename modm::Ssd1306 to Ssd1306I2c
  • Add modm::Ssd1306Spi
    • Initialize sequence for 128x32px, 0.91inch, blue, HP12832-02 display module
  • Convert all enums in struct modm::ssd1306 to enum class
  • Fix mistake in SH1106 driver
  • Add example for (existing) SH1106 driver

@@ -12,19 +12,20 @@


def init(module):
module.name = ":driver:ssd1306"
module.description = "SSD1306 Display"
module.name = ":driver:ssd1306.i2c"
Copy link
Member Author

@rleh rleh Oct 9, 2023

Choose a reason for hiding this comment

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

Should we add an alias for the old module name?
If so, how does it work?

Copy link
Member

Choose a reason for hiding this comment

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

yes, with module.add_alias in the :driver module. See example here. Also add a DEPRECATED: 2024q4 so we can remove it and not forget it like in my own example *cough*😇.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added the following code to src/modm/driver/module.lb:

# DEPRECATED: 2024q4
module.add_alias(
    Alias(name="ssd1306",
          destination=":ssd1306.i2c",
          description="DEPRECATED: Please use :driver:ssd1306.i2c instead."))

lbuild recognizes the alias and does not complain if I use it in project.xml, but does not generate any files...

Copy link
Member

Choose a reason for hiding this comment

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

needs to be destination=":driver:ssd1306.i2c", I'll check why it doesn't complain.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, still does not work 😞

Copy link
Member

Choose a reason for hiding this comment

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

Oh ffs, I'll check it over the weekend. I need to rewrite lbuild, it's so unpythonic…

Copy link
Member

Choose a reason for hiding this comment

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

It does build the alias destination for me though.

The reason it doesn't give a warning is that the :driver:ssd1306.i2c module is a dependency of the :driver:sh1106.i2c module, and is thus already included by the time the alias is resolved. If you change the dependency back to the alias:

 $ lbuild build
[WARNING] lbuild.node: Node 'modm:driver:ssd1306' has been moved to ':driver:ssd1306.i2c'!

>> modm:driver:ssd1306  [Alias]

DEPRECATED: Please use `:driver:ssd1306.i2c` instead.

Destination: :driver:ssd1306.i2c

>> modm:driver:ssd1306.i2c  [Module]

SSD1306 Display in I2C mode

@rleh rleh force-pushed the ssd1306_spi branch 3 times, most recently from efc4ce5 to b9dd0fb Compare October 10, 2023 17:29
@rleh
Copy link
Member Author

rleh commented Oct 10, 2023

All drivers (ssd1306.i2c, ssd1306.spi and sh1106.i2c) are now tested successfully on Hardware with a HP12832-02 module for SPI and respectively a GME12864-41 module for I²C.
image

Comment on lines -42 to -48
this->commandBuffer[0] = ssd1306::AdressingCommands::HigherColumnStartAddress;
this->commandBuffer[1] = 0x02;

for (page = 0; page < Height / 8; page++)
{
this->commandBuffer[2] = 0xB0 | page;
this->transaction_success &= RF_CALL(this->writeCommands(3));
Copy link
Member Author

Choose a reason for hiding this comment

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

The command sequence {0x10, 0x02, 0xB0 | page} gets interpreted (at least on my SSD1306 GME12864 module) as three command:
1.0x10: Set Higher Column Start Address for Page Addressing Mode (10h~1Fh) to value 0
2.0x02 Set Lower Column Start Address for Page Addressing Mode (00h~0Fh) to value 2
3. 0xB0 Set Page Start Address for Page Addressing Mode (B0h~B7h) to value page

The first two commands result in the first two columns of display pixels displaying garbage and the last two columns of the frame not getting displayed, so I removed them.
SSD1106 should behave the same way like SH1106 in Page Addressing Mode, but I don't have SH1106 hardware laying arround, so I can't test it. Maybe @TomSaw could check?

Copy link
Contributor

Choose a reason for hiding this comment

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

And the hardware test shows:
These lines have a purpose. Whitout, the displays pages (columns of pixels) get ugly shifted.
I remember having read about this necessary micro-management in an adafruit or arduino library comment, not in the datasheet or elsewhere.

Copy link
Member

@chris-durand chris-durand left a comment

Choose a reason for hiding this comment

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

Nice!

examples/nucleo_g474re/sh1106_i2c/main.cpp Outdated Show resolved Hide resolved
src/modm/driver/display/sh1106_i2c.hpp Outdated Show resolved Hide resolved
src/modm/driver/display/ssd1306_i2c.hpp Outdated Show resolved Hide resolved
src/modm/driver/display/ssd1306_i2c.hpp Outdated Show resolved Hide resolved
src/modm/driver/display/ssd1306_i2c.hpp Outdated Show resolved Hide resolved
src/modm/driver/display/ssd1306_i2c_impl.hpp Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/modm/driver/display/ssd1306_i2c.lb Outdated Show resolved Hide resolved
src/modm/driver/display/ssd1306_i2c.hpp Show resolved Hide resolved
src/modm/driver/display/ssd1306.hpp Outdated Show resolved Hide resolved
@rleh
Copy link
Member Author

rleh commented Oct 11, 2023

As I understood, you could test with sh1106 @rleh ? I've got these around. Let me know if I can help with hardware tests.

@TomSaw I tested the examples/nucleo_g474re/sh1106_i2c/ example only with an (genuine) SSD1306 display module, because I don't have any SH1106 modules.
It would be very cool if you could test the example with your SH1106 display.
I assume you know how to get the example running on a dev board other than the Nucleo-G474RE, otherwise let me know if you need help.

@TomSaw
Copy link
Contributor

TomSaw commented Oct 11, 2023

As I understood, you could test with sh1106 @rleh ? I've got these around. Let me know if I can help with hardware tests.

@TomSaw I tested the examples/nucleo_g474re/sh1106_i2c/ example only with an (genuine) SSD1306 display module, because I don't have any SH1106 modules.
It would be very cool if you could test the example with your SH1106 display.
I assume you know how to get the example running on a dev board other than the Nucleo-G474RE, otherwise let me know if you need help.

ok, but gimme 1,2 days pls.

@salkinium
Copy link
Member

Is there an update for this?

@TomSaw
Copy link
Contributor

TomSaw commented Mar 5, 2024

Tested SH1106 and you actually have to keep the ssd1306::AdressingCommands::HigherColumnStartAddress` assignments in the SH1106 driver if you don't have a preference for fuzzy diagonally shifted pages of pixels.

The memory mapping of sh1106 is different (and worse) than SSD1306

@rleh

This comment was marked as off-topic.

@rleh rleh added this to the 2024q2 milestone Mar 14, 2024
@TomSaw

This comment was marked as off-topic.

@rleh

This comment was marked as off-topic.

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

Successfully merging this pull request may close these issues.

None yet

4 participants