mirror of
https://github.com/adafruit/Adafruit-GFX-Library.git
synced 2024-10-03 18:18:46 -04:00
Merge 6da3d76da5
into 0e32d7dc76
This commit is contained in:
commit
61c032eca0
@ -1726,6 +1726,37 @@ bool Adafruit_GFX_Button::justPressed() { return (currstate && !laststate); }
|
||||
/**************************************************************************/
|
||||
bool Adafruit_GFX_Button::justReleased() { return (!currstate && laststate); }
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Set label to button object.
|
||||
@param label char pointer to new button label
|
||||
*/
|
||||
void Adafruit_GFX_Button::setLabel(char *label) {
|
||||
strncpy(_label, label, 9);
|
||||
_label[9] = 0;
|
||||
drawButton();
|
||||
}
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Get button label
|
||||
@return button label char pointer
|
||||
*/
|
||||
char *Adafruit_GFX_Button::getLabel() { return _label; }
|
||||
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Set the button to enable/disable
|
||||
@param enable boolean true to enable, false to disable
|
||||
@param fillColor uint16_t set button fillColor
|
||||
*/
|
||||
/**********************************************************************/
|
||||
void Adafruit_GFX_Button::setEnabled(bool enable, uint16_t fillColor) {
|
||||
_enabled = enable;
|
||||
_fillcolor = fillColor;
|
||||
currstate = (enable ? currstate : false);
|
||||
drawButton();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// GFXcanvas1, GFXcanvas8 and GFXcanvas16 (currently a WIP, don't get too
|
||||
|
@ -271,6 +271,8 @@ public:
|
||||
uint8_t textsize_y);
|
||||
void drawButton(bool inverted = false);
|
||||
bool contains(int16_t x, int16_t y);
|
||||
char *getLabel();
|
||||
void setLabel(char *label);
|
||||
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@ -280,7 +282,7 @@ public:
|
||||
/**********************************************************************/
|
||||
void press(bool p) {
|
||||
laststate = currstate;
|
||||
currstate = p;
|
||||
currstate = p & _enabled;
|
||||
}
|
||||
|
||||
bool justPressed();
|
||||
@ -294,6 +296,16 @@ public:
|
||||
/**********************************************************************/
|
||||
bool isPressed(void) { return currstate; };
|
||||
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Check whether the button is enabled
|
||||
@returns True if enabled
|
||||
*/
|
||||
/**********************************************************************/
|
||||
bool isEnabled(void) { return _enabled; }
|
||||
|
||||
void setEnabled(bool enable, uint16_t fillColor);
|
||||
|
||||
private:
|
||||
Adafruit_GFX *_gfx;
|
||||
int16_t _x1, _y1; // Coordinates of top-left corner
|
||||
@ -303,7 +315,7 @@ private:
|
||||
uint16_t _outlinecolor, _fillcolor, _textcolor;
|
||||
char _label[10];
|
||||
|
||||
bool currstate, laststate;
|
||||
bool currstate, laststate, _enabled = true;
|
||||
};
|
||||
|
||||
/// A GFX 1-bit canvas context for graphics
|
||||
|
Loading…
Reference in New Issue
Block a user