Files
lightswitch/include/main.h
Pim van Pelt 4a083555e8 Clean up RPC response.
- Refactor mqtt_publish_stat() to take va_list
- Make publish_stat format its response with json_vprintf() so it is
  valid JSON.
- Call publish_stat in channel_set, the only place where the GPIO state
  changes
- Return (valid) JSON response in all RPCs
2018-01-24 14:08:29 +01:00

33 lines
690 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);
#endif // __MAIN_H