adafruit / Adafruit_SSD1306

Arduino library for SSD1306 monochrome 128x64 and 128x32 OLEDs
http://www.adafruit.com/category/63_98
Other
1.75k stars 964 forks source link

Allow a sketch to sub-class the SSD1306 object and change SPI settings #168

Closed KurtE closed 4 years ago

KurtE commented 4 years ago

At least some of the SSD1309 displays can work with this library if SPI_MODE0 is changed to SPI_MODE3.

Instead of allowing the main constructor to do this, we pulled the spiSettings member out to be protected instead of private. This allows us to create a smple subclass of this code base to run on these displays. With this I have a version of the ssd1306_128x64_spi sketch that has the subclass code:

class Adafruit_SSD1309_SPI : public Adafruit_SSD1306 {
 public:
  Adafruit_SSD1309_SPI(uint8_t w, uint8_t h, SPIClass *spi,
    int8_t dc_pin, int8_t rst_pin, int8_t cs_pin, uint32_t bitrate=8000000UL) :
    Adafruit_SSD1306(w, h, spi, dc_pin, rst_pin, cs_pin, bitrate) {
#ifdef SPI_HAS_TRANSACTION
  spiSettings = SPISettings(bitrate, MSBFIRST, SPI_MODE3);
#endif

    }
};

and then I used the hardware version of the constructor:

#define OLED_DC     6
#define OLED_CS     7
#define OLED_RESET  8
Adafruit_SSD1309_SPI display(SCREEN_WIDTH, SCREEN_HEIGHT,
  &SPI, OLED_DC, OLED_RESET, OLED_CS);

And it now runs on this display

This is to address the issues mentioned in #167

ladyada commented 4 years ago

nice work - thanks :)

KurtE commented 4 years ago

You are welcome,

Just trying to help out some users…

Current thing I am hacking on is sort of trying to understand why the GUI Slice code is not working well with

RA8875 and T4… Currently it uses the Adafruit_RA8875 driver… I am currently trying to build a version that uses

Our modified version of SumoToys library which is working a lot better at least for me on the T4…

I can currently run it on T4 with your library, but often times I have to reboot or repower the setup to get it to work at all.

My current WIP version of the GUISlice is up at: https://github.com/KurtE/GUIslice/tree/t4_sumo_ra8875

There are big pieces not working like text, but…

At some point would like to diagnose why your driver is currently more temperamental.

More details up on the thread: https://forum.pjrc.com/threads/59563-Teensy-4-0-RA8875

Not sure if I or someone else should open up new Issue on RA8875…

From: ladyada notifications@github.com Sent: Monday, February 17, 2020 8:50 AM To: adafruit/Adafruit_SSD1306 Adafruit_SSD1306@noreply.github.com Cc: KurtE kurte@rockisland.com; Author author@noreply.github.com Subject: Re: [adafruit/Adafruit_SSD1306] Allow a sketch to sub-class the SSD1306 object and change SPI settings (#168)

nice work - thanks :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/adafruit/Adafruit_SSD1306/pull/168?email_source=notifications&email_token=AAL4MQBI7BJKQT7MQAGKKD3RDK52JA5CNFSM4KWHUJL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEL7CHIQ#issuecomment-587080610 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AAL4MQBONPLBN7DXTXWIXLTRDK52JANCNFSM4KWHUJLQ .