Commit for SWO for HW validation menu updates
git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@245 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -34,6 +34,8 @@
|
||||
|
||||
#include "spi.h"
|
||||
|
||||
#include "Logger.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -67,7 +69,7 @@ static int nhd0420_cursorRowOffset[NHD0420_NUMBER_OF_ROWS] =
|
||||
static ErrorStatus setState(const struct DisplayDevice* self, DisplayDevice_functionalState state);
|
||||
static ErrorStatus write(const struct DisplayDevice* self, const char* buffer, size_t length, size_t row, size_t column);
|
||||
static ErrorStatus clear(const struct DisplayDevice* self);
|
||||
static ErrorStatus clearLine(const struct DisplayDevice* self);
|
||||
static ErrorStatus clearLine(const struct DisplayDevice* self, size_t row);
|
||||
static ErrorStatus setBrightness(const struct DisplayDevice* self, size_t brightness);
|
||||
static ErrorStatus setContrast(const struct DisplayDevice* self, size_t contrast);
|
||||
|
||||
@@ -94,6 +96,9 @@ ErrorStatus NHD0420_construct(struct NHD0420* self, const struct IODevice* devic
|
||||
ddParameters.contrastMin = NHD0420_CONTRAST_MIN;
|
||||
ddParameters.contrastMax = NHD0420_CONTRAST_MAX;
|
||||
DisplayDevice_construct(&self->displayDevice, &ddParameters, NULL, setState, write, clear, clearLine, setBrightness, setContrast, NULL);
|
||||
|
||||
self->initialized = true;
|
||||
NHD0420_sendData(self, "Hallo", 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -163,7 +168,7 @@ ErrorStatus NHD0420_getSpiParameters(struct SpiParameters* parameters)
|
||||
ErrorStatus NHD0420_setCursorToPosition(const struct NHD0420* self, size_t row, size_t column)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!self->initialized)
|
||||
if (self->initialized)
|
||||
{
|
||||
// Setting cursor requires sending a command sequence with an additional
|
||||
// address parameter representing the line/column
|
||||
@@ -198,7 +203,7 @@ ErrorStatus NHD0420_setCursorToPosition(const struct NHD0420* self, size_t row,
|
||||
ErrorStatus NHD0420_setContrast(const struct NHD0420* self, char contrast)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!self->initialized)
|
||||
if (self->initialized)
|
||||
{
|
||||
// Setting contrast requires sending a command sequence with an additional
|
||||
// parameter representing the contrast
|
||||
@@ -229,7 +234,7 @@ ErrorStatus NHD0420_setContrast(const struct NHD0420* self, char contrast)
|
||||
ErrorStatus NHD0420_setBacklightBrightness(const struct NHD0420* self, char brightness)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!self->initialized)
|
||||
if (self->initialized)
|
||||
{
|
||||
// Setting backlight brightness requires sending a command sequence with an
|
||||
// additional parameter representing the brightness
|
||||
@@ -260,7 +265,7 @@ ErrorStatus NHD0420_setBacklightBrightness(const struct NHD0420* self, char brig
|
||||
ErrorStatus NHD0420_setRS232Baudrate(const struct NHD0420* self, char baudrate)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!self->initialized)
|
||||
if (self->initialized)
|
||||
{
|
||||
// Setting baudrate requires sending a command sequence with an
|
||||
// additional parameter representing the baudrate
|
||||
@@ -290,7 +295,7 @@ ErrorStatus NHD0420_setRS232Baudrate(const struct NHD0420* self, char baudrate)
|
||||
ErrorStatus NHD0420_setI2CAddress(const struct NHD0420* self, char address)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!self->initialized)
|
||||
if (self->initialized)
|
||||
{
|
||||
// Setting I2C requires sending a command sequence with an
|
||||
// additional parameter representing the address
|
||||
@@ -331,7 +336,7 @@ ErrorStatus NHD0420_setI2CAddress(const struct NHD0420* self, char address)
|
||||
ErrorStatus NHD0420_sendCommand(const struct NHD0420* self, char command)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!self->initialized)
|
||||
if (self->initialized)
|
||||
{
|
||||
char buffer[NHD0420_CMD_LENGTH] = {NHD0420_CMD_PREFIX, command};
|
||||
|
||||
@@ -348,7 +353,7 @@ ErrorStatus NHD0420_sendCommand(const struct NHD0420* self, char command)
|
||||
ErrorStatus NHD0420_sendData(const struct NHD0420* self, const char* buffer, size_t length)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!self->initialized)
|
||||
if (self->initialized)
|
||||
{
|
||||
returnValue = IODevice_write(self->device, buffer, length);
|
||||
}
|
||||
@@ -363,7 +368,7 @@ ErrorStatus NHD0420_sendData(const struct NHD0420* self, const char* buffer, siz
|
||||
static ErrorStatus setState(const struct DisplayDevice* self, DisplayDevice_functionalState state)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!self->initialized)
|
||||
if (self->initialized)
|
||||
{
|
||||
if (state == ON)
|
||||
{
|
||||
@@ -385,7 +390,7 @@ static ErrorStatus setState(const struct DisplayDevice* self, DisplayDevice_func
|
||||
static ErrorStatus write(const struct DisplayDevice* self, const char* buffer, size_t length, size_t row, size_t column)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!self->initialized)
|
||||
if (self->initialized)
|
||||
{
|
||||
// Set cursor on display
|
||||
returnValue = NHD0420_setCursorToPosition((const struct NHD0420*)self, row, column);
|
||||
@@ -405,7 +410,7 @@ static ErrorStatus write(const struct DisplayDevice* self, const char* buffer, s
|
||||
|
||||
static ErrorStatus clear(const struct DisplayDevice* self)
|
||||
{
|
||||
if (!self->initialized)
|
||||
if (self->initialized)
|
||||
{
|
||||
return NHD0420_clearScreen((const struct NHD0420*)self);
|
||||
}
|
||||
@@ -421,12 +426,18 @@ static ErrorStatus clearLine(const struct DisplayDevice* self, size_t row)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (!self->initialized)
|
||||
if (self->initialized)
|
||||
{
|
||||
// Set cursor on display
|
||||
returnValue = NHD0420_setCursorToPosition((const struct NHD0420*)self, row, 1);
|
||||
|
||||
char buffer[self->parameters.numberOfColumns] = {0x20,};
|
||||
char buffer[self->parameters.numberOfColumns];
|
||||
|
||||
int loopcounter;
|
||||
for (loopcounter = 0; loopcounter < self->parameters.numberOfColumns; loopcounter++)
|
||||
{
|
||||
buffer[loopcounter] = 0x20;
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
@@ -444,7 +455,7 @@ static ErrorStatus clearLine(const struct DisplayDevice* self, size_t row)
|
||||
|
||||
static ErrorStatus setBrightness(const struct DisplayDevice* self, size_t brightness)
|
||||
{
|
||||
if (!self->initialized)
|
||||
if (self->initialized)
|
||||
{
|
||||
return NHD0420_setBacklightBrightness((const struct NHD0420*)self, brightness);
|
||||
}
|
||||
@@ -457,7 +468,7 @@ static ErrorStatus setBrightness(const struct DisplayDevice* self, size_t bright
|
||||
|
||||
static ErrorStatus setContrast(const struct DisplayDevice* self, size_t contrast)
|
||||
{
|
||||
if (!self->initialized)
|
||||
if (self->initialized)
|
||||
{
|
||||
return NHD0420_setContrast((const struct NHD0420*)self, contrast);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user