35 lines
1 KiB
C
35 lines
1 KiB
C
#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(uint_fast8_t i = 0; i < controller->relay_count; ++i)
|
|
{
|
|
for(int test_run = 2; test_run >= 0; --test_run)
|
|
{
|
|
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:
|
|
driver_gpio_set(global_config.relay_configs[i].pin, is_active);
|
|
break;
|
|
case RELAY_DRIVER_PIFACE:
|
|
driver_piface_set(global_config.relay_configs[i].pin, is_active);
|
|
break;
|
|
default:
|
|
LOG_WARN("relay %d is not using a driver\n", i);
|
|
}
|
|
sleep(1);
|
|
}
|
|
}
|
|
}
|