Thanks @vindar,
Actually if you look at both analyzers in the picture, the top is from your 99... sketch and it also has DC..
But: the main issue was I was shooting myself in the foot. As I mentioned in the OV7670 thread, the test board with the camera has all of the pins wired for the display and I did not set the CS pin for the touch screen high, so it was screwing around with the MISO pin... I found my code was working on test sketch on the breadboard that I setup with your wiring and code. Also worked when I moved DC to a none CS pin, and then I wired up another breadboard with the SPI pins I was using on OV... board and it worked... Then the Oops throught came to mind about the CS pins... Should have put on PD resistors on all of the CS pins...
Yesterday in a fork of the ILI9341_t3n library I added simple:
Code:
void ILI9341_t3n::setFrameRateControl(uint8_t mode) {
// Do simple version
beginSPITransaction(_SPI_CLOCK);
writecommand_cont(ILI9341_FRMCTR1);
writedata8_cont((mode >> 4) & 0x3); // Output DIVA setting (0-3)
writedata8_cont(0x10 + (mode & 0xf)); // Output RTNA
endSPITransaction();
}
The OV7670 CSI code sketch I added similar functions like you have in your library to measure the frame rate:
Code:
void sampleRefreshRate()
{
#ifdef USE_ILI9488
Serial.println("sampleRefreshRate: only supported in ILI9341_t3n");
#else
Serial.printf("sampleRefreshRate start");
static const uint32_t NB_SAMPLE_FRAMES = 10;
static const uint32_t MAX_SAMPLE_LOOP_COUNT = 10000;
elapsedMicros em;
uint32_t sum = 0;
uint32_t loop_count = 0;
uint32_t count_frame_samples = 0;
for (count_frame_samples = 0; count_frame_samples < NB_SAMPLE_FRAMES; count_frame_samples++)
{
delayMicroseconds(5000); // must be less than 200 FPS so wait at least 5ms
loop_count=0;
while ((tft.readScanLine() != 0) && (++loop_count < MAX_SAMPLE_LOOP_COUNT)); // wait to reach scanline 0
if (loop_count >= MAX_SAMPLE_LOOP_COUNT) break;
loop_count=0;
while ((tft.readScanLine() != 1) && (++loop_count < MAX_SAMPLE_LOOP_COUNT)); // wait to reach scanline 1
if (loop_count >= MAX_SAMPLE_LOOP_COUNT) break;
em = 0; // start counter at begining of scanline 1
delayMicroseconds(5000); // must be less than 200 FPS so wait at least 5ms
loop_count=0;
while ((tft.readScanLine() != 0) && (++loop_count < MAX_SAMPLE_LOOP_COUNT)); // wait to reach scanline 0
if (loop_count >= MAX_SAMPLE_LOOP_COUNT) break;
loop_count=0;
while ((tft.readScanLine() != 1) && (++loop_count < MAX_SAMPLE_LOOP_COUNT)); // wait to reach scanline 1
if (loop_count >= MAX_SAMPLE_LOOP_COUNT) break;
sum += em; // stop counter and add to current sum.
}
if (loop_count >= MAX_SAMPLE_LOOP_COUNT) {
Serial.printf("sampleRefreshRate: loop_index:%u\n", count_frame_samples );
} else {
uint32_t _period = (uint32_t)round(((double)sum) / NB_SAMPLE_FRAMES);
Serial.printf("sum:%lu count:%lu period:%lu frames per second:%u\n", sum, NB_SAMPLE_FRAMES, _period,
(uint32_t)(1000000l / _period));
}
#endif
}
I did add timeouts and the like as if something goes wrong like CS pins screw up, won't have the code completely hang.
Then added simple F <number> command in the Serial input check code, that called off to:
Code:
void set_frame_rate_control() {
#ifdef USE_ILI9488
Serial.println("frame rate control: only supported in ILI9341_t3n");
#else
uint8_t diva_rtna = Serial.parseInt();
Serial.printf("Setting Frame Rate control to %x\n", diva_rtna);
tft.setFrameRateControl(diva_rtna);
// get frame rate info.
sampleRefreshRate();
#endif
}
The thing I notice is the image on the screen changes when I change the Frame Rate register.. Like less detail more grain? ... Back to playing