27 lines
		
	
	
		
			596 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			596 B
		
	
	
	
		
			C
		
	
	
	
	
	
| #ifndef __RELAYS_H
 | |
| #define __RELAYS_H
 | |
| 
 | |
| #include "mgos.h"
 | |
| #include <string.h>
 | |
| 
 | |
| #define MAX_RELAYS 8
 | |
| 
 | |
| struct relay_t {
 | |
|   uint8_t gpio;
 | |
|   float last_change;
 | |
|   bool state;
 | |
| };
 | |
| 
 | |
| int relays_init(const char *flag);
 | |
| uint8_t relays_find_by_gpio(uint8_t gpio);
 | |
| bool relays_set_by_gpio(uint8_t gpio, bool state);
 | |
| bool relays_get_by_gpio(uint8_t gpio);
 | |
| float relays_get_last_change_by_gpio(uint8_t gpio);
 | |
| 
 | |
| bool relays_set_by_idx(uint8_t idx, bool state);
 | |
| bool relays_get_by_idx(uint8_t idx);
 | |
| float relays_get_last_change_by_idx(uint8_t idx);
 | |
| uint8_t relays_get_gpio_by_idx(uint8_t idx);
 | |
| #endif // __RELAYS_H
 | |
| 
 |