28 lines
564 B
C
28 lines
564 B
C
#include <driver/gpio.h>
|
|
#include "esp_log.h"
|
|
|
|
#include "relays.h"
|
|
#include "constants.h"
|
|
|
|
static const char *TAG = "relays";
|
|
|
|
/**
|
|
* Device relays GPIO ids
|
|
*/
|
|
static int DEVICE_GPIO_IDS[5] = {2, 4, 12, 14, 15};
|
|
|
|
void relays_turn_off_all()
|
|
{
|
|
ESP_LOGI(TAG, "Turning off all relays...");
|
|
|
|
for (size_t i = 0; i < DEV_MAX_RELAYS; i++)
|
|
{
|
|
relays_set(i, false);
|
|
}
|
|
}
|
|
|
|
void relays_set(int number, bool is_on)
|
|
{
|
|
size_t gpio_id = DEVICE_GPIO_IDS[number];
|
|
ESP_LOGI(TAG, "Set relay %d (gpio %d) to %s", number, gpio_id, is_on ? "on" : "off");
|
|
} |