2012-03-12 20:32:18 -04:00
|
|
|
#ifndef _ADAFRUIT_GFX_H
|
|
|
|
#define _ADAFRUIT_GFX_H
|
|
|
|
|
|
|
|
#if ARDUINO >= 100
|
2019-12-27 17:10:08 -05:00
|
|
|
#include "Arduino.h"
|
|
|
|
#include "Print.h"
|
2012-03-12 20:32:18 -04:00
|
|
|
#else
|
2019-12-27 17:10:08 -05:00
|
|
|
#include "WProgram.h"
|
2012-03-12 20:32:18 -04:00
|
|
|
#endif
|
2015-12-22 15:02:43 -05:00
|
|
|
#include "gfxfont.h"
|
2015-11-24 00:06:48 -05:00
|
|
|
|
2022-06-07 11:38:02 -04:00
|
|
|
#include <Adafruit_I2CDevice.h>
|
|
|
|
#include <Adafruit_SPIDevice.h>
|
|
|
|
|
2019-12-27 17:10:08 -05:00
|
|
|
/// A generic graphics superclass that can handle all sorts of drawing. At a
|
|
|
|
/// minimum you can subclass and provide drawPixel(). At a maximum you can do a
|
|
|
|
/// ton of overriding to optimize. Used for any/all Adafruit displays!
|
2012-03-16 14:25:07 -04:00
|
|
|
class Adafruit_GFX : public Print {
|
|
|
|
|
2019-12-27 17:10:08 -05:00
|
|
|
public:
|
2013-07-05 14:37:02 -04:00
|
|
|
Adafruit_GFX(int16_t w, int16_t h); // Constructor
|
2012-03-12 20:32:18 -04:00
|
|
|
|
2020-05-13 19:02:32 -04:00
|
|
|
/**********************************************************************/
|
|
|
|
/*!
|
|
|
|
@brief Draw to the screen/framebuffer/etc.
|
|
|
|
Must be overridden in subclass.
|
|
|
|
@param x X coordinate in pixels
|
|
|
|
@param y Y coordinate in pixels
|
|
|
|
@param color 16-bit pixel color.
|
|
|
|
*/
|
|
|
|
/**********************************************************************/
|
|
|
|
virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
|
2012-03-12 20:32:18 -04:00
|
|
|
|
2017-02-22 20:11:09 -05:00
|
|
|
// TRANSACTION API / CORE DRAW API
|
|
|
|
// These MAY be overridden by the subclass to provide device-specific
|
|
|
|
// optimized code. Otherwise 'generic' versions are used.
|
|
|
|
virtual void startWrite(void);
|
|
|
|
virtual void writePixel(int16_t x, int16_t y, uint16_t color);
|
2019-12-27 17:10:08 -05:00
|
|
|
virtual void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
|
|
|
uint16_t color);
|
2017-02-22 20:11:09 -05:00
|
|
|
virtual void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
|
|
|
virtual void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
2019-12-27 17:10:08 -05:00
|
|
|
virtual void writeLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
|
|
|
|
uint16_t color);
|
2017-02-22 20:11:09 -05:00
|
|
|
virtual void endWrite(void);
|
|
|
|
|
|
|
|
// CONTROL API
|
|
|
|
// These MAY be overridden by the subclass to provide device-specific
|
|
|
|
// optimized code. Otherwise 'generic' versions are used.
|
|
|
|
virtual void setRotation(uint8_t r);
|
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
|
|
|
virtual void invertDisplay(bool i);
|
2017-02-22 20:11:09 -05:00
|
|
|
|
|
|
|
// BASIC DRAW API
|
2013-07-05 14:37:02 -04:00
|
|
|
// These MAY be overridden by the subclass to provide device-specific
|
|
|
|
// optimized code. Otherwise 'generic' versions are used.
|
2020-05-13 19:02:32 -04:00
|
|
|
|
2019-12-27 17:10:08 -05:00
|
|
|
// It's good to implement those, even if using transaction API
|
2020-05-13 19:02:32 -04:00
|
|
|
virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
|
|
|
virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
|
|
|
virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
|
|
|
uint16_t color);
|
|
|
|
virtual void fillScreen(uint16_t color);
|
|
|
|
// Optional and probably not necessary to change
|
|
|
|
virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
|
|
|
|
uint16_t color);
|
|
|
|
virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
|
|
|
uint16_t color);
|
2012-04-09 23:46:33 -04:00
|
|
|
|
2013-07-05 14:37:02 -04:00
|
|
|
// These exist only with Adafruit_GFX (no subclass overrides)
|
2020-05-13 19:02:32 -04:00
|
|
|
void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
|
|
|
|
void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,
|
|
|
|
uint16_t color);
|
|
|
|
void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
|
|
|
|
void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,
|
|
|
|
int16_t delta, uint16_t color);
|
|
|
|
void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2,
|
|
|
|
int16_t y2, uint16_t color);
|
|
|
|
void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2,
|
|
|
|
int16_t y2, uint16_t color);
|
|
|
|
void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
|
|
|
|
int16_t radius, uint16_t color);
|
|
|
|
void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
|
|
|
|
int16_t radius, uint16_t color);
|
|
|
|
void drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[], int16_t w,
|
|
|
|
int16_t h, uint16_t color);
|
|
|
|
void drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[], int16_t w,
|
|
|
|
int16_t h, uint16_t color, uint16_t bg);
|
|
|
|
void drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h,
|
|
|
|
uint16_t color);
|
|
|
|
void drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h,
|
|
|
|
uint16_t color, uint16_t bg);
|
|
|
|
void drawXBitmap(int16_t x, int16_t y, const uint8_t bitmap[], int16_t w,
|
|
|
|
int16_t h, uint16_t color);
|
|
|
|
void drawGrayscaleBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
|
|
|
|
int16_t w, int16_t h);
|
|
|
|
void drawGrayscaleBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w,
|
|
|
|
int16_t h);
|
|
|
|
void drawGrayscaleBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
|
|
|
|
const uint8_t mask[], int16_t w, int16_t h);
|
|
|
|
void drawGrayscaleBitmap(int16_t x, int16_t y, uint8_t *bitmap, uint8_t *mask,
|
|
|
|
int16_t w, int16_t h);
|
|
|
|
void drawRGBBitmap(int16_t x, int16_t y, const uint16_t bitmap[], int16_t w,
|
|
|
|
int16_t h);
|
|
|
|
void drawRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap, int16_t w,
|
|
|
|
int16_t h);
|
|
|
|
void drawRGBBitmap(int16_t x, int16_t y, const uint16_t bitmap[],
|
|
|
|
const uint8_t mask[], int16_t w, int16_t h);
|
|
|
|
void drawRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap, uint8_t *mask,
|
|
|
|
int16_t w, int16_t h);
|
|
|
|
void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,
|
|
|
|
uint16_t bg, uint8_t size);
|
|
|
|
void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,
|
|
|
|
uint16_t bg, uint8_t size_x, uint8_t size_y);
|
|
|
|
void getTextBounds(const char *string, int16_t x, int16_t y, int16_t *x1,
|
|
|
|
int16_t *y1, uint16_t *w, uint16_t *h);
|
|
|
|
void getTextBounds(const __FlashStringHelper *s, int16_t x, int16_t y,
|
|
|
|
int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h);
|
|
|
|
void getTextBounds(const String &str, int16_t x, int16_t y, int16_t *x1,
|
|
|
|
int16_t *y1, uint16_t *w, uint16_t *h);
|
|
|
|
void setTextSize(uint8_t s);
|
|
|
|
void setTextSize(uint8_t sx, uint8_t sy);
|
|
|
|
void setFont(const GFXfont *f = NULL);
|
2019-05-29 23:33:31 -04:00
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
/*!
|
|
|
|
@brief Set text cursor location
|
|
|
|
@param x X coordinate in pixels
|
|
|
|
@param y Y coordinate in pixels
|
|
|
|
*/
|
|
|
|
/**********************************************************************/
|
2019-12-27 17:10:08 -05:00
|
|
|
void setCursor(int16_t x, int16_t y) {
|
|
|
|
cursor_x = x;
|
|
|
|
cursor_y = y;
|
|
|
|
}
|
2019-05-29 23:33:31 -04:00
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
/*!
|
|
|
|
@brief Set text font color with transparant background
|
|
|
|
@param c 16-bit 5-6-5 Color to draw text with
|
|
|
|
@note For 'transparent' background, background and foreground
|
|
|
|
are set to same color rather than using a separate flag.
|
|
|
|
*/
|
|
|
|
/**********************************************************************/
|
|
|
|
void setTextColor(uint16_t c) { textcolor = textbgcolor = c; }
|
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
/*!
|
|
|
|
@brief Set text font color with custom background color
|
|
|
|
@param c 16-bit 5-6-5 Color to draw text with
|
2019-05-29 23:42:31 -04:00
|
|
|
@param bg 16-bit 5-6-5 Color to draw background/fill with
|
2019-05-29 23:33:31 -04:00
|
|
|
*/
|
|
|
|
/**********************************************************************/
|
|
|
|
void setTextColor(uint16_t c, uint16_t bg) {
|
2019-12-27 17:10:08 -05:00
|
|
|
textcolor = c;
|
2019-05-29 23:33:31 -04:00
|
|
|
textbgcolor = bg;
|
|
|
|
}
|
2012-04-09 23:46:33 -04:00
|
|
|
|
2019-05-29 23:33:31 -04:00
|
|
|
/**********************************************************************/
|
|
|
|
/*!
|
|
|
|
@brief Set whether text that is too long for the screen width should
|
|
|
|
automatically wrap around to the next line (else clip right).
|
|
|
|
@param w true for wrapping, false for clipping
|
|
|
|
*/
|
|
|
|
/**********************************************************************/
|
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
|
|
|
void setTextWrap(bool w) { wrap = w; }
|
2019-05-29 23:33:31 -04:00
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
/*!
|
|
|
|
@brief Enable (or disable) Code Page 437-compatible charset.
|
|
|
|
There was an error in glcdfont.c for the longest time -- one
|
|
|
|
character (#176, the 'light shade' block) was missing -- this
|
|
|
|
threw off the index of every character that followed it.
|
|
|
|
But a TON of code has been written with the erroneous
|
|
|
|
character indices. By default, the library uses the original
|
|
|
|
'wrong' behavior and old sketches will still work. Pass
|
|
|
|
'true' to this function to use correct CP437 character values
|
|
|
|
in your code.
|
|
|
|
@param x true = enable (new behavior), false = disable (old behavior)
|
|
|
|
*/
|
|
|
|
/**********************************************************************/
|
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
|
|
|
void cp437(bool x = true) { _cp437 = x; }
|
2017-08-26 16:09:12 -04:00
|
|
|
|
2019-12-24 03:12:04 -05:00
|
|
|
using Print::write;
|
2012-03-12 20:32:18 -04:00
|
|
|
#if ARDUINO >= 100
|
|
|
|
virtual size_t write(uint8_t);
|
|
|
|
#else
|
2019-12-27 17:10:08 -05:00
|
|
|
virtual void write(uint8_t);
|
2012-03-12 20:32:18 -04:00
|
|
|
#endif
|
|
|
|
|
2019-05-29 23:33:31 -04:00
|
|
|
/************************************************************************/
|
|
|
|
/*!
|
|
|
|
@brief Get width of the display, accounting for current rotation
|
|
|
|
@returns Width in pixels
|
|
|
|
*/
|
|
|
|
/************************************************************************/
|
|
|
|
int16_t width(void) const { return _width; };
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
/*!
|
|
|
|
@brief Get height of the display, accounting for current rotation
|
|
|
|
@returns Height in pixels
|
|
|
|
*/
|
|
|
|
/************************************************************************/
|
|
|
|
int16_t height(void) const { return _height; }
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
/*!
|
|
|
|
@brief Get rotation setting for display
|
|
|
|
@returns 0 thru 3 corresponding to 4 cardinal rotations
|
|
|
|
*/
|
|
|
|
/************************************************************************/
|
|
|
|
uint8_t getRotation(void) const { return rotation; }
|
2012-03-12 20:32:18 -04:00
|
|
|
|
2019-05-29 23:33:31 -04:00
|
|
|
// get current cursor position (get rotation safe maximum values,
|
|
|
|
// using: width() for x, height() for y)
|
|
|
|
/************************************************************************/
|
|
|
|
/*!
|
|
|
|
@brief Get text cursor X location
|
|
|
|
@returns X coordinate in pixels
|
|
|
|
*/
|
|
|
|
/************************************************************************/
|
|
|
|
int16_t getCursorX(void) const { return cursor_x; }
|
2012-03-12 20:32:18 -04:00
|
|
|
|
2019-05-29 23:33:31 -04:00
|
|
|
/************************************************************************/
|
|
|
|
/*!
|
|
|
|
@brief Get text cursor Y location
|
|
|
|
@returns Y coordinate in pixels
|
|
|
|
*/
|
|
|
|
/************************************************************************/
|
|
|
|
int16_t getCursorY(void) const { return cursor_y; };
|
2012-03-12 20:32:18 -04:00
|
|
|
|
2019-12-27 17:10:08 -05:00
|
|
|
protected:
|
2020-05-17 12:35:25 -04:00
|
|
|
void charBounds(unsigned char c, int16_t *x, int16_t *y, int16_t *minx,
|
|
|
|
int16_t *miny, int16_t *maxx, int16_t *maxy);
|
2020-05-13 19:02:32 -04:00
|
|
|
int16_t WIDTH; ///< This is the 'raw' display width - never changes
|
|
|
|
int16_t HEIGHT; ///< This is the 'raw' display height - never changes
|
|
|
|
int16_t _width; ///< Display width as modified by current rotation
|
|
|
|
int16_t _height; ///< Display height as modified by current rotation
|
|
|
|
int16_t cursor_x; ///< x location to start print()ing text
|
|
|
|
int16_t cursor_y; ///< y location to start print()ing text
|
|
|
|
uint16_t textcolor; ///< 16-bit background color for print()
|
|
|
|
uint16_t textbgcolor; ///< 16-bit text color for print()
|
|
|
|
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)
|
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
|
|
|
bool wrap; ///< If set, 'wrap' text at right edge of display
|
|
|
|
bool _cp437; ///< If set, use correct CP437 charset (default is off)
|
2020-05-13 19:02:32 -04:00
|
|
|
GFXfont *gfxFont; ///< Pointer to special font
|
2012-03-12 20:32:18 -04:00
|
|
|
};
|
|
|
|
|
2018-07-14 15:21:57 -04:00
|
|
|
/// A simple drawn button UI element
|
2015-05-20 13:55:54 -04:00
|
|
|
class Adafruit_GFX_Button {
|
|
|
|
|
2019-12-27 17:10:08 -05:00
|
|
|
public:
|
2015-05-20 13:55:54 -04:00
|
|
|
Adafruit_GFX_Button(void);
|
2017-03-07 13:24:06 -05:00
|
|
|
// "Classic" initButton() uses center & size
|
2019-12-27 17:10:08 -05:00
|
|
|
void initButton(Adafruit_GFX *gfx, int16_t x, int16_t y, uint16_t w,
|
|
|
|
uint16_t h, uint16_t outline, uint16_t fill,
|
|
|
|
uint16_t textcolor, char *label, uint8_t textsize);
|
|
|
|
void initButton(Adafruit_GFX *gfx, int16_t x, int16_t y, uint16_t w,
|
|
|
|
uint16_t h, uint16_t outline, uint16_t fill,
|
|
|
|
uint16_t textcolor, char *label, uint8_t textsize_x,
|
|
|
|
uint8_t textsize_y);
|
2017-03-07 13:24:06 -05:00
|
|
|
// New/alt initButton() uses upper-left corner & size
|
2019-12-27 17:10:08 -05:00
|
|
|
void initButtonUL(Adafruit_GFX *gfx, int16_t x1, int16_t y1, uint16_t w,
|
|
|
|
uint16_t h, uint16_t outline, uint16_t fill,
|
|
|
|
uint16_t textcolor, char *label, uint8_t textsize);
|
|
|
|
void initButtonUL(Adafruit_GFX *gfx, int16_t x1, int16_t y1, uint16_t w,
|
|
|
|
uint16_t h, uint16_t outline, uint16_t fill,
|
|
|
|
uint16_t textcolor, char *label, uint8_t textsize_x,
|
|
|
|
uint8_t textsize_y);
|
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
|
|
|
void drawButton(bool inverted = false);
|
|
|
|
bool contains(int16_t x, int16_t y);
|
2015-05-20 13:55:54 -04:00
|
|
|
|
2019-05-29 23:33:31 -04:00
|
|
|
/**********************************************************************/
|
|
|
|
/*!
|
|
|
|
@brief Sets button state, should be done by some touch function
|
|
|
|
@param p True for pressed, false for not.
|
|
|
|
*/
|
|
|
|
/**********************************************************************/
|
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
|
|
|
void press(bool p) {
|
2019-12-27 17:10:08 -05:00
|
|
|
laststate = currstate;
|
|
|
|
currstate = p;
|
|
|
|
}
|
2019-05-29 23:33:31 -04:00
|
|
|
|
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
|
|
|
bool justPressed();
|
|
|
|
bool justReleased();
|
2015-05-20 13:55:54 -04:00
|
|
|
|
2019-05-29 23:33:31 -04:00
|
|
|
/**********************************************************************/
|
|
|
|
/*!
|
|
|
|
@brief Query whether the button is currently pressed
|
|
|
|
@returns True if pressed
|
|
|
|
*/
|
|
|
|
/**********************************************************************/
|
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
|
|
|
bool isPressed(void) { return currstate; };
|
2019-05-29 23:33:31 -04:00
|
|
|
|
2019-12-27 17:10:08 -05:00
|
|
|
private:
|
2015-05-20 13:55:54 -04:00
|
|
|
Adafruit_GFX *_gfx;
|
2019-12-27 17:10:08 -05:00
|
|
|
int16_t _x1, _y1; // Coordinates of top-left corner
|
|
|
|
uint16_t _w, _h;
|
|
|
|
uint8_t _textsize_x;
|
|
|
|
uint8_t _textsize_y;
|
|
|
|
uint16_t _outlinecolor, _fillcolor, _textcolor;
|
|
|
|
char _label[10];
|
2015-05-20 13:55:54 -04:00
|
|
|
|
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
|
|
|
bool currstate, laststate;
|
2015-05-20 13:55:54 -04:00
|
|
|
};
|
|
|
|
|
2018-07-14 15:21:57 -04:00
|
|
|
/// A GFX 1-bit canvas context for graphics
|
2015-12-28 13:58:40 -05:00
|
|
|
class GFXcanvas1 : public Adafruit_GFX {
|
2019-12-27 17:10:08 -05:00
|
|
|
public:
|
2015-12-28 13:58:40 -05:00
|
|
|
GFXcanvas1(uint16_t w, uint16_t h);
|
|
|
|
~GFXcanvas1(void);
|
2020-05-13 19:02:32 -04:00
|
|
|
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
|
|
|
void fillScreen(uint16_t color);
|
2020-08-19 01:25:19 -04:00
|
|
|
void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
|
|
|
void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
2019-07-13 23:21:37 -04:00
|
|
|
bool getPixel(int16_t x, int16_t y) const;
|
2019-05-29 23:33:31 -04:00
|
|
|
/**********************************************************************/
|
|
|
|
/*!
|
|
|
|
@brief Get a pointer to the internal buffer memory
|
|
|
|
@returns A pointer to the allocated buffer
|
|
|
|
*/
|
|
|
|
/**********************************************************************/
|
|
|
|
uint8_t *getBuffer(void) const { return buffer; }
|
2019-12-27 17:10:08 -05:00
|
|
|
|
2019-07-13 23:21:37 -04:00
|
|
|
protected:
|
|
|
|
bool getRawPixel(int16_t x, int16_t y) const;
|
2020-08-19 01:25:19 -04:00
|
|
|
void drawFastRawVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
|
|
|
void drawFastRawHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
2023-01-16 18:18:35 -05:00
|
|
|
uint8_t *buffer; ///< Raster data: no longer private, allow subclass access
|
2020-06-05 14:00:20 -04:00
|
|
|
|
2019-12-27 17:10:08 -05:00
|
|
|
private:
|
2019-07-13 23:21:37 -04:00
|
|
|
#ifdef __AVR__
|
|
|
|
// Bitmask tables of 0x80>>X and ~(0x80>>X), because X>>Y is slow on AVR
|
|
|
|
static const uint8_t PROGMEM GFXsetBit[], GFXclrBit[];
|
|
|
|
#endif
|
2017-05-05 01:06:09 -04:00
|
|
|
};
|
|
|
|
|
2018-07-14 15:21:57 -04:00
|
|
|
/// A GFX 8-bit canvas context for graphics
|
2017-05-05 01:06:09 -04:00
|
|
|
class GFXcanvas8 : public Adafruit_GFX {
|
2019-12-27 17:10:08 -05:00
|
|
|
public:
|
2017-05-05 01:06:09 -04:00
|
|
|
GFXcanvas8(uint16_t w, uint16_t h);
|
|
|
|
~GFXcanvas8(void);
|
2020-05-13 19:02:32 -04:00
|
|
|
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
|
|
|
void fillScreen(uint16_t color);
|
2020-08-19 01:25:19 -04:00
|
|
|
void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
|
|
|
void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
2019-07-13 23:21:37 -04:00
|
|
|
uint8_t getPixel(int16_t x, int16_t y) const;
|
2019-05-29 23:33:31 -04:00
|
|
|
/**********************************************************************/
|
|
|
|
/*!
|
|
|
|
@brief Get a pointer to the internal buffer memory
|
|
|
|
@returns A pointer to the allocated buffer
|
|
|
|
*/
|
|
|
|
/**********************************************************************/
|
|
|
|
uint8_t *getBuffer(void) const { return buffer; }
|
2019-12-27 17:10:08 -05:00
|
|
|
|
2019-07-13 23:21:37 -04:00
|
|
|
protected:
|
|
|
|
uint8_t getRawPixel(int16_t x, int16_t y) const;
|
2020-08-19 01:25:19 -04:00
|
|
|
void drawFastRawVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
|
|
|
void drawFastRawHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
2023-01-16 18:18:35 -05:00
|
|
|
uint8_t *buffer; ///< Raster data: no longer private, allow subclass access
|
2015-12-28 13:58:40 -05:00
|
|
|
};
|
|
|
|
|
2018-07-14 15:21:57 -04:00
|
|
|
/// A GFX 16-bit canvas context for graphics
|
2015-12-28 13:58:40 -05:00
|
|
|
class GFXcanvas16 : public Adafruit_GFX {
|
2019-12-27 17:10:08 -05:00
|
|
|
public:
|
2015-12-28 13:58:40 -05:00
|
|
|
GFXcanvas16(uint16_t w, uint16_t h);
|
|
|
|
~GFXcanvas16(void);
|
2020-05-13 19:02:32 -04:00
|
|
|
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
|
|
|
void fillScreen(uint16_t color);
|
|
|
|
void byteSwap(void);
|
2020-08-19 01:25:19 -04:00
|
|
|
void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
|
|
|
void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
2020-06-05 14:00:20 -04:00
|
|
|
uint16_t getPixel(int16_t x, int16_t y) const;
|
2019-05-29 23:33:31 -04:00
|
|
|
/**********************************************************************/
|
|
|
|
/*!
|
|
|
|
@brief Get a pointer to the internal buffer memory
|
|
|
|
@returns A pointer to the allocated buffer
|
|
|
|
*/
|
|
|
|
/**********************************************************************/
|
|
|
|
uint16_t *getBuffer(void) const { return buffer; }
|
2019-12-27 17:10:08 -05:00
|
|
|
|
2019-07-13 23:21:37 -04:00
|
|
|
protected:
|
2020-06-05 14:00:20 -04:00
|
|
|
uint16_t getRawPixel(int16_t x, int16_t y) const;
|
2020-08-19 01:25:19 -04:00
|
|
|
void drawFastRawVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
|
|
|
void drawFastRawHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
2023-01-16 18:18:35 -05:00
|
|
|
uint16_t *buffer; ///< Raster data: no longer private, allow subclass access
|
2015-12-28 13:58:40 -05:00
|
|
|
};
|
|
|
|
|
2013-07-05 14:37:02 -04:00
|
|
|
#endif // _ADAFRUIT_GFX_H
|