Fixed a display error
display has now a refresh timer to totally refresh the display contents (to prevent EMC issues) Fixed PCBA names git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@229 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -54,15 +54,14 @@ static void DisplayTask(void* parameters);
|
||||
inline static void Display_characterUpdate (struct DisplayCharacter* displayCharacter, char character);
|
||||
inline static bool Display_isCharacterUpdated (struct DisplayCharacter* displayCharacter);
|
||||
inline static char Display_getUpdatedCharacter (struct DisplayCharacter* displayCharacter);
|
||||
static void Display_characterUpdateAll(struct Display* self);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
ErrorStatus Display_construct(struct Display* self, struct DisplayDevice* displayDevice, int TaskPriority, uint16_t stackSize, int maxCharactersPerTransmit)
|
||||
ErrorStatus Display_construct(struct Display* self, struct DisplayDevice* displayDevice, int TaskPriority, uint16_t stackSize, int maxCharactersPerTransmit, int refreshFeedFrequency_ms, int refreshPeriod)
|
||||
{
|
||||
int rowCounter = 0;
|
||||
int colCounter = 0;
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
|
||||
@@ -70,21 +69,27 @@ ErrorStatus Display_construct(struct Display* self, struct DisplayDevice* displa
|
||||
self->TaskPriority = TaskPriority;
|
||||
self->stackSize = stackSize;
|
||||
self->maxCharactersPerTransmit = maxCharactersPerTransmit;
|
||||
self->refreshFeedCounter = 0;
|
||||
self->refreshFeedFrequency_ms = refreshFeedFrequency_ms;
|
||||
self->refreshPeriod_ms = refreshPeriod;
|
||||
|
||||
// Clear the display shadow
|
||||
for (rowCounter = 0; rowCounter < self->displayDevice->parameters.numberOfRows; rowCounter++)
|
||||
{
|
||||
for (colCounter = 0; colCounter < self->displayDevice->parameters.numberOfColumns; colCounter++)
|
||||
{
|
||||
Display_characterUpdate(&self->displayShadow[rowCounter][colCounter], 0x20);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(returnValue == SUCCESS)
|
||||
{
|
||||
// Create a semaphore to sync access to the display shadow
|
||||
vSemaphoreCreateBinary(self->displayShadowAccessSemaphore);
|
||||
xSemaphoreGive(self->displayShadowAccessSemaphore);
|
||||
|
||||
// Clear the display shadow
|
||||
size_t rowCounter;
|
||||
size_t colCounter;
|
||||
for (rowCounter = 0; rowCounter < self->displayDevice->parameters.numberOfRows; rowCounter++)
|
||||
{
|
||||
for (colCounter = 0; colCounter < self->displayDevice->parameters.numberOfColumns; colCounter++)
|
||||
{
|
||||
Display_characterUpdate(&self->displayShadow[rowCounter][colCounter], 0x20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self->runTask = true;
|
||||
@@ -186,6 +191,13 @@ ErrorStatus Display_write(struct Display* self, const char* buffer, unsigned int
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
void Display_feedRefreshCounter(struct Display* self)
|
||||
{
|
||||
self->refreshFeedCounter++;
|
||||
}
|
||||
|
||||
|
||||
inline static void Display_characterUpdate (struct DisplayCharacter* displayCharacter, char character)
|
||||
{
|
||||
displayCharacter->character = character;
|
||||
@@ -206,6 +218,25 @@ inline static char Display_getUpdatedCharacter (struct DisplayCharacter* display
|
||||
}
|
||||
|
||||
|
||||
static void Display_characterUpdateAll(struct Display* self)
|
||||
{
|
||||
size_t rowCounter;
|
||||
size_t colCounter;
|
||||
|
||||
// Get the access semaphore to the shadow - wait until the other functions are finished with updating the shadow
|
||||
xSemaphoreTake(self->displayShadowAccessSemaphore, portMAX_DELAY);
|
||||
// Clear the display shadow
|
||||
for (rowCounter = 0; rowCounter < self->displayDevice->parameters.numberOfRows; rowCounter++)
|
||||
{
|
||||
for (colCounter = 0; colCounter < self->displayDevice->parameters.numberOfColumns; colCounter++)
|
||||
{
|
||||
self->displayShadow[rowCounter][colCounter].isUpdated = true;
|
||||
}
|
||||
}
|
||||
// Give back display memory access semaphore to allow new updates
|
||||
xSemaphoreGive(self->displayShadowAccessSemaphore);
|
||||
}
|
||||
|
||||
static void DisplayTask(void* parameters)
|
||||
{
|
||||
struct Display* self = (struct Display*)parameters;
|
||||
@@ -220,7 +251,7 @@ static void DisplayTask(void* parameters)
|
||||
size_t columnStart;
|
||||
while (self->runTask)
|
||||
{
|
||||
// Get the access semaphore to the shadow - wait until the write function is finished with updating the shadow
|
||||
// Get the access semaphore to the shadow - wait until the other functions are finished with updating the shadow
|
||||
xSemaphoreTake(self->displayShadowAccessSemaphore, portMAX_DELAY);
|
||||
leaveLoops = false;
|
||||
bufferIndex = 0;
|
||||
@@ -299,6 +330,14 @@ static void DisplayTask(void* parameters)
|
||||
rowCounter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for display refresh timings
|
||||
if (self->refreshFeedCounter * self->refreshFeedFrequency_ms > self->refreshPeriod_ms)
|
||||
{
|
||||
self->refreshFeedCounter = 0;
|
||||
Display_characterUpdateAll(self);
|
||||
}
|
||||
|
||||
vTaskDelay(10);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user