FEATURE: correctly initialize and reset relays
This commit is contained in:
parent
526546f0a4
commit
036f5c9bf4
@ -20,6 +20,8 @@ namespace floatpump::io {
|
||||
|
||||
void switchRelay(state st);
|
||||
|
||||
void forceRefresh();
|
||||
|
||||
void setInverted(bool inv);
|
||||
|
||||
void setCooldown(uint16_t ms);
|
||||
|
@ -27,6 +27,7 @@ namespace floatpump {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RelayChannel::setCooldown(uint16_t ms) {
|
||||
m_cooldown = ms;
|
||||
}
|
||||
@ -43,5 +44,13 @@ namespace floatpump {
|
||||
void RelayChannel::setInverted(bool inv) {
|
||||
m_inverted = inv;
|
||||
}
|
||||
|
||||
void RelayChannel::forceRefresh() {
|
||||
if ( m_state == state::ON) {
|
||||
HAL_GPIO_WritePin(m_gpio, m_gpio_pin, (m_inverted) ? GPIO_PIN_RESET : GPIO_PIN_SET);
|
||||
} else if (m_state == state::OFF) {
|
||||
HAL_GPIO_WritePin(m_gpio, m_gpio_pin, (m_inverted) ? GPIO_PIN_SET : GPIO_PIN_RESET);
|
||||
}
|
||||
}
|
||||
} // floatpump
|
||||
} // io
|
Loading…
Reference in New Issue
Block a user