jim lee
Well-known member
I'm new to the whole SPI thing. What really got me digging into it was the uncannyEyes project that Adafruit has on their website. Bought the parts, 128x128 OLED & Teensy 3.2 processor. Hooked it all up and after some monkeying about, got it all running. The uncannyEyes runs so fast I see no refresh at all. I thought that was really slick. So, I tried writing some test code to the display myself and its really slow!
So, of course I decided to try and steal the eye code..
Having very little luck and my lack of SPI experience is holding me back.
This is the routine I wrote for doing a screen fill of a constant color. Using the same hardware as the uncannyEyes. I basically took the eye draw function, stripped out the color calculation and adapted it to my code. The line "theOLED->fillScreen(inColor->getColor16());" is my original that works, but is slow.
This is as it sits now with trace prints & things commented out that caused it to hang. I need help/info understanding this.
First issue is //SPI.beginTransaction(settings); This caused a hang. What could cause this to hang?
Thanks!
-jim lee
So, of course I decided to try and steal the eye code..
Having very little luck and my lack of SPI experience is holding me back.
This is the routine I wrote for doing a screen fill of a constant color. Using the same hardware as the uncannyEyes. I basically took the eye draw function, stripped out the color calculation and adapted it to my code. The line "theOLED->fillScreen(inColor->getColor16());" is my original that works, but is slow.
Code:
void adafruit_1431_Obj::fillScreen(colorObj* inColor) {
Serial.println("In fill screen");
//theOLED->fillScreen(inColor->getColor16());
byte screenX;
byte screenY;
word color = inColor->getColor16();
Serial.println("Gonna make the settings..");
SPISettings settings(24000000, MSBFIRST, SPI_MODE3); // Teensy 3.1 max SPI
Serial.println("Settings made, now lets NOT set them..");
//SPI.beginTransaction(settings);
Serial.println("Just set the settings");
theOLED->writeCommand(SSD1351_CMD_SETROW); // Y range
theOLED->writeData(0);
theOLED->writeData(SCREEN_HEIGHT - 1);
theOLED->writeCommand(SSD1351_CMD_SETCOLUMN); // X range
theOLED->writeData(0);
theOLED->writeData(SCREEN_WIDTH - 1);
theOLED->writeCommand(SSD1351_CMD_WRITERAM); // Begin write
Serial.println("Just sent the block of commands");
digitalWrite(cs, LOW); // Chip select
digitalWrite(dc, HIGH); // Data mode
// Now just issue raw 16-bit values for every pixel...
Serial.println("Chip select done. Starting loops..");
for(screenY=0; screenY<SCREEN_HEIGHT; screenY++) {
for(screenX=0; screenX<SCREEN_WIDTH; screenX++) {
// SPI FIFO technique from Paul Stoffregen's ILI9341_t3 library:
Serial.println("In loop, going to check for space..");
while(KINETISK_SPI0.SR & 0xC000) Serial.println("Waiting for space.."); // Wait for space in FIFO
Serial.println("They sid there was space.");
KINETISK_SPI0.PUSHR = color | SPI_PUSHR_CTAS(1) | SPI_PUSHR_CONT;
}
}
Serial.println("Loops done, cleaning up.");
KINETISK_SPI0.SR |= SPI_SR_TCF; // Clear transfer flag
while((KINETISK_SPI0.SR & 0xF000) || // Wait for SPI FIFO to drain
!(KINETISK_SPI0.SR & SPI_SR_TCF)); // Wait for last bit out
digitalWrite(cs, HIGH); // Deselect
SPI.endTransaction();
Serial.println("All done, exiting.");
}
This is as it sits now with trace prints & things commented out that caused it to hang. I need help/info understanding this.
First issue is //SPI.beginTransaction(settings); This caused a hang. What could cause this to hang?
Thanks!
-jim lee
Last edited: