Template Class StateHUDIndicator
Defined in File state_hud_indicator.hpp
Inheritance Relationships
Base Type
public modm::Resumable< 2 >
Class Documentation
-
template<typename T>
class StateHUDIndicator : public modm::Resumable<2> Draws a graphic. Each graphic has an associated state (of type specified by the template parameter). Can be true/false, some enumeration type, or something else. When the state associated with this object is updated, a function is called in which the user can update the graphic based on the state. In this way, the user may select to update color or shape of a graphic based on the indicator’s state.
To use this drawer, pass in a
Graphic1Messageobject that you must configure via calls toconfigGraphicGenericsandconfig<circle|line|etc.>.Usage:
To construct some
StateHUDIndicator<bool> indicatoryou must pass it anUpdateHUDIndicatorStatefunction. For example, the function can be something like this:void updateColor(bool state, Tx::Graphic1Message *graphic) { graphic->graphicData.color = indicatorStatus ? GREEN : YELLOW; }
Assuming some
Tx::Graphic1Message graphichas been declared, to use theindicator, calls toinitializeanddrawmust be done in a prothread similar to the following. It is recommended you putPT_YIELDin protothread loops to avoid infinite looping since the indicator’sdrawfunction is not guaranteed to block:PT_CALL(indicator.initialize()); while (true) { PT_CALL(indicator.draw()); PT_YIELD(); } // Initialize the declare a drawer
Note
initializeshould be called once at the start of a protothread being used to write graphic information to the referee system anddrawshould be called repeatedly, and will either resend the graphic if the color has changed or do nothing.- Template Parameters:
T – Type of the state associated with the HUD indicator.
Public Types
-
using UpdateHUDIndicatorState = void (*)(T state, tap::communication::serial::RefSerial::Tx::Graphic1Message *graphic)
Function pointer, this type of function will be called when the state of the graphic needs updating. Expected that the user will update the graphic appropriately based on the current state.
Public Functions
-
inline StateHUDIndicator(tap::communication::serial::RefSerialTransmitter &refSerialTransmitter, tap::communication::serial::RefSerial::Tx::Graphic1Message *graphic, UpdateHUDIndicatorState updateFunction, T initialState)
-
inline modm::ResumableResult<bool> initialize()
-
inline modm::ResumableResult<bool> draw()
Public Static Attributes
-
static uint32_t MIN_UPDATE_PERIOD = 500
The state HUD indicator will ignore calls in
setIndicatorStateMIN_UPDATE_PERIOD ms aftersetIndicatorStateis drawn. This is to avoid rapid back and forth updating of the graphic.