Skip to content

Commit 7589eca

Browse files
Extra-persnickety declarations in PROGMEM bitmap functions
1 parent d0e78f9 commit 7589eca

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

Adafruit_GFX.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ void Adafruit_GFX::fillTriangle(int16_t x0, int16_t y0,
462462
// Draw a PROGMEM-resident 1-bit image at the specified (x,y) position,
463463
// using the specified foreground color (unset bits are transparent).
464464
void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
465-
const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color) {
465+
PROGMEM const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color) {
466466

467467
int16_t byteWidth = (w + 7) / 8; // Bitmap scanline pad = whole byte
468468
uint8_t byte = 0;
@@ -482,7 +482,8 @@ void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
482482
// using the specified foreground (for set bits) and background (unset
483483
// bits) colors.
484484
void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
485-
const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg) {
485+
PROGMEM const uint8_t bitmap[], int16_t w, int16_t h,
486+
uint16_t color, uint16_t bg) {
486487

487488
int16_t byteWidth = (w + 7) / 8; // Bitmap scanline pad = whole byte
488489
uint8_t byte = 0;
@@ -539,9 +540,11 @@ void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
539540

540541
// Draw PROGMEM-resident XBitMap Files (*.xbm), exported from GIMP,
541542
// Usage: Export from GIMP to *.xbm, rename *.xbm to *.c and open in editor.
542-
// C Array can be directly used with this function
543+
// C Array can be directly used with this function.
544+
// There is no RAM-resident version of this function; if generating bitmaps
545+
// in RAM, use the format defined by drawBitmap() and call that instead.
543546
void Adafruit_GFX::drawXBitmap(int16_t x, int16_t y,
544-
const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color) {
547+
PROGMEM const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color) {
545548

546549
int16_t byteWidth = (w + 7) / 8; // Bitmap scanline pad = whole byte
547550
uint8_t byte = 0;
@@ -563,7 +566,7 @@ void Adafruit_GFX::drawXBitmap(int16_t x, int16_t y,
563566
// pos. Specifically for 8-bit display devices such as IS31FL3731;
564567
// no color reduction/expansion is performed.
565568
void Adafruit_GFX::drawGrayscaleBitmap(int16_t x, int16_t y,
566-
const uint8_t *bitmap, int16_t w, int16_t h) {
569+
PROGMEM const uint8_t bitmap[], int16_t w, int16_t h) {
567570
startWrite();
568571
for(int16_t j=0; j<h; j++, y++) {
569572
for(int16_t i=0; i<w; i++ ) {
@@ -593,7 +596,8 @@ void Adafruit_GFX::drawGrayscaleBitmap(int16_t x, int16_t y,
593596
// Specifically for 8-bit display devices such as IS31FL3731;
594597
// no color reduction/expansion is performed.
595598
void Adafruit_GFX::drawGrayscaleBitmap(int16_t x, int16_t y,
596-
const uint8_t *bitmap, const uint8_t *mask, int16_t w, int16_t h) {
599+
PROGMEM const uint8_t bitmap[], PROGMEM const uint8_t mask[],
600+
int16_t w, int16_t h) {
597601
int16_t bw = (w + 7) / 8; // Bitmask scanline pad = whole byte
598602
uint8_t byte = 0;
599603
startWrite();
@@ -634,7 +638,7 @@ void Adafruit_GFX::drawGrayscaleBitmap(int16_t x, int16_t y,
634638
// Draw a PROGMEM-resident 16-bit image (RGB 5/6/5) at the specified (x,y)
635639
// position. For 16-bit display devices; no color reduction performed.
636640
void Adafruit_GFX::drawRGBBitmap(int16_t x, int16_t y,
637-
const uint16_t *bitmap, int16_t w, int16_t h) {
641+
PROGMEM const uint16_t bitmap[], int16_t w, int16_t h) {
638642
startWrite();
639643
for(int16_t j=0; j<h; j++, y++) {
640644
for(int16_t i=0; i<w; i++ ) {
@@ -662,7 +666,8 @@ void Adafruit_GFX::drawRGBBitmap(int16_t x, int16_t y,
662666
// BOTH buffers (color and mask) must be PROGMEM-resident.
663667
// For 16-bit display devices; no color reduction performed.
664668
void Adafruit_GFX::drawRGBBitmap(int16_t x, int16_t y,
665-
const uint16_t *bitmap, const uint8_t *mask, int16_t w, int16_t h) {
669+
PROGMEM const uint16_t bitmap[], PROGMEM const uint8_t mask[],
670+
int16_t w, int16_t h) {
666671
int16_t bw = (w + 7) / 8; // Bitmask scanline pad = whole byte
667672
uint8_t byte = 0;
668673
startWrite();

Adafruit_GFX.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,30 +64,32 @@ class Adafruit_GFX : public Print {
6464
int16_t radius, uint16_t color),
6565
fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
6666
int16_t radius, uint16_t color),
67-
drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
67+
drawBitmap(int16_t x, int16_t y, PROGMEM const uint8_t bitmap[],
6868
int16_t w, int16_t h, uint16_t color),
69-
drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
69+
drawBitmap(int16_t x, int16_t y, PROGMEM const uint8_t bitmap[],
7070
int16_t w, int16_t h, uint16_t color, uint16_t bg),
7171
drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,
7272
int16_t w, int16_t h, uint16_t color),
7373
drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,
7474
int16_t w, int16_t h, uint16_t color, uint16_t bg),
75-
drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
75+
drawXBitmap(int16_t x, int16_t y, PROGMEM const uint8_t bitmap[],
7676
int16_t w, int16_t h, uint16_t color),
77-
drawGrayscaleBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
77+
drawGrayscaleBitmap(int16_t x, int16_t y, PROGMEM const uint8_t bitmap[],
7878
int16_t w, int16_t h),
7979
drawGrayscaleBitmap(int16_t x, int16_t y, uint8_t *bitmap,
8080
int16_t w, int16_t h),
8181
drawGrayscaleBitmap(int16_t x, int16_t y,
82-
const uint8_t *bitmap, const uint8_t *mask, int16_t w, int16_t h),
82+
PROGMEM const uint8_t bitmap[], PROGMEM const uint8_t mask[],
83+
int16_t w, int16_t h),
8384
drawGrayscaleBitmap(int16_t x, int16_t y,
8485
uint8_t *bitmap, uint8_t *mask, int16_t w, int16_t h),
85-
drawRGBBitmap(int16_t x, int16_t y, const uint16_t *bitmap,
86+
drawRGBBitmap(int16_t x, int16_t y, PROGMEM const uint16_t bitmap[],
8687
int16_t w, int16_t h),
8788
drawRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap,
8889
int16_t w, int16_t h),
8990
drawRGBBitmap(int16_t x, int16_t y,
90-
const uint16_t *bitmap, const uint8_t *mask, int16_t w, int16_t h),
91+
PROGMEM const uint16_t bitmap[], PROGMEM const uint8_t mask[],
92+
int16_t w, int16_t h),
9193
drawRGBBitmap(int16_t x, int16_t y,
9294
uint16_t *bitmap, uint8_t *mask, int16_t w, int16_t h),
9395
drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Adafruit GFX Library
2-
version=1.2.0
2+
version=1.2.1
33
author=Adafruit
44
maintainer=Adafruit <[email protected]>
55
sentence=Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from.

0 commit comments

Comments
 (0)