diff options
Diffstat (limited to 'apps/px4io')
-rw-r--r-- | apps/px4io/comms.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/apps/px4io/comms.c b/apps/px4io/comms.c index bfdad019d..2b8f95534 100644 --- a/apps/px4io/comms.c +++ b/apps/px4io/comms.c @@ -210,9 +210,25 @@ comms_handle_command(const void *buffer, size_t length) */ mixer_tick(); - /* XXX do relay changes here */ + /* handle relay state changes here */ for (unsigned i = 0; i < PX4IO_RELAY_CHANNELS; i++) { - system_state.relays[i] = cmd->relay_state[i]; + if (system_state.relays[i] != cmd->relay_state[i]) { + switch (i) { + case 0: + POWER_ACC1(cmd->relay_state[i]); + break; + case 1: + POWER_ACC2(cmd->relay_state[i]); + break; + case 2: + POWER_RELAY1(cmd->relay_state[i]); + break; + case 3: + POWER_RELAY2(cmd->relay_state[i]); + break; + } + } + system_state.relays[i] != cmd->relay_state[i] } irqrestore(flags); |