drawCircleHelper and fillCircleHelper wrote pixels without startWrite,
so direct calls drew nothing on SPI displays (#437). They now open
their own write, and fillCircle, drawRoundRect and fillRoundRect close
theirs first so writes never nest.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
yield() panics when drawing from a timer or Ticker callback (#285).
optimistic_yield(10000) still yields on long draws so the watchdog
stays fed, and does nothing where yielding is not allowed.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
If malloc fails in a GFXcanvas1/8/16 constructor, buffer is NULL and
fillRect, lines and text write through it and crash the board. Set the
canvas size to 0x0 instead so every draw call clips out, and sketches
can check width()/height() or getBuffer().
Based on #441 by @aremmell and the 0x0 idea from @jepler.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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>
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
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>
* 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
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.
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
* 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); }
// -------------------------------------------------------------------------
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.