Here is still code that updates the whole screen with random data (noise). According to the display specifications 2 MHz is max SPI clock, but tested it up to 16 MHz, there is clearly starts to have problems, 10 MHz seems to work fine but not sure if it would cause damage on long run.
with 2 MHz the update for the whole screen is 18 fps, faster if less lines are updated.
with 10 MHz ca. 83 fps :0
with 2 MHz the update for the whole screen is 18 fps, faster if less lines are updated.
with 10 MHz ca. 83 fps :0
Code:
#include <SPI.h>
#define CS 10
// write line command 0x80, reversed 0x01
// clear memory command 0x20, reversed 0x04
// static mode command 0x00
// VCOM bit 0x40 , reversed 0x02
byte Vcom;
byte Line;
uint32_t synchTime;
void setup() {
pinMode (CS, OUTPUT);
SPI.begin();
SPI.beginTransaction(SPISettings(2000000, LSBFIRST, SPI_MODE0));
clearDisplay();
}
void loop() {
Vcom = Vcom ? 0x00 : 0x02;
//clearDisplay();
drawScreen(0, 240);
Serial.print("Frame rate: ");Serial.print(1000/(millis()-synchTime)); Serial.println(" fps");
synchTime = millis();
}
void drawScreen(byte firstLine, byte lastLine) {
byte lineData[50];
digitalWrite(CS,HIGH);
SPI.transfer(0x01 | Vcom);//Command
for (int y = firstLine; y <= lastLine; y++)
{
SPI.transfer(y); //line number
for (int x = 0; x <50; x++) { lineData[x] = random(255);}//data for one line
SPI.transfer(lineData, 50);
SPI.transfer(0x00); //Trailer for line
}
SPI.transfer(0x00); //Trailer for screen
digitalWrite(CS,LOW);
}
void clearDisplay() {
digitalWrite(CS,HIGH);
SPI.transfer(0x04 | Vcom);
SPI.transfer(0x00);
digitalWrite(CS,LOW);
}
Last edited: