0

Speed Memory display
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Speed Memory display

by blnkjns on Tue May 17, 2022 12:51 am

I am playing a bit with the Sharp Memory Display, the "Playdate" screen on a Metro M4.
I've a simple piece of Arduino code that writes the whole screen black, then white, over and over.
On the standard setting it achieves 10 FPS, on "Here be dragons", with SPI at 1/2 processor speed and 200MHz overclock I can push it to 16.7 fps.
Should it be possible to reach 30 or even 60fps?
Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_GFX.h>
#include <Adafruit_SharpMem.h>
#define WIDTH  400
#define HEIGHT 240
#define CS     10
Adafruit_SharpMem display(SCK,MOSI,CS,WIDTH,HEIGHT);
int frameCount=0;
float fps;
unsigned long startTime;

void setup(void)
{
  Serial.begin(9600);
  display.begin();
  display.clearDisplay();
  startTime=millis();
}

void loop(void){
  frameCount++;
  Flicker(frameCount);
  fps=float(scroll)*1000/float(millis()-startTime);
  Serial.println(fps,1);
}

void Flicker(int offsetx){
  for(unsigned x=0; x<WIDTH; ++x){
    for(unsigned y=0; y<HEIGHT; ++y){
      display.drawPixel(x,y,offsetx%2);
    }
  }
  display.refresh();
}

Or is the drawPixel command slowing things down to great extends? Can that be replaced with a simple bitwrite somewhere?

blnkjns
 
Posts: 791
Joined: Fri Oct 02, 2020 3:33 am

Re: Speed Memory display

by blnkjns on Tue May 17, 2022 6:01 am

Just found out that the drawPixel function has some bloat to deal with colours, which is pretty useless on a B&W device.
So this speeds things up quite a bit:
Code: Select all | TOGGLE FULL SIZE
      bitWrite(display.sharpmem_buffer[(y*WIDTH+x)/8],x%8,offsetx%2);
      //display.drawPixel(x,y,offsetx%2);

I replaced drawPixel by a bitWrite. This gets me to 29fps. It also required to set the sharpmem_buffer to public in the library file Adafruit_SharpMem.h
Or is there a display driver that is true b&w like u2g2? The Adafruit GFX compatible ones usually support 16 bit colour.

blnkjns
 
Posts: 791
Joined: Fri Oct 02, 2020 3:33 am

Please be positive and constructive with your questions and comments.