Files
hsb/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/DisplayContent.c
mmi bb08cae83a Major updates:
- added DAConverter(s)
- added ADConverter(s)
- Fixed some display issues
- Made repair process and signalProfileGenerator calculate with voltages (signed) instead of DAC/ADC values
- Fixed several bugs in task handlings
- Put display data mirror into dedicated file displaycontent

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@261 05563f52-14a8-4384-a975-3d1654cca0fa
2017-10-24 13:56:55 +00:00

193 lines
5.3 KiB
C

// -----------------------------------------------------------------------------
/// @file DisplayContent.c
/// @brief Description
// -----------------------------------------------------------------------------
// Micro-Key bv
// Industrieweg 28, 9804 TG Noordhorn
// Postbus 92, 9800 AB Zuidhorn
// The Netherlands
// Tel: +31 594 503020
// Fax: +31 594 505825
// Email: support@microkey.nl
// Web: www.microkey.nl
// -----------------------------------------------------------------------------
/// $Revision$
/// $Author$
/// $Date$
// (c) 2017 Micro-Key bv
// -----------------------------------------------------------------------------
/// @file DisplayContent.c
/// @ingroup {group_name}
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
#include "DisplayContent.h"
#include "Logger.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Type definitions
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// File-scope variables
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Function definitions
// -----------------------------------------------------------------------------
ErrorStatus DisplayContent_construct(struct DisplayContent* self, size_t numberOfRows, size_t numberOfColumns)
{
ErrorStatus returnValue = SUCCESS;
if (!self->initialized)
{
vSemaphoreCreateBinary(self->contentAccess);
self->numberOfRows = numberOfRows;
self->numberOfColumns = numberOfColumns;
self->initialized = true;
}
else
{
returnValue = ERROR;
}
return returnValue;
}
void DisplayContent_destruct(struct DisplayContent* self)
{
vSemaphoreDelete(self->contentAccess);
self->initialized = false;
}
void DisplayContent_updateCharacter(struct DisplayContent* self, unsigned int row, unsigned int column, char character)
{
if (self->initialized)
{
if ((row < self->numberOfRows) && (column < self->numberOfColumns))
{
if (self->DisplayContent[row][column].character != character)
{
xSemaphoreTake(self->contentAccess, portMAX_DELAY);
self->DisplayContent[row][column].character = character;
self->DisplayContent[row][column].isUpdated = true;
xSemaphoreGive(self->contentAccess);
}
}
}
}
bool DisplayContent_isCharacterUpdated(struct DisplayContent* self, unsigned int row, unsigned int column)
{
bool returnValue = false;
if (self->initialized)
{
if ((row < self->numberOfRows) && (column < self->numberOfColumns))
{
returnValue = self->DisplayContent[row][column].isUpdated;
}
else
{
returnValue = false;
}
}
else
{
returnValue = false;
}
return returnValue;
}
char DisplayContent_getCharacter(struct DisplayContent* self, unsigned int row, unsigned int column)
{
char returnValue = 0;
if (self->initialized)
{
if ((row < self->numberOfRows) && (column < self->numberOfColumns))
{
xSemaphoreTake(self->contentAccess, portMAX_DELAY);
returnValue = self->DisplayContent[row][column].character;
self->DisplayContent[row][column].isUpdated = false;
xSemaphoreGive(self->contentAccess);
}
else
{
returnValue = 0;
}
}
else
{
returnValue = 0;
}
return returnValue;
}
void DisplayContent_refresh(struct DisplayContent* self)
{
if (self->initialized)
{
int rowCounter;
int columnCounter;
xSemaphoreTake(self->contentAccess, portMAX_DELAY);
for (rowCounter = 0; rowCounter < self->numberOfRows; rowCounter++)
{
for (columnCounter = 0; columnCounter < self->numberOfColumns; columnCounter++)
{
self->DisplayContent[rowCounter][columnCounter].isUpdated = true;
}
}
xSemaphoreGive(self->contentAccess);
}
}
void DisplayContent_clear(struct DisplayContent* self)
{
if (self->initialized)
{
int rowCounter;
int columnCounter;
xSemaphoreTake(self->contentAccess, portMAX_DELAY);
for (rowCounter = 0; rowCounter < self->numberOfRows; rowCounter++)
{
for (columnCounter = 0; columnCounter < self->numberOfColumns; columnCounter++)
{
self->DisplayContent[rowCounter][columnCounter].character = ' ';
self->DisplayContent[rowCounter][columnCounter].isUpdated = true;
}
}
xSemaphoreGive(self->contentAccess);
}
}