Open Garden  0.10.1-21
Functions
program.h File Reference

Functions to handle programs. More...

#include <avr/eeprom.h>
#include <util/crc16.h>
#include "ogstruct.h"
#include "io_pin.h"
#include "debug.h"
#include "date.h"
#include "temperature.h"
#include "queue.h"
Include dependency graph for program.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

uint8_t * serno_read (uint8_t *serno, struct debug_t *debug)
 
uint8_t * serno_write (uint8_t *serno)
 
void serno_print (uint8_t *serno, struct debug_t *debug)
 
uint8_t serno_check (uint8_t *serno)
 
uint8_t * serno_init (uint8_t *serno)
 
struct programs_tprog_init (struct programs_t *progs)
 initialize the program area and IO lines
 
void prog_free (struct programs_t *progs)
 
void prog_load (struct programs_t *progs)
 Load or re-load the programs from the eeprom. More...
 
void prog_save (struct programs_t *progs)
 Store the programs into the eeprom area.
 
void prog_list (struct programs_t *progs, struct debug_t *debug)
 
void prog_clear (struct programs_t *progs)
 
void prog_add (struct programs_t *progs, const char *s)
 
uint8_t prog_del (struct programs_t *progs, const uint8_t n)
 remove a program from the memory
 
void prog_run (struct programs_t *progs, struct tm *tm_clock, struct debug_t *debug)
 
uint8_t prog_alarm (struct programs_t *progs)
 

Detailed Description

Functions to handle programs.

Function Documentation

◆ prog_add()

void prog_add ( struct programs_t progs,
const char *  s 
)

add a program into memory

Parameters
progsptr to programs.
sstring in the form pShSm,shsm,DD,OO where: Sh Start hour in the form 0..24. Sm Start minutes. sh Stop hour. sm Stop minutes. DD Day of the week sun..sat bit for day (HEX number). OO output line 0..7 bit for line 0 to 7 (HEX number).

◆ prog_alarm()

uint8_t prog_alarm ( struct programs_t progs)

check the alarm lines and act accordingly.

An alarm must be present for ALRM_THRESHOLD number of cycle before triggering the event (like close all the lines and set the ALARM flag). It must also be absent for the same amount of cycle in order to trigger the clear event (like clear the ALARM flag).

If there is an alarm and we haven't reached the ALRM_THRESHOLD and it is the first time we hit the alarm, then close the lines and clear all the programs. If the ALRM_THRESHOLD is not yet reached, then increment it. If the is not an alarm, but we still have an alarm counter > 0 then decrement it. Finally if the alarm counter = 0, clear the ALARM flag.

Bug:
Bistable valve non-compatible.

◆ prog_clear()

void prog_clear ( struct programs_t progs)

remove all programs from the memory

◆ prog_free()

void prog_free ( struct programs_t progs)

Free the allocated memory and close the IO lines

Todo:
shut IO down, to be implemented but useless.

◆ prog_list()

void prog_list ( struct programs_t progs,
struct debug_t debug 
)

list all valid programs

◆ prog_load()

void prog_load ( struct programs_t progs)

Load or re-load the programs from the eeprom.

There are 2 case scenario, one on boot or after a reset, the other after an 'C' command. In the first case we do not have many valid information like all the temperature informations and log status. On the other case instead we have all the information updated.

◆ prog_run()

void prog_run ( struct programs_t progs,
struct tm tm_clock,
struct debug_t debug 
)

Check which program to exec.

Parameters
progs
tm_clocktime now.
debug

◆ serno_check()

uint8_t serno_check ( uint8_t *  serno)

Check the serial number store in EEPROM

◆ serno_init()

uint8_t* serno_init ( uint8_t *  serno)

Initialize and allocate the serial number space

◆ serno_read()

uint8_t* serno_read ( uint8_t *  serno,
struct debug_t debug 
)

Read the serial number from the EEPROM.

Parameters
sernothe pointer to a pre-allocated area of SERNO_SIZE byte.

◆ serno_write()

uint8_t* serno_write ( uint8_t *  serno)

Write the serial number to the EEPROM