1336 SPI Colour Display VERY slow

Hi Guys,

I have created a program on a Mega 2560 to coordinate 3 inputs, a colour 1336 OLED display (96x64) and 6 channels of LED strips. The buttons control the program that's running and the LED screen provides info on the current and next programs.

I wont post all of the code as it's huge, but the setup bits are below. I only update the parts of the display I am changing to keep the timing down, but the refresh is SOOO slow! (up to 2 seconds depending on what's changing). As the processor is supposed to be running the dynamic patterns to the LEDs, it is interrupting that process.

Grateful for any thoughts. I have tried hardware and software SPI, but doesnt appear to be any difference.

thanks!

//Display Includes
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1331.h>

//LED Includes
#include <Adafruit_NeoPixel.h>

//Display Definitions
// You can use any (4 or) 5 pins 
#define sclk 52 //13
#define mosi 51 //11
#define cs   53 //10
#define rst  50 //9
#define dc   48 //8
//Adafruit_SSD1331 display = Adafruit_SSD1331(cs, dc, rst);
Adafruit_SSD1331 display = Adafruit_SSD1331(cs, dc, mosi, sclk, rst);  

//#define LOGO16_GLCD_HEIGHT 16 
//#define LOGO16_GLCD_WIDTH  16 

#define ChangeButtonPin 19
#define FlipFlopButtonPin 18
#define SmokeButton 17

I see that you have chosen the Software constructor.
The hardware SPI constructor will be quicker.

Note that you can use "any" pins for GPIO but you should avoid MISO or the Serial pins.
Change your wiring of the RST pin to a different GPIO pin.

David.

Hi Delta_G, thanks for your reply. Slightly confused by your post - I cant see anything that has changed!

Delta_G:
Here's the setup part for the code that you need. This will run a lot faster. I left out the same parts you left out since you said they aren't important. Though I am a bit confused because that's where all the timing issues pop up. But if you say you can get it from just this part then I guess that's all you need.

//Display Includes

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1331.h>

//LED Includes
#include <Adafruit_NeoPixel.h>

//Display Definitions
// You can use any (4 or) 5 pins
#define sclk 52 //13
#define mosi 51 //11
#define cs  53 //10
#define rst  50 //9
#define dc  48 //8
//Adafruit_SSD1331 display = Adafruit_SSD1331(cs, dc, rst);
Adafruit_SSD1331 display = Adafruit_SSD1331(cs, dc, mosi, sclk, rst);

//#define LOGO16_GLCD_HEIGHT 16
//#define LOGO16_GLCD_WIDTH  16

#define ChangeButtonPin 19
#define FlipFlopButtonPin 18
#define SmokeButton 17

Hi David,

Thanks for taking the time to reply. So I think the hardware solution is supposed to be faster right? I had just commented that out to try the software version. Will the pins I had listed above work with the hardware SPI option? My understanding was that to activate the hardware version, simply use this:

Adafruit_SSD1331 display = Adafruit_SSD1331(cs, dc, rst);

thanks.

david_prentice:
I see that you have chosen the Software constructor.
The hardware SPI constructor will be quicker.

Note that you can use "any" pins for GPIO but you should avoid MISO or the Serial pins.
Change your wiring of the RST pin to a different GPIO pin.

David.

Thanks Delta_G. I had just assumed it was a setup issue... here is an example of just inverting the colour of a small part of the screen. Takes just under a second for a small rectangle.

  if ((SmokeButtonState == LOW) || (SmokePermOn == 1)){
    display.fillRect(76,39,18,24,SmokeDescCol[ACT]);
    display.setTextSize(3);
    display.setTextColor(BLACK);
    display.setCursor(77,40);
    display.println("S");
  } else {
    display.fillRect(76,39,18,24,BLACK);
    display.setTextSize(3);
    display.setTextColor(SmokeDescCol[ACT]);
    display.setCursor(77,40);
    display.println("S");
  }

I suggest that you try this:

//Display Definitions
// You can use any (4 or) 5 pins .kbv except MISO
#define sclk 52 //SCK  13
#define mosi 51 //MOSI 11
#define cs   53 //SS   10
#define rst  49 //.kbv use a different pin 
#define dc   48 //8
Adafruit_SSD1331 display = Adafruit_SSD1331(cs, dc, rst);
//Adafruit_SSD1331 display = Adafruit_SSD1331(cs, dc, mosi, sclk, rst);

David.

Sorry Delta_G, hadnt picked up on the sarcasm on the first post, but definitely got the hint on the second.

Sadly I can't post all of the code publicly, so was hoping to gain some insight from those with experience, purely based on the initialisation and the way I am writing to the screen. I'm relatively new to this so was seeking assistance from those experts on this forum that kindly give their time to helping those like me (thank you!).

I totally get that you dont want to engage if it's not a full program though, so thanks for your inputs this far.

I think that the OP was worried about message size when pasting to a CODE window.
You can always attach a file. Or better still, attach a ZIP of a complete project.

I don't think anyone minds answering a technical question.
It is your job to create the smallest (non-commercially sensitive) code that exhibits your problem.
Then a reader can replicate it for herself.

If you make the effort to ask your question well, you get a good response from your readers.
And often a solution in the first reply.

David.

Delta_G - there is no commercial / profit / derived benefit from it, however I know there is someone trying to do something similar with not such good intentions. Hence my reasoning behind not posting the whole code. You have jumped to a conclusion that is not the case.

Thanks david_prentice - changed the pin out for the reset, and made it back to hardware SPI. sadly no change. Out of interest, what sort of frame rate would you expect.

I do not have a SSD1331 or a SSD1336. I can guess about the performance.

I suggest that you try the library examples with your wiring. And compare the two constructors.

Regarding your application performance.
This is normally down to your flowchart and coding of the loop().

It will take 20 minutes of your life to cut your project down to minimal "buildable" that exhibits the behaviour.

A reader will either advise from inspection of your flow structure or build the project herself.

Either way, you get sensible advice. Readers have not wasted time on a protracted thread.

The longer that it takes to draw blood from a stone, the less likely that you will get any help. Delta_G has already abandoned you.

David.