Files
lightswitch/include/main.h
Pim van Pelt bb62e9b6ae Add DHT support.
Very rough stab just to test the waters -- this will need some
more work.

For now, hard code 4,5,15 pins (as per Sonoff SV), but before
rolling this out, add a config flag for this behavior.

Neat trick -- the presence of dht library in mos.yml triggers
inclusion of the code via define -DMGOS_HAVE_DHT=1
2018-02-11 13:20:36 +01:00

35 lines
708 B
C

#ifndef __MAIN_H
#define __MAIN_H
#include "mgos.h"
#include "mgos_gpio.h"
#define CHANNEL_CHANGE_COOLDOWN_SECONDS 0.250
#define CHANNEL_MAX 16
#define GPIO_INVALID 255
#define GPIO_MIN 0
#define GPIO_MAX 16
struct channel_t {
uint8_t button_gpio;
uint8_t led_gpio;
uint8_t relay_gpio;
bool relay_state;
double button_last_change;
};
void statusled_blink();
void statusled_init(uint8_t gpio, bool state_off);
bool channel_init(const char *fn);
uint8_t channel_gpio_by_idx(int idx);
uint8_t channel_idx_by_gpio(int gpio);
void channel_set(int idx, bool state);
bool channel_get(int idx);
int channel_get_total();
void channel_handler(int gpio, void *arg);
void dht_init();
#endif // __MAIN_H