Fixed some minor issues/bugs git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@284 05563f52-14a8-4384-a975-3d1654cca0fa
317 lines
8.5 KiB
C
317 lines
8.5 KiB
C
// -----------------------------------------------------------------------------
|
|
/// @file DisplayDevice.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 DisplayDevice.c
|
|
/// @ingroup {group_name}
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Include files
|
|
// -----------------------------------------------------------------------------
|
|
|
|
#include "DisplayDevice.h"
|
|
|
|
#include "Logger.h"
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Constant and macro definitions
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Type definitions
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// File-scope variables
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Function declarations
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Function definitions
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
ErrorStatus DisplayDevice_construct (struct DisplayDevice* self, struct DisplayDeviceParameters* parameters,
|
|
DisplayResetFunction reset,
|
|
DisplaySetStateFunction setState,
|
|
DisplayBackspaceFunction backspace,
|
|
DisplayCursorPositionFunction setCursorToPosition,
|
|
DisplayWriteCharacterFunction writeCharacter,
|
|
DisplayWriteFunction write,
|
|
DisplayClearFunction clear,
|
|
DisplayClearLineFunction clearLine,
|
|
DisplaySetBrightnessFunction setBrightness,
|
|
DisplaySetContrastFunction setContrast,
|
|
DisplayInvertFunction invert,
|
|
DisplaySetBlinkingCursor setBlinkingCursor)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
|
|
if (!self->initialized)
|
|
{
|
|
self->_reset = reset;
|
|
self->_setState = setState;
|
|
self->_backspace = backspace;
|
|
self->_setCursorToPosition = setCursorToPosition;
|
|
self->_writeCharacter = writeCharacter;
|
|
self->_write = write;
|
|
self->_clear = clear;
|
|
self->_clearLine = clearLine,
|
|
self->_setBrightness = setBrightness;
|
|
self->_setContrast = setContrast;
|
|
self->_invert = invert;
|
|
self->_setBlinkingCursor = setBlinkingCursor;
|
|
|
|
self->initialized = true;
|
|
|
|
self->parameters = *parameters;
|
|
}
|
|
else
|
|
{
|
|
returnValue = ERROR;
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
ErrorStatus DisplayDevice_reset(const struct DisplayDevice* self)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
if (self->initialized)
|
|
{
|
|
if (self->_reset != NULL)
|
|
{
|
|
returnValue = self->_reset(self);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
returnValue = ERROR;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
ErrorStatus DisplayDevice_setState(const struct DisplayDevice* self, DisplayDevice_functionalState state)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
if (self->initialized)
|
|
{
|
|
if (self->_setState != NULL)
|
|
{
|
|
returnValue = self->_setState(self, state);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
returnValue = ERROR;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
ErrorStatus DisplayDevice_backspace(const struct DisplayDevice* self)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
if (self->initialized)
|
|
{
|
|
if (self->_backspace != NULL)
|
|
{
|
|
returnValue = self->_backspace(self);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
returnValue = ERROR;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
ErrorStatus DisplayDevice_setCursorToPosition(const struct DisplayDevice* self, unsigned int row, unsigned int column)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
if (self->initialized)
|
|
{
|
|
if (self->_setCursorToPosition != NULL)
|
|
{
|
|
returnValue = self->_setCursorToPosition(self, row, column);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
returnValue = ERROR;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
ErrorStatus DisplayDevice_writeCharacter(const struct DisplayDevice* self, const char* buffer, unsigned int row, unsigned int column)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
if (self->initialized)
|
|
{
|
|
if (self->_writeCharacter != NULL)
|
|
{
|
|
returnValue = self->_writeCharacter(self, buffer, row, column);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
returnValue = ERROR;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
ErrorStatus DisplayDevice_write(const struct DisplayDevice* self, const char* buffer, unsigned int length, unsigned int row, unsigned int column)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
if (self->initialized)
|
|
{
|
|
if (self->_write != NULL)
|
|
{
|
|
returnValue = self->_write(self, buffer, length, row, column);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
returnValue = ERROR;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
ErrorStatus DisplayDevice_clear(const struct DisplayDevice* self)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
if (self->initialized)
|
|
{
|
|
if (self->_clear != NULL)
|
|
{
|
|
returnValue = self->_clear(self);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
returnValue = ERROR;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
ErrorStatus DisplayDevice_clearLine(const struct DisplayDevice* self, unsigned int row)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
if (self->initialized)
|
|
{
|
|
if (self->_clearLine != NULL)
|
|
{
|
|
returnValue = self->_clearLine(self, row);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
returnValue = ERROR;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
ErrorStatus DisplayDevice_setBrightness(const struct DisplayDevice* self, unsigned int brightness)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
if (self->initialized)
|
|
{
|
|
if (self->_setBrightness != NULL)
|
|
{
|
|
returnValue = self->_setBrightness(self, brightness);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
returnValue = ERROR;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
ErrorStatus DisplayDevice_setContrast(const struct DisplayDevice* self, unsigned int contrast)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
if (self->initialized)
|
|
{
|
|
if (self->_setContrast != NULL)
|
|
{
|
|
returnValue = self->_setContrast(self, contrast);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
returnValue = ERROR;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
ErrorStatus DisplayDevice_invert(const struct DisplayDevice* self)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
if (self->initialized)
|
|
{
|
|
if (self->_invert != NULL)
|
|
{
|
|
returnValue = self->_invert(self);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
returnValue = ERROR;
|
|
}
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
ErrorStatus DisplayDevice_setBlinkingCursorState(const struct DisplayDevice* self, DisplayDevice_functionalState state)
|
|
{
|
|
ErrorStatus returnValue = SUCCESS;
|
|
if (self->initialized)
|
|
{
|
|
if (self->_setBlinkingCursor != NULL)
|
|
{
|
|
returnValue = self->_setBlinkingCursor(self, state);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
returnValue = ERROR;
|
|
}
|
|
return returnValue;
|
|
}
|