|
Open Garden
0.10.1-21
|
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"

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_t * | prog_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) |
Functions to handle programs.
| void prog_add | ( | struct programs_t * | progs, |
| const char * | s | ||
| ) |
add a program into memory
| progs | ptr to programs. |
| s | string 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). |
| 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.
| void prog_clear | ( | struct programs_t * | progs | ) |
remove all programs from the memory
| void prog_free | ( | struct programs_t * | progs | ) |
Free the allocated memory and close the IO lines
| void prog_list | ( | struct programs_t * | progs, |
| struct debug_t * | debug | ||
| ) |
list all valid programs
| 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.
| void prog_run | ( | struct programs_t * | progs, |
| struct tm * | tm_clock, | ||
| struct debug_t * | debug | ||
| ) |
Check which program to exec.
| progs | |
| tm_clock | time now. |
| debug |
| uint8_t serno_check | ( | uint8_t * | serno | ) |
Check the serial number store in EEPROM
| uint8_t* serno_init | ( | uint8_t * | serno | ) |
Initialize and allocate the serial number space
| uint8_t* serno_read | ( | uint8_t * | serno, |
| struct debug_t * | debug | ||
| ) |
Read the serial number from the EEPROM.
| serno | the pointer to a pre-allocated area of SERNO_SIZE byte. |
| uint8_t* serno_write | ( | uint8_t * | serno | ) |
Write the serial number to the EEPROM
1.8.13