From f11f001beed4f7a6d6c6a66389b6d10f1e9286c9 Mon Sep 17 00:00:00 2001 From: ildus hakov Date: Wed, 25 Oct 2023 15:34:27 -0400 Subject: [PATCH 01/16] Added public methods for button label --- Adafruit_GFX.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Adafruit_GFX.h b/Adafruit_GFX.h index 63c6ab68..bc2b2d6e 100644 --- a/Adafruit_GFX.h +++ b/Adafruit_GFX.h @@ -271,6 +271,9 @@ class Adafruit_GFX_Button { uint8_t textsize_y); void drawButton(bool inverted = false); bool contains(int16_t x, int16_t y); + // Public methods to access button label to reuse the Button object. + char* getLabel() { return _label;} + void setLabel(char* label) {strncpy(_label, label, 9);_label[9]=0;} /**********************************************************************/ /*! From a52ac70d8e6e5c6b69faaf2ae31c0dac9e3c7824 Mon Sep 17 00:00:00 2001 From: ildus hakov Date: Wed, 25 Oct 2023 16:42:52 -0400 Subject: [PATCH 02/16] Fix clang failure --- Adafruit_GFX.cpp | 9 +++++++++ Adafruit_GFX.h | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Adafruit_GFX.cpp b/Adafruit_GFX.cpp index af989002..933bdf5d 100644 --- a/Adafruit_GFX.cpp +++ b/Adafruit_GFX.cpp @@ -1726,6 +1726,15 @@ bool Adafruit_GFX_Button::justPressed() { return (currstate && !laststate); } /**************************************************************************/ bool Adafruit_GFX_Button::justReleased() { return (!currstate && laststate); } +/**************************************************************************/ +/*! + @brief Set label to button object. +*/ +void Adafruit_GFX_Button::setLabel(char *label) { + strncpy(_label, label, 9); + _label[9]=0; +} + // ------------------------------------------------------------------------- // GFXcanvas1, GFXcanvas8 and GFXcanvas16 (currently a WIP, don't get too diff --git a/Adafruit_GFX.h b/Adafruit_GFX.h index bc2b2d6e..8877bc78 100644 --- a/Adafruit_GFX.h +++ b/Adafruit_GFX.h @@ -272,8 +272,8 @@ class Adafruit_GFX_Button { void drawButton(bool inverted = false); bool contains(int16_t x, int16_t y); // Public methods to access button label to reuse the Button object. - char* getLabel() { return _label;} - void setLabel(char* label) {strncpy(_label, label, 9);_label[9]=0;} + char *getLabel() { return _label;} + void setLabel(char *label); /**********************************************************************/ /*! From 62c9fe3562500632635585a9a9f081cd8cb72413 Mon Sep 17 00:00:00 2001 From: ildus hakov Date: Wed, 25 Oct 2023 16:57:21 -0400 Subject: [PATCH 03/16] Clang fix #2 --- Adafruit_GFX.cpp | 4 ++-- Adafruit_GFX.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Adafruit_GFX.cpp b/Adafruit_GFX.cpp index 933bdf5d..bb600d11 100644 --- a/Adafruit_GFX.cpp +++ b/Adafruit_GFX.cpp @@ -1731,8 +1731,8 @@ bool Adafruit_GFX_Button::justReleased() { return (!currstate && laststate); } @brief Set label to button object. */ void Adafruit_GFX_Button::setLabel(char *label) { - strncpy(_label, label, 9); - _label[9]=0; + strncpy(_label, label, 9); + _label[9]=0; } // ------------------------------------------------------------------------- diff --git a/Adafruit_GFX.h b/Adafruit_GFX.h index 8877bc78..e800337d 100644 --- a/Adafruit_GFX.h +++ b/Adafruit_GFX.h @@ -272,7 +272,7 @@ class Adafruit_GFX_Button { void drawButton(bool inverted = false); bool contains(int16_t x, int16_t y); // Public methods to access button label to reuse the Button object. - char *getLabel() { return _label;} + char *getLabel() { return _label; } void setLabel(char *label); /**********************************************************************/ From 3096b939f5bc3f15317ead8263ab43b4f50680be Mon Sep 17 00:00:00 2001 From: ildus hakov Date: Wed, 25 Oct 2023 17:05:14 -0400 Subject: [PATCH 04/16] Clang fix 3 --- Adafruit_GFX.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Adafruit_GFX.cpp b/Adafruit_GFX.cpp index bb600d11..48bd0763 100644 --- a/Adafruit_GFX.cpp +++ b/Adafruit_GFX.cpp @@ -1732,7 +1732,7 @@ bool Adafruit_GFX_Button::justReleased() { return (!currstate && laststate); } */ void Adafruit_GFX_Button::setLabel(char *label) { strncpy(_label, label, 9); - _label[9]=0; + _label[9] = 0; } // ------------------------------------------------------------------------- From a124bcce302dc6a0d56bed0be39d39f6902454fc Mon Sep 17 00:00:00 2001 From: ildus hakov Date: Wed, 25 Oct 2023 20:42:40 -0400 Subject: [PATCH 05/16] Clang 4 --- Adafruit_GFX.cpp | 12 ++++++++++-- Adafruit_GFX.h | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Adafruit_GFX.cpp b/Adafruit_GFX.cpp index 48bd0763..ba864f26 100644 --- a/Adafruit_GFX.cpp +++ b/Adafruit_GFX.cpp @@ -1728,13 +1728,21 @@ bool Adafruit_GFX_Button::justReleased() { return (!currstate && laststate); } /**************************************************************************/ /*! - @brief Set label to button object. + @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; } - +/**************************************************************************/ +/*! + @brief Get button label + @return button label char pointer +*/ +char *Adafruit_GFX_Button::getLabel() { + return _label; +} // ------------------------------------------------------------------------- // GFXcanvas1, GFXcanvas8 and GFXcanvas16 (currently a WIP, don't get too diff --git a/Adafruit_GFX.h b/Adafruit_GFX.h index e800337d..de4bb954 100644 --- a/Adafruit_GFX.h +++ b/Adafruit_GFX.h @@ -271,8 +271,8 @@ class Adafruit_GFX_Button { uint8_t textsize_y); void drawButton(bool inverted = false); bool contains(int16_t x, int16_t y); - // Public methods to access button label to reuse the Button object. - char *getLabel() { return _label; } + + char *getLabel(); void setLabel(char *label); /**********************************************************************/ From 9832b8b16d3d2d92bd0947b6b6d0df86b4a49bb8 Mon Sep 17 00:00:00 2001 From: ildus hakov Date: Wed, 25 Oct 2023 20:55:24 -0400 Subject: [PATCH 06/16] Clang 5 --- Adafruit_GFX.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Adafruit_GFX.cpp b/Adafruit_GFX.cpp index ba864f26..922c3aad 100644 --- a/Adafruit_GFX.cpp +++ b/Adafruit_GFX.cpp @@ -1740,9 +1740,7 @@ void Adafruit_GFX_Button::setLabel(char *label) { @brief Get button label @return button label char pointer */ -char *Adafruit_GFX_Button::getLabel() { - return _label; -} +char *Adafruit_GFX_Button::getLabel() { return _label; } // ------------------------------------------------------------------------- // GFXcanvas1, GFXcanvas8 and GFXcanvas16 (currently a WIP, don't get too From 781c90bf7afaca376953ed4e5936f188f8082355 Mon Sep 17 00:00:00 2001 From: ildus hakov Date: Wed, 25 Oct 2023 21:02:44 -0400 Subject: [PATCH 07/16] Clang 6. This is too much for 2 simple public methods. --- Adafruit_GFX.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Adafruit_GFX.h b/Adafruit_GFX.h index de4bb954..bdc5d93e 100644 --- a/Adafruit_GFX.h +++ b/Adafruit_GFX.h @@ -270,8 +270,7 @@ class Adafruit_GFX_Button { uint16_t textcolor, char *label, uint8_t textsize_x, uint8_t textsize_y); void drawButton(bool inverted = false); - bool contains(int16_t x, int16_t y); - + bool contains(int16_t x, int16_t y); char *getLabel(); void setLabel(char *label); From 7143b8eb4ea729519bb3f785866f42216c433c8e Mon Sep 17 00:00:00 2001 From: ildus hakov Date: Wed, 25 Oct 2023 22:12:27 -0400 Subject: [PATCH 08/16] Clang 7. Tooooo strict. --- Adafruit_GFX.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Adafruit_GFX.h b/Adafruit_GFX.h index bdc5d93e..4e0de36b 100644 --- a/Adafruit_GFX.h +++ b/Adafruit_GFX.h @@ -270,7 +270,7 @@ class Adafruit_GFX_Button { uint16_t textcolor, char *label, uint8_t textsize_x, uint8_t textsize_y); void drawButton(bool inverted = false); - bool contains(int16_t x, int16_t y); + bool contains(int16_t x, int16_t y); char *getLabel(); void setLabel(char *label); From 9fbafe4540c519f699218fc30a967e2ada8e831f Mon Sep 17 00:00:00 2001 From: ildus hakov Date: Thu, 26 Oct 2023 16:20:23 -0400 Subject: [PATCH 09/16] setLabel modified --- Adafruit_GFX.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Adafruit_GFX.cpp b/Adafruit_GFX.cpp index 922c3aad..16c92c32 100644 --- a/Adafruit_GFX.cpp +++ b/Adafruit_GFX.cpp @@ -1734,6 +1734,7 @@ bool Adafruit_GFX_Button::justReleased() { return (!currstate && laststate); } void Adafruit_GFX_Button::setLabel(char *label) { strncpy(_label, label, 9); _label[9] = 0; + drawButton(); } /**************************************************************************/ /*! From 5d22d2cdfe65db6764bd309ed65a89aa4edf31be Mon Sep 17 00:00:00 2001 From: ildus hakov Date: Thu, 26 Oct 2023 18:47:27 -0400 Subject: [PATCH 10/16] added button enable/disable --- Adafruit_GFX.cpp | 14 ++++++++++++++ Adafruit_GFX.h | 16 +++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Adafruit_GFX.cpp b/Adafruit_GFX.cpp index 16c92c32..1434296d 100644 --- a/Adafruit_GFX.cpp +++ b/Adafruit_GFX.cpp @@ -1742,6 +1742,20 @@ void Adafruit_GFX_Button::setLabel(char *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; + drawButton(); +} + // ------------------------------------------------------------------------- // GFXcanvas1, GFXcanvas8 and GFXcanvas16 (currently a WIP, don't get too diff --git a/Adafruit_GFX.h b/Adafruit_GFX.h index 4e0de36b..2d303b66 100644 --- a/Adafruit_GFX.h +++ b/Adafruit_GFX.h @@ -282,7 +282,7 @@ class Adafruit_GFX_Button { /**********************************************************************/ void press(bool p) { laststate = currstate; - currstate = p; + currstate = p & _enabled; } bool justPressed(); @@ -294,8 +294,18 @@ class Adafruit_GFX_Button { @returns True if pressed */ /**********************************************************************/ - bool isPressed(void) { return currstate; }; + 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 @@ -305,7 +315,7 @@ class Adafruit_GFX_Button { uint16_t _outlinecolor, _fillcolor, _textcolor; char _label[10]; - bool currstate, laststate; + bool currstate, laststate, _enabled = true; }; /// A GFX 1-bit canvas context for graphics From 64122c6a345e40ae2d521b07597dea43fb030c93 Mon Sep 17 00:00:00 2001 From: ildus hakov Date: Thu, 26 Oct 2023 18:54:55 -0400 Subject: [PATCH 11/16] mod2 --- Adafruit_GFX.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Adafruit_GFX.cpp b/Adafruit_GFX.cpp index 1434296d..cb26376a 100644 --- a/Adafruit_GFX.cpp +++ b/Adafruit_GFX.cpp @@ -1753,6 +1753,7 @@ char *Adafruit_GFX_Button::getLabel() { return _label; } void Adafruit_GFX_Button::setEnabled(bool enable, uint16_t fillColor) { _enabled = enable; _fillcolor = fillColor; + currstate = (enable? currstate: false); drawButton(); } From 43d71e63d80dcde02f0f494c7eb206a9fbd71595 Mon Sep 17 00:00:00 2001 From: ildus hakov Date: Thu, 26 Oct 2023 19:14:02 -0400 Subject: [PATCH 12/16] clang1 --- Adafruit_GFX.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Adafruit_GFX.cpp b/Adafruit_GFX.cpp index cb26376a..51bc5f65 100644 --- a/Adafruit_GFX.cpp +++ b/Adafruit_GFX.cpp @@ -1750,11 +1750,11 @@ char *Adafruit_GFX_Button::getLabel() { return _label; } @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(); +void Adafruit_GFX_Button::setEnabled(bool enable, uint16_t fillColor) { + _enabled = enable; + _fillcolor = fillColor; + currstate = (enable? currstate: false); + drawButton(); } // ------------------------------------------------------------------------- From 6573d34ac181d97ab475c5cc65e2588937a686bc Mon Sep 17 00:00:00 2001 From: ildus hakov Date: Thu, 26 Oct 2023 19:22:38 -0400 Subject: [PATCH 13/16] clang2 --- Adafruit_GFX.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Adafruit_GFX.cpp b/Adafruit_GFX.cpp index 51bc5f65..77dc38ba 100644 --- a/Adafruit_GFX.cpp +++ b/Adafruit_GFX.cpp @@ -1753,7 +1753,7 @@ char *Adafruit_GFX_Button::getLabel() { return _label; } void Adafruit_GFX_Button::setEnabled(bool enable, uint16_t fillColor) { _enabled = enable; _fillcolor = fillColor; - currstate = (enable? currstate: false); + currstate = (enable ? currstate : false); drawButton(); } From 77acfbb198947270529f931fa28d3279f99124ea Mon Sep 17 00:00:00 2001 From: ildus hakov Date: Thu, 26 Oct 2023 19:39:35 -0400 Subject: [PATCH 14/16] clang3 --- Adafruit_GFX.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Adafruit_GFX.cpp b/Adafruit_GFX.cpp index 77dc38ba..6fe32701 100644 --- a/Adafruit_GFX.cpp +++ b/Adafruit_GFX.cpp @@ -1729,7 +1729,7 @@ bool Adafruit_GFX_Button::justReleased() { return (!currstate && laststate); } /**************************************************************************/ /*! @brief Set label to button object. - @param label char pointer to new button label + @param label char pointer to new button label */ void Adafruit_GFX_Button::setLabel(char *label) { strncpy(_label, label, 9); @@ -1745,9 +1745,9 @@ char *Adafruit_GFX_Button::getLabel() { return _label; } /**********************************************************************/ /*! - @brief Set the button to enable/disable + @brief Set the button to enable/disable @param enable boolean true to enable, false to disable - @param fillColor uint16_t set button fillColor + @param fillColor uint16_t set button fillColor */ /**********************************************************************/ void Adafruit_GFX_Button::setEnabled(bool enable, uint16_t fillColor) { From dc2d52eb8db06bf997b81d4548a6d08d00fda008 Mon Sep 17 00:00:00 2001 From: ildus hakov Date: Thu, 26 Oct 2023 19:52:40 -0400 Subject: [PATCH 15/16] clang4 --- Adafruit_GFX.cpp | 2 +- Adafruit_GFX.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Adafruit_GFX.cpp b/Adafruit_GFX.cpp index 6fe32701..7ed6bdf6 100644 --- a/Adafruit_GFX.cpp +++ b/Adafruit_GFX.cpp @@ -1742,7 +1742,7 @@ void Adafruit_GFX_Button::setLabel(char *label) { @return button label char pointer */ char *Adafruit_GFX_Button::getLabel() { return _label; } - + /**********************************************************************/ /*! @brief Set the button to enable/disable diff --git a/Adafruit_GFX.h b/Adafruit_GFX.h index 2d303b66..5867cc7a 100644 --- a/Adafruit_GFX.h +++ b/Adafruit_GFX.h @@ -294,18 +294,18 @@ class Adafruit_GFX_Button { @returns True if pressed */ /**********************************************************************/ - bool isPressed(void) { return currstate; }; - - /**********************************************************************/ - /*! + 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 From 6da3d76da53d698a09b2b92b1b66d6b7a471585e Mon Sep 17 00:00:00 2001 From: ildus hakov Date: Thu, 26 Oct 2023 20:02:09 -0400 Subject: [PATCH 16/16] clang5 --- Adafruit_GFX.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Adafruit_GFX.h b/Adafruit_GFX.h index 5867cc7a..bb5ca204 100644 --- a/Adafruit_GFX.h +++ b/Adafruit_GFX.h @@ -296,11 +296,11 @@ class Adafruit_GFX_Button { /**********************************************************************/ bool isPressed(void) { return currstate; }; -/**********************************************************************/ -/*! + /**********************************************************************/ + /*! @brief Check whether the button is enabled @returns True if enabled -*/ + */ /**********************************************************************/ bool isEnabled(void) { return _enabled; }