24#ifndef TAPROOT_STATE_HUD_INDICATOR_HPP_
25#define TAPROOT_STATE_HUD_INDICATOR_HPP_
31#include "modm/processing/resumable.hpp"
93 void (*)(T state, tap::communication::serial::RefSerial::Tx::Graphic1Message *graphic);
103 tap::communication::serial::RefSerial::Tx::Graphic1Message *graphic,
106 : refSerialTransmitter(refSerialTransmitter),
108 updateFunction(updateFunction),
109 initialState(initialState),
110 indicatorState(initialState)
112 minUpdatePeriodTimeout.
stop();
119 indicatorState = initialState;
122 graphic->graphicData.operation = tap::communication::serial::RefSerial::Tx::GRAPHIC_ADD;
123 RF_CALL(refSerialTransmitter.
sendGraphic(graphic));
125 graphic->graphicData.operation = tap::communication::serial::RefSerial::Tx::GRAPHIC_MODIFY;
129 RF_WAIT_UNTIL(delayTimeout.
execute());
134 modm::ResumableResult<bool>
draw()
137 if (indicatorChanged)
140 RF_CALL(refSerialTransmitter.
sendGraphic(graphic));
141 indicatorChanged =
false;
145 RF_WAIT_UNTIL(delayTimeout.
execute());
154 if (indicatorState != newIndicatorState)
156 indicatorState = newIndicatorState;
157 updateFunction(indicatorState, graphic);
158 indicatorChanged =
true;
167 tap::communication::serial::RefSerial::Tx::Graphic1Message *graphic;
171 const T initialState;
173 bool indicatorChanged =
false;
Definition timeout.hpp:44
void restart(uint32_t timeout)
Definition timeout.hpp:70
bool isExpired() const
Definition timeout.hpp:95
void stop()
Definition timeout.hpp:80
bool execute()
Definition timeout.hpp:115
bool isStopped() const
Definition timeout.hpp:89
Definition state_hud_indicator.hpp:85
static constexpr uint32_t MIN_UPDATE_PERIOD
Definition state_hud_indicator.hpp:99
void(*)(T state, tap::communication::serial::RefSerial::Tx::Graphic1Message *graphic) UpdateHUDIndicatorState
Definition state_hud_indicator.hpp:93
modm::ResumableResult< bool > draw()
Definition state_hud_indicator.hpp:134
void setIndicatorState(T newIndicatorState)
Definition state_hud_indicator.hpp:150
modm::ResumableResult< bool > initialize()
Definition state_hud_indicator.hpp:115
StateHUDIndicator(tap::communication::serial::RefSerialTransmitter &refSerialTransmitter, tap::communication::serial::RefSerial::Tx::Graphic1Message *graphic, UpdateHUDIndicatorState updateFunction, T initialState)
Definition state_hud_indicator.hpp:101
static constexpr uint32_t getWaitTimeAfterGraphicSendMs(T *)
Definition ref_serial_data.hpp:678
Definition ref_serial_transmitter.hpp:56
mockable modm::ResumableResult< void > sendGraphic(Tx::Graphic1Message *graphicMsg, bool configMsgHeader=true, bool sendMsg=true)
Definition ref_serial_transmitter.cpp:293
Definition state_hud_indicator.hpp:39
Definition ballistics.cpp:29
tap::Drivers Drivers
Definition drivers.hpp:11