1 #ifndef _TWR_MODULE_RELAY_H
2 #define _TWR_MODULE_RELAY_H
4 #include <twr_tca9534a.h>
5 #include <twr_scheduler.h>
7 #define TWR_MODULE_RELAY_I2C_ADDRESS_DEFAULT 0x3B
8 #define TWR_MODULE_RELAY_I2C_ADDRESS_ALTERNATE 0x3F
57 TWR_MODULE_RELAY_TASK_STATE_IDLE,
58 TWR_MODULE_RELAY_TASK_STATE_SET,
59 TWR_MODULE_RELAY_TASK_STATE_SET_DEMAGNETIZE,
60 TWR_MODULE_RELAY_TASK_STATE_PULSE,
61 TWR_MODULE_RELAY_TASK_STATE_PULSE_DEMAGNETIZE,
62 TWR_MODULE_RELAY_TASK_STATE_PULSE_REVERSE,
63 TWR_MODULE_RELAY_TASK_STATE_PULSE_DEMAGNETIZE_2
65 } twr_module_relay_task_state_t;
69 TWR_MODULE_RELAY_COMMAND_NONE = 0,
70 TWR_MODULE_RELAY_COMMAND_SET = 1,
71 TWR_MODULE_RELAY_COMMAND_PULSE = 2
73 } twr_module_relay_command_t;
82 twr_module_relay_task_state_t _state;
83 twr_module_relay_command_t _command;
twr_module_relay_state_t
Reported relay states.
void twr_module_relay_set_state(twr_module_relay_t *self, bool state)
Set relay to specified state.
struct twr_module_relay_t twr_module_relay_t
HARDWARIO Relay Module instance.
void twr_module_relay_toggle(twr_module_relay_t *self)
Toggle relay to opposite state.
void twr_module_relay_pulse(twr_module_relay_t *self, bool direction, twr_tick_t duration)
Generate pulse to specified state for given duration.
bool twr_module_relay_init(twr_module_relay_t *self, uint8_t i2c_address)
Initialize HARDWARIO Relay Module.
twr_module_relay_state_t twr_module_relay_get_state(twr_module_relay_t *self)
Get current relay state.
@ TWR_MODULE_RELAY_STATE_UNKNOWN
State is unknown.
@ TWR_MODULE_RELAY_STATE_FALSE
State is false.
@ TWR_MODULE_RELAY_STATE_TRUE
State is true.
size_t twr_scheduler_task_id_t
Task ID assigned by scheduler.
uint64_t twr_tick_t
Timestamp data type.