Commit Graph
115 Commits
Author SHA1 Message Date
Mikey Sklar 4a57ac5e9e Merge pull request #454 from gilesp1729/master
Make Adafruit_GFX_Button::drawButton work with custom fonts by using …
2026-10-15 14:14:55 -07:00
Mikey Sklar e21f500c28 Merge pull request #493 from bobmoss/fix-fillellipse-function
Modified fillEllipse to use writeFastHLine instead of drawFastHLine
2026-10-15 14:14:45 -07:00
Mikey Sklar 15ca7a42b0 Merge pull request #513 from 94xhn/fix/button-uninitialized-state
fix(GFX_Button): initialize currstate/laststate
2026-10-15 14:14:36 -07:00
Mikey SklarandClaude Opus 5.5 a0f92f1f27 Measure button label at (0,0) and keep charBounds non-virtual
Measuring at the button position predicts a line wrap that print()
never does, so a wide label on a button near the right edge moved
off its button. Measure at (0,0) and offset by the returned x/y.

The charBounds virtual change is unrelated to this fix, so it is
dropped.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-15 08:11:04 -07:00
94xhn 43e293c138 Preserve wide custom-font ranges on big-endian targets
GFXfont stores first and last as uint16_t, but the custom-font paths read them as bytes. Use word-width reads while retaining the existing 8-bit character API, so the stored range is interpreted correctly without changing the font format or adding UTF-8 behavior.

Constraint: Keep the public 8-bit character API and limit the patch to issue #490\nRejected: UTF-8/API refactor | broader scope is outside the reported portability bug\nConfidence: high\nScope-risk: narrow\nReversibility: clean\nDirective: Keep GFXfont first/last accesses word-width when reading the stored range\nTested: MinGW GCC 8 -Wall -Wextra -Werror with an endian-aware host fixture; WSL GCC AddressSanitizer and UBSan; baseline fixture fails with 0x0 bounds while the fix passes with 5x7\nNot-tested: Physical Arduino board hardware
2026-07-18 14:13:48 +08:00
94xhn b522b1edba fix(GFX_Button): initialize currstate/laststate
Adafruit_GFX_Button's constructor only initializes _gfx, leaving
currstate/laststate as indeterminate memory. justPressed()/
justReleased() read these before the first press() call, so they can
report a spurious press/release transition on a button that was never
actually touched.

Fixes #401

Signed-off-by: 94xhn <87560781+94xhn@users.noreply.github.com>
2026-07-11 16:35:19 +08:00
BillMerryman c5f9fb14f1 Add drawRotatedRect and fillRotatedRect methods (#508)
* Add drawRotatedRect and fillRotatedRect methods

* Corrected docs
2026-04-01 10:21:37 -04:00
Bob Moss d68f27b7bf Modified fillEllipse to use writeFastHLine instead of drawFastHLine 2025-11-28 11:10:51 +00:00
BillMerryman 20abf158a1 Correct circle method docs (#487) 2025-11-07 14:26:52 -05:00
DS-Aditya-928 4c89798ccd Optimise fillEllipse function. ~36% faster (#478)
* Optimised fillEllipse function

* Cleaned up code
2025-09-17 12:08:09 -04:00
DS-Aditya-928 32da3d2094 Added drawEllipse and fillEllipse functions (#477)
* Added drawEllipse and fillEllipse functions

* Formatting fixes
2025-09-14 08:28:20 -04:00
Jeff Epler f80daa51c9 GFXcanvas: Allow subclass to take charge of buffer allocations (#465)
* GFXcanvas: Allow subclass to take charge of buffer allocations

In Adafruit_dvhstx, the low level driver takes charge of the framebuffer
allocations. Consequently, any allocation by the GFXcanvas class would be
an unused waste of memory.

Introduce a new constructor parameter `bool allocate_buffer=true`. The
default preserves the old behavior of allocating the buffer in the
constructor and freeing it in the destructor, while passing in `false`
skips buffer allocation & freeing.

In this case, the subclass must allocate the buffer before the first
drawing operation (such as in its constructor or begin method), and
free it in its own destructor or end method.

The subclass can also freely change the buffer pointer at runtime, for
instance in a swap method if the underlying framebuffer is double-buffered.

* experimentally run a different clang-format

This runs version 19.1.7: uvx clang-format -i *.cpp *.h

the changes look similar to what was shown during CI

* undo one edit that ci doesn't like
2025-02-19 10:15:01 -05:00
gilesp1729 81764008a4 Reformat a line of code that apparently violated some coding standard. 2024-07-09 20:23:16 +10:00
gilesp1729 4e46790eda Make Adafruit_GFX_Button::drawButton work with custom fonts by using getTextBounds to obtain the text bounds. 2024-07-09 14:58:37 +10:00
Phillip Burgess 5ea4be3ffe Fix bug w/large GFXcanvas1's (use 32-bit byte counts) 2023-01-18 14:53:07 -08:00
Wayne Piekarski c341c18f7a Fixes -Wshadow "error: declaration of 'byte' shadows a global declaration"
Arduino.h defines "typedef uint8_t byte" that conflicts with this declaration
2022-06-22 09:33:21 -07:00
Wayne Piekarski f8e9621bad Fixes -Wshadow "error: declaration of 'buffer' shadows a member of 'GFXcanvas1'"
No need to declare local buffer variable for getBuffer() since it already exists.
2022-06-22 09:32:00 -07:00
Melissa LeBlanc-Williams 605ea88e40 Revert "Speed up internal font drawing for opaque background color" 2022-03-16 11:51:38 -07:00
Laurence Bank 77d05f5ab5 Attempt to fix doxygen errors 2022-03-09 11:52:32 +00:00
Laurence Bank c035859fcc ran clang-format 2022-03-09 11:19:00 +00:00
Laurence Bank a8f1bd54bb missed removing one more #ifdef 2022-03-08 17:28:04 +00:00
Laurence Bank 8bab5dba75 revered AVR exclusions 2022-03-08 17:18:26 +00:00
Laurence Bank 99c324d33e second attempt to stop AVR build from messing things up for everyone else 2022-03-08 15:55:52 +00:00
Laurence Bank 14fd8ab168 disabled change for AVR targets 2022-03-08 15:42:34 +00:00
Laurence Bank 9ac47e8616 Sped up internal font drawing for opaque background color 2022-03-08 14:38:41 +00:00
Phillip Burgess 0b6068e833 clang-format fix 2021-09-06 21:38:47 -07:00
Robert Wolff 7e596016cd Dangerous edge case for non-null-terminated string
strncpy() does not place a null terminator when the max characters is reached of '9' in this case. So, any buttons with 9 or more in the source will wind up with a potentially non-null-terminated _label.
2021-05-07 14:12:16 -07:00
Brian Park 58606c5701 Fix -Wunused-parameter warnings (#328) 2020-12-08 17:37:27 -05:00
KurtE 6c648c6d68 Fix GFXcanvas16::drawFastRawHLine (#326)
This is a quick fix to fix functions like:
```
GFXcanvas16 *canvas = new GFXcanvas16 (240, 320)
canvas -> fillTriangle(0, 0, 239, 0, 120, 310, ILI9341_BLUE)
```
Could all on down to drawFastRawHLine and the
computerd buffer_index > 32767 which is the largest that could be held in int16_t.  So switched to uint32_t also converted the computed value to uint32_t as well as to remove compiler warning.

Removed another compiler warning as well.

This addresses the problem in
#325
2020-11-21 12:11:50 -05:00
Phillip Burgess 1459233d38 clang-format fix 2020-10-19 12:16:15 -07:00
Phillip Burgess f876b1360c Fix clipping in fast H/V lines on canvases 2020-10-19 12:00:55 -07:00
Michael Kamprath c9d7f3cccc added method documentation 2020-08-18 23:05:17 -07:00
Michael Kamprath 18eec8bb9e fixed fast line drawing in GFXcanvas* classes 2020-08-18 22:25:19 -07:00
Melissa LeBlanc-Williams e4fcdba2b2 Merge pull request #237 from michaelkamprath/master
Added support in GFXcanvas* classes to access pixel values
2020-06-16 16:02:58 -07:00
nuxeh e806c84d3f Change boolean to bool (#303)
* Change boolean to bool

This avoids compiler warnings such as:

    In file included from /home/ed/git/dryer-arduino/ui/src/graphicstest.ino:18:
    .pio/libdeps/nucleo_f446re/Adafruit GFX Library_ID13/Adafruit_GFX.h:48:39: warning: 'boolean' is deprecated [-Wdeprecated-declarations]
       48 |   virtual void invertDisplay(boolean i);
          |                                       ^
    In file included from /home/ed/.platformio/packages/framework-arduinoststm32/cores/arduino/wiring.h:34,
                     from /home/ed/.platformio/packages/framework-arduinoststm32/cores/arduino/Arduino.h:32,
                     from /tmp/tmpvslwxjr7:1:
    /home/ed/.platformio/packages/framework-arduinoststm32/cores/arduino/wiring_constants.h:110:14: note: declared here

* Fix clang format issues unrelated to this PR

Addresses the following from CI:

    $ python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
    --- ./Adafruit_GFX.h	(original)
    +++ ./Adafruit_GFX.h	(reformatted)
    @@ -240,8 +240,8 @@
       uint8_t textsize_x;   ///< Desired magnification in X-axis of text to print()
       uint8_t textsize_y;   ///< Desired magnification in Y-axis of text to print()
       uint8_t rotation;     ///< Display rotation (0 thru 3)
    -  bool wrap;         ///< If set, 'wrap' text at right edge of display
    -  bool _cp437;       ///< If set, use correct CP437 charset (default is off)
    +  bool wrap;            ///< If set, 'wrap' text at right edge of display
    +  bool _cp437;          ///< If set, use correct CP437 charset (default is off)
       GFXfont *gfxFont;     ///< Pointer to special font
     };

    --- ./Adafruit_GFX.cpp	(original)
    +++ ./Adafruit_GFX.cpp	(reformatted)
    @@ -1713,9 +1713,7 @@
        @returns  True if was pressed before, now is not.
     */
     /**************************************************************************/
    -bool Adafruit_GFX_Button::justReleased() {
    -  return (!currstate && laststate);
    -}
    +bool Adafruit_GFX_Button::justReleased() { return (!currstate && laststate); }

     // -------------------------------------------------------------------------
2020-06-15 11:20:29 -04:00
Melissa LeBlanc-Williams 8be8308f03 Revert "Optimized drawChar and drawCircleHelper" 2020-06-08 10:05:48 -07:00
Laurence Bank 632cf443a8 Reformatted with clang-format 2020-06-07 12:32:37 -04:00
Laurence Bank e1e51b09e1 pr cleanup 2020-06-07 10:11:36 -04:00
Laurence Bank 1b93789997 Optimized drwChar and drawCircleHelper 2020-06-06 18:51:57 -04:00
Michael Kamprath 6791eaca01 Re-running clang-format after the rebase 2020-06-05 11:00:20 -07:00
Michael Kamprath c53e9d24aa added support in GFXcanvas* classes to access pixel values
Alsp added and example for GFXcanvas that demonstrates the impact of rotation
on pixel layout and also demonstrates getting a pixel based on raw
physical coordinates.
2020-06-05 10:52:32 -07:00
lady ada d2b4b25559 manual implementation of https://github.com/adafruit/Adafruit-GFX-Library/pull/282 2020-05-17 12:35:25 -04:00
Limor "Ladyada" Fried 6abf693056 Actionsci2 (#264)
add library dependancy
remove travis CI
update badge
enable Actions
2019-12-27 17:10:08 -05:00
Melissa LeBlanc-Williams 4a161f1e00 Merge branch 'master' of https://github.com/adafruit/Adafruit-GFX-Library 2019-06-12 14:00:37 -07:00
Melissa LeBlanc-Williams 60e0e6335f Revert "Revert "Text magnification factor can be defined separately for X and for Y axis"" 2019-06-12 13:53:17 -07:00
Melissa LeBlanc-Williams 988f73af04 Revert "Text magnification factor can be defined separately for X and for Y axis" 2019-06-12 13:47:08 -07:00
jonnieZG 098fa70aae Fixed @param argument documentation 2019-06-12 22:11:21 +02:00
jonnieZG 022e8920cc Text magnification factor can be defined separately for X and for Y axis level. It allows you to print "tall" or "wide" text. 2019-06-12 20:31:45 +02:00
Oleksandr Masliuchenko 7c26ed40f5 Fix indentation (tab vs spaces) 2019-06-07 09:21:25 +03:00
Oleksandr Masliuchenko 50c1a22d20 Re-apply warning fix patch 2019-06-07 09:09:30 +03:00