-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrawBitmap.cpp
More file actions
35 lines (26 loc) · 878 Bytes
/
drawBitmap.cpp
File metadata and controls
35 lines (26 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
//
//
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include "drawBitmap.h"
// Thanks to https://github.com/KrisKasprzak
/*-----------------------------------------------------------------*/
void drawBitmap(Adafruit_ILI9341& tft, int x, int y, const uint16_t* bitmap, int bw, int bh) {
//int h = 64, w = 64, row, col, buffidx = 0;
int buffidx = 0;
int row;
int col;
int w = bw + y;
int h = bh + x;
for (row = x; row < h; row++) {
// For each scanline...
for (col = y; col < w; col++) { // For each pixel...
//To read from Flash Memory, pgm_read_XXX is required.
//Since image is stored as uint16_t, pgm_read_word is used as it uses 16bit address
tft.drawPixel(col, row, pgm_read_word(bitmap + buffidx));
buffidx++;
} // end pixel
}
} // Close function.
/*-----------------------------------------------------------------*/