Open Garden  0.10.1-21
Data Structures | Macros | Functions
ogstruct.h File Reference

structures. More...

#include "date.h"
#include "debug.h"
Include dependency graph for ogstruct.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  program_t
 
struct  queue_t
 the queue buffer More...
 
struct  programs_t
 

Macros

#define CHECK_VALID_CODE   0x09
 check code to control if a valid program is in memory. More...
 
#define SERNO_SIZE   0x10
 
#define MAX_PROGS   20
 maximum number of programs
 
#define PROG_MAX_FACTOR   3.0
 
#define PROG_TOMORROW_FACTOR   2.0
 
#define Q_NEW   0
 
#define Q_OFF   1
 
#define Q_RUN   2
 
#define Q_DELAYED   3
 
#define FULLSUN   0
 
#define HALFSUN   1
 
#define SHADOW   2
 
#define MONOSTABLE   1
 
#define BISTABLE   2
 
#define FL_SUNSITE   0
 
#define FL_VTYPE   2
 
#define FL_LOG   3
 
#define FL_LEVEL   4
 
#define FL_LED   5
 
#define FL_ALRM   6
 
#define ALRM_THRESHOLD   3
 
#define FALSE   0
 
#define TRUE   1
 
#define LOW   0
 
#define HIGH   1
 
#define OFF   0
 
#define ON   1
 

Functions

void flag_set (struct programs_t *progs, const uint8_t bit, const uint8_t val)
 
uint8_t flag_get (struct programs_t *progs, const uint8_t bit)
 

Detailed Description

structures.

Macro Definition Documentation

◆ ALRM_THRESHOLD

#define ALRM_THRESHOLD   3

Number of consecutive alarm to be active to switch alarm on/off

◆ BISTABLE

#define BISTABLE   2

valve type

◆ CHECK_VALID_CODE

#define CHECK_VALID_CODE   0x09

check code to control if a valid program is in memory.

Change this code any time the struct program_t has been changed when reprogram the micro. During boot the program read from flash this code, and, if it is valid, retrive from flash the stored programs. If the structs are changed, we should change this code too, to avoid retrival of wrong data. If, during programming, you nuke the flash memory too, this check code is useless.

◆ FALSE

#define FALSE   0

Macro FALSE

◆ FL_ALRM

#define FL_ALRM   6

flag alarm active

Bug:
since alarms are not immediate and therefor can be read from the hardware I/O lines, but they have a number of events to be counted before actually signal an alarm (digital low pass filter) then there is the need of 2 counter for the two lines and 2 flags for the two separate lines. For the moment we keep only the main alarm. This will be fixed when alarms and lines will be treated indipendently.

◆ FL_LED

#define FL_LED   5

flag leds ON or OFF

◆ FL_LEVEL

#define FL_LEVEL   4

flag alarm level High or Low

◆ FL_LOG

#define FL_LOG   3

flag log enable/disable

◆ FL_SUNSITE

#define FL_SUNSITE   0

flag sunsite 2 bit (0, 1)

◆ FL_VTYPE

#define FL_VTYPE   2

flag valve type mono/bi-stable

◆ FULLSUN

#define FULLSUN   0

sunlight position.

◆ HALFSUN

#define HALFSUN   1

sunlight position.

◆ HIGH

#define HIGH   1

Macro HIGH

◆ LOW

#define LOW   0

Macro LOW

◆ MONOSTABLE

#define MONOSTABLE   1

valve type

◆ OFF

#define OFF   0

Macro OFF

◆ ON

#define ON   1

Macro ON

◆ PROG_MAX_FACTOR

#define PROG_MAX_FACTOR   3.0

Maximum increment factor for time increase.

◆ PROG_TOMORROW_FACTOR

#define PROG_TOMORROW_FACTOR   2.0

Factor increment for tomorrow program reschedule.

◆ Q_DELAYED

#define Q_DELAYED   3

queue status DELAYED

◆ Q_NEW

#define Q_NEW   0

queue status NEW

◆ Q_OFF

#define Q_OFF   1

queue status OFF

◆ Q_RUN

#define Q_RUN   2

queue status RUN

◆ SERNO_SIZE

#define SERNO_SIZE   0x10

Serial number size in byte.

Like: PPVVYYMMDDxxxx0C where: PP - Hardware manufacturer code VV - Hardware version YY - Year MM - Month DD - Day xxxx - Incremental number 0 - \0 string terminator C - crc8 checksum

◆ SHADOW

#define SHADOW   2

sunlight position.

◆ TRUE

#define TRUE   1

Macro TRUE

Function Documentation

◆ flag_get()

uint8_t flag_get ( struct programs_t progs,
const uint8_t  bit 
)

Get flag value.

This function will get the correspondent bit in the flags byte.

ex. check the led flag value is if (flag_get(progs, FL_LEDS)) ...

Parameters
*progsthe ogstruct.
bitthe bit of the flag's byte.
Returns
TRUE or FALSE

◆ flag_set()

void flag_set ( struct programs_t progs,
const uint8_t  bit,
const uint8_t  val 
)

Set flag value.

This function will set or clear the correspondent bit in the flags byte.

ex. set the led flag is

flag_set(progs, FL_LEDS, TRUE);

ex. clear the led flag value is

flag_set(progs, FL_LEDS, FALSE);
Parameters
*progsthe ogstruct.
bitthe bit of the flag's byte.
valTRUE or FALSE.