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:
@@ -27,6 +27,8 @@
|
||||
|
||||
#include "DisplayDevice.h"
|
||||
|
||||
#include "Logger.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -78,6 +80,8 @@ ErrorStatus DisplayDevice_construct (struct DisplayDevice* self, struct DisplayD
|
||||
self->_setContrast = setContrast;
|
||||
self->_invert = invert;
|
||||
|
||||
self->initialized = true;
|
||||
|
||||
self->parameters = *parameters;
|
||||
}
|
||||
else
|
||||
@@ -91,7 +95,7 @@ ErrorStatus DisplayDevice_construct (struct DisplayDevice* self, struct DisplayD
|
||||
ErrorStatus DisplayDevice_reset(const struct DisplayDevice* self)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!self->initialized)
|
||||
if (self->initialized)
|
||||
{
|
||||
if (self->_reset != NULL)
|
||||
{
|
||||
@@ -109,7 +113,7 @@ ErrorStatus DisplayDevice_reset(const struct DisplayDevice* self)
|
||||
ErrorStatus DisplayDevice_setState(const struct DisplayDevice* self, DisplayDevice_functionalState state)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!self->initialized)
|
||||
if (self->initialized)
|
||||
{
|
||||
if (self->_setState != NULL)
|
||||
{
|
||||
@@ -127,7 +131,7 @@ ErrorStatus DisplayDevice_setState(const struct DisplayDevice* self, DisplayDevi
|
||||
ErrorStatus DisplayDevice_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)
|
||||
{
|
||||
if (self->_write != NULL)
|
||||
{
|
||||
@@ -145,7 +149,7 @@ ErrorStatus DisplayDevice_write(const struct DisplayDevice* self, const char* bu
|
||||
ErrorStatus DisplayDevice_clear(const struct DisplayDevice* self)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!self->initialized)
|
||||
if (self->initialized)
|
||||
{
|
||||
if (self->_clear != NULL)
|
||||
{
|
||||
@@ -163,7 +167,7 @@ ErrorStatus DisplayDevice_clear(const struct DisplayDevice* self)
|
||||
ErrorStatus DisplayDevice_clearLine(const struct DisplayDevice* self, size_t row)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!self->initialized)
|
||||
if (self->initialized)
|
||||
{
|
||||
if (self->_clearLine != NULL)
|
||||
{
|
||||
@@ -181,7 +185,7 @@ ErrorStatus DisplayDevice_clearLine(const struct DisplayDevice* self, size_t row
|
||||
ErrorStatus DisplayDevice_setBrightness(const struct DisplayDevice* self, size_t brightness)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!self->initialized)
|
||||
if (self->initialized)
|
||||
{
|
||||
if (self->_setBrightness != NULL)
|
||||
{
|
||||
@@ -199,7 +203,7 @@ ErrorStatus DisplayDevice_setBrightness(const struct DisplayDevice* self, size_t
|
||||
ErrorStatus DisplayDevice_setContrast(const struct DisplayDevice* self, size_t contrast)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!self->initialized)
|
||||
if (self->initialized)
|
||||
{
|
||||
if (self->_setContrast != NULL)
|
||||
{
|
||||
@@ -217,7 +221,7 @@ ErrorStatus DisplayDevice_setContrast(const struct DisplayDevice* self, size_t c
|
||||
ErrorStatus DisplayDevice_invert(const struct DisplayDevice* self)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!self->initialized)
|
||||
if (self->initialized)
|
||||
{
|
||||
if (self->_invert != NULL)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file KeyboardDevice.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 KeyboardDevice.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "KeyboardDevice.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
ErrorStatus KeyboardDevice_construct (struct KeyboardDevice* self, struct KeyboardDeviceParameters* parameters, KeyboardReadFunction read)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (!self->initialized)
|
||||
{
|
||||
self->_read = read;
|
||||
self->parameters = *parameters;
|
||||
self->initialized = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
ErrorStatus KeyboardDevice_read(const struct KeyboardDevice* self, char* buffer, Keypad_KeyState* keyState)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (self->_read != NULL)
|
||||
{
|
||||
returnValue = self->_read(self, buffer, keyState);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file PID.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 PID.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "PID.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
ErrorStatus PID_construct(struct Pid* self, int Kp, int Ki, int Kd)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (!self->initialized)
|
||||
{
|
||||
self->Kd = Kd;
|
||||
self->Ki = Ki;
|
||||
self->Kp = Kp;
|
||||
self->input_d1 = 0;
|
||||
self->initialized = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
int PID_calculate(struct Pid* self, int error)
|
||||
{
|
||||
int returnValue = 0;
|
||||
|
||||
if (self->initialized)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file storm700.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 storm700.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "storm700.h"
|
||||
|
||||
#include "keypadMatrix.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static char keyLookupTable[STORM700_NUMBER_OF_ROWS][STORM700_NUMBER_OF_COLUMNS] =
|
||||
{
|
||||
{ '1', '2', '3', 'X' },
|
||||
{ '4', '5', '6', 'U' },
|
||||
{ '7', '8', '9', 'D' },
|
||||
{ 'L', '0', 'R', '\n'}
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static ErrorStatus read(const struct KeyboardDevice* self, char* buffer, Keypad_KeyState* keyState);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
ErrorStatus Storm700_construct(struct Storm700* self, const struct IODevice* device)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (!self->initialized)
|
||||
{
|
||||
if (device != NULL)
|
||||
{
|
||||
self->device = device;
|
||||
|
||||
struct KeyboardDeviceParameters kbParameters;
|
||||
kbParameters.numberOfKeys = STORM700_NUMBER_OF_ROWS * STORM700_NUMBER_OF_COLUMNS;
|
||||
|
||||
KeyboardDevice_construct(&self->keyboardDevice, &kbParameters, read);
|
||||
|
||||
self->initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
void Storm700_destruct(struct Storm700* self)
|
||||
{
|
||||
self->initialized= false;
|
||||
self->device = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ErrorStatus Storm700_readKey(const struct Storm700* self, char* key, Keypad_KeyState* keyState)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (self->initialized)
|
||||
{
|
||||
size_t actualLength;
|
||||
char buffer[sizeof(struct KeypadQueueItem) / sizeof(char)];
|
||||
returnValue = IODevice_read(self->device, buffer, sizeof(struct KeypadQueueItem) / sizeof(char), &actualLength);
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
struct KeypadQueueItem* rxQueueItem = (struct KeypadQueueItem*)buffer;
|
||||
|
||||
*key = keyLookupTable[rxQueueItem->rowCoordinate][rxQueueItem->columnCoordinate];
|
||||
*keyState = rxQueueItem->keyEvent;
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
static ErrorStatus read(const struct KeyboardDevice* self, char* buffer, Keypad_KeyState* keyState)
|
||||
{
|
||||
return Storm700_readKey((const struct Storm700*)self, buffer, keyState);
|
||||
}
|
||||
Reference in New Issue
Block a user