Skip to content

Commit

Permalink
AP_ICEngine: Add support for relay control of the starter and ignition
Browse files Browse the repository at this point in the history
  • Loading branch information
WickedShell committed Sep 26, 2023
1 parent 263f1f7 commit d9dcc3e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions libraries/AP_ICEngine/AP_ICEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <RC_Channel/RC_Channel.h>
#include <AP_RPM/AP_RPM.h>
#include <AP_Parachute/AP_Parachute.h>
#include <AP_Relay/AP_Relay.h>

extern const AP_HAL::HAL& hal;

Expand Down Expand Up @@ -354,23 +355,44 @@ void AP_ICEngine::update(void)
}
#endif // AP_RPM_ENABLED

#if AP_RELAY_ENABLED
AP_Relay *relay = AP::relay();
#endif // AP_RELAY_ENABLED
/* now set output channels */
switch (state) {
case ICE_OFF:
SRV_Channels::set_output_pwm(SRV_Channel::k_ignition, pwm_ignition_off);
SRV_Channels::set_output_pwm(SRV_Channel::k_starter, pwm_starter_off);
#if AP_RELAY_ENABLED
if (relay != nullptr) {
relay->set(AP_Relay_Params::Function::ignition, false);
relay->set(AP_Relay_Params::Function::starter, false);
}
#endif // AP_RELAY_ENABLED
starter_start_time_ms = 0;
break;

case ICE_START_HEIGHT_DELAY:
case ICE_START_DELAY:
SRV_Channels::set_output_pwm(SRV_Channel::k_ignition, pwm_ignition_on);
SRV_Channels::set_output_pwm(SRV_Channel::k_starter, pwm_starter_off);
#if AP_RELAY_ENABLED
if (relay != nullptr) {
relay->set(AP_Relay_Params::Function::ignition, true);
relay->set(AP_Relay_Params::Function::starter, false);
}
#endif // AP_RELAY_ENABLED
break;

case ICE_STARTING:
SRV_Channels::set_output_pwm(SRV_Channel::k_ignition, pwm_ignition_on);
SRV_Channels::set_output_pwm(SRV_Channel::k_starter, pwm_starter_on);
#if AP_RELAY_ENABLED
if (relay != nullptr) {
relay->set(AP_Relay_Params::Function::ignition, true);
relay->set(AP_Relay_Params::Function::starter, true);
}
#endif // AP_RELAY_ENABLED
if (starter_start_time_ms == 0) {
starter_start_time_ms = now;
}
Expand All @@ -380,6 +402,12 @@ void AP_ICEngine::update(void)
case ICE_RUNNING:
SRV_Channels::set_output_pwm(SRV_Channel::k_ignition, pwm_ignition_on);
SRV_Channels::set_output_pwm(SRV_Channel::k_starter, pwm_starter_off);
#if AP_RELAY_ENABLED
if (relay != nullptr) {
relay->set(AP_Relay_Params::Function::ignition, true);
relay->set(AP_Relay_Params::Function::starter, false);
}
#endif // AP_RELAY_ENABLED
starter_start_time_ms = 0;
break;
}
Expand Down

0 comments on commit d9dcc3e

Please sign in to comment.