Fixed language problems. Menu is totally independent from constant strings now, all messages are taken from dedicated include file "MenuText.h"
Makefile is adapted Added "Dispay_writeCentered" function, which safes a lot of code git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@281 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -232,6 +232,69 @@ ErrorStatus Display_write(struct Display* self, const char* buffer, size_t row,
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus Display_writeCentered(struct Display* self, const char* buffer, unsigned int row)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (self->initialized)
|
||||
{
|
||||
int length = 0;
|
||||
int column;
|
||||
// Prior to any action on the display memory, perform necessary checkings
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
// Check that the row coordinate does not exceed the display boundary
|
||||
if (row - 1 >= self->displayDevice->parameters.numberOfRows)
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
length = strlen(buffer);
|
||||
// Check that the length request does not exceed the display boundary
|
||||
// This is checked in combination with the column coordinate
|
||||
// numberOfColumns - column >= length
|
||||
// must be valid in order to put the requested message on display
|
||||
if (length > self->displayDevice->parameters.numberOfColumns )
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
// Calculate the column to start writing for a centered string
|
||||
// simply put, the length of the row minus the length of the string divided by two
|
||||
column = (self->displayDevice->parameters.numberOfColumns - length) / 2;
|
||||
// In case of an uneven string length, add one column
|
||||
column += ((self->displayDevice->parameters.numberOfColumns - length) % 2);
|
||||
// Add one column because the driver should start at column 1 (human readable)
|
||||
column += 1;
|
||||
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
int loopCounter;
|
||||
for (loopCounter = 0; loopCounter < length; loopCounter++)
|
||||
{
|
||||
DisplayContent_updateCharacter(&self->displayContent, (row - 1), (column - 1) + loopCounter, buffer[loopCounter]);
|
||||
}
|
||||
|
||||
xSemaphoreGive(self->displayWriteRequest);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
void Display_feedRefreshCounter(struct Display* self)
|
||||
{
|
||||
if (self->initialized)
|
||||
|
||||
Reference in New Issue
Block a user