void frame_callback() {
//Serial.printf("FCB: %d %d\n", tft.frameCount(), tft.subFrameCount());
uint32_t frameCount = tft.frameCount();
bool start_of_frame = tft.subFrameCount() == 0;
// See if end of test signalled.
if (start_of_frame) {
if (shutdown_cont_update_count == COUNT_SHUTDOWN_FRAMES) {
uint8_t color_index = (frameCount >> 4) & 0x7;
tft.setCursor(TCENTER, TCENTER);
tft.setTextColor(our_pallet[(color_index + 3) & 7]);
if (tft.width() > 240) tft.setFont(Arial_20_Bold);
else if (tft.width() > 160 ) tft.setFont(Arial_14_Bold);
else tft.setFont(Arial_10_Bold);
tft.println("Stop Signalled");
shutdown_cont_update_count--;
arm_dcache_flush(tft_frame_buffer, FRAME_BUFFER_SIZE);
return;
} else if (shutdown_cont_update_count == 0) {
tft.setCursor(TCENTER, tft.getCursorY());
tft.println("endUpdateAsync");
tft.endUpdateAsync();
Serial.println("after endUpdateAsync");
arm_dcache_flush(tft_frame_buffer, FRAME_BUFFER_SIZE);
return;
} else if (shutdown_cont_update_count < COUNT_SHUTDOWN_FRAMES) {
shutdown_cont_update_count--;
}
}
#ifndef UPDATE_HALF_FRAME
else return;
#endif
#ifdef UPDATE_HALF_FRAME
bool draw_frame = false;
if (((frameCount & 0xf) == 0) && tft.subFrameCount()) {
draw_frame = true;
tft.setClipRect(0, 0, tft.width(), tft.height() / 2);
} else if (((frameCount & 0xf) == 1) && !tft.subFrameCount()) {
draw_frame = true;
tft.setClipRect(0, tft.height() / 2, tft.width(), tft.height() / 2);
}
if (draw_frame)
#else
if ((frameCount & 0xf) == 0)
#endif
{
// First pass ignore subframe...
uint8_t color_index = (frameCount >> 4) & 0x7;
tft.fillScreen(our_pallet[color_index]);
tft.drawRect(5, 5, tft.width() - 10, tft.height() - 10, our_pallet[(color_index + 1) & 7]);
tft.drawRect(25, 25, tft.width() - 50, tft.height() - 50, our_pallet[(color_index + 2) & 7]);
static uint8_t display_other = 0;
switch (display_other) {
case 0:
tft.fillRect(50, 50, tft.width() - 100, tft.height() - 100, our_pallet[(color_index + 1) & 7]);
break;
case 1:
tft.fillCircle(tft.width() / 2, tft.height() / 2, 100, our_pallet[(color_index + 1) & 7]);
break;
case 2:
tft.fillTriangle(50, 50, tft.width() - 50, 50, tft.width() / 2, tft.height() - 50, our_pallet[(color_index + 1) & 7]);
break;
}
if (!tft.subFrameCount()) {
display_other++;
if (display_other > 2) display_other = 0 ;
}
arm_dcache_flush(tft_frame_buffer, FRAME_BUFFER_SIZE);
tft.setClipRect();
}
}