I have run across a non-deterministic problem that may be due to an interaction between the display hardware access and program writes to RAM.
I'm using the LTDC lib associated with this branch of the core: https://github.com/fpistm/Arduino_Core_ ... TEST_1.9.0
UPDATED PROBLEM SUMMARY: in certain regions of the screen, the points commanded by drawPixel() do not appear in the same order with which they are commanded, sometimes with delays of seconds.
A simple program that demos the problem is posted below. It is intended to represent the path of a ball bouncing around the screen. Adding a delay, blocking or nonblocking, causes the draw routine to skip pixels. Pixels are skipped non-deterministically, and bizarrely, some are filled in after an arbitrary pause, as if memory writes are somehow queued and postponed. By non-deterministic, I mean that restarting the program results in a completely different pattern of skipped pixels.
Unfortunately the forum software does not allow me to post even a small, cropped (139 Kb) photo of the corrupted display ("file too large").
Suggestions appreciated!
Code: Select all
// illustrates nondeterministic problem with the graphics library.
// Program restarts show different skipped pixels, if delay() is included in the code.
#include "LTDC_F746_Discovery.h"
// display has 480w X 272h pixels
#define H_RES 480
#define V_RES 272
LTDC_F746_Discovery tft;
int ballDirectionX = 1;
int ballDirectionY = 1;
int ballX = 10, ballY = 10, oldBallX = 10, oldBallY = 10;
// allocate screen buffer
uint16_t screen_buf[LTDC_F746_ROKOTECH.width * LTDC_F746_ROKOTECH.height];
void setup() {
tft.begin(screen_buf);
tft.fillScreen( LTDC_BLACK );
}
void loop() {
moveBall();
//delay(1); //*********************USE OF DELAY() CAUSES SKIPPED PIXELS
}
// this function determines the ball's position on screen
void moveBall() {
// if the ball goes offscreen, reverse the direction:
if (ballX > H_RES - 5 || ballX < 5) {
ballDirectionX = -ballDirectionX;
}
if (ballY > V_RES - 5 || ballY < 5) {
ballDirectionY = -ballDirectionY;
}
// update the ball's position
ballX += ballDirectionX;
ballY += ballDirectionY;
tft.drawPixel(ballX, ballY, LTDC_WHITE);
}