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

Expose setting to select SPI bus for ESP32 #5

Closed
sidoh opened this issue May 28, 2019 · 5 comments
Closed

Expose setting to select SPI bus for ESP32 #5

sidoh opened this issue May 28, 2019 · 5 comments

Comments

@sidoh
Copy link
Owner

sidoh commented May 28, 2019

ESP32s have multiple SPI busses.

With GxEPD2, the user is supposed to configure the global SPI instance, which it then uses.

To change the SPI bus, one must do the following:

SPI.end();
SPI.begin(13, 12, 14, 15); // replace these with the appropriate SPI pins
@Ivanverdonck
Copy link

Hi,

Where does this code need to be added?
I have a Waveshare ESP32 driver board. I tried adding this to the setup(), but this did not work.

I use a waveshare - GDEW075Z09 7.5" b/w/r
Is it possible to use the red color?

Kind regards,
Ivan

@sidoh
Copy link
Owner Author

sidoh commented Mar 19, 2020

Hi Ivan,

If you're making the modification yourself, it should be enough to drop it somewhere in main.cpp (initDisplay is probably a good place https://github.com/sidoh/epaper_templates/blob/master/src/main.cpp#L54).

You might need to adjust the other pins as well (dc, rst, busy).

Unfortunately not currently possible to use the multi-color displays.

@nullstalgia
Copy link
Contributor

nullstalgia commented Mar 29, 2020

Notes:

SPI.end();
SPI.begin(13, 12, 14, 15); // replace these with the appropriate SPI pins

Can go both above and below the current initDisplay() code. Example from the E-Paper driver lib.

I personally do it above, but that's just me.


Also, this library requires the default hardware SPI bus pins. My tests with changing those SPI pins ends up with the display doing nothing.

There is an internal fork for using Software SPI, but the author does not recommend that.

Luckily, the ESP32 has a spare bus (as shown by @sidoh above) that works fine when using it's set of pins.

SPI1 isn't usually allowed to be used by users, as it's commonly used for SPI RAM (PSRAM), and SPI0 is the main system flash.

(If you wish, you can set up the PSRAM bus, but I would not recommend it)

As such, I put forth this suggestion for selecting the 2 free busses. This would fit best on the Hardware tab in the Settings page.

image

@nullstalgia
Copy link
Contributor

I started a little bit yesterday, but I got chumped when it came to the Web interface once again 😅

The main bit that matters is this:

...
void initDisplay() {
  #if defined(ESP32)
    if(settings.hardware.spi_bus != HSPI){
        if (settings.hardware.spi_bus == VSPI){
            SPI.end();
            SPI.begin(18, 23, 19, 5);
        }
    }
  #endif
  if (display) {
    delete display;
    display = NULL;
  }
...

And in case you're not using an editor that shows the definitions of HSPI/VSPI easily, here are screenshots from VSCode

image
image

@nullstalgia
Copy link
Contributor

@sidoh, we should be good to close this if you feel the new features are satisfactory. :)

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

No branches or pull requests

3 participants