Going on with structure
Added observer/observable for RTC git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@251 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -24,12 +24,14 @@ ARFLAGS = rs
|
||||
|
||||
OBJECTS = \
|
||||
DisplayDevice.o \
|
||||
hsb-mrts.o \
|
||||
Interlock.o \
|
||||
IODevice.o \
|
||||
KeyboardDevice.o \
|
||||
Logger.o \
|
||||
MAX5715.o \
|
||||
nhd0420.o \
|
||||
Observable.o \
|
||||
PID.o \
|
||||
storm700.o
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Class.h (c) 2013 Micro-Key bv
|
||||
* -----------------------------------------------------------------------------
|
||||
* 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
|
||||
* -----------------------------------------------------------------------------
|
||||
* Description: Macro utilities to hide or protect struct members
|
||||
* -----------------------------------------------------------------------------
|
||||
* $Id$
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _CLASS_H_
|
||||
#define _CLASS_H_
|
||||
|
||||
#ifndef CLASS_INTERNAL_INCLUDE
|
||||
|
||||
#define PRIVATE(member) DONOTUSE ## member
|
||||
#undef CLASS_INTERNAL_INCLUDE
|
||||
|
||||
#else
|
||||
|
||||
#define PRIVATE(member) member
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -82,6 +82,7 @@
|
||||
Logger_logISR(a, "", "", 0, LOGTYPE_PRINT, ##__VA_ARGS__)
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
#include "Class.h"
|
||||
#include "Observer.h"
|
||||
|
||||
/* -------------------------------*
|
||||
@@ -37,17 +36,14 @@
|
||||
/**
|
||||
* Maximal number of Observers for one Observable.
|
||||
*/
|
||||
#define OBSERVABLE_MAX_OBSERVERS (32)
|
||||
#define OBSERVABLE_MAX_OBSERVERS (10)
|
||||
|
||||
/**
|
||||
* Static initializer for the Observable class.
|
||||
* Typical usage: struct Observable observable = OBSERVABLE_INITIALIZER;
|
||||
*/
|
||||
#ifdef CLASS_INTERNAL_INCLUDE
|
||||
#define OBSERVABLE_INITIALIZER { .nrOfObservers = 0, .observers = { 0, } }
|
||||
#else
|
||||
#define OBSERVABLE_INITIALIZER { .DONOTUSEnrOfObservers = 0, .DONOTUSEobservers = { 0, } }
|
||||
#endif
|
||||
#define OBSERVABLE_INITIALIZER { .nrOfObservers = 0, .observers = { 0, } }
|
||||
|
||||
|
||||
/* ------------------*
|
||||
* Type definitions. *
|
||||
@@ -59,8 +55,8 @@
|
||||
*/
|
||||
struct Observable
|
||||
{
|
||||
int PRIVATE(nrOfObservers);
|
||||
Observer PRIVATE(observers)[OBSERVABLE_MAX_OBSERVERS];
|
||||
int nrOfObservers;
|
||||
Observer observers[OBSERVABLE_MAX_OBSERVERS];
|
||||
};
|
||||
|
||||
/* ----------------------*
|
||||
@@ -74,14 +70,14 @@ struct Observable
|
||||
* @param self: address of the Observable struct.
|
||||
* @retval none.
|
||||
*/
|
||||
void Observable_initialize(struct Observable* self);
|
||||
void Observable_construct(struct Observable* self);
|
||||
|
||||
/**
|
||||
* Terminates the Observable class. All Observers are removed.
|
||||
* @param self: address of the Observable struct.
|
||||
* @retval none.
|
||||
*/
|
||||
void Observable_terminate(struct Observable* self);
|
||||
void Observable_destruct(struct Observable* self);
|
||||
|
||||
/**
|
||||
* Adds one Observer to the Observable.
|
||||
|
||||
@@ -47,12 +47,12 @@ static int indexOfObserverInList(const struct Observable* self, const Observer o
|
||||
* ---------------------*
|
||||
*/
|
||||
|
||||
void Observable_initialize(struct Observable* self)
|
||||
void Observable_construct(struct Observable* self)
|
||||
{
|
||||
Observable_deleteObservers(self);
|
||||
}
|
||||
|
||||
void Observable_terminate(struct Observable* self)
|
||||
void Observable_destruct(struct Observable* self)
|
||||
{
|
||||
Observable_deleteObservers(self);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ ErrorStatus Observable_addObserver(struct Observable* self, const Observer obser
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER_ERROR("No space left to store a new observer");
|
||||
LOGGER_ERROR(mainLog, "No space left to store a new observer");
|
||||
errorStatus = ERROR;
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ ErrorStatus Observable_addObserverAtFront(struct Observable* self, const Observe
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER_ERROR("No space left to store a new observer");
|
||||
LOGGER_ERROR(mainLog, "No space left to store a new observer");
|
||||
errorStatus = ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,10 +94,14 @@ ErrorStatus NHD0420_construct(struct NHD0420* self, const struct IODevice* devic
|
||||
ddParameters.brightnessMax = NHD0420_BRIGHTNESS_MAX;
|
||||
ddParameters.contrastMin = NHD0420_CONTRAST_MIN;
|
||||
ddParameters.contrastMax = NHD0420_CONTRAST_MAX;
|
||||
DisplayDevice_construct(&self->displayDevice, &ddParameters, NULL, setState, write, clear, NULL, setBrightness, setContrast, NULL);
|
||||
|
||||
self->initialized = true;
|
||||
NHD0420_sendData(self, "Hallo", 5);
|
||||
returnValue = DisplayDevice_construct(&self->displayDevice, &ddParameters, NULL, setState, write, clear, NULL, setBrightness, setContrast, NULL);
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
self->initialized = true;
|
||||
NHD0420_sendData(self, "Hallo", 5);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ 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'}
|
||||
{ 'L', '0', 'R', 'E' }
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user