device.h 1.21 KB
#ifndef __DEVICE_H_
#define __DEVICE_H_

/* #include <stdio.h> */
/* #include <string.h> */
/* #include <stdlib.h> */
/* #include <time.h> */
/* #include <stddef.h> */

#include <string.h>
#include "pcf.h"
#include "mqtt.h"

// Number = pcfPIN - one action per pin / no diode crap anymore
#define dst_valve_rotate 1
#define dst_valve_watersource 2
#define diaphragm 3
#define peristaltic 4
#define peristaltic_reverse 5
#define dive 6
#define src_valve_pump 7



#define off 0

struct sequence {
  struct action *action;
  int device;
  int start_value;
  int end_value;
  double start;
  double end;
  struct sequence *next;
};

struct sequence *sequence_head = NULL;
struct sequence *sequence_tail = NULL;

const int startpumpheight = 50;
const int stoppumpheight = 5;

int waterlevel = 0;
unsigned int pumpstate = 0;
unsigned long timeStored = 0;

void loop_device();

void insertSequence(int device, int start_value, int end_value, double duration, struct action *action);
void next_sequence_step();
void monitor_sequence_duration();
void set_relay(struct sequence *step);
int fill_start(struct action *ptr);
int rotate_start(struct action *ptr);
int rotate_start(struct button *ptr);
int fertilize_start(struct action *ptr);


#endif