mirror of
https://github.com/adafruit/Adafruit-GFX-Library.git
synced 2024-10-03 18:18:46 -04:00
Merged with master
This commit is contained in:
commit
4fd0d465ad
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
default.vim
|
||||
fontconvert/fontconvert
|
||||
# Our handy .gitignore for automation ease
|
||||
Doxyfile*
|
||||
doxygen_sqlite3.db
|
||||
html
|
26
.travis.yml
Normal file
26
.travis.yml
Normal file
@ -0,0 +1,26 @@
|
||||
language: c
|
||||
sudo: false
|
||||
cache:
|
||||
directories:
|
||||
- ~/arduino_ide
|
||||
- ~/.arduino15/packages/
|
||||
git:
|
||||
depth: false
|
||||
quiet: true
|
||||
env:
|
||||
global:
|
||||
- PRETTYNAME="Adafruit GFX Library"
|
||||
|
||||
before_install:
|
||||
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh)
|
||||
|
||||
install:
|
||||
- arduino --install-library "Adafruit ILI9341"
|
||||
|
||||
script:
|
||||
- build_main_platforms
|
||||
|
||||
# Generate and deploy documentation
|
||||
after_success:
|
||||
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/library_check.sh)
|
||||
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/doxy_gen_and_deploy.sh)
|
1459
Adafruit_GFX.cpp
1459
Adafruit_GFX.cpp
File diff suppressed because it is too large
Load Diff
@ -9,6 +9,7 @@
|
||||
#endif
|
||||
#include "gfxfont.h"
|
||||
|
||||
/// 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!
|
||||
class Adafruit_GFX : public Print {
|
||||
|
||||
public:
|
||||
@ -16,7 +17,7 @@ class Adafruit_GFX : public Print {
|
||||
Adafruit_GFX(int16_t w, int16_t h); // Constructor
|
||||
|
||||
// This MUST be defined by the subclass:
|
||||
virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
|
||||
virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0; ///< Virtual drawPixel() function to draw to the screen/framebuffer/etc, must be overridden in subclass. @param x X coordinate. @param y Y coordinate. @param color 16-bit pixel color.
|
||||
|
||||
// TRANSACTION API / CORE DRAW API
|
||||
// These MAY be overridden by the subclass to provide device-specific
|
||||
@ -64,16 +65,34 @@ class Adafruit_GFX : public Print {
|
||||
int16_t radius, uint16_t color),
|
||||
fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
|
||||
int16_t radius, uint16_t color),
|
||||
drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
|
||||
drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
|
||||
int16_t w, int16_t h, uint16_t color),
|
||||
drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
|
||||
drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
|
||||
int16_t w, int16_t h, uint16_t color, uint16_t bg),
|
||||
drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,
|
||||
int16_t w, int16_t h, uint16_t color),
|
||||
drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,
|
||||
int16_t w, int16_t h, uint16_t color, uint16_t bg),
|
||||
drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
|
||||
drawXBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
|
||||
int16_t w, int16_t h, uint16_t color),
|
||||
drawGrayscaleBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
|
||||
int16_t w, int16_t h),
|
||||
drawGrayscaleBitmap(int16_t x, int16_t y, uint8_t *bitmap,
|
||||
int16_t w, int16_t h),
|
||||
drawGrayscaleBitmap(int16_t x, int16_t y,
|
||||
const uint8_t bitmap[], const uint8_t mask[],
|
||||
int16_t w, int16_t h),
|
||||
drawGrayscaleBitmap(int16_t x, int16_t y,
|
||||
uint8_t *bitmap, uint8_t *mask, int16_t w, int16_t h),
|
||||
drawRGBBitmap(int16_t x, int16_t y, const uint16_t bitmap[],
|
||||
int16_t w, int16_t h),
|
||||
drawRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap,
|
||||
int16_t w, int16_t h),
|
||||
drawRGBBitmap(int16_t x, int16_t y,
|
||||
const uint16_t bitmap[], const uint8_t mask[],
|
||||
int16_t w, int16_t h),
|
||||
drawRGBBitmap(int16_t x, int16_t y,
|
||||
uint16_t *bitmap, uint8_t *mask, int16_t w, int16_t h),
|
||||
drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,
|
||||
uint16_t bg, uint8_t size),
|
||||
setCursor(int16_t x, int16_t y),
|
||||
@ -83,11 +102,14 @@ class Adafruit_GFX : public Print {
|
||||
setTextWrap(boolean w),
|
||||
cp437(boolean x=true),
|
||||
setFont(const GFXfont *f = NULL),
|
||||
getTextBounds(char *string, int16_t x, int16_t y,
|
||||
getTextBounds(const char *string, int16_t x, int16_t y,
|
||||
int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h),
|
||||
getTextBounds(const __FlashStringHelper *s, int16_t x, int16_t y,
|
||||
int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h),
|
||||
getTextBounds(const String &str, int16_t x, int16_t y,
|
||||
int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h);
|
||||
|
||||
|
||||
#if ARDUINO >= 100
|
||||
virtual size_t write(uint8_t);
|
||||
#else
|
||||
@ -104,23 +126,32 @@ class Adafruit_GFX : public Print {
|
||||
int16_t getCursorY(void) const;
|
||||
|
||||
protected:
|
||||
void
|
||||
charBounds(char c, int16_t *x, int16_t *y,
|
||||
int16_t *minx, int16_t *miny, int16_t *maxx, int16_t *maxy);
|
||||
const int16_t
|
||||
WIDTH, HEIGHT; // This is the 'raw' display w/h - never changes
|
||||
WIDTH, ///< This is the 'raw' display width - never changes
|
||||
HEIGHT; ///< This is the 'raw' display height - never changes
|
||||
int16_t
|
||||
_width, _height, // Display w/h as modified by current rotation
|
||||
cursor_x, cursor_y;
|
||||
_width, ///< Display width as modified by current rotation
|
||||
_height, ///< Display height as modified by current rotation
|
||||
cursor_x, ///< x location to start print()ing text
|
||||
cursor_y; ///< y location to start print()ing text
|
||||
uint16_t
|
||||
textcolor, textbgcolor;
|
||||
textcolor, ///< 16-bit background color for print()
|
||||
textbgcolor; ///< 16-bit text color for print()
|
||||
uint8_t
|
||||
textsize,
|
||||
rotation;
|
||||
textsize, ///< Desired magnification of text to print()
|
||||
rotation; ///< Display rotation (0 thru 3)
|
||||
boolean
|
||||
wrap, // If set, 'wrap' text at right edge of display
|
||||
_cp437; // If set, use correct CP437 charset (default is off)
|
||||
wrap, ///< If set, 'wrap' text at right edge of display
|
||||
_cp437; ///< If set, use correct CP437 charset (default is off)
|
||||
GFXfont
|
||||
*gfxFont;
|
||||
*gfxFont; ///< Pointer to special font
|
||||
};
|
||||
|
||||
|
||||
/// A simple drawn button UI element
|
||||
class Adafruit_GFX_Button {
|
||||
|
||||
public:
|
||||
@ -152,8 +183,9 @@ class Adafruit_GFX_Button {
|
||||
boolean currstate, laststate;
|
||||
};
|
||||
|
||||
class GFXcanvas1 : public Adafruit_GFX {
|
||||
|
||||
/// A GFX 1-bit canvas context for graphics
|
||||
class GFXcanvas1 : public Adafruit_GFX {
|
||||
public:
|
||||
GFXcanvas1(uint16_t w, uint16_t h);
|
||||
~GFXcanvas1(void);
|
||||
@ -164,7 +196,25 @@ class GFXcanvas1 : public Adafruit_GFX {
|
||||
uint8_t *buffer;
|
||||
};
|
||||
|
||||
|
||||
/// A GFX 8-bit canvas context for graphics
|
||||
class GFXcanvas8 : public Adafruit_GFX {
|
||||
public:
|
||||
GFXcanvas8(uint16_t w, uint16_t h);
|
||||
~GFXcanvas8(void);
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color),
|
||||
fillScreen(uint16_t color),
|
||||
writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
||||
|
||||
uint8_t *getBuffer(void);
|
||||
private:
|
||||
uint8_t *buffer;
|
||||
};
|
||||
|
||||
|
||||
/// A GFX 16-bit canvas context for graphics
|
||||
class GFXcanvas16 : public Adafruit_GFX {
|
||||
public:
|
||||
GFXcanvas16(uint16_t w, uint16_t h);
|
||||
~GFXcanvas16(void);
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color),
|
||||
|
2190
Adafruit_SPITFT.cpp
Normal file
2190
Adafruit_SPITFT.cpp
Normal file
File diff suppressed because it is too large
Load Diff
499
Adafruit_SPITFT.h
Normal file
499
Adafruit_SPITFT.h
Normal file
@ -0,0 +1,499 @@
|
||||
/*!
|
||||
* @file Adafruit_SPITFT.h
|
||||
*
|
||||
* Part of Adafruit's GFX graphics library. Originally this class was
|
||||
* written to handle a range of color TFT displays connected via SPI,
|
||||
* but over time this library and some display-specific subclasses have
|
||||
* mutated to include some color OLEDs as well as parallel-interfaced
|
||||
* displays. The name's been kept for the sake of older code.
|
||||
*
|
||||
* Adafruit invests time and resources providing this open source code,
|
||||
* please support Adafruit and open-source hardware by purchasing
|
||||
* products from Adafruit!
|
||||
*
|
||||
* Written by Limor "ladyada" Fried for Adafruit Industries,
|
||||
* with contributions from the open source community.
|
||||
*
|
||||
* BSD license, all text here must be included in any redistribution.
|
||||
*/
|
||||
|
||||
#ifndef _ADAFRUIT_SPITFT_H_
|
||||
#define _ADAFRUIT_SPITFT_H_
|
||||
|
||||
#if !defined(__AVR_ATtiny85__) // Not for ATtiny, at all
|
||||
|
||||
#include <SPI.h>
|
||||
#include "Adafruit_GFX.h"
|
||||
|
||||
// HARDWARE CONFIG ---------------------------------------------------------
|
||||
|
||||
#if defined(__AVR__)
|
||||
typedef uint8_t PORT_t; ///< PORT values are 8-bit
|
||||
#define USE_FAST_PINIO ///< Use direct PORT register access
|
||||
#elif defined(ARDUINO_STM32_FEATHER) // WICED
|
||||
typedef class HardwareSPI SPIClass; ///< SPI is a bit odd on WICED
|
||||
typedef uint32_t PORT_t; ///< PORT values are 32-bit
|
||||
#elif defined(__arm__)
|
||||
#if defined(ARDUINO_ARCH_SAMD)
|
||||
// Adafruit M0, M4
|
||||
typedef uint32_t PORT_t; ///< PORT values are 32-bit
|
||||
#define USE_FAST_PINIO ///< Use direct PORT register access
|
||||
#define HAS_PORT_SET_CLR ///< PORTs have set & clear registers
|
||||
#elif defined(CORE_TEENSY)
|
||||
// PJRC Teensy 3.x
|
||||
typedef uint8_t PORT_t; ///< PORT values are 8-bit
|
||||
#define USE_FAST_PINIO ///< Use direct PORT register access
|
||||
#define HAS_PORT_SET_CLR ///< PORTs have set & clear registers
|
||||
#else
|
||||
// Arduino Due?
|
||||
typedef uint32_t PORT_t; ///< PORT values are 32-bit
|
||||
// USE_FAST_PINIO not available here (yet)...Due has a totally different
|
||||
// GPIO register set and will require some changes elsewhere (e.g. in
|
||||
// constructors especially).
|
||||
#endif
|
||||
#else // !ARM
|
||||
// Probably ESP8266 or ESP32. USE_FAST_PINIO is not available here (yet)
|
||||
// but don't worry about it too much...the digitalWrite() implementation
|
||||
// on these platforms is reasonably efficient and already RAM-resident,
|
||||
// only gotcha then is no parallel connection support for now.
|
||||
typedef uint32_t PORT_t; ///< PORT values are 32-bit
|
||||
#endif // end !ARM
|
||||
typedef volatile PORT_t* PORTreg_t; ///< PORT register type
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define DEFAULT_SPI_FREQ 8000000L ///< Hardware SPI default speed
|
||||
#else
|
||||
#define DEFAULT_SPI_FREQ 16000000L ///< Hardware SPI default speed
|
||||
#endif
|
||||
|
||||
#if defined(ADAFRUIT_PYPORTAL)
|
||||
#define USE_SPI_DMA ///< Auto DMA if using PyPortal
|
||||
#else
|
||||
//#define USE_SPI_DMA ///< If set, use DMA if available
|
||||
#endif
|
||||
// Another "oops" name -- this now also handles parallel DMA.
|
||||
// If DMA is enabled, Arduino sketch MUST #include <Adafruit_ZeroDMA.h>
|
||||
// Estimated RAM usage:
|
||||
// 4 bytes/pixel on display major axis + 8 bytes/pixel on minor axis,
|
||||
// e.g. 320x240 pixels = 320 * 4 + 240 * 8 = 3,200 bytes.
|
||||
|
||||
#if !defined(ARDUINO_ARCH_SAMD)
|
||||
#undef USE_SPI_DMA ///< DMA currently for SAMD chips only
|
||||
#endif
|
||||
|
||||
#if defined(USE_SPI_DMA)
|
||||
#pragma message ("GFX DMA IS ENABLED. HIGHLY EXPERIMENTAL.")
|
||||
#include <Adafruit_ZeroDMA.h>
|
||||
#endif
|
||||
|
||||
// This is kind of a kludge. Needed a way to disambiguate the software SPI
|
||||
// and parallel constructors via their argument lists. Originally tried a
|
||||
// bool as the first argument to the parallel constructor (specifying 8-bit
|
||||
// vs 16-bit interface) but the compiler regards this as equivalent to an
|
||||
// integer and thus still ambiguous. SO...the parallel constructor requires
|
||||
// an enumerated type as the first argument: tft8 (for 8-bit parallel) or
|
||||
// tft16 (for 16-bit)...even though 16-bit isn't fully implemented or tested
|
||||
// and might never be, still needed that disambiguation from soft SPI.
|
||||
enum tftBusWidth { tft8bitbus, tft16bitbus }; ///< For first arg to parallel constructor
|
||||
|
||||
// CLASS DEFINITION --------------------------------------------------------
|
||||
|
||||
/*!
|
||||
@brief Adafruit_SPITFT is an intermediary class between Adafruit_GFX
|
||||
and various hardware-specific subclasses for different displays.
|
||||
It handles certain operations that are common to a range of
|
||||
displays (address window, area fills, etc.). Originally these were
|
||||
all color TFT displays interfaced via SPI, but it's since expanded
|
||||
to include color OLEDs and parallel-interfaced TFTs. THE NAME HAS
|
||||
BEEN KEPT TO AVOID BREAKING A LOT OF SUBCLASSES AND EXAMPLE CODE.
|
||||
Many of the class member functions similarly live on with names
|
||||
that don't necessarily accurately describe what they're doing,
|
||||
again to avoid breaking a lot of other code. If in doubt, read
|
||||
the comments.
|
||||
*/
|
||||
class Adafruit_SPITFT : public Adafruit_GFX {
|
||||
|
||||
public:
|
||||
|
||||
// CONSTRUCTORS --------------------------------------------------------
|
||||
|
||||
// Software SPI constructor: expects width & height (at default rotation
|
||||
// setting 0), 4 signal pins (cs, dc, mosi, sclk), 2 optional pins
|
||||
// (reset, miso). cs argument is required but can be -1 if unused --
|
||||
// rather than moving it to the optional arguments, it was done this way
|
||||
// to avoid breaking existing code (-1 option was a later addition).
|
||||
Adafruit_SPITFT(uint16_t w, uint16_t h,
|
||||
int8_t cs, int8_t dc, int8_t mosi, int8_t sck,
|
||||
int8_t rst = -1, int8_t miso = -1);
|
||||
|
||||
// Hardware SPI constructor using the default SPI port: expects width &
|
||||
// height (at default rotation setting 0), 2 signal pins (cs, dc),
|
||||
// optional reset pin. cs is required but can be -1 if unused -- rather
|
||||
// than moving it to the optional arguments, it was done this way to
|
||||
// avoid breaking existing code (-1 option was a later addition).
|
||||
Adafruit_SPITFT(uint16_t w, uint16_t h,
|
||||
int8_t cs, int8_t dc, int8_t rst = -1);
|
||||
|
||||
#if !defined(ESP8266) // See notes in .cpp
|
||||
// Hardware SPI constructor using an arbitrary SPI peripheral: expects
|
||||
// width & height (rotation 0), SPIClass pointer, 2 signal pins (cs, dc)
|
||||
// and optional reset pin. cs is required but can be -1 if unused.
|
||||
Adafruit_SPITFT(uint16_t w, uint16_t h, SPIClass *spiClass,
|
||||
int8_t cs, int8_t dc, int8_t rst = -1);
|
||||
#endif // end !ESP8266
|
||||
|
||||
// Parallel constructor: expects width & height (rotation 0), flag
|
||||
// indicating whether 16-bit (true) or 8-bit (false) interface, 3 signal
|
||||
// pins (d0, wr, dc), 3 optional pins (cs, rst, rd). 16-bit parallel
|
||||
// isn't even fully implemented but the 'wide' flag was added as a
|
||||
// required argument to avoid ambiguity with other constructors.
|
||||
Adafruit_SPITFT(uint16_t w, uint16_t h, tftBusWidth busWidth,
|
||||
int8_t d0, int8_t wr, int8_t dc,
|
||||
int8_t cs = -1, int8_t rst = -1, int8_t rd = -1);
|
||||
|
||||
// CLASS MEMBER FUNCTIONS ----------------------------------------------
|
||||
|
||||
// These first two functions MUST be declared by subclasses:
|
||||
|
||||
/*!
|
||||
@brief Display-specific initialization function.
|
||||
@param freq SPI frequency, in hz (or 0 for default or unused).
|
||||
*/
|
||||
virtual void begin(uint32_t freq) = 0;
|
||||
|
||||
/*!
|
||||
@brief Set up the specific display hardware's "address window"
|
||||
for subsequent pixel-pushing operations.
|
||||
@param x Leftmost pixel of area to be drawn (MUST be within
|
||||
display bounds at current rotation setting).
|
||||
@param y Topmost pixel of area to be drawn (MUST be within
|
||||
display bounds at current rotation setting).
|
||||
@param w Width of area to be drawn, in pixels (MUST be >0 and,
|
||||
added to x, within display bounds at current rotation).
|
||||
@param h Height of area to be drawn, in pixels (MUST be >0 and,
|
||||
added to x, within display bounds at current rotation).
|
||||
*/
|
||||
virtual void setAddrWindow(
|
||||
uint16_t x, uint16_t y, uint16_t w, uint16_t h) = 0;
|
||||
|
||||
// Remaining functions do not need to be declared in subclasses
|
||||
// unless they wish to provide hardware-specific optimizations.
|
||||
// Brief comments here...documented more thoroughly in .cpp file.
|
||||
|
||||
// Subclass' begin() function invokes this to initialize hardware.
|
||||
// Name is outdated (interface may be parallel) but for compatibility:
|
||||
void initSPI(uint32_t freq = 0); // 0 = use default SPI speed
|
||||
// Chip select and/or hardware SPI transaction start as needed:
|
||||
void startWrite(void);
|
||||
// Chip deselect and/or hardware SPI transaction end as needed:
|
||||
void endWrite(void);
|
||||
void sendCommand(uint8_t commandByte, uint8_t *dataBytes = NULL, uint8_t numDataBytes = 0);
|
||||
void sendCommand(uint8_t commandByte, const uint8_t *dataBytes, uint8_t numDataBytes);
|
||||
uint8_t readcommand8(uint8_t commandByte, uint8_t index = 0);
|
||||
|
||||
// These functions require a chip-select and/or SPI transaction
|
||||
// around them. Higher-level graphics primitives might start a
|
||||
// single transaction and then make multiple calls to these functions
|
||||
// (e.g. circle or text rendering might make repeated lines or rects)
|
||||
// before ending the transaction. It's more efficient than starting a
|
||||
// transaction every time.
|
||||
void writePixel(int16_t x, int16_t y, uint16_t color);
|
||||
void writePixels(uint16_t *colors, uint32_t len,
|
||||
bool block=true, bool bigEndian=false);
|
||||
void writeColor(uint16_t color, uint32_t len);
|
||||
void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||
uint16_t color);
|
||||
void writeFastHLine(int16_t x, int16_t y, int16_t w,
|
||||
uint16_t color);
|
||||
void writeFastVLine(int16_t x, int16_t y, int16_t h,
|
||||
uint16_t color);
|
||||
// This is a new function, similar to writeFillRect() except that
|
||||
// all arguments MUST be onscreen, sorted and clipped. If higher-level
|
||||
// primitives can handle their own sorting/clipping, it avoids repeating
|
||||
// such operations in the low-level code, making it potentially faster.
|
||||
// CALLING THIS WITH UNCLIPPED OR NEGATIVE VALUES COULD BE DISASTROUS.
|
||||
inline void writeFillRectPreclipped(int16_t x, int16_t y,
|
||||
int16_t w, int16_t h, uint16_t color);
|
||||
// Another new function, companion to the new non-blocking
|
||||
// writePixels() variant.
|
||||
void dmaWait(void);
|
||||
|
||||
|
||||
// These functions are similar to the 'write' functions above, but with
|
||||
// a chip-select and/or SPI transaction built-in. They're typically used
|
||||
// solo -- that is, as graphics primitives in themselves, not invoked by
|
||||
// higher-level primitives (which should use the functions above).
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
||||
void fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||
uint16_t color);
|
||||
void drawFastHLine(int16_t x, int16_t y, int16_t w,
|
||||
uint16_t color);
|
||||
void drawFastVLine(int16_t x, int16_t y, int16_t h,
|
||||
uint16_t color);
|
||||
// A single-pixel push encapsulated in a transaction. I don't think
|
||||
// this is used anymore (BMP demos might've used it?) but is provided
|
||||
// for backward compatibility, consider it deprecated:
|
||||
void pushColor(uint16_t color);
|
||||
|
||||
using Adafruit_GFX::drawRGBBitmap; // Check base class first
|
||||
void drawRGBBitmap(int16_t x, int16_t y,
|
||||
uint16_t *pcolors, int16_t w, int16_t h);
|
||||
|
||||
void invertDisplay(bool i);
|
||||
uint16_t color565(uint8_t r, uint8_t g, uint8_t b);
|
||||
|
||||
// Despite parallel additions, function names kept for compatibility:
|
||||
void spiWrite(uint8_t b); // Write single byte as DATA
|
||||
void writeCommand(uint8_t cmd); // Write single byte as COMMAND
|
||||
uint8_t spiRead(void); // Read single byte of data
|
||||
|
||||
// Most of these low-level functions were formerly macros in
|
||||
// Adafruit_SPITFT_Macros.h. Some have been made into inline functions
|
||||
// to avoid macro mishaps. Despite the addition of code for a parallel
|
||||
// display interface, the names have been kept for backward
|
||||
// compatibility (some subclasses may be invoking these):
|
||||
void SPI_WRITE16(uint16_t w); // Not inline
|
||||
void SPI_WRITE32(uint32_t l); // Not inline
|
||||
// Old code had both a spiWrite16() function and SPI_WRITE16 macro
|
||||
// in addition to the SPI_WRITE32 macro. The latter two have been
|
||||
// made into functions here, and spiWrite16() removed (use SPI_WRITE16()
|
||||
// instead). It looks like most subclasses had gotten comfortable with
|
||||
// SPI_WRITE16 and SPI_WRITE32 anyway so those names were kept rather
|
||||
// than the less-obnoxious camelcase variants, oh well.
|
||||
|
||||
// Placing these functions entirely in the class definition inlines
|
||||
// them implicitly them while allowing their use in other code:
|
||||
|
||||
/*!
|
||||
@brief Set the chip-select line HIGH. Does NOT check whether CS pin
|
||||
is set (>=0), that should be handled in calling function.
|
||||
Despite function name, this is used even if the display
|
||||
connection is parallel.
|
||||
*/
|
||||
void SPI_CS_HIGH(void) {
|
||||
#if defined(USE_FAST_PINIO)
|
||||
#if defined(HAS_PORT_SET_CLR)
|
||||
#if defined(KINETISK)
|
||||
*csPortSet = 1;
|
||||
#else // !KINETISK
|
||||
*csPortSet = csPinMask;
|
||||
#endif // end !KINETISK
|
||||
#else // !HAS_PORT_SET_CLR
|
||||
*csPort |= csPinMaskSet;
|
||||
#endif // end !HAS_PORT_SET_CLR
|
||||
#else // !USE_FAST_PINIO
|
||||
digitalWrite(_cs, HIGH);
|
||||
#endif // end !USE_FAST_PINIO
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief Set the chip-select line LOW. Does NOT check whether CS pin
|
||||
is set (>=0), that should be handled in calling function.
|
||||
Despite function name, this is used even if the display
|
||||
connection is parallel.
|
||||
*/
|
||||
void SPI_CS_LOW(void) {
|
||||
#if defined(USE_FAST_PINIO)
|
||||
#if defined(HAS_PORT_SET_CLR)
|
||||
#if defined(KINETISK)
|
||||
*csPortClr = 1;
|
||||
#else // !KINETISK
|
||||
*csPortClr = csPinMask;
|
||||
#endif // end !KINETISK
|
||||
#else // !HAS_PORT_SET_CLR
|
||||
*csPort &= csPinMaskClr;
|
||||
#endif // end !HAS_PORT_SET_CLR
|
||||
#else // !USE_FAST_PINIO
|
||||
digitalWrite(_cs, LOW);
|
||||
#endif // end !USE_FAST_PINIO
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief Set the data/command line HIGH (data mode).
|
||||
*/
|
||||
void SPI_DC_HIGH(void) {
|
||||
#if defined(USE_FAST_PINIO)
|
||||
#if defined(HAS_PORT_SET_CLR)
|
||||
#if defined(KINETISK)
|
||||
*dcPortSet = 1;
|
||||
#else // !KINETISK
|
||||
*dcPortSet = dcPinMask;
|
||||
#endif // end !KINETISK
|
||||
#else // !HAS_PORT_SET_CLR
|
||||
*dcPort |= dcPinMaskSet;
|
||||
#endif // end !HAS_PORT_SET_CLR
|
||||
#else // !USE_FAST_PINIO
|
||||
digitalWrite(_dc, HIGH);
|
||||
#endif // end !USE_FAST_PINIO
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief Set the data/command line LOW (command mode).
|
||||
*/
|
||||
void SPI_DC_LOW(void) {
|
||||
#if defined(USE_FAST_PINIO)
|
||||
#if defined(HAS_PORT_SET_CLR)
|
||||
#if defined(KINETISK)
|
||||
*dcPortClr = 1;
|
||||
#else // !KINETISK
|
||||
*dcPortClr = dcPinMask;
|
||||
#endif // end !KINETISK
|
||||
#else // !HAS_PORT_SET_CLR
|
||||
*dcPort &= dcPinMaskClr;
|
||||
#endif // end !HAS_PORT_SET_CLR
|
||||
#else // !USE_FAST_PINIO
|
||||
digitalWrite(_dc, LOW);
|
||||
#endif // end !USE_FAST_PINIO
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
// A few more low-level member functions -- some may have previously
|
||||
// been macros. Shouldn't have a need to access these externally, so
|
||||
// they've been moved to the protected section. Additionally, they're
|
||||
// declared inline here and the code is in the .cpp file, since outside
|
||||
// code doesn't need to see these.
|
||||
inline void SPI_MOSI_HIGH(void);
|
||||
inline void SPI_MOSI_LOW(void);
|
||||
inline void SPI_SCK_HIGH(void);
|
||||
inline void SPI_SCK_LOW(void);
|
||||
inline bool SPI_MISO_READ(void);
|
||||
inline void SPI_BEGIN_TRANSACTION(void);
|
||||
inline void SPI_END_TRANSACTION(void);
|
||||
inline void TFT_WR_STROBE(void); // Parallel interface write strobe
|
||||
inline void TFT_RD_HIGH(void); // Parallel interface read high
|
||||
inline void TFT_RD_LOW(void); // Parallel interface read low
|
||||
|
||||
// CLASS INSTANCE VARIABLES --------------------------------------------
|
||||
|
||||
// Here be dragons! There's a big union of three structures here --
|
||||
// one each for hardware SPI, software (bitbang) SPI, and parallel
|
||||
// interfaces. This is to save some memory, since a display's connection
|
||||
// will be only one of these. The order of some things is a little weird
|
||||
// in an attempt to get values to align and pack better in RAM.
|
||||
|
||||
#if defined(USE_FAST_PINIO)
|
||||
#if defined(HAS_PORT_SET_CLR)
|
||||
PORTreg_t csPortSet; ///< PORT register for chip select SET
|
||||
PORTreg_t csPortClr; ///< PORT register for chip select CLEAR
|
||||
PORTreg_t dcPortSet; ///< PORT register for data/command SET
|
||||
PORTreg_t dcPortClr; ///< PORT register for data/command CLEAR
|
||||
#else // !HAS_PORT_SET_CLR
|
||||
PORTreg_t csPort; ///< PORT register for chip select
|
||||
PORTreg_t dcPort; ///< PORT register for data/command
|
||||
#endif // end HAS_PORT_SET_CLR
|
||||
#endif // end USE_FAST_PINIO
|
||||
#if defined(__cplusplus) && (__cplusplus >= 201100)
|
||||
union {
|
||||
#endif
|
||||
struct { // Values specific to HARDWARE SPI:
|
||||
SPIClass *_spi; ///< SPI class pointer
|
||||
#if defined(SPI_HAS_TRANSACTION)
|
||||
SPISettings settings; ///< SPI transaction settings
|
||||
#else
|
||||
uint32_t _freq; ///< SPI bitrate (if no SPI transactions)
|
||||
#endif
|
||||
} hwspi; ///< Hardware SPI values
|
||||
struct { // Values specific to SOFTWARE SPI:
|
||||
#if defined(USE_FAST_PINIO)
|
||||
PORTreg_t misoPort; ///< PORT (PIN) register for MISO
|
||||
#if defined(HAS_PORT_SET_CLR)
|
||||
PORTreg_t mosiPortSet; ///< PORT register for MOSI SET
|
||||
PORTreg_t mosiPortClr; ///< PORT register for MOSI CLEAR
|
||||
PORTreg_t sckPortSet; ///< PORT register for SCK SET
|
||||
PORTreg_t sckPortClr; ///< PORT register for SCK CLEAR
|
||||
#if !defined(KINETISK)
|
||||
PORT_t mosiPinMask; ///< Bitmask for MOSI
|
||||
PORT_t sckPinMask; ///< Bitmask for SCK
|
||||
#endif // end !KINETISK
|
||||
#else // !HAS_PORT_SET_CLR
|
||||
PORTreg_t mosiPort; ///< PORT register for MOSI
|
||||
PORTreg_t sckPort; ///< PORT register for SCK
|
||||
PORT_t mosiPinMaskSet; ///< Bitmask for MOSI SET (OR)
|
||||
PORT_t mosiPinMaskClr; ///< Bitmask for MOSI CLEAR (AND)
|
||||
PORT_t sckPinMaskSet; ///< Bitmask for SCK SET (OR bitmask)
|
||||
PORT_t sckPinMaskClr; ///< Bitmask for SCK CLEAR (AND)
|
||||
#endif // end HAS_PORT_SET_CLR
|
||||
#if !defined(KINETISK)
|
||||
PORT_t misoPinMask; ///< Bitmask for MISO
|
||||
#endif // end !KINETISK
|
||||
#endif // end USE_FAST_PINIO
|
||||
int8_t _mosi; ///< MOSI pin #
|
||||
int8_t _miso; ///< MISO pin #
|
||||
int8_t _sck; ///< SCK pin #
|
||||
} swspi; ///< Software SPI values
|
||||
struct { // Values specific to 8-bit parallel:
|
||||
#if defined(USE_FAST_PINIO)
|
||||
volatile uint8_t *writePort; ///< PORT register for DATA WRITE
|
||||
volatile uint8_t *readPort; ///< PORT (PIN) register for DATA READ
|
||||
#if defined(HAS_PORT_SET_CLR)
|
||||
// Port direction register pointers are always 8-bit regardless of
|
||||
// PORTreg_t -- even if 32-bit port, we modify a byte-aligned 8 bits.
|
||||
volatile uint8_t *dirSet; ///< PORT byte data direction SET
|
||||
volatile uint8_t *dirClr; ///< PORT byte data direction CLEAR
|
||||
PORTreg_t wrPortSet; ///< PORT register for write strobe SET
|
||||
PORTreg_t wrPortClr; ///< PORT register for write strobe CLEAR
|
||||
PORTreg_t rdPortSet; ///< PORT register for read strobe SET
|
||||
PORTreg_t rdPortClr; ///< PORT register for read strobe CLEAR
|
||||
#if !defined(KINETISK)
|
||||
PORT_t wrPinMask; ///< Bitmask for write strobe
|
||||
#endif // end !KINETISK
|
||||
PORT_t rdPinMask; ///< Bitmask for read strobe
|
||||
#else // !HAS_PORT_SET_CLR
|
||||
// Port direction register pointer is always 8-bit regardless of
|
||||
// PORTreg_t -- even if 32-bit port, we modify a byte-aligned 8 bits.
|
||||
volatile uint8_t *portDir; ///< PORT direction register
|
||||
PORTreg_t wrPort; ///< PORT register for write strobe
|
||||
PORTreg_t rdPort; ///< PORT register for read strobe
|
||||
PORT_t wrPinMaskSet; ///< Bitmask for write strobe SET (OR)
|
||||
PORT_t wrPinMaskClr; ///< Bitmask for write strobe CLEAR (AND)
|
||||
PORT_t rdPinMaskSet; ///< Bitmask for read strobe SET (OR)
|
||||
PORT_t rdPinMaskClr; ///< Bitmask for read strobe CLEAR (AND)
|
||||
#endif // end HAS_PORT_SET_CLR
|
||||
#endif // end USE_FAST_PINIO
|
||||
int8_t _d0; ///< Data pin 0 #
|
||||
int8_t _wr; ///< Write strobe pin #
|
||||
int8_t _rd; ///< Read strobe pin # (or -1)
|
||||
bool wide = 0; ///< If true, is 16-bit interface
|
||||
} tft8; ///< Parallel interface settings
|
||||
#if defined(__cplusplus) && (__cplusplus >= 201100)
|
||||
}; ///< Only one interface is active
|
||||
#endif
|
||||
#if defined(USE_SPI_DMA) // Used by hardware SPI and tft8
|
||||
Adafruit_ZeroDMA dma; ///< DMA instance
|
||||
DmacDescriptor *dptr = NULL; ///< 1st descriptor
|
||||
DmacDescriptor *descriptor = NULL; ///< Allocated descriptor list
|
||||
uint16_t *pixelBuf[2]; ///< Working buffers
|
||||
uint16_t maxFillLen; ///< Max pixels per DMA xfer
|
||||
uint16_t lastFillColor = 0; ///< Last color used w/fill
|
||||
uint32_t lastFillLen = 0; ///< # of pixels w/last fill
|
||||
uint8_t onePixelBuf; ///< For hi==lo fill
|
||||
#endif
|
||||
#if defined(USE_FAST_PINIO)
|
||||
#if defined(HAS_PORT_SET_CLR)
|
||||
#if !defined(KINETISK)
|
||||
PORT_t csPinMask; ///< Bitmask for chip select
|
||||
PORT_t dcPinMask; ///< Bitmask for data/command
|
||||
#endif // end !KINETISK
|
||||
#else // !HAS_PORT_SET_CLR
|
||||
PORT_t csPinMaskSet; ///< Bitmask for chip select SET (OR)
|
||||
PORT_t csPinMaskClr; ///< Bitmask for chip select CLEAR (AND)
|
||||
PORT_t dcPinMaskSet; ///< Bitmask for data/command SET (OR)
|
||||
PORT_t dcPinMaskClr; ///< Bitmask for data/command CLEAR (AND)
|
||||
#endif // end HAS_PORT_SET_CLR
|
||||
#endif // end USE_FAST_PINIO
|
||||
uint8_t connection; ///< TFT_HARD_SPI, TFT_SOFT_SPI, etc.
|
||||
int8_t _rst; ///< Reset pin # (or -1)
|
||||
int8_t _cs; ///< Chip select pin # (or -1)
|
||||
int8_t _dc; ///< Data/command pin #
|
||||
|
||||
int16_t _xstart = 0; ///< Internal framebuffer X offset
|
||||
int16_t _ystart = 0; ///< Internal framebuffer Y offset
|
||||
uint8_t invertOnCommand = 0; ///< Command to enable invert mode
|
||||
uint8_t invertOffCommand = 0; ///< Command to disable invert mode
|
||||
|
||||
uint32_t _freq = 0; ///< Dummy var to keep subclasses happy
|
||||
};
|
||||
|
||||
#endif // end __AVR_ATtiny85__
|
||||
#endif // end _ADAFRUIT_SPITFT_H_
|
6
Adafruit_SPITFT_Macros.h
Normal file
6
Adafruit_SPITFT_Macros.h
Normal file
@ -0,0 +1,6 @@
|
||||
// THIS FILE INTENTIONALLY LEFT BLANK.
|
||||
|
||||
// Macros previously #defined here have been made into (mostly) inline
|
||||
// functions in the Adafruit_SPITFT class. Other libraries might still
|
||||
// contain code trying to #include this header file, so until everything's
|
||||
// updated this file still exists (but doing nothing) to avoid trouble.
|
130
Fonts/Tiny3x3a2pt7b.h
Normal file
130
Fonts/Tiny3x3a2pt7b.h
Normal file
@ -0,0 +1,130 @@
|
||||
/**
|
||||
** The FontStruction “Tiny3x3a”
|
||||
** (https://fontstruct.com/fontstructions/show/670512) by “Michaelangel007” is
|
||||
** licensed under a Creative Commons Attribution Non-commercial Share Alike license
|
||||
** (http://creativecommons.org/licenses/by-nc-sa/3.0/).
|
||||
** “Tiny3x3a” was originally cloned (copied) from the FontStruction
|
||||
** “CHECKER” (https://fontstruct.com/fontstructions/show/2391) by Wolf grant
|
||||
** Grant, which is licensed under a Creative Commons Attribution Non-commercial
|
||||
** Share Alike license (http://creativecommons.org/licenses/by-nc-sa/3.0/).
|
||||
*
|
||||
* Converted by eadmaster with fontconvert
|
||||
**/
|
||||
|
||||
const uint8_t Tiny3x3a2pt7bBitmaps[] PROGMEM = {
|
||||
0xC0, 0xB4, 0xBF, 0x80, 0x6B, 0x00, 0xDD, 0x80, 0x59, 0x80, 0x80, 0x64,
|
||||
0x98, 0xF0, 0x5D, 0x00, 0xC0, 0xE0, 0x80, 0x2A, 0x00, 0x55, 0x00, 0x94,
|
||||
0xC9, 0x80, 0xEF, 0x80, 0xBC, 0x80, 0x6B, 0x00, 0x9F, 0x80, 0xE4, 0x80,
|
||||
0x7F, 0x00, 0xFC, 0x80, 0xA0, 0x58, 0x64, 0xE3, 0x80, 0x98, 0xD8, 0xD8,
|
||||
0x80, 0x5E, 0x80, 0xDF, 0x80, 0x71, 0x80, 0xD7, 0x00, 0xFB, 0x80, 0xFA,
|
||||
0x00, 0xD7, 0x80, 0xBE, 0x80, 0xE0, 0x27, 0x00, 0xBA, 0x80, 0x93, 0x80,
|
||||
0xFE, 0x80, 0xF6, 0x80, 0xF7, 0x80, 0xFE, 0x00, 0xF7, 0x00, 0xDE, 0x80,
|
||||
0x6B, 0x00, 0xE9, 0x00, 0xB7, 0x80, 0xB5, 0x00, 0xBF, 0x80, 0xAA, 0x80,
|
||||
0xA9, 0x00, 0xEB, 0x80, 0xEC, 0x88, 0x80, 0xDC, 0x54, 0xE0, 0x90, 0x70,
|
||||
0xBC, 0xF0, 0x7C, 0xB0, 0x68, 0xFC, 0xBC, 0xC0, 0x58, 0x9A, 0x80, 0xA4,
|
||||
0xDC, 0xD4, 0xF0, 0xF8, 0xF4, 0xE0, 0x60, 0x59, 0x80, 0xBC, 0xA8, 0xEC,
|
||||
0xF0, 0xAC, 0x80, 0x90, 0x79, 0x80, 0xF0, 0xCF, 0x00, 0x78 };
|
||||
|
||||
const GFXglyph Tiny3x3a2pt7bGlyphs[] PROGMEM = {
|
||||
{ 0, 0, 0, 4, 0, 1 }, // 0x20 ' '
|
||||
{ 0, 1, 2, 3, 1, -2 }, // 0x21 '!'
|
||||
{ 1, 3, 2, 4, 0, -2 }, // 0x22 '"'
|
||||
{ 2, 3, 3, 4, 0, -2 }, // 0x23 '#'
|
||||
{ 4, 3, 3, 4, 0, -2 }, // 0x24 '$'
|
||||
{ 6, 3, 3, 4, 0, -2 }, // 0x25 '%'
|
||||
{ 8, 3, 3, 4, 0, -2 }, // 0x26 '&'
|
||||
{ 10, 1, 1, 3, 1, -2 }, // 0x27 '''
|
||||
{ 11, 2, 3, 3, 0, -2 }, // 0x28 '('
|
||||
{ 12, 2, 3, 4, 1, -2 }, // 0x29 ')'
|
||||
{ 13, 2, 2, 4, 1, -2 }, // 0x2A '*'
|
||||
{ 14, 3, 3, 4, 0, -2 }, // 0x2B '+'
|
||||
{ 16, 1, 2, 2, 0, 0 }, // 0x2C ','
|
||||
{ 17, 3, 1, 4, 0, -1 }, // 0x2D '-'
|
||||
{ 18, 1, 1, 2, 0, 0 }, // 0x2E '.'
|
||||
{ 19, 3, 3, 4, 0, -2 }, // 0x2F '/'
|
||||
{ 21, 3, 3, 4, 0, -2 }, // 0x30 '0'
|
||||
{ 23, 2, 3, 3, 0, -2 }, // 0x31 '1'
|
||||
{ 24, 3, 3, 4, 0, -2 }, // 0x32 '2'
|
||||
{ 26, 3, 3, 4, 0, -2 }, // 0x33 '3'
|
||||
{ 28, 3, 3, 4, 0, -2 }, // 0x34 '4'
|
||||
{ 30, 3, 3, 4, 0, -2 }, // 0x35 '5'
|
||||
{ 32, 3, 3, 4, 0, -2 }, // 0x36 '6'
|
||||
{ 34, 3, 3, 4, 0, -2 }, // 0x37 '7'
|
||||
{ 36, 3, 3, 4, 0, -2 }, // 0x38 '8'
|
||||
{ 38, 3, 3, 4, 0, -2 }, // 0x39 '9'
|
||||
{ 40, 1, 3, 3, 1, -2 }, // 0x3A ':'
|
||||
{ 41, 2, 3, 3, 0, -1 }, // 0x3B ';'
|
||||
{ 42, 2, 3, 3, 0, -2 }, // 0x3C '<'
|
||||
{ 43, 3, 3, 4, 0, -2 }, // 0x3D '='
|
||||
{ 45, 2, 3, 4, 1, -2 }, // 0x3E '>'
|
||||
{ 46, 2, 3, 4, 1, -2 }, // 0x3F '?'
|
||||
{ 47, 3, 3, 4, 0, -2 }, // 0x40 '@'
|
||||
{ 49, 3, 3, 4, 0, -2 }, // 0x41 'A'
|
||||
{ 51, 3, 3, 4, 0, -2 }, // 0x42 'B'
|
||||
{ 53, 3, 3, 4, 0, -2 }, // 0x43 'C'
|
||||
{ 55, 3, 3, 4, 0, -2 }, // 0x44 'D'
|
||||
{ 57, 3, 3, 4, 0, -2 }, // 0x45 'E'
|
||||
{ 59, 3, 3, 4, 0, -2 }, // 0x46 'F'
|
||||
{ 61, 3, 3, 4, 0, -2 }, // 0x47 'G'
|
||||
{ 63, 3, 3, 4, 0, -2 }, // 0x48 'H'
|
||||
{ 65, 1, 3, 3, 1, -2 }, // 0x49 'I'
|
||||
{ 66, 3, 3, 4, 0, -2 }, // 0x4A 'J'
|
||||
{ 68, 3, 3, 4, 0, -2 }, // 0x4B 'K'
|
||||
{ 70, 3, 3, 4, 0, -2 }, // 0x4C 'L'
|
||||
{ 72, 3, 3, 4, 0, -2 }, // 0x4D 'M'
|
||||
{ 74, 3, 3, 4, 0, -2 }, // 0x4E 'N'
|
||||
{ 76, 3, 3, 4, 0, -2 }, // 0x4F 'O'
|
||||
{ 78, 3, 3, 4, 0, -2 }, // 0x50 'P'
|
||||
{ 80, 3, 3, 4, 0, -2 }, // 0x51 'Q'
|
||||
{ 82, 3, 3, 4, 0, -2 }, // 0x52 'R'
|
||||
{ 84, 3, 3, 4, 0, -2 }, // 0x53 'S'
|
||||
{ 86, 3, 3, 4, 0, -2 }, // 0x54 'T'
|
||||
{ 88, 3, 3, 4, 0, -2 }, // 0x55 'U'
|
||||
{ 90, 3, 3, 4, 0, -2 }, // 0x56 'V'
|
||||
{ 92, 3, 3, 4, 0, -2 }, // 0x57 'W'
|
||||
{ 94, 3, 3, 4, 0, -2 }, // 0x58 'X'
|
||||
{ 96, 3, 3, 4, 0, -2 }, // 0x59 'Y'
|
||||
{ 98, 3, 3, 4, 0, -2 }, // 0x5A 'Z'
|
||||
{ 100, 2, 3, 3, 0, -2 }, // 0x5B '['
|
||||
{ 101, 3, 3, 4, 0, -2 }, // 0x5C '\'
|
||||
{ 103, 2, 3, 4, 1, -2 }, // 0x5D ']'
|
||||
{ 104, 3, 2, 4, 0, -2 }, // 0x5E '^'
|
||||
{ 105, 3, 1, 4, 0, 0 }, // 0x5F '_'
|
||||
{ 106, 2, 2, 3, 0, -2 }, // 0x60 '`'
|
||||
{ 107, 2, 2, 3, 0, -1 }, // 0x61 'a'
|
||||
{ 108, 2, 3, 3, 0, -2 }, // 0x62 'b'
|
||||
{ 109, 2, 2, 3, 0, -1 }, // 0x63 'c'
|
||||
{ 110, 2, 3, 3, 0, -2 }, // 0x64 'd'
|
||||
{ 111, 2, 2, 3, 0, -1 }, // 0x65 'e'
|
||||
{ 112, 2, 3, 3, 0, -2 }, // 0x66 'f'
|
||||
{ 113, 2, 3, 3, 0, -1 }, // 0x67 'g'
|
||||
{ 114, 2, 3, 3, 0, -2 }, // 0x68 'h'
|
||||
{ 115, 1, 2, 2, 0, -1 }, // 0x69 'i'
|
||||
{ 116, 2, 3, 3, 0, -1 }, // 0x6A 'j'
|
||||
{ 117, 3, 3, 4, 0, -2 }, // 0x6B 'k'
|
||||
{ 119, 2, 3, 3, 0, -2 }, // 0x6C 'l'
|
||||
{ 120, 3, 2, 4, 0, -1 }, // 0x6D 'm'
|
||||
{ 121, 3, 2, 4, 0, -1 }, // 0x6E 'n'
|
||||
{ 122, 2, 2, 3, 0, -1 }, // 0x6F 'o'
|
||||
{ 123, 2, 3, 3, 0, -1 }, // 0x70 'p'
|
||||
{ 124, 2, 3, 3, 0, -1 }, // 0x71 'q'
|
||||
{ 125, 2, 2, 3, 0, -1 }, // 0x72 'r'
|
||||
{ 126, 2, 2, 3, 0, -1 }, // 0x73 's'
|
||||
{ 127, 3, 3, 4, 0, -2 }, // 0x74 't'
|
||||
{ 129, 3, 2, 4, 0, -1 }, // 0x75 'u'
|
||||
{ 130, 3, 2, 4, 0, -1 }, // 0x76 'v'
|
||||
{ 131, 3, 2, 4, 0, -1 }, // 0x77 'w'
|
||||
{ 132, 2, 2, 3, 0, -1 }, // 0x78 'x'
|
||||
{ 133, 3, 3, 4, 0, -1 }, // 0x79 'y'
|
||||
{ 135, 2, 2, 3, 0, -1 }, // 0x7A 'z'
|
||||
{ 136, 3, 3, 4, 0, -2 }, // 0x7B '{'
|
||||
{ 138, 1, 4, 3, 1, -2 }, // 0x7C '|'
|
||||
{ 139, 3, 3, 4, 0, -2 }, // 0x7D '}'
|
||||
{ 141, 3, 2, 4, 0, -2 } }; // 0x7E '~'
|
||||
|
||||
const GFXfont Tiny3x3a2pt7b PROGMEM = {
|
||||
(uint8_t *)Tiny3x3a2pt7bBitmaps,
|
||||
(GFXglyph *)Tiny3x3a2pt7bGlyphs,
|
||||
0x20, 0x7E, 4 };
|
||||
|
||||
// Approx. 814 bytes
|
18
README.md
18
README.md
@ -1,4 +1,4 @@
|
||||
# Adafruit GFX Library
|
||||
# Adafruit GFX Library [![Build Status](https://travis-ci.com/adafruit/Adafruit-GFX-Library.svg?branch=master)](https://travis-ci.com/adafruit/Adafruit-GFX-Library)
|
||||
|
||||
This is the core graphics library for all our displays, providing a common set of graphics primitives (points, lines, circles, etc.). It needs to be paired with a hardware-specific library for each display device we carry (to handle the lower-level functions).
|
||||
|
||||
@ -8,7 +8,7 @@ Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, check license.txt for more information.
|
||||
All text above must be included in any redistribution.
|
||||
|
||||
Recent Arduino IDE releases include the Library Manager for easy installation. Otherwise, to download, click the DOWNLOAD ZIP button, uncompress and rename the uncompressed folder Adafruit_GFX. Confirm that the Adafruit_GFX folder contains Adafruit_GFX.cpp and Adafruit_GFX.h. Place the Adafruit_GFX library folder your <arduinosketchfolder>/Libraries/ folder. You may need to create the Libraries subfolder if its your first library. Restart the IDE.
|
||||
Recent Arduino IDE releases include the Library Manager for easy installation. Otherwise, to download, click the DOWNLOAD ZIP button, uncompress and rename the uncompressed folder Adafruit_GFX. Confirm that the Adafruit_GFX folder contains Adafruit_GFX.cpp and Adafruit_GFX.h. Place the Adafruit_GFX library folder your ArduinoSketchFolder/Libraries/ folder. You may need to create the Libraries subfolder if its your first library. Restart the IDE.
|
||||
|
||||
# Useful Resources
|
||||
|
||||
@ -16,6 +16,16 @@ Recent Arduino IDE releases include the Library Manager for easy installation. O
|
||||
|
||||
- drawXBitmap function: You can use the GIMP photo editor to save a .xbm file and use the array saved in the file to draw a bitmap with the drawXBitmap function. See the pull request here for more details: https://github.com/adafruit/Adafruit-GFX-Library/pull/31
|
||||
|
||||
- 'Fonts' folder contains bitmap fonts for use with recent (1.1 and later) Adafruit_GFX. To use a font in your Arduino sketch, #include the corresponding .h file and pass address of GFXfont struct to setFont(). Pass NULL to revert to 'classic' fixed-space bitmap font.
|
||||
- 'Fonts' folder contains bitmap fonts for use with recent (1.1 and later) Adafruit_GFX. To use a font in your Arduino sketch, \#include the corresponding .h file and pass address of GFXfont struct to setFont(). Pass NULL to revert to 'classic' fixed-space bitmap font.
|
||||
|
||||
- 'fontconvert' folder contains a command-line tool for converting TTF fonts to Adafruit_GFX .h format.
|
||||
- 'fontconvert' folder contains a command-line tool for converting TTF fonts to Adafruit_GFX header format.
|
||||
|
||||
---
|
||||
|
||||
### Roadmap
|
||||
|
||||
The PRIME DIRECTIVE is to maintain backward compatibility with existing Arduino sketches -- many are hosted elsewhere and don't track changes here, some are in print and can never be changed! This "little" library has grown organically over time and sometimes we paint ourselves into a design corner and just have to live with it or add ungainly workarounds.
|
||||
|
||||
Highly unlikely to merge any changes for additional or incompatible font formats (see Prime Directive above). There are already two formats and the code is quite bloaty there as it is (this also creates liabilities for tools and documentation). If you *must* have a more sophisticated font format, consider creating a fork with the features required for your project. For similar reasons, also unlikely to add any more bitmap formats, it's getting messy.
|
||||
|
||||
Please don't reformat code for the sake of reformatting code. The resulting large "visual diff" makes it impossible to untangle actual bug fixes from merely rearranged lines.
|
||||
|
365
examples/mock_ili9341/mock_ili9341.ino
Normal file
365
examples/mock_ili9341/mock_ili9341.ino
Normal file
@ -0,0 +1,365 @@
|
||||
/***************************************************
|
||||
This is our GFX example for the Adafruit ILI9341 Breakout and Shield
|
||||
----> http://www.adafruit.com/products/1651
|
||||
|
||||
Check out the links above for our tutorials and wiring diagrams
|
||||
These displays use SPI to communicate, 4 or 5 pins are required to
|
||||
interface (RST is optional)
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
MIT license, all text above must be included in any redistribution
|
||||
****************************************************/
|
||||
|
||||
|
||||
#include "SPI.h"
|
||||
#include "Adafruit_GFX.h"
|
||||
#include "Adafruit_ILI9341.h"
|
||||
|
||||
// For the Adafruit shield, these are the default.
|
||||
#define TFT_DC 9
|
||||
#define TFT_CS 10
|
||||
|
||||
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
|
||||
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
|
||||
// If using the breakout, change pins as desired
|
||||
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("ILI9341 Test!");
|
||||
|
||||
tft.begin();
|
||||
|
||||
// read diagnostics (optional but can help debug problems)
|
||||
uint8_t x = tft.readcommand8(ILI9341_RDMODE);
|
||||
Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX);
|
||||
x = tft.readcommand8(ILI9341_RDMADCTL);
|
||||
Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX);
|
||||
x = tft.readcommand8(ILI9341_RDPIXFMT);
|
||||
Serial.print("Pixel Format: 0x"); Serial.println(x, HEX);
|
||||
x = tft.readcommand8(ILI9341_RDIMGFMT);
|
||||
Serial.print("Image Format: 0x"); Serial.println(x, HEX);
|
||||
x = tft.readcommand8(ILI9341_RDSELFDIAG);
|
||||
Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX);
|
||||
|
||||
Serial.println(F("Benchmark Time (microseconds)"));
|
||||
delay(10);
|
||||
Serial.print(F("Screen fill "));
|
||||
Serial.println(testFillScreen());
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Text "));
|
||||
Serial.println(testText());
|
||||
delay(3000);
|
||||
|
||||
Serial.print(F("Lines "));
|
||||
Serial.println(testLines(ILI9341_CYAN));
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Horiz/Vert Lines "));
|
||||
Serial.println(testFastLines(ILI9341_RED, ILI9341_BLUE));
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Rectangles (outline) "));
|
||||
Serial.println(testRects(ILI9341_GREEN));
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Rectangles (filled) "));
|
||||
Serial.println(testFilledRects(ILI9341_YELLOW, ILI9341_MAGENTA));
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Circles (filled) "));
|
||||
Serial.println(testFilledCircles(10, ILI9341_MAGENTA));
|
||||
|
||||
Serial.print(F("Circles (outline) "));
|
||||
Serial.println(testCircles(10, ILI9341_WHITE));
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Triangles (outline) "));
|
||||
Serial.println(testTriangles());
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Triangles (filled) "));
|
||||
Serial.println(testFilledTriangles());
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Rounded rects (outline) "));
|
||||
Serial.println(testRoundRects());
|
||||
delay(500);
|
||||
|
||||
Serial.print(F("Rounded rects (filled) "));
|
||||
Serial.println(testFilledRoundRects());
|
||||
delay(500);
|
||||
|
||||
Serial.println(F("Done!"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
void loop(void) {
|
||||
for(uint8_t rotation=0; rotation<4; rotation++) {
|
||||
tft.setRotation(rotation);
|
||||
testText();
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long testFillScreen() {
|
||||
unsigned long start = micros();
|
||||
tft.fillScreen(ILI9341_BLACK);
|
||||
yield();
|
||||
tft.fillScreen(ILI9341_RED);
|
||||
yield();
|
||||
tft.fillScreen(ILI9341_GREEN);
|
||||
yield();
|
||||
tft.fillScreen(ILI9341_BLUE);
|
||||
yield();
|
||||
tft.fillScreen(ILI9341_BLACK);
|
||||
yield();
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testText() {
|
||||
tft.fillScreen(ILI9341_BLACK);
|
||||
unsigned long start = micros();
|
||||
tft.setCursor(0, 0);
|
||||
tft.setTextColor(ILI9341_WHITE); tft.setTextSize(1);
|
||||
tft.println("Hello World!");
|
||||
tft.setTextColor(ILI9341_YELLOW); tft.setTextSize(2);
|
||||
tft.println(1234.56);
|
||||
tft.setTextColor(ILI9341_RED); tft.setTextSize(3);
|
||||
tft.println(0xDEADBEEF, HEX);
|
||||
tft.println();
|
||||
tft.setTextColor(ILI9341_GREEN);
|
||||
tft.setTextSize(5);
|
||||
tft.println("Groop");
|
||||
tft.setTextSize(2);
|
||||
tft.println("I implore thee,");
|
||||
tft.setTextSize(1);
|
||||
tft.println("my foonting turlingdromes.");
|
||||
tft.println("And hooptiously drangle me");
|
||||
tft.println("with crinkly bindlewurdles,");
|
||||
tft.println("Or I will rend thee");
|
||||
tft.println("in the gobberwarts");
|
||||
tft.println("with my blurglecruncheon,");
|
||||
tft.println("see if I don't!");
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testLines(uint16_t color) {
|
||||
unsigned long start, t;
|
||||
int x1, y1, x2, y2,
|
||||
w = tft.width(),
|
||||
h = tft.height();
|
||||
|
||||
tft.fillScreen(ILI9341_BLACK);
|
||||
yield();
|
||||
|
||||
x1 = y1 = 0;
|
||||
y2 = h - 1;
|
||||
start = micros();
|
||||
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
x2 = w - 1;
|
||||
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
t = micros() - start; // fillScreen doesn't count against timing
|
||||
|
||||
yield();
|
||||
tft.fillScreen(ILI9341_BLACK);
|
||||
yield();
|
||||
|
||||
x1 = w - 1;
|
||||
y1 = 0;
|
||||
y2 = h - 1;
|
||||
start = micros();
|
||||
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
x2 = 0;
|
||||
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
t += micros() - start;
|
||||
|
||||
yield();
|
||||
tft.fillScreen(ILI9341_BLACK);
|
||||
yield();
|
||||
|
||||
x1 = 0;
|
||||
y1 = h - 1;
|
||||
y2 = 0;
|
||||
start = micros();
|
||||
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
x2 = w - 1;
|
||||
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
t += micros() - start;
|
||||
|
||||
yield();
|
||||
tft.fillScreen(ILI9341_BLACK);
|
||||
yield();
|
||||
|
||||
x1 = w - 1;
|
||||
y1 = h - 1;
|
||||
y2 = 0;
|
||||
start = micros();
|
||||
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
x2 = 0;
|
||||
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
|
||||
|
||||
yield();
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testFastLines(uint16_t color1, uint16_t color2) {
|
||||
unsigned long start;
|
||||
int x, y, w = tft.width(), h = tft.height();
|
||||
|
||||
tft.fillScreen(ILI9341_BLACK);
|
||||
start = micros();
|
||||
for(y=0; y<h; y+=5) tft.drawFastHLine(0, y, w, color1);
|
||||
for(x=0; x<w; x+=5) tft.drawFastVLine(x, 0, h, color2);
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testRects(uint16_t color) {
|
||||
unsigned long start;
|
||||
int n, i, i2,
|
||||
cx = tft.width() / 2,
|
||||
cy = tft.height() / 2;
|
||||
|
||||
tft.fillScreen(ILI9341_BLACK);
|
||||
n = min(tft.width(), tft.height());
|
||||
start = micros();
|
||||
for(i=2; i<n; i+=6) {
|
||||
i2 = i / 2;
|
||||
tft.drawRect(cx-i2, cy-i2, i, i, color);
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testFilledRects(uint16_t color1, uint16_t color2) {
|
||||
unsigned long start, t = 0;
|
||||
int n, i, i2,
|
||||
cx = tft.width() / 2 - 1,
|
||||
cy = tft.height() / 2 - 1;
|
||||
|
||||
tft.fillScreen(ILI9341_BLACK);
|
||||
n = min(tft.width(), tft.height());
|
||||
for(i=n; i>0; i-=6) {
|
||||
i2 = i / 2;
|
||||
start = micros();
|
||||
tft.fillRect(cx-i2, cy-i2, i, i, color1);
|
||||
t += micros() - start;
|
||||
// Outlines are not included in timing results
|
||||
tft.drawRect(cx-i2, cy-i2, i, i, color2);
|
||||
yield();
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
unsigned long testFilledCircles(uint8_t radius, uint16_t color) {
|
||||
unsigned long start;
|
||||
int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2;
|
||||
|
||||
tft.fillScreen(ILI9341_BLACK);
|
||||
start = micros();
|
||||
for(x=radius; x<w; x+=r2) {
|
||||
for(y=radius; y<h; y+=r2) {
|
||||
tft.fillCircle(x, y, radius, color);
|
||||
}
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testCircles(uint8_t radius, uint16_t color) {
|
||||
unsigned long start;
|
||||
int x, y, r2 = radius * 2,
|
||||
w = tft.width() + radius,
|
||||
h = tft.height() + radius;
|
||||
|
||||
// Screen is not cleared for this one -- this is
|
||||
// intentional and does not affect the reported time.
|
||||
start = micros();
|
||||
for(x=0; x<w; x+=r2) {
|
||||
for(y=0; y<h; y+=r2) {
|
||||
tft.drawCircle(x, y, radius, color);
|
||||
}
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testTriangles() {
|
||||
unsigned long start;
|
||||
int n, i, cx = tft.width() / 2 - 1,
|
||||
cy = tft.height() / 2 - 1;
|
||||
|
||||
tft.fillScreen(ILI9341_BLACK);
|
||||
n = min(cx, cy);
|
||||
start = micros();
|
||||
for(i=0; i<n; i+=5) {
|
||||
tft.drawTriangle(
|
||||
cx , cy - i, // peak
|
||||
cx - i, cy + i, // bottom left
|
||||
cx + i, cy + i, // bottom right
|
||||
tft.color565(i, i, i));
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testFilledTriangles() {
|
||||
unsigned long start, t = 0;
|
||||
int i, cx = tft.width() / 2 - 1,
|
||||
cy = tft.height() / 2 - 1;
|
||||
|
||||
tft.fillScreen(ILI9341_BLACK);
|
||||
start = micros();
|
||||
for(i=min(cx,cy); i>10; i-=5) {
|
||||
start = micros();
|
||||
tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
|
||||
tft.color565(0, i*10, i*10));
|
||||
t += micros() - start;
|
||||
tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
|
||||
tft.color565(i*10, i*10, 0));
|
||||
yield();
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
unsigned long testRoundRects() {
|
||||
unsigned long start;
|
||||
int w, i, i2,
|
||||
cx = tft.width() / 2 - 1,
|
||||
cy = tft.height() / 2 - 1;
|
||||
|
||||
tft.fillScreen(ILI9341_BLACK);
|
||||
w = min(tft.width(), tft.height());
|
||||
start = micros();
|
||||
for(i=0; i<w; i+=6) {
|
||||
i2 = i / 2;
|
||||
tft.drawRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(i, 0, 0));
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
|
||||
unsigned long testFilledRoundRects() {
|
||||
unsigned long start;
|
||||
int i, i2,
|
||||
cx = tft.width() / 2 - 1,
|
||||
cy = tft.height() / 2 - 1;
|
||||
|
||||
tft.fillScreen(ILI9341_BLACK);
|
||||
start = micros();
|
||||
for(i=min(tft.width(), tft.height()); i>20; i-=6) {
|
||||
i2 = i / 2;
|
||||
tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0));
|
||||
yield();
|
||||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
@ -16,12 +16,14 @@ Keep 7-bit fonts around as an option in that case, more compact.
|
||||
|
||||
See notes at end for glyph nomenclature & other tidbits.
|
||||
*/
|
||||
#ifndef ARDUINO
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <stdint.h>
|
||||
#include <ft2build.h>
|
||||
#include FT_GLYPH_H
|
||||
#include FT_TRUETYPE_DRIVER_H
|
||||
#include "../gfxfont.h" // Adafruit_GFX font structures
|
||||
|
||||
#define DPI 141 // Approximate res. of Adafruit 2.8" TFT
|
||||
@ -116,6 +118,16 @@ int main(int argc, char *argv[]) {
|
||||
fprintf(stderr, "FreeType init error: %d", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
// Use TrueType engine version 35, without subpixel rendering.
|
||||
// This improves clarity of fonts since this library does not
|
||||
// support rendering multiple levels of gray in a glyph.
|
||||
// See https://github.com/adafruit/Adafruit-GFX-Library/issues/103
|
||||
FT_UInt interpreter_version = TT_INTERPRETER_VERSION_35;
|
||||
FT_Property_Set( library, "truetype",
|
||||
"interpreter-version",
|
||||
&interpreter_version );
|
||||
|
||||
if((err = FT_New_Face(library, argv[1], 0, &face))) {
|
||||
fprintf(stderr, "Font load error: %d", err);
|
||||
FT_Done_FreeType(library);
|
||||
@ -222,8 +234,14 @@ int main(int argc, char *argv[]) {
|
||||
printf("const GFXfont %s PROGMEM = {\n", fontName);
|
||||
printf(" (uint8_t *)%sBitmaps,\n", fontName);
|
||||
printf(" (GFXglyph *)%sGlyphs,\n", fontName);
|
||||
printf(" 0x%02X, 0x%02X, %ld };\n\n",
|
||||
first, last, face->size->metrics.height >> 6);
|
||||
if (face->size->metrics.height == 0) {
|
||||
// No face height info, assume fixed width and get from a glyph.
|
||||
printf(" 0x%02X, 0x%02X, %d };\n\n",
|
||||
first, last, table[0].height);
|
||||
} else {
|
||||
printf(" 0x%02X, 0x%02X, %ld };\n\n",
|
||||
first, last, face->size->metrics.height >> 6);
|
||||
}
|
||||
printf("// Approx. %d bytes\n",
|
||||
bitmapOffset + (last - first + 1) * 7 + 7);
|
||||
// Size estimate is based on AVR struct and pointer sizes;
|
||||
@ -276,3 +294,5 @@ the cursor on the X axis after drawing the corresponding symbol.
|
||||
There's also some changes with regard to 'background' color and new GFX
|
||||
fonts (classic fonts unchanged). See Adafruit_GFX.cpp for explanation.
|
||||
*/
|
||||
|
||||
#endif /* !ARDUINO */
|
||||
|
25
gfxfont.h
25
gfxfont.h
@ -7,18 +7,23 @@
|
||||
#ifndef _GFXFONT_H_
|
||||
#define _GFXFONT_H_
|
||||
|
||||
typedef struct { // Data stored PER GLYPH
|
||||
uint16_t bitmapOffset; // Pointer into GFXfont->bitmap
|
||||
uint8_t width, height; // Bitmap dimensions in pixels
|
||||
uint8_t xAdvance; // Distance to advance cursor (x axis)
|
||||
int8_t xOffset, yOffset; // Dist from cursor pos to UL corner
|
||||
/// Font data stored PER GLYPH
|
||||
typedef struct {
|
||||
uint16_t bitmapOffset; ///< Pointer into GFXfont->bitmap
|
||||
uint8_t width; ///< Bitmap dimensions in pixels
|
||||
uint8_t height; ///< Bitmap dimensions in pixels
|
||||
uint8_t xAdvance; ///< Distance to advance cursor (x axis)
|
||||
int8_t xOffset; ///< X dist from cursor pos to UL corner
|
||||
int8_t yOffset; ///< Y dist from cursor pos to UL corner
|
||||
} GFXglyph;
|
||||
|
||||
typedef struct { // Data stored for FONT AS A WHOLE:
|
||||
uint8_t *bitmap; // Glyph bitmaps, concatenated
|
||||
GFXglyph *glyph; // Glyph array
|
||||
uint8_t first, last; // ASCII extents
|
||||
uint8_t yAdvance; // Newline distance (y axis)
|
||||
/// Data stored for FONT AS A WHOLE
|
||||
typedef struct {
|
||||
uint8_t *bitmap; ///< Glyph bitmaps, concatenated
|
||||
GFXglyph *glyph; ///< Glyph array
|
||||
uint8_t first; ///< ASCII extents (first char)
|
||||
uint8_t last; ///< ASCII extents (last char)
|
||||
uint8_t yAdvance; ///< Newline distance (y axis)
|
||||
} GFXfont;
|
||||
|
||||
#endif // _GFXFONT_H_
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=Adafruit GFX Library
|
||||
version=1.1.9
|
||||
version=1.5.0
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <info@adafruit.com>
|
||||
sentence=Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from.
|
||||
|
Loading…
x
Reference in New Issue
Block a user