controller-legacy/runners/test.c

36 lines
1 KiB
C
Raw Normal View History

#include <unistd.h>
#include <runners.h>
#include <logger.h>
#include <drivers.h>
#include <drivers.h>
void
runner_test(controller_t *controller)
{
// from x down to 0 to turn all relays off in the end
for(int test_run = 2; test_run >= 0; --test_run)
{
for(uint_fast8_t i = 0; i < controller->relay_count; ++i)
{
2020-04-18 00:09:50 +00:00
int is_active = test_run % 2;
if(global_config.relay_configs[i].inverted)
{
is_active = !is_active;
}
switch(global_config.relay_configs[i].driver)
{
case RELAY_DRIVER_GPIO:
2020-04-18 00:09:50 +00:00
driver_gpio_set(global_config.relay_configs[i].pin, is_active);
break;
case RELAY_DRIVER_PIFACE:
2020-04-18 00:09:50 +00:00
driver_piface_set(global_config.relay_configs[i].pin, is_active);
break;
default:
LOG_WARN("relay %d is not using a driver", i);
}
sleep(1);
}
}
}