Solo Controller Documentation 1.0
Documentation for the Solo Controller
 
Loading...
Searching...
No Matches
MomentaryButton Class Reference

Defines a momentary buttons with 2 states. Upon release, the button automatically returns to state 0. More...

#include <Button.h>

Inheritance diagram for MomentaryButton:
ToggleButton Button

Public Member Functions

void release (void) override
 Releases the button if it has been pressed.
 
Constructors and Destructors
 MomentaryButton (const char *buttonName, Canvas &Destination, const Block_Image &DestLoc, const char *buttonText0, FontList::FontID Font0, uint16_t fillColor0, const char *buttonText1, FontList::FontID Font1, uint16_t fillColor1, ButtonState::buttonCallbackFunction callback, uint16_t fontBaseline, const ButtonConfig_t< 2 > config=DEFAULT_BUTTON_CONFIG)
 Constructor for a Momentary Button that displays text in each state.
 
 MomentaryButton (const char *buttonName, Canvas &Destination, const Block_Image &DestLoc, ROM_Image ButtonImg0, uint16_t ButtonImgColor0, uint16_t ButtonFillColor0, ROM_Image ButtonImg1, uint16_t ButtonImgColor1, uint16_t ButtonFillColor1, ButtonState::buttonCallbackFunction callback, const ButtonConfig_t< 2 > config=DEFAULT_BUTTON_CONFIG)
 Constructor for a Momentary Button that displays images in each state.
 
 ~MomentaryButton (void)=default
 Default destructor.
 
- Public Member Functions inherited from ToggleButton
 ToggleButton (const char *buttonName, Canvas &Destination, const Block_Image &DestLoc, const char *buttonText0, FontList::FontID Font0, uint16_t fillColor0, ButtonState::buttonCallbackFunction callback0, const char *buttonText1, FontList::FontID Font1, uint16_t fillColor1, ButtonState::buttonCallbackFunction callback1, uint16_t fontBaseline, const ButtonConfig_t< 2 > config=DEFAULT_BUTTON_CONFIG)
 Constructor for a Toggle Button that displays text in each state.
 
 ToggleButton (const char *buttonName, Canvas &Destination, const Block_Image &DestLoc, ROM_Image ButtonImg0, uint16_t ButtonImgColor0, uint16_t ButtonFillColor0, ButtonState::buttonCallbackFunction callback0, ROM_Image ButtonImg1, uint16_t ButtonImgColor1, uint16_t ButtonFillColor1, ButtonState::buttonCallbackFunction callback1, const ButtonConfig_t< 2 > config=DEFAULT_BUTTON_CONFIG)
 Constructor for a Toggle Button that displays images in each state.
 
 ~ToggleButton (void)=default
 Default destructor.
 
void begin (void) override
 Initializes the button. This method should be called before first use.
 
- Public Member Functions inherited from Button
 Button (const char *buttonName, Canvas &DestCanvas, uint16_t dest_x, uint16_t dest_y, uint16_t width, uint16_t height, callback_type whenCallback)
 Constructor for creating a Button object.
 
virtual ~Button (void)=default
 Default destructor.
 
virtual bool press (FT5316::TouchLocation loc)
 Presses the button if loc is within the bounds of the button.
 
void enable (void)
 Enables the button, making it accept button presses.
 
void disable (void)
 Disables the button, so that it ignores button presses.
 
void setState (uint8_t state)
 Sets the button to the specified state.
 
void nextState (void)
 Advances the button to the next state.
 
void draw (void)
 Draws the image from the current ButtonState onto the destination canvas.
 
void draw (Canvas &newCanvas)
 Draws the image from the current ButtonState onto the specified canvas.
 
bool isEnabled (void) const
 Indicates whether the Button is enabled.
 
uint16_t width (void) const
 Returns the width of the button in pixels.
 
uint16_t height (void) const
 Returns the height of the button in pixels.
 
uint8_t state (void) const
 Returns the current state of the button.
 

Additional Inherited Members

- Public Types inherited from Button
enum  callback_type { ON_PRESS , ON_RELEASE }
 Type definition that defines when the callback function is called relative to button press/release. More...
 
- Protected Member Functions inherited from Button
void _validateObject (void)
 Validates that all ButtonState objects have been defined.
 
void _registerButtonStates (ButtonState **buttonStatePtrArr, uint8_t numStates)
 Registers the ButtonState objects that define this button.
 
void _changeCallback (callback_type type)
 Convenience method that changes when the callback is called.
 

Detailed Description

Defines a momentary buttons with 2 states. Upon release, the button automatically returns to state 0.

This button has two images (pressed and unpressed). The button's single callback function is called when the button is released.

Constructor & Destructor Documentation

◆ MomentaryButton() [1/2]

MomentaryButton::MomentaryButton ( const char * buttonName,
Canvas & Destination,
const Block_Image & DestLoc,
const char * buttonText0,
FontList::FontID Font0,
uint16_t fillColor0,
const char * buttonText1,
FontList::FontID Font1,
uint16_t fillColor1,
ButtonState::buttonCallbackFunction callback,
uint16_t fontBaseline,
const ButtonConfig_t< 2 > config = DEFAULT_BUTTON_CONFIG )
inline

Constructor for a Momentary Button that displays text in each state.

Parameters
[in]buttonNameString containing the name of the button (used for error messages)
[in]DestinationDestination canvas to where the current button image is drawn
[in]DestLocUL x-y coordinate within DestCanvas where the button is to be drawn
[in]buttonText0Text to be displayed on the button in state 0
[in]Font0Font to be used when the button is in state 0
[in]fillColor0Fill color to be used when the button is in state 0
[in]buttonText1Text to be displayed on the button in state 1
[in]Font1Font to be used when the button is in state 1
[in]fillColor1Fill color to be used when the button is in state 1
[in]callbackCallback function when the button is released (transitions to state 0)
[in]fontBaselineBaseline to be used when rendering characters (measured fom top of button)
[in]config(Optional) Graphical configuration parameters for the button

◆ MomentaryButton() [2/2]

MomentaryButton::MomentaryButton ( const char * buttonName,
Canvas & Destination,
const Block_Image & DestLoc,
ROM_Image ButtonImg0,
uint16_t ButtonImgColor0,
uint16_t ButtonFillColor0,
ROM_Image ButtonImg1,
uint16_t ButtonImgColor1,
uint16_t ButtonFillColor1,
ButtonState::buttonCallbackFunction callback,
const ButtonConfig_t< 2 > config = DEFAULT_BUTTON_CONFIG )
inline

Constructor for a Momentary Button that displays images in each state.

Parameters
[in]buttonNameString containing the name of the button (used for error messages)
[in]DestinationDestination canvas to where the current button image is drawn
[in]DestLocUL x-y coordinate within DestCanvas where the button is to be drawn
[in]ButtonImg0Image in Flash ROM for button in state 0
[in]ButtonImgColor0Foreground color of the button image in state 0
[in]ButtonFillColor0Fill color of the button image in state 0
[in]ButtonImg1Image in Flash ROM for button in state 1
[in]ButtonImgColor1Foreground color of the button image in state 1
[in]ButtonFillColor1Fill color of the button image in state 1
[in]callbackCallback function when the button is released (transitions to state 0)
[in]config(Optional) Graphical configuration parameters for the button

The images used by this constructor have transparent backgrounds. They arein the 16-bit color (ARGB format). This object overrides the RGB color of the image with the provided ButtonImgColor value. This color is then overlaid on top of the button fill color to create the final button appearance.

◆ ~MomentaryButton()

MomentaryButton::~MomentaryButton ( void )
default

Default destructor.

Parameters
None.

Member Function Documentation

◆ release()

void MomentaryButton::release ( void )
overridevirtual

Releases the button if it has been pressed.

Parameters
None.

Reimplemented from Button.


The documentation for this class was generated from the following files: