From 5cb631057c5f750b734b53c202454732a89e1bd4 Mon Sep 17 00:00:00 2001 From: Jorj Bauer Date: Sun, 30 Jan 2022 15:30:11 -0500 Subject: [PATCH] looking for a bug... --- teensy/ILI9341_wrap.h | 2 +- teensy/RA8875_t4.cpp | 4 +++- teensy/RA8875_t4.h | 6 +++--- teensy/teensy-display.cpp | 30 +++++++++++++++--------------- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/teensy/ILI9341_wrap.h b/teensy/ILI9341_wrap.h index 201034a..8fc1baf 100644 --- a/teensy/ILI9341_wrap.h +++ b/teensy/ILI9341_wrap.h @@ -14,7 +14,7 @@ class ILI9341_Wrap : public BaseDisplay { public: - ILI9341_Wrap(uint8_t cs_pin, uint8_t rst_pin, uint8_t mosi_pin, uint8_t sck_pin, uint8_t miso_pin, uint8_t dc_pin); + ILI9341_Wrap(uint8_t cs_pin, uint8_t rst_pin, uint8_t mosi_pin, uint8_t sck_pin, uint8_t miso_pin, uint8_t dc_pin=255); ~ILI9341_Wrap(); virtual void begin(uint32_t spi_clock=30000000u, uint32_t spi_clock_read=2000000); diff --git a/teensy/RA8875_t4.cpp b/teensy/RA8875_t4.cpp index 4196d4a..e1a8e1b 100644 --- a/teensy/RA8875_t4.cpp +++ b/teensy/RA8875_t4.cpp @@ -119,8 +119,10 @@ RA8875_t4::~RA8875_t4() void RA8875_t4::begin(uint32_t spi_clock, uint32_t spi_clock_read) { + Serial.print(" starting RA8875 @ "); + Serial.println(spi_clock); _spi_clock = spi_clock; - _spi_clock_read = spi_clock_read; + _spi_clock_read = spi_clock_read; // FIXME not used at the moment, not sure we need it yet _clock = 4000000UL; // start at low speed // figure out which SPI bus we're using diff --git a/teensy/RA8875_t4.h b/teensy/RA8875_t4.h index bc0e20a..73d0046 100644 --- a/teensy/RA8875_t4.h +++ b/teensy/RA8875_t4.h @@ -23,7 +23,7 @@ enum { class RA8875_t4 : public BaseDisplay { public: - RA8875_t4(uint8_t cs_pin, uint8_t rst_pin, uint8_t mosi_pin, uint8_t sck_pin, uint8_t miso_pin, uint8_t dc_pin); // dc pin is unused for this display but it's needed for the ILI and base class. + RA8875_t4(uint8_t cs_pin, uint8_t rst_pin, uint8_t mosi_pin, uint8_t sck_pin, uint8_t miso_pin, uint8_t dc_pin=255); // dc pin is unused for this display but it's needed for the ILI and base class. ~RA8875_t4(); @@ -77,8 +77,8 @@ private: uint32_t _clock; // current clock, used in starting transactions (b/c we have to slow down sometimes) // DMA stuff - DMASetting _dmasettings[12]; - DMAChannel _dmatx; + DMASetting _dmasettings[12]; + DMAChannel _dmatx; uint32_t _spi_fcr_save; uint8_t *_pfbtft; volatile uint8_t _dma_state; diff --git a/teensy/teensy-display.cpp b/teensy/teensy-display.cpp index 7d1d61b..4603388 100644 --- a/teensy/teensy-display.cpp +++ b/teensy/teensy-display.cpp @@ -30,11 +30,6 @@ DMAMEM uint8_t dmaBuffer[RA8875_HEIGHT * RA8875_WIDTH] __attribute__((aligned(32 uint16_t *dmaBuffer16 = NULL; // At runtime, this points to dmaBuffer. #include -// 30MHz: solid performance, 9 FPS -// 57.5MHz: solid performance, 14/15 FPS -// 60MHz: unexpected palatte shifts & (may be audio overruns, needs checking since bumping up buffer sizes) 17 FPS -// And I can't get the SPI bus working at 80MHz or higher. Not sure why yet... -#define _clock 57500000u #define PIN_RST 8 #define PIN_DC 9 @@ -90,8 +85,10 @@ TeensyDisplay::TeensyDisplay() pinMode(11, INPUT); digitalWrite(11, HIGH); // turn on pull-up - if (digitalRead(11)) { + // FIXME: reversed for debugging + if (!digitalRead(11)) { // Default: use older, small ILI display if pin 11 is not connected to ground + Serial.println(" using ILI9341 display"); tft = new ILI9341_Wrap(PIN_CS, PIN_RST, PIN_MOSI, PIN_SCK, PIN_MISO, PIN_DC); use8875 = false; @@ -102,9 +99,12 @@ TeensyDisplay::TeensyDisplay() getImageInfoAndData(IMG_9341_D2OPEN, &driveWidth, &driveHeight, &d2OpenImage); getImageInfoAndData(IMG_9341_D2CLOSED, &driveWidth, &driveHeight, &d2ClosedImage); getImageInfoAndData(IMG_9341_APPLEBATTERY, &appleImageWidth, &appleImageHeight, &appleImage); + + tft->begin(50000000u); } else { // If someone grounded pin 11, then use the new RA8875 display - tft = new RA8875_t4(PIN_CS, PIN_RST, PIN_MOSI, PIN_SCK, PIN_MISO, 255); + Serial.println(" using RA8875 display"); + tft = new RA8875_t4(PIN_CS, PIN_RST, PIN_MOSI, PIN_SCK, PIN_MISO); use8875 = true; // Load the 8875 images @@ -114,9 +114,13 @@ TeensyDisplay::TeensyDisplay() getImageInfoAndData(IMG_8875_D2OPEN, &driveWidth, &driveHeight, &d2OpenImage); getImageInfoAndData(IMG_8875_D2CLOSED, &driveWidth, &driveHeight, &d2ClosedImage); getImageInfoAndData(IMG_8875_APPLEBATTERY, &appleImageWidth, &appleImageHeight, &appleImage); + // 30MHz: solid performance, 9 FPS + // 57.5MHz: solid performance, 14/15 FPS + // 60MHz: unexpected palatte shifts & (may be audio overruns, needs checking since bumping up buffer sizes) 17 FPS + // And I can't get the SPI bus working at 80MHz or higher. Not sure why yet... + tft->begin(57500000); } - - tft->begin(_clock); + tft->setFrameBuffer((uint8_t *)dmaBuffer); tft->fillWindow(); } @@ -383,12 +387,8 @@ void TeensyDisplay::cacheDoubleWidePixel(uint16_t x, uint16_t y, uint16_t color1 { if (use8875) { for (int yoff=0; yoff<2; yoff++) { - if (use8875) { - for (int xoff=0; xoff<2; xoff++) { - dmaBuffer[((y*2)+SCREENINSET_8875_Y+yoff)*RA8875_WIDTH+(x*2)+SCREENINSET_8875_X+xoff] = _565To332(color16); - } - } else { - dmaBuffer[((y*2)+SCREENINSET_8875_Y+yoff)*RA8875_WIDTH+x+SCREENINSET_8875_X] = _565To332(color16); + for (int xoff=0; xoff<2; xoff++) { + dmaBuffer[((y*2)+SCREENINSET_8875_Y+yoff)*RA8875_WIDTH+(x*2)+SCREENINSET_8875_X+xoff] = _565To332(color16); } } } else {