Compare commits

...

60 commits

Author SHA1 Message Date
Liz
fb050eebd7
Update library.properties 2025-08-01 16:32:10 -04:00
Liz
fd1328040b
Merge pull request #65 from adafruit/quad
add support for quad color eInks
2025-08-01 14:59:58 -04:00
Liz
5f7c29566d manually deal with clang spaces 2025-08-01 11:16:33 -04:00
Liz
a3086d3c22 update clang-format to match original clang
only adjusts some comment spaces in ImageReader.cpp
2025-08-01 10:33:05 -04:00
Liz
9f470611e6 Revert "clang again"
This reverts commit 04b3d3f7b7.
2025-08-01 10:15:02 -04:00
Liz
04b3d3f7b7 clang again 2025-08-01 09:27:48 -04:00
Liz
94bbaf973f clang 2025-08-01 08:56:34 -04:00
Liz
147f31d68d remove result from testing 2025-07-31 18:35:42 -04:00
Liz
923a861821 add support for quad-color eInk displays 2025-07-31 18:34:34 -04:00
Tyeth Gundry
12d776a358
Update library.properties - bump to 2.9.3 2025-07-01 14:32:57 +01:00
shebuildsrobots
77d5d67858
Correct filename in comment. (#64) 2025-06-28 12:55:01 -04:00
Liz
925149da6d
Merge pull request #63 from adafruit/rp2040_ifdef
adding ifdef for feather rp2040
2025-06-27 16:34:28 -04:00
Liz
15422ff998 adding ifdef for feather rp2040
adding ifdef for feather rp2040 for featherwing display examples. the original feather rp2040's "pin 5" is actually pin 7 in arduino (labeled on back of board silk)

this came up in https://github.com/adafruit/Adafruit_ImageReader/issues/62
2025-06-27 15:35:11 -04:00
Mikey Sklar
15778a2136
Featherwings SPI Slowdown to 12 MHz (#61)
The Feather M0 stops working above 12 MHz. This change it to lower the current FeatherWing display examples from 25 MHz --> 12 MHz.
2025-06-26 16:28:18 -04:00
Liz
cd4fda5dbb
add inits for new 2.9 tricolor (#60)
* add inits for new 2.9 tricolor

* rp2040 CI fix

* clang

* clang again
2025-06-26 09:59:29 -04:00
Tyeth Gundry
4588e48153
Update library.properties - bump version to 2.9.2 2023-09-26 13:29:40 +01:00
ladyada
e47f345706 ESP seems to want delay not yield (?) 2023-09-24 01:06:04 -04:00
dherrada
12516b8811 Update CI action versions 2023-05-12 11:24:00 -04:00
Paint Your Dragon
3aaafb7063
Increment version number for SdFat changes 2022-10-25 11:18:14 -07:00
Phillip Burgess
e13bca8c78 Skip feather_rp2040 on Gizmo CI tests 2022-10-25 10:53:40 -07:00
Ha Thach
207e82cacc
Merge pull request #54 from adafruit/fix-esp8266-build
Fix esp8266 build
2022-10-26 00:24:14 +07:00
Phillip Burgess
d719afe88d Add Feather RP2040 to Github workflow 2022-10-25 09:32:48 -07:00
hathach
40086a2140
clang 2022-10-25 15:59:57 +07:00
hathach
a1110530c6
rename FatFileSystem -> FatVolume for examples 2022-10-25 15:18:53 +07:00
hathach
90871c298f update SdFat v2 compatible
- use FatVolume to replace FatFileSystem
- use File32 to replace File
2022-10-25 15:17:27 +07:00
Phillip Burgess
fc8a3d43d4 Fix uninitialized variables 2022-10-24 14:48:15 -07:00
Eva Herrada
c790f7ed64
Bump to 2.8.1 2022-05-16 15:58:57 -04:00
Kattni
15cd42a45e
Merge pull request #53 from makermelissa/master
Add 2.7-inch eInk Image
2022-05-13 14:42:24 -04:00
Melissa LeBlanc-Williams
261fbf24b1 Add 2.7-inch eInk Image 2022-05-12 14:14:44 -07:00
Melissa LeBlanc-Williams
233c71e7b6 Bumped version for release 2022-03-22 16:06:43 -07:00
Melissa LeBlanc-Williams
c1e29cdd47
Merge pull request #50 from makermelissa/master
Add/update examples/images for 1.47/1.9 inch displays
2022-03-22 16:04:29 -07:00
Melissa LeBlanc-Williams
1937738e5d Minor changes after testing all displays 2022-03-22 15:33:12 -07:00
Melissa LeBlanc-Williams
85bd4f0486 Add examples for 1.69, 1.3, and 1.14 for the future 2022-03-22 15:00:56 -07:00
Melissa LeBlanc-Williams
7d9d55b08c Remove esp32 check 2022-03-22 14:42:59 -07:00
Melissa LeBlanc-Williams
f3f4ede73b Add/update examples/images for 1.47/1.9 inch displays 2022-03-22 14:13:17 -07:00
Eva Herrada
f8acf76da2
Bump to 2.7.0 2022-01-03 16:45:59 -05:00
lady ada
c6b7fc5f4d (sigh) 2022-01-03 15:07:04 -05:00
lady ada
294d448c7b right 2022-01-03 15:05:30 -05:00
lady ada
0729d00059 add esp32-s2 feather pin defs, and new mini display brekaout 2022-01-03 15:04:39 -05:00
Melissa LeBlanc-Williams
013a6b657f Bumped version for release 2021-09-15 11:35:58 -07:00
Melissa LeBlanc-Williams
716522d4a6
Merge pull request #46 from makermelissa/master
Add monochrome flexible display initializer to ThinkInkDisplays demo
2021-09-15 11:35:08 -07:00
Melissa LeBlanc-Williams
8f8ba1c075 Add monochrome flexible display initializer to ThinkInkDisplays demo 2021-09-15 08:57:36 -07:00
Dylan Herrada
205ffb6398
Bump to 2.6.2 2021-06-14 16:12:02 -04:00
dherrada
7ae0b6c51a Clanged 2021-06-14 15:57:02 -04:00
Ha Thach
4a0f19cae4
Fix warnings (#44)
* fix warnings

skip too big example for uno

* skip more uno test due to rom space
2021-05-27 15:46:16 -04:00
Dylan Herrada
5a9bb341de
Bump to 2.6.1 2021-03-16 15:44:36 -04:00
Melissa LeBlanc-Williams
4f11a220e7
Merge pull request #42 from makermelissa/master
Added 250x122 Tri-Color Blinka Image
2021-03-11 13:02:07 -08:00
Melissa LeBlanc-Williams
18d8c69efc Added 250x122 Tri-Color Blinka Image 2021-03-11 12:22:32 -08:00
Dylan Herrada
065db15bbe
Bump to 2.6.0 2021-03-02 15:57:02 -05:00
lady ada
64702faa7e Merge branch 'master' of github.com:adafruit/Adafruit_ImageReader 2021-02-23 15:30:56 -05:00
lady ada
9c9dce45e6 update to thinkink 2021-02-23 15:30:51 -05:00
Dylan Herrada
07fff09bc3
Bump to 2.5.4 2021-02-23 15:22:39 -05:00
Melissa LeBlanc-Williams
67bd18f954
Merge pull request #41 from makermelissa/master
Added Tri-Color Blinka for 200x200 eInk
2021-02-17 11:28:05 -08:00
Melissa LeBlanc-Williams
89b7734355 Added Tri-Color Blinka for 200x200 eInk 2021-02-17 11:13:33 -08:00
Melissa LeBlanc-Williams
742eebb684 Merge branch 'master' of https://github.com/adafruit/Adafruit_ImageReader 2021-02-17 11:12:44 -08:00
Melissa LeBlanc-Williams
ad376f9eb4
Add Monochrome 1.54-inch blinka bmp (#40) 2021-02-16 17:57:05 -05:00
Melissa LeBlanc-Williams
6064349a61 Add Monochrome 1.54-inch blinka bmp 2021-02-16 14:42:12 -08:00
Dylan Herrada
f996ae3811
Bump to 2.5.3 2021-01-21 21:54:46 -05:00
lady ada
4ced09ef18 fix readme 2021-01-17 18:07:53 -05:00
lady ada
d058dd89cb clang 2021-01-17 18:06:52 -05:00
49 changed files with 1006 additions and 153 deletions

22
.clang-format Normal file
View file

@ -0,0 +1,22 @@
Language: Cpp
BasedOnStyle: Google
IndentWidth: 2
ColumnLimit: 80
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
BinPackArguments: true
BinPackParameters: true
BreakBeforeBraces: Attach
DerivePointerAlignment: false
PointerAlignment: Right
SpacesBeforeTrailingComments: 1
IndentCaseLabels: true
SortIncludes: false
AlignTrailingComments: true
MaxEmptyLinesToKeep: 2
SpaceAfterCStyleCast: false
AllowShortBlocksOnASingleLine: false
KeepEmptyLinesAtTheStartOfBlocks: true
AccessModifierOffset: -2
IndentAccessModifiers: false

View file

@ -8,17 +8,18 @@ jobs:
fail-fast: false
matrix:
arduino-platform: ["uno", "leonardo", "mega2560", "esp8266", "esp32",
"zero", "metro_m4", "nrf52840", "pybadge", "hallowing_m4",
"cpb", "cpx_ada", "pyportal"]
"zero", "metro_m4", "nrf52840", "pybadge",
"hallowing_m4", "cpb", "cpx_ada", "pyportal",
"feather_rp2040"]
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v1
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- uses: actions/checkout@v2
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
repository: adafruit/ci-arduino
path: ci
@ -33,12 +34,12 @@ jobs:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/setup-python@v1
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
repository: adafruit/ci-arduino
path: ci

View file

@ -214,7 +214,7 @@ void Adafruit_Image::draw(Adafruit_SPITFT &tft, int16_t x, int16_t y) {
often be in pre-setup() declaration, but DOES need initializing
before any of the image loading or size functions are called!
*/
Adafruit_ImageReader::Adafruit_ImageReader(FatFileSystem &fs) { filesys = &fs; }
Adafruit_ImageReader::Adafruit_ImageReader(FatVolume &fs) { filesys = &fs; }
/*!
@brief Destructor.
@ -246,7 +246,7 @@ Adafruit_ImageReader::~Adafruit_ImageReader(void) {
@return One of the ImageReturnCode values (IMAGE_SUCCESS on successful
completion, other values on failure).
*/
ImageReturnCode Adafruit_ImageReader::drawBMP(char *filename,
ImageReturnCode Adafruit_ImageReader::drawBMP(const char *filename,
Adafruit_SPITFT &tft, int16_t x,
int16_t y, boolean transact) {
uint16_t tftbuf[BUFPIXELS]; // Temp space for buffering TFT data
@ -270,7 +270,7 @@ ImageReturnCode Adafruit_ImageReader::drawBMP(char *filename,
@return One of the ImageReturnCode values (IMAGE_SUCCESS on successful
completion, other values on failure).
*/
ImageReturnCode Adafruit_ImageReader::loadBMP(char *filename,
ImageReturnCode Adafruit_ImageReader::loadBMP(const char *filename,
Adafruit_Image &img) {
// Call core BMP-reading function. TFT and working buffer are NULL
// (unused and allocated in function, respectively), X & Y position are
@ -308,7 +308,7 @@ ImageReturnCode Adafruit_ImageReader::loadBMP(char *filename,
completion, other values on failure).
*/
ImageReturnCode Adafruit_ImageReader::coreBMP(
char *filename, // SD file to load
const char *filename, // SD file to load
Adafruit_SPITFT *tft, // Pointer to TFT object, or NULL if to image
uint16_t *dest, // TFT working buffer, or NULL if to canvas
int16_t x, // Position if loading to TFT (else ignored)
@ -464,9 +464,9 @@ ImageReturnCode Adafruit_ImageReader::coreBMP(
}
for (row = 0; row < loadHeight; row++) { // For each scanline...
yield(); // Keep ESP8266 happy
#ifdef ESP8266
delay(1); // Keep ESP8266 happy
#endif
// Seek to start of scan line. It might seem labor-intensive
// to be doing this on every line, but this method covers a
// lot of gritty details like cropping, flip and scanline
@ -529,8 +529,8 @@ ImageReturnCode Adafruit_ImageReader::coreBMP(
}
} else { // Canvas is simpler,
file.read(sdbuf, sizeof sdbuf); // just load sdbuf
} // (destidx never resets)
srcidx = 0; // Reset bmp buf index
} // (destidx never resets)
srcidx = 0; // Reset bmp buf index
}
if (depth == 24) {
// Convert each pixel from BMP to 565 format, save in dest
@ -564,7 +564,7 @@ ImageReturnCode Adafruit_ImageReader::coreBMP(
}
}
}
} // end pixel loop
} // end pixel loop
if (tft) { // Drawing to TFT?
if (destidx) { // Any remainders?
// See notes above re: DMA
@ -584,11 +584,11 @@ ImageReturnCode Adafruit_ImageReader::coreBMP(
img->palette = quantized; // Keep palette with img
}
} // end depth>24 or quantized malloc OK
} // end top/left clip
} // end malloc check
} // end depth check
} // end planes/compression check
} // end signature
} // end top/left clip
} // end malloc check
} // end depth check
} // end planes/compression check
} // end signature
file.close();
return status;
@ -605,7 +605,7 @@ ImageReturnCode Adafruit_ImageReader::coreBMP(
@return One of the ImageReturnCode values (IMAGE_SUCCESS on successful
completion, other values on failure).
*/
ImageReturnCode Adafruit_ImageReader::bmpDimensions(char *filename,
ImageReturnCode Adafruit_ImageReader::bmpDimensions(const char *filename,
int32_t *width,
int32_t *height) {
@ -628,9 +628,9 @@ ImageReturnCode Adafruit_ImageReader::bmpDimensions(char *filename,
}
status = IMAGE_SUCCESS; // YAY.
}
file.close();
}
file.close();
return status;
}
@ -643,7 +643,7 @@ ImageReturnCode Adafruit_ImageReader::bmpDimensions(char *filename,
@return Unsigned 16-bit value, native endianism.
*/
uint16_t Adafruit_ImageReader::readLE16(void) {
#if !defined(ESP32) && !defined(ESP8266) && \
#if !defined(ESP32) && !defined(ESP8266) && \
(__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
// Read directly into result -- BMP data and variable both little-endian.
uint16_t result;
@ -662,7 +662,7 @@ uint16_t Adafruit_ImageReader::readLE16(void) {
@return Unsigned 32-bit value, native endianism.
*/
uint32_t Adafruit_ImageReader::readLE32(void) {
#if !defined(ESP32) && !defined(ESP8266) && \
#if !defined(ESP32) && !defined(ESP8266) && \
(__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
// Read directly into result -- BMP data and variable both little-endian.
uint32_t result;

View file

@ -94,20 +94,20 @@ protected:
*/
class Adafruit_ImageReader {
public:
Adafruit_ImageReader(FatFileSystem &fs);
Adafruit_ImageReader(FatVolume &fs);
~Adafruit_ImageReader(void);
ImageReturnCode drawBMP(char *filename, Adafruit_SPITFT &tft, int16_t x,
ImageReturnCode drawBMP(const char *filename, Adafruit_SPITFT &tft, int16_t x,
int16_t y, boolean transact = true);
ImageReturnCode loadBMP(char *filename, Adafruit_Image &img);
ImageReturnCode bmpDimensions(char *filename, int32_t *w, int32_t *h);
ImageReturnCode loadBMP(const char *filename, Adafruit_Image &img);
ImageReturnCode bmpDimensions(const char *filename, int32_t *w, int32_t *h);
void printStatus(ImageReturnCode stat, Stream &stream = Serial);
protected:
FatFileSystem *filesys; ///< FAT FileSystem Object
File file; ///< Current Open file
ImageReturnCode coreBMP(char *filename, Adafruit_SPITFT *tft, uint16_t *dest,
int16_t x, int16_t y, Adafruit_Image *img,
boolean transact);
FatVolume *filesys; ///< FAT FileSystem Object
File32 file; ///< Current Open file
ImageReturnCode coreBMP(const char *filename, Adafruit_SPITFT *tft,
uint16_t *dest, int16_t x, int16_t y,
Adafruit_Image *img, boolean transact);
uint16_t readLE16(void);
uint32_t readLE32(void);
};

View file

@ -6,6 +6,86 @@
#define BUFPIXELS 200 ///< 200 * 5 = 1000 bytes
#endif
/*!
@brief Maps RGB color values to EPD display colors based on display mode.
@param r
Red component of the color (0-255).
@param g
Green component of the color (0-255).
@param b
Blue component of the color (0-255).
@param mode
The display mode (THINKINK_MONO, THINKINK_TRICOLOR,
THINKINK_GRAYSCALE4, THINKINK_QUADCOLOR, etc.) that
determines the available colors and mapping strategy.
@return EPD color constant (EPD_BLACK, EPD_WHITE, EPD_RED, EPD_YELLOW,
EPD_DARK, EPD_LIGHT) appropriate for the display mode.
@note Color mapping thresholds:
- Monochrome: Simple average threshold at 128
- Tricolor: Black < 0x60, Red >= 0x80 (red only), White otherwise
- Grayscale: Black < 0x40, Dark < 0x80, Light < 0xC0, White >= 0xC0
- Quadcolor: Black < 0x60, White >= 0xE0 (all channels),
Yellow >= 0xC0 red + >= 0x80 green, Red >= 0xC0 red + < 0x80
green
*/
uint8_t Adafruit_ImageReader_EPD::mapColorForDisplay(uint8_t r, uint8_t g,
uint8_t b,
thinkinkmode_t mode) {
switch (mode) {
case THINKINK_MONO:
case THINKINK_MONO_PARTIAL:
if ((r + g + b) / 3 < 128) {
return EPD_BLACK;
} else {
return EPD_WHITE;
}
case THINKINK_TRICOLOR:
if ((r < 0x60) && (g < 0x60) && (b < 0x60)) {
return EPD_BLACK;
} else if ((r >= 0x80) && (g < 0x80) && (b < 0x80)) {
return EPD_RED;
} else {
return EPD_WHITE;
}
case THINKINK_GRAYSCALE4: {
uint8_t gray = (r + g + b) / 3;
if (gray < 0x40) {
return EPD_BLACK;
} else if (gray < 0x80) {
return EPD_DARK;
} else if (gray < 0xC0) {
return EPD_LIGHT;
} else {
return EPD_WHITE;
}
}
case THINKINK_QUADCOLOR:
if ((r < 0x60) && (g < 0x60) && (b < 0x60)) {
return EPD_BLACK;
} else if ((r >= 0xE0) && (g >= 0xE0) && (b >= 0xE0)) {
return EPD_WHITE;
} else if ((r >= 0xC0) && (g >= 0x80) && (b < 0x40)) {
return EPD_YELLOW;
} else if ((r >= 0xC0) && (g < 0x80) && (b < 0x40)) {
return EPD_RED;
} else {
return EPD_WHITE;
}
default:
if ((r < 0x60) && (g < 0x60) && (b < 0x60)) {
return EPD_BLACK;
} else if ((r >= 0x80) && (g < 0x80) && (b < 0x80)) {
return EPD_RED;
} else {
return EPD_WHITE;
}
}
}
/*!
@brief Draw image to an Adafruit ePaper-type display.
@param epd
@ -43,24 +123,16 @@ void Adafruit_Image_EPD::draw(Adafruit_EPD &epd, int16_t x, int16_t y) {
} else if (format == IMAGE_8) {
} else if (format == IMAGE_16) {
uint16_t *buffer = canvas.canvas16->getBuffer();
thinkinkmode_t displayMode = epd.getMode();
while (row < y + canvas.canvas16->height()) {
// RGB in 565 format
uint8_t r = (*buffer & 0xf800) >> 8;
uint8_t g = (*buffer & 0x07e0) >> 3;
uint8_t b = (*buffer & 0x001f) << 3;
uint8_t c = 0;
if ((r < 0x60) && (g < 0x60) && (b < 0x60)) {
c = EPD_BLACK; // try to infer black
} else if ((r < 0x80) && (g < 0x80) && (b < 0x80)) {
c = EPD_DARK; // try to infer dark gray
} else if ((r < 0xD0) && (g < 0xD0) && (b < 0xD0)) {
c = EPD_LIGHT; // try to infer light gray
} else if ((r >= 0x80) && (g >= 0x80) && (b >= 0x80)) {
c = EPD_WHITE;
} else if (r >= 0x80) {
c = EPD_RED; // try to infer red color
}
uint8_t c =
Adafruit_ImageReader_EPD::mapColorForDisplay(r, g, b, displayMode);
epd.writePixel(col, row, c);
col++;
@ -88,7 +160,7 @@ void Adafruit_Image_EPD::draw(Adafruit_EPD &epd, int16_t x, int16_t y) {
often be in pre-setup() declaration, but DOES need initializing
before any of the image loading or size functions are called!
*/
Adafruit_ImageReader_EPD::Adafruit_ImageReader_EPD(FatFileSystem &fs)
Adafruit_ImageReader_EPD::Adafruit_ImageReader_EPD(FatVolume &fs)
: Adafruit_ImageReader(fs) {}
/*!
@ -157,7 +229,7 @@ ImageReturnCode Adafruit_ImageReader_EPD::coreBMP(
int16_t y,
Adafruit_Image_EPD *img, // NULL if load-to-screen
boolean transact) { // SD & EPD sharing bus, use transactions
thinkinkmode_t displayMode = epd ? epd->getMode() : THINKINK_TRICOLOR;
ImageReturnCode status = IMAGE_ERR_FORMAT; // IMAGE_SUCCESS on valid file
uint32_t offset; // Start of image data in file
uint32_t headerSize; // Indicates BMP version
@ -169,7 +241,7 @@ ImageReturnCode Adafruit_ImageReader_EPD::coreBMP(
uint16_t *quantized = NULL; // EPD Color palette
uint32_t rowSize; // >bmpWidth if scanline padding
uint8_t sdbuf[3 * BUFPIXELS]; // BMP read buf (R+G+B/pixel)
int16_t epd_col, epd_row;
int16_t epd_col = 0, epd_row = 0;
#if ((3 * BUFPIXELS) <= 255)
uint8_t srcidx = sizeof sdbuf; // Current position in sdbuf
#else
@ -297,23 +369,14 @@ ImageReturnCode Adafruit_ImageReader_EPD::coreBMP(
(quantized = (uint16_t *)malloc(colors * sizeof(uint16_t)))) {
if (depth < 16) {
// Load and quantize color table
thinkinkmode_t displayMode =
epd ? epd->getMode() : THINKINK_TRICOLOR;
for (uint16_t c = 0; c < colors; c++) {
b = file.read();
g = file.read();
r = file.read();
(void)file.read(); // Ignore 4th byte
color = 0;
if ((r < 0x60) && (g < 0x60) && (b < 0x60)) {
color = EPD_BLACK; // try to infer black
} else if ((r < 0x80) && (g < 0x80) && (b < 0x80)) {
color = EPD_DARK; // try to infer dark gray
} else if ((r < 0xD0) && (g < 0xD0) && (b < 0xD0)) {
color = EPD_LIGHT; // try to infer light gray
} else if ((r >= 0x80) && (g >= 0x80) && (b >= 0x80)) {
color = EPD_WHITE;
} else if (r >= 0x80) {
color = EPD_RED; // try to infer red color
}
color = mapColorForDisplay(r, g, b, displayMode);
quantized[c] = color;
}
}
@ -391,8 +454,8 @@ ImageReturnCode Adafruit_ImageReader_EPD::coreBMP(
}
} else { // Canvas is simpler,
file.read(sdbuf, sizeof sdbuf); // just load sdbuf
} // (destidx never resets)
srcidx = 0; // Reset bmp buf index
} // (destidx never resets)
srcidx = 0; // Reset bmp buf index
}
if (depth == 24) {
// Convert each pixel from BMP to 565 format, save in dest
@ -400,18 +463,7 @@ ImageReturnCode Adafruit_ImageReader_EPD::coreBMP(
g = sdbuf[srcidx++];
r = sdbuf[srcidx++];
color = 0;
if ((r < 0x60) && (g < 0x60) && (b < 0x60)) {
color = EPD_BLACK; // try to infer black
} else if ((r < 0x80) && (g < 0x80) && (b < 0x80)) {
color = EPD_DARK; // try to infer dark gray
} else if ((r < 0xD0) && (g < 0xD0) && (b < 0xD0)) {
color = EPD_LIGHT; // try to infer light gray
} else if ((r >= 0x80) && (g >= 0x80) && (b >= 0x80)) {
color = EPD_WHITE;
} else if (r >= 0x80) {
color = EPD_RED; // try to infer red color
}
color = mapColorForDisplay(r, g, b, displayMode);
dest[destidx++] = color;
} else {
// Extract 1-bit color index
@ -438,7 +490,7 @@ ImageReturnCode Adafruit_ImageReader_EPD::coreBMP(
}
}
}
} // end pixel loop
} // end pixel loop
if (epd) { // Drawing to TFT?
if (destidx) { // Any remainders?
uint16_t index = 0;
@ -464,11 +516,11 @@ ImageReturnCode Adafruit_ImageReader_EPD::coreBMP(
img->palette = quantized; // Keep palette with img
}
} // end depth>24 or quantized malloc OK
} // end top/left clip
} // end malloc check
} // end depth check
} // end planes/compression check
} // end signature
} // end top/left clip
} // end malloc check
} // end depth check
} // end planes/compression check
} // end signature
file.close();
return status;

View file

@ -44,10 +44,13 @@ protected:
*/
class Adafruit_ImageReader_EPD : public Adafruit_ImageReader {
public:
Adafruit_ImageReader_EPD(FatFileSystem &fs);
Adafruit_ImageReader_EPD(FatVolume &fs);
ImageReturnCode drawBMP(char *filename, Adafruit_EPD &epd, int16_t x,
int16_t y, boolean transact = true);
static uint8_t mapColorForDisplay(uint8_t r, uint8_t g, uint8_t b,
thinkinkmode_t mode);
private:
ImageReturnCode coreBMP(char *filename, Adafruit_EPD *epd, uint16_t *dest,
int16_t x, int16_t y, Adafruit_Image_EPD *img,

View file

@ -1,4 +1,4 @@
# Adafruit_ImageReader ![Build Status](https://github.com/adafruit/Adafruit_ImageReader/workflows/Arduino%20Library%20CI/badge.svg)
# Adafruit ImageReader Arduino Library [![Build Status](https://github.com/adafruit/Adafruit_ImageReader/workflows/Arduino%20Library%20CI/badge.svg)](https://github.com/adafruit/Adafruit_ImageReader/actions)[![Documentation](https://github.com/adafruit/ci-arduino/blob/master/assets/doxygen_badge.svg)](http://adafruit.github.io/Adafruit_ImageReader/html/index.html)
Companion library for Adafruit_GFX to load images from SD card or SPI Flash

View file

@ -9,7 +9,7 @@
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_SSD1331.h> // Hardware-specific library
#include <SdFat.h> // SD card & FAT filesystem library
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions
@ -50,7 +50,7 @@
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
FatVolume filesys;
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif
@ -72,7 +72,7 @@ void setup(void) {
tft.begin(); // Initialize screen
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// accepts an uninitialized SdFat or FatVolume object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)

View file

@ -9,7 +9,7 @@
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_SSD1351.h> // Hardware-specific library
#include <SdFat.h> // SD card & FAT filesystem library
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions
@ -54,7 +54,7 @@
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
FatVolume filesys;
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif
@ -76,7 +76,7 @@ void setup(void) {
tft.begin(); // Initialize screen
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// accepts an uninitialized SdFat or FatVolume object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)

View file

@ -9,7 +9,7 @@
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SdFat.h> // SD card & FAT filesystem library
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions
@ -40,7 +40,7 @@
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
FatVolume filesys;
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif
@ -61,7 +61,7 @@ void setup(void) {
tft.initR(INITR_144GREENTAB); // Initialize screen
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// accepts an uninitialized SdFat or FatVolume object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)

View file

@ -9,7 +9,7 @@
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SdFat.h> // SD card & FAT filesystem library
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions
@ -40,7 +40,7 @@
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
FatVolume filesys;
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif
@ -61,7 +61,7 @@ void setup(void) {
tft.initR(INITR_BLACKTAB); // Initialize screen
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// accepts an uninitialized SdFat or FatVolume object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)

View file

@ -10,7 +10,7 @@
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SdFat.h> // SD card & FAT filesystem library
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions
@ -41,7 +41,7 @@
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
FatVolume filesys;
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif
@ -63,7 +63,7 @@ void setup(void) {
Serial.println(F("TFT initialized."));
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// accepts an uninitialized SdFat or FatVolume object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)

View file

@ -0,0 +1,149 @@
// Adafruit_ImageReader test for Adafruit ST7789 320x240 TFT Breakout for Arduino.
// Demonstrates loading images to the screen, to RAM, and how to query
// image file dimensions.
// Requires three BMP files in root directory of SD card:
// parrot.bmp, miniwoof.bmp and wales.bmp.
// As written, this uses the microcontroller's SPI interface for the screen
// (not 'bitbang') and must be wired to specific pins (e.g. for Arduino Uno,
// MOSI = pin 11, MISO = 12, SCK = 13). Other pins are configurable below.
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions
// Comment out the next line to load from SPI/QSPI flash instead of SD card:
#define USE_SD_CARD
// TFT display and SD card share the hardware SPI interface, using
// 'select' pins for each to identify the active device on the bus.
#define SD_CS 4 // SD card select pin
#define TFT_CS 10 // TFT select pin
#define TFT_DC 8 // TFT display/command pin
#define TFT_RST 9 // Or set to -1 and connect to Arduino RESET pin
#if defined(USE_SD_CARD)
SdFat SD; // SD card filesystem
Adafruit_ImageReader reader(SD); // Image-reader object, pass in SD filesys
#else
// SPI or QSPI flash filesystem (i.e. CIRCUITPY drive)
#if defined(__SAMD51__) || defined(NRF52840_XXAA)
Adafruit_FlashTransport_QSPI flashTransport(PIN_QSPI_SCK, PIN_QSPI_CS,
PIN_QSPI_IO0, PIN_QSPI_IO1, PIN_QSPI_IO2, PIN_QSPI_IO3);
#else
#if (SPI_INTERFACES_COUNT == 1)
Adafruit_FlashTransport_SPI flashTransport(SS, &SPI);
#else
Adafruit_FlashTransport_SPI flashTransport(SS1, &SPI1);
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
Adafruit_Image img; // An image loaded into RAM
int32_t width = 0, // BMP image dimensions
height = 0;
void setup(void) {
ImageReturnCode stat; // Status from image-reading functions
Serial.begin(9600);
while(!Serial); // Wait for Serial Monitor before continuing
tft.init(170, 320); // Init ST7789 170x320
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)
// SD card is pretty straightforward, a single call...
if(!SD.begin(SD_CS, SD_SCK_MHZ(10))) { // Breakouts require 10 MHz limit due to longer wires
Serial.println(F("SD begin() failed"));
for(;;); // Fatal error, do not continue
}
#else
// SPI or QSPI flash requires two steps, one to access the bare flash
// memory itself, then the second to access the filesystem within...
if(!flash.begin()) {
Serial.println(F("flash begin() failed"));
for(;;);
}
if(!filesys.begin(&flash)) {
Serial.println(F("filesys begin() failed"));
for(;;);
}
#endif
Serial.println(F("OK!"));
// Fill screen blue. Not a required step, this just shows that we're
// successfully communicating with the screen.
tft.fillScreen(ST77XX_BLUE);
tft.setRotation(3);
// Load full-screen BMP file 'adabot.bmp' at position (0,0) (top left).
// Notice the 'reader' object performs this, with 'tft' as an argument.
Serial.print(F("Loading adabot.bmp to screen..."));
stat = reader.drawBMP("/adabot.bmp", tft, 0, 0);
reader.printStatus(stat); // How'd we do?
// Query the dimensions of image 'miniwoof.bmp' WITHOUT loading to screen:
Serial.print(F("Querying miniwoof.bmp image size..."));
stat = reader.bmpDimensions("/miniwoof.bmp", &width, &height);
reader.printStatus(stat); // How'd we do?
if(stat == IMAGE_SUCCESS) { // If it worked, print image size...
Serial.print(F("Image dimensions: "));
Serial.print(width);
Serial.write('x');
Serial.println(height);
}
// Load small BMP 'wales.bmp' into a GFX canvas in RAM. This should fail
// gracefully on Arduino Uno and other small devices, meaning the image
// will not load, but this won't make the program stop or crash, it just
// continues on without it. Should work on Arduino Mega, Zero, etc.
Serial.print(F("Loading wales.bmp to canvas..."));
stat = reader.loadBMP("/wales.bmp", img);
reader.printStatus(stat); // How'd we do?
delay(2000); // Pause 2 seconds before moving on to loop()
}
void loop() {
for(int r=0; r<4; r++) { // For each of 4 rotations...
tft.setRotation(r); // Set rotation
tft.fillScreen(0); // and clear screen
// Load 4 copies of the 'miniwoof.bmp' image to the screen, some
// partially off screen edges to demonstrate clipping. Globals
// 'width' and 'height' were set by bmpDimensions() call in setup().
for(int i=0; i<4; i++) {
reader.drawBMP("/miniwoof.bmp", tft,
(tft.width() * i / 3) - (width / 2),
(tft.height() * i / 3) - (height / 2));
}
delay(1000); // Pause 1 sec.
// Draw 50 Welsh dragon flags in random positions. This has no effect
// on memory-constrained boards like the Arduino Uno, where the image
// failed to load due to insufficient RAM, but it's NOT fatal.
for(int i=0; i<50; i++) {
// Rather than reader.drawBMP() (which works from SD card),
// a different function is used for RAM-resident images:
img.draw(tft, // Pass in tft object
(int16_t)random(-img.width() , tft.width()) , // Horiz pos.
(int16_t)random(-img.height(), tft.height())); // Vert pos
// Reiterating a prior point: img.draw() does nothing and returns
// if the image failed to load. It's unfortunate but not disastrous.
}
delay(2000); // Pause 2 sec.
}
}

View file

@ -0,0 +1,149 @@
// Adafruit_ImageReader test for Adafruit ST7789 320x240 TFT Breakout for Arduino.
// Demonstrates loading images to the screen, to RAM, and how to query
// image file dimensions.
// Requires three BMP files in root directory of SD card:
// parrot.bmp, miniwoof.bmp and wales.bmp.
// As written, this uses the microcontroller's SPI interface for the screen
// (not 'bitbang') and must be wired to specific pins (e.g. for Arduino Uno,
// MOSI = pin 11, MISO = 12, SCK = 13). Other pins are configurable below.
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions
// Comment out the next line to load from SPI/QSPI flash instead of SD card:
#define USE_SD_CARD
// TFT display and SD card share the hardware SPI interface, using
// 'select' pins for each to identify the active device on the bus.
#define SD_CS 4 // SD card select pin
#define TFT_CS 10 // TFT select pin
#define TFT_DC 8 // TFT display/command pin
#define TFT_RST 9 // Or set to -1 and connect to Arduino RESET pin
#if defined(USE_SD_CARD)
SdFat SD; // SD card filesystem
Adafruit_ImageReader reader(SD); // Image-reader object, pass in SD filesys
#else
// SPI or QSPI flash filesystem (i.e. CIRCUITPY drive)
#if defined(__SAMD51__) || defined(NRF52840_XXAA)
Adafruit_FlashTransport_QSPI flashTransport(PIN_QSPI_SCK, PIN_QSPI_CS,
PIN_QSPI_IO0, PIN_QSPI_IO1, PIN_QSPI_IO2, PIN_QSPI_IO3);
#else
#if (SPI_INTERFACES_COUNT == 1)
Adafruit_FlashTransport_SPI flashTransport(SS, &SPI);
#else
Adafruit_FlashTransport_SPI flashTransport(SS1, &SPI1);
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
Adafruit_Image img; // An image loaded into RAM
int32_t width = 0, // BMP image dimensions
height = 0;
void setup(void) {
ImageReturnCode stat; // Status from image-reading functions
Serial.begin(9600);
while(!Serial); // Wait for Serial Monitor before continuing
tft.init(172, 320); // Init ST7789 172x320
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)
// SD card is pretty straightforward, a single call...
if(!SD.begin(SD_CS, SD_SCK_MHZ(10))) { // Breakouts require 10 MHz limit due to longer wires
Serial.println(F("SD begin() failed"));
for(;;); // Fatal error, do not continue
}
#else
// SPI or QSPI flash requires two steps, one to access the bare flash
// memory itself, then the second to access the filesystem within...
if(!flash.begin()) {
Serial.println(F("flash begin() failed"));
for(;;);
}
if(!filesys.begin(&flash)) {
Serial.println(F("filesys begin() failed"));
for(;;);
}
#endif
Serial.println(F("OK!"));
// Fill screen blue. Not a required step, this just shows that we're
// successfully communicating with the screen.
tft.fillScreen(ST77XX_BLUE);
tft.setRotation(3);
// Load full-screen BMP file 'adabot.bmp' at position (0,0) (top left).
// Notice the 'reader' object performs this, with 'tft' as an argument.
Serial.print(F("Loading adabot.bmp to screen..."));
stat = reader.drawBMP("/adabot.bmp", tft, 0, 0);
reader.printStatus(stat); // How'd we do?
// Query the dimensions of image 'miniwoof.bmp' WITHOUT loading to screen:
Serial.print(F("Querying miniwoof.bmp image size..."));
stat = reader.bmpDimensions("/miniwoof.bmp", &width, &height);
reader.printStatus(stat); // How'd we do?
if(stat == IMAGE_SUCCESS) { // If it worked, print image size...
Serial.print(F("Image dimensions: "));
Serial.print(width);
Serial.write('x');
Serial.println(height);
}
// Load small BMP 'wales.bmp' into a GFX canvas in RAM. This should fail
// gracefully on Arduino Uno and other small devices, meaning the image
// will not load, but this won't make the program stop or crash, it just
// continues on without it. Should work on Arduino Mega, Zero, etc.
Serial.print(F("Loading wales.bmp to canvas..."));
stat = reader.loadBMP("/wales.bmp", img);
reader.printStatus(stat); // How'd we do?
delay(2000); // Pause 2 seconds before moving on to loop()
}
void loop() {
for(int r=0; r<4; r++) { // For each of 4 rotations...
tft.setRotation(r); // Set rotation
tft.fillScreen(0); // and clear screen
// Load 4 copies of the 'miniwoof.bmp' image to the screen, some
// partially off screen edges to demonstrate clipping. Globals
// 'width' and 'height' were set by bmpDimensions() call in setup().
for(int i=0; i<4; i++) {
reader.drawBMP("/miniwoof.bmp", tft,
(tft.width() * i / 3) - (width / 2),
(tft.height() * i / 3) - (height / 2));
}
delay(1000); // Pause 1 sec.
// Draw 50 Welsh dragon flags in random positions. This has no effect
// on memory-constrained boards like the Arduino Uno, where the image
// failed to load due to insufficient RAM, but it's NOT fatal.
for(int i=0; i<50; i++) {
// Rather than reader.drawBMP() (which works from SD card),
// a different function is used for RAM-resident images:
img.draw(tft, // Pass in tft object
(int16_t)random(-img.width() , tft.width()) , // Horiz pos.
(int16_t)random(-img.height(), tft.height())); // Vert pos
// Reiterating a prior point: img.draw() does nothing and returns
// if the image failed to load. It's unfortunate but not disastrous.
}
delay(2000); // Pause 2 sec.
}
}

View file

@ -0,0 +1,149 @@
// Adafruit_ImageReader test for Adafruit ST7789 320x240 TFT Breakout for Arduino.
// Demonstrates loading images to the screen, to RAM, and how to query
// image file dimensions.
// Requires three BMP files in root directory of SD card:
// parrot.bmp, miniwoof.bmp and wales.bmp.
// As written, this uses the microcontroller's SPI interface for the screen
// (not 'bitbang') and must be wired to specific pins (e.g. for Arduino Uno,
// MOSI = pin 11, MISO = 12, SCK = 13). Other pins are configurable below.
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions
// Comment out the next line to load from SPI/QSPI flash instead of SD card:
#define USE_SD_CARD
// TFT display and SD card share the hardware SPI interface, using
// 'select' pins for each to identify the active device on the bus.
#define SD_CS 4 // SD card select pin
#define TFT_CS 10 // TFT select pin
#define TFT_DC 8 // TFT display/command pin
#define TFT_RST 9 // Or set to -1 and connect to Arduino RESET pin
#if defined(USE_SD_CARD)
SdFat SD; // SD card filesystem
Adafruit_ImageReader reader(SD); // Image-reader object, pass in SD filesys
#else
// SPI or QSPI flash filesystem (i.e. CIRCUITPY drive)
#if defined(__SAMD51__) || defined(NRF52840_XXAA)
Adafruit_FlashTransport_QSPI flashTransport(PIN_QSPI_SCK, PIN_QSPI_CS,
PIN_QSPI_IO0, PIN_QSPI_IO1, PIN_QSPI_IO2, PIN_QSPI_IO3);
#else
#if (SPI_INTERFACES_COUNT == 1)
Adafruit_FlashTransport_SPI flashTransport(SS, &SPI);
#else
Adafruit_FlashTransport_SPI flashTransport(SS1, &SPI1);
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
Adafruit_Image img; // An image loaded into RAM
int32_t width = 0, // BMP image dimensions
height = 0;
void setup(void) {
ImageReturnCode stat; // Status from image-reading functions
Serial.begin(9600);
while(!Serial); // Wait for Serial Monitor before continuing
tft.init(135, 240); // Init ST7789 172x320
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)
// SD card is pretty straightforward, a single call...
if(!SD.begin(SD_CS, SD_SCK_MHZ(10))) { // Breakouts require 10 MHz limit due to longer wires
Serial.println(F("SD begin() failed"));
for(;;); // Fatal error, do not continue
}
#else
// SPI or QSPI flash requires two steps, one to access the bare flash
// memory itself, then the second to access the filesystem within...
if(!flash.begin()) {
Serial.println(F("flash begin() failed"));
for(;;);
}
if(!filesys.begin(&flash)) {
Serial.println(F("filesys begin() failed"));
for(;;);
}
#endif
Serial.println(F("OK!"));
// Fill screen blue. Not a required step, this just shows that we're
// successfully communicating with the screen.
tft.fillScreen(ST77XX_BLUE);
tft.setRotation(3);
// Load full-screen BMP file 'adabot.bmp' at position (0,0) (top left).
// Notice the 'reader' object performs this, with 'tft' as an argument.
Serial.print(F("Loading adabot.bmp to screen..."));
stat = reader.drawBMP("/adabot.bmp", tft, 0, 0);
reader.printStatus(stat); // How'd we do?
// Query the dimensions of image 'miniwoof.bmp' WITHOUT loading to screen:
Serial.print(F("Querying miniwoof.bmp image size..."));
stat = reader.bmpDimensions("/miniwoof.bmp", &width, &height);
reader.printStatus(stat); // How'd we do?
if(stat == IMAGE_SUCCESS) { // If it worked, print image size...
Serial.print(F("Image dimensions: "));
Serial.print(width);
Serial.write('x');
Serial.println(height);
}
// Load small BMP 'wales.bmp' into a GFX canvas in RAM. This should fail
// gracefully on Arduino Uno and other small devices, meaning the image
// will not load, but this won't make the program stop or crash, it just
// continues on without it. Should work on Arduino Mega, Zero, etc.
Serial.print(F("Loading wales.bmp to canvas..."));
stat = reader.loadBMP("/wales.bmp", img);
reader.printStatus(stat); // How'd we do?
delay(2000); // Pause 2 seconds before moving on to loop()
}
void loop() {
for(int r=0; r<4; r++) { // For each of 4 rotations...
tft.setRotation(r); // Set rotation
tft.fillScreen(0); // and clear screen
// Load 4 copies of the 'miniwoof.bmp' image to the screen, some
// partially off screen edges to demonstrate clipping. Globals
// 'width' and 'height' were set by bmpDimensions() call in setup().
for(int i=0; i<4; i++) {
reader.drawBMP("/miniwoof.bmp", tft,
(tft.width() * i / 3) - (width / 2),
(tft.height() * i / 3) - (height / 2));
}
delay(1000); // Pause 1 sec.
// Draw 50 Welsh dragon flags in random positions. This has no effect
// on memory-constrained boards like the Arduino Uno, where the image
// failed to load due to insufficient RAM, but it's NOT fatal.
for(int i=0; i<50; i++) {
// Rather than reader.drawBMP() (which works from SD card),
// a different function is used for RAM-resident images:
img.draw(tft, // Pass in tft object
(int16_t)random(-img.width() , tft.width()) , // Horiz pos.
(int16_t)random(-img.height(), tft.height())); // Vert pos
// Reiterating a prior point: img.draw() does nothing and returns
// if the image failed to load. It's unfortunate but not disastrous.
}
delay(2000); // Pause 2 sec.
}
}

View file

@ -0,0 +1,148 @@
// Adafruit_ImageReader test for Adafruit ST7789 320x240 TFT Breakout for Arduino.
// Demonstrates loading images to the screen, to RAM, and how to query
// image file dimensions.
// Requires three BMP files in root directory of SD card:
// adabot.bmp, miniwoof.bmp and wales.bmp.
// As written, this uses the microcontroller's SPI interface for the screen
// (not 'bitbang') and must be wired to specific pins (e.g. for Arduino Uno,
// MOSI = pin 11, MISO = 12, SCK = 13). Other pins are configurable below.
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions
// Comment out the next line to load from SPI/QSPI flash instead of SD card:
#define USE_SD_CARD
// TFT display and SD card share the hardware SPI interface, using
// 'select' pins for each to identify the active device on the bus.
#define SD_CS 4 // SD card select pin
#define TFT_CS 10 // TFT select pin
#define TFT_DC 8 // TFT display/command pin
#define TFT_RST 9 // Or set to -1 and connect to Arduino RESET pin
#if defined(USE_SD_CARD)
SdFat SD; // SD card filesystem
Adafruit_ImageReader reader(SD); // Image-reader object, pass in SD filesys
#else
// SPI or QSPI flash filesystem (i.e. CIRCUITPY drive)
#if defined(__SAMD51__) || defined(NRF52840_XXAA)
Adafruit_FlashTransport_QSPI flashTransport(PIN_QSPI_SCK, PIN_QSPI_CS,
PIN_QSPI_IO0, PIN_QSPI_IO1, PIN_QSPI_IO2, PIN_QSPI_IO3);
#else
#if (SPI_INTERFACES_COUNT == 1)
Adafruit_FlashTransport_SPI flashTransport(SS, &SPI);
#else
Adafruit_FlashTransport_SPI flashTransport(SS1, &SPI1);
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
Adafruit_Image img; // An image loaded into RAM
int32_t width = 0, // BMP image dimensions
height = 0;
void setup(void) {
ImageReturnCode stat; // Status from image-reading functions
Serial.begin(9600);
while(!Serial); // Wait for Serial Monitor before continuing
tft.init(240, 240); // Init ST7789 172x320
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)
// SD card is pretty straightforward, a single call...
if(!SD.begin(SD_CS, SD_SCK_MHZ(10))) { // Breakouts require 10 MHz limit due to longer wires
Serial.println(F("SD begin() failed"));
for(;;); // Fatal error, do not continue
}
#else
// SPI or QSPI flash requires two steps, one to access the bare flash
// memory itself, then the second to access the filesystem within...
if(!flash.begin()) {
Serial.println(F("flash begin() failed"));
for(;;);
}
if(!filesys.begin(&flash)) {
Serial.println(F("filesys begin() failed"));
for(;;);
}
#endif
Serial.println(F("OK!"));
// Fill screen blue. Not a required step, this just shows that we're
// successfully communicating with the screen.
tft.fillScreen(ST77XX_BLUE);
// Load full-screen BMP file 'adabot.bmp' at position (0,0) (top left).
// Notice the 'reader' object performs this, with 'tft' as an argument.
Serial.print(F("Loading adabot.bmp to screen..."));
stat = reader.drawBMP("/adabot.bmp", tft, 0, 0);
reader.printStatus(stat); // How'd we do?
// Query the dimensions of image 'miniwoof.bmp' WITHOUT loading to screen:
Serial.print(F("Querying miniwoof.bmp image size..."));
stat = reader.bmpDimensions("/miniwoof.bmp", &width, &height);
reader.printStatus(stat); // How'd we do?
if(stat == IMAGE_SUCCESS) { // If it worked, print image size...
Serial.print(F("Image dimensions: "));
Serial.print(width);
Serial.write('x');
Serial.println(height);
}
// Load small BMP 'wales.bmp' into a GFX canvas in RAM. This should fail
// gracefully on Arduino Uno and other small devices, meaning the image
// will not load, but this won't make the program stop or crash, it just
// continues on without it. Should work on Arduino Mega, Zero, etc.
Serial.print(F("Loading wales.bmp to canvas..."));
stat = reader.loadBMP("/wales.bmp", img);
reader.printStatus(stat); // How'd we do?
delay(2000); // Pause 2 seconds before moving on to loop()
}
void loop() {
for(int r=0; r<4; r++) { // For each of 4 rotations...
tft.setRotation(r); // Set rotation
tft.fillScreen(0); // and clear screen
// Load 4 copies of the 'miniwoof.bmp' image to the screen, some
// partially off screen edges to demonstrate clipping. Globals
// 'width' and 'height' were set by bmpDimensions() call in setup().
for(int i=0; i<4; i++) {
reader.drawBMP("/miniwoof.bmp", tft,
(tft.width() * i / 3) - (width / 2),
(tft.height() * i / 3) - (height / 2));
}
delay(1000); // Pause 1 sec.
// Draw 50 Welsh dragon flags in random positions. This has no effect
// on memory-constrained boards like the Arduino Uno, where the image
// failed to load due to insufficient RAM, but it's NOT fatal.
for(int i=0; i<50; i++) {
// Rather than reader.drawBMP() (which works from SD card),
// a different function is used for RAM-resident images:
img.draw(tft, // Pass in tft object
(int16_t)random(-img.width() , tft.width()) , // Horiz pos.
(int16_t)random(-img.height(), tft.height())); // Vert pos
// Reiterating a prior point: img.draw() does nothing and returns
// if the image failed to load. It's unfortunate but not disastrous.
}
delay(2000); // Pause 2 sec.
}
}

View file

@ -0,0 +1,148 @@
// Adafruit_ImageReader test for Adafruit ST7789 320x240 TFT Breakout for Arduino.
// Demonstrates loading images to the screen, to RAM, and how to query
// image file dimensions.
// Requires three BMP files in root directory of SD card:
// parrot.bmp, miniwoof.bmp and wales.bmp.
// As written, this uses the microcontroller's SPI interface for the screen
// (not 'bitbang') and must be wired to specific pins (e.g. for Arduino Uno,
// MOSI = pin 11, MISO = 12, SCK = 13). Other pins are configurable below.
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions
// Comment out the next line to load from SPI/QSPI flash instead of SD card:
#define USE_SD_CARD
// TFT display and SD card share the hardware SPI interface, using
// 'select' pins for each to identify the active device on the bus.
#define SD_CS 4 // SD card select pin
#define TFT_CS 10 // TFT select pin
#define TFT_DC 8 // TFT display/command pin
#define TFT_RST 9 // Or set to -1 and connect to Arduino RESET pin
#if defined(USE_SD_CARD)
SdFat SD; // SD card filesystem
Adafruit_ImageReader reader(SD); // Image-reader object, pass in SD filesys
#else
// SPI or QSPI flash filesystem (i.e. CIRCUITPY drive)
#if defined(__SAMD51__) || defined(NRF52840_XXAA)
Adafruit_FlashTransport_QSPI flashTransport(PIN_QSPI_SCK, PIN_QSPI_CS,
PIN_QSPI_IO0, PIN_QSPI_IO1, PIN_QSPI_IO2, PIN_QSPI_IO3);
#else
#if (SPI_INTERFACES_COUNT == 1)
Adafruit_FlashTransport_SPI flashTransport(SS, &SPI);
#else
Adafruit_FlashTransport_SPI flashTransport(SS1, &SPI1);
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
Adafruit_Image img; // An image loaded into RAM
int32_t width = 0, // BMP image dimensions
height = 0;
void setup(void) {
ImageReturnCode stat; // Status from image-reading functions
Serial.begin(9600);
while(!Serial); // Wait for Serial Monitor before continuing
tft.init(240, 280); // Init ST7789 172x320
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)
// SD card is pretty straightforward, a single call...
if(!SD.begin(SD_CS, SD_SCK_MHZ(10))) { // Breakouts require 10 MHz limit due to longer wires
Serial.println(F("SD begin() failed"));
for(;;); // Fatal error, do not continue
}
#else
// SPI or QSPI flash requires two steps, one to access the bare flash
// memory itself, then the second to access the filesystem within...
if(!flash.begin()) {
Serial.println(F("flash begin() failed"));
for(;;);
}
if(!filesys.begin(&flash)) {
Serial.println(F("filesys begin() failed"));
for(;;);
}
#endif
Serial.println(F("OK!"));
// Fill screen blue. Not a required step, this just shows that we're
// successfully communicating with the screen.
tft.fillScreen(ST77XX_BLUE);
// Load full-screen BMP file 'adabot.bmp' at position (0,0) (top left).
// Notice the 'reader' object performs this, with 'tft' as an argument.
Serial.print(F("Loading adabot.bmp to screen..."));
stat = reader.drawBMP("/adabot.bmp", tft, 0, 0);
reader.printStatus(stat); // How'd we do?
// Query the dimensions of image 'miniwoof.bmp' WITHOUT loading to screen:
Serial.print(F("Querying miniwoof.bmp image size..."));
stat = reader.bmpDimensions("/miniwoof.bmp", &width, &height);
reader.printStatus(stat); // How'd we do?
if(stat == IMAGE_SUCCESS) { // If it worked, print image size...
Serial.print(F("Image dimensions: "));
Serial.print(width);
Serial.write('x');
Serial.println(height);
}
// Load small BMP 'wales.bmp' into a GFX canvas in RAM. This should fail
// gracefully on Arduino Uno and other small devices, meaning the image
// will not load, but this won't make the program stop or crash, it just
// continues on without it. Should work on Arduino Mega, Zero, etc.
Serial.print(F("Loading wales.bmp to canvas..."));
stat = reader.loadBMP("/wales.bmp", img);
reader.printStatus(stat); // How'd we do?
delay(2000); // Pause 2 seconds before moving on to loop()
}
void loop() {
for(int r=0; r<4; r++) { // For each of 4 rotations...
tft.setRotation(r); // Set rotation
tft.fillScreen(0); // and clear screen
// Load 4 copies of the 'miniwoof.bmp' image to the screen, some
// partially off screen edges to demonstrate clipping. Globals
// 'width' and 'height' were set by bmpDimensions() call in setup().
for(int i=0; i<4; i++) {
reader.drawBMP("/miniwoof.bmp", tft,
(tft.width() * i / 3) - (width / 2),
(tft.height() * i / 3) - (height / 2));
}
delay(1000); // Pause 1 sec.
// Draw 50 Welsh dragon flags in random positions. This has no effect
// on memory-constrained boards like the Arduino Uno, where the image
// failed to load due to insufficient RAM, but it's NOT fatal.
for(int i=0; i<50; i++) {
// Rather than reader.drawBMP() (which works from SD card),
// a different function is used for RAM-resident images:
img.draw(tft, // Pass in tft object
(int16_t)random(-img.width() , tft.width()) , // Horiz pos.
(int16_t)random(-img.height(), tft.height())); // Vert pos
// Reiterating a prior point: img.draw() does nothing and returns
// if the image failed to load. It's unfortunate but not disastrous.
}
delay(2000); // Pause 2 sec.
}
}

View file

@ -9,7 +9,7 @@
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SdFat.h> // SD card & FAT filesystem library
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions
@ -40,7 +40,7 @@
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
FatVolume filesys;
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif
@ -61,7 +61,7 @@ void setup(void) {
tft.init(240, 320); // Init ST7789 320x240
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// accepts an uninitialized SdFat or FatVolume object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)

View file

@ -6,7 +6,7 @@
#include <Adafruit_GFX.h> // Core graphics library
#include "Adafruit_EPD.h" // Hardware-specific library for EPD
#include <SdFat.h> // SD card & FAT filesystem library
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader_EPD.h> // Image-reading functions
@ -60,7 +60,7 @@ Adafruit_IL0373 display(152, 152, EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
FatVolume filesys;
Adafruit_ImageReader_EPD reader(filesys); // Image-reader, pass in flash filesys
#endif
@ -84,7 +84,7 @@ void setup(void) {
#endif
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// accepts an uninitialized SdFat or FatVolume object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
// SPI or QSPI flash requires two steps, one to access the bare flash

View file

@ -6,7 +6,7 @@
#include <Adafruit_GFX.h> // Core graphics library
#include "Adafruit_EPD.h" // Hardware-specific library for EPD
#include <SdFat.h> // SD card & FAT filesystem library
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader_EPD.h> // Image-reading functions
@ -76,7 +76,7 @@ Adafruit_IL0373 display(212, 104, EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
FatVolume filesys;
Adafruit_ImageReader_EPD reader(filesys); // Image-reader, pass in flash filesys
#endif
@ -100,7 +100,7 @@ void setup(void) {
#endif
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// accepts an uninitialized SdFat or FatVolume object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
// SPI or QSPI flash requires two steps, one to access the bare flash

View file

@ -4,8 +4,7 @@
// Requires BMP file in root directory of QSPI Flash:
// blinka.bmp.
#include <Adafruit_GFX.h> // Core graphics library
#include "Adafruit_EPD.h" // Hardware-specific library for EPD
#include "Adafruit_ThinkInk.h" // Hardware-specific library for EPD
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader_EPD.h> // Image-reading functions
@ -15,7 +14,10 @@
#define EPD_RESET PIN_A3
#define EPD_BUSY -1
Adafruit_IL0373 display(152, 152, EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
// 1.54" 152x152 Tricolor EPD with ILI0373 chipset
//ThinkInk_154_Tricolor_Z17 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
// 1.54" 200x200 Tricolor EPD with SSD1681 chipset
ThinkInk_154_Tricolor_Z90 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
// SPI or QSPI flash filesystem (i.e. CIRCUITPY drive)
#if defined(__SAMD51__) || defined(NRF52840_XXAA)
@ -30,7 +32,7 @@ Adafruit_IL0373 display(152, 152, EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_B
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
FatVolume filesys;
Adafruit_ImageReader_EPD reader(filesys); // Image-reader, pass in flash filesys
Adafruit_Image_EPD img; // An image loaded into RAM
@ -40,25 +42,23 @@ int32_t width = 0, // BMP image dimensions
void setup(void) {
ImageReturnCode stat; // Status from image-reading functions
Serial.begin(9600);
//while(!Serial); // Wait for Serial Monitor before continuing
Serial.begin(115200);
//while(!Serial) delay(10); // Wait for Serial Monitor before continuing
display.begin();
display.begin(THINKINK_TRICOLOR);
display.setRotation(3);
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// accepts an uninitialized SdFat or FatVolume object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
// SPI or QSPI flash requires two steps, one to access the bare flash
// memory itself, then the second to access the filesystem within...
if(!flash.begin()) {
Serial.println(F("flash begin() failed"));
for(;;);
errorEPD("Flash begin() failed");
}
if(!filesys.begin(&flash)) {
Serial.println(F("filesys begin() failed"));
for(;;);
errorEPD("filesys begin() failed");
}
Serial.println(F("OK!"));
@ -68,6 +68,9 @@ void setup(void) {
Serial.print(F("Loading blinka.bmp to canvas..."));
stat = reader.drawBMP((char *)"/blinka.bmp", display, 0, 0);
reader.printStatus(stat); // How'd we do?
if (stat != IMAGE_SUCCESS) {
errorEPD("Unable to draw image");
}
display.display();
// Query the dimensions of image 'blinka.bmp' WITHOUT loading to screen:
@ -104,3 +107,17 @@ void loop() {
delay(30 * 1000); // Pause 30 sec.
}
}
void errorEPD(const char *errormsg) {
display.fillScreen(0); // clear screen
display.clearBuffer();
display.setTextSize(2);
display.setCursor(10, 10);
display.setTextColor(EPD_BLACK);
display.print(errormsg);
display.display();
while (1) {
delay(10);
}
}

View file

@ -1,6 +1,6 @@
#include <Adafruit_GFX.h> // Core graphics library
#include "Adafruit_ThinkInk.h"
#include <SdFat.h> // SD card & FAT filesystem library
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
#include <Adafruit_ImageReader_EPD.h> // Image-reading functions

View file

@ -6,7 +6,7 @@
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_HX8357.h> // Hardware-specific library
#include <SdFat.h> // SD card & FAT filesystem library
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions
@ -19,7 +19,7 @@
#define TFT_CS 0
#define TFT_DC 15
#define SD_CS 2
#elif defined(ESP32)
#elif defined(ESP32) && !defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2)
#define TFT_CS 15
#define TFT_DC 33
#define SD_CS 14
@ -40,6 +40,10 @@
#define TFT_CS P5_3
#define STMPE_CS P3_3
#define SD_CS P3_2
#elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040)
#define TFT_CS 9
#define TFT_DC 10
#define SD_CS 7 // "pin 5" on original rp2040 feather ONLY
#else // Anything else!
#define TFT_CS 9
#define TFT_DC 10
@ -62,7 +66,7 @@
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
FatVolume filesys;
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif
@ -83,12 +87,14 @@ void setup(void) {
tft.begin(); // Initialize screen
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// accepts an uninitialized SdFat or FatVolume object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)
// SD card is pretty straightforward, a single call...
if(!SD.begin(SD_CS, SD_SCK_MHZ(25))) { // ESP32 requires 25 MHz limit
// M0 max SPI is 12 MHz
// ESP32 can handl 25 MHz
if(!SD.begin(SD_CS, SD_SCK_MHZ(12))) {
Serial.println(F("SD begin() failed"));
for(;;); // Fatal error, do not continue
}

View file

@ -6,7 +6,7 @@
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ILI9341.h> // Hardware-specific library
#include <SdFat.h> // SD card & FAT filesystem library
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions
@ -19,7 +19,7 @@
#define TFT_CS 0
#define TFT_DC 15
#define SD_CS 2
#elif defined(ESP32)
#elif defined(ESP32) && !defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2)
#define TFT_CS 15
#define TFT_DC 33
#define SD_CS 14
@ -40,6 +40,10 @@
#define TFT_CS P5_3
#define STMPE_CS P3_3
#define SD_CS P3_2
#elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040)
#define TFT_CS 9
#define TFT_DC 10
#define SD_CS 7 // "pin 5" on original rp2040 feather ONLY
#else // Anything else!
#define TFT_CS 9
#define TFT_DC 10
@ -62,7 +66,7 @@
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
FatVolume filesys;
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif
@ -76,19 +80,19 @@ void setup(void) {
ImageReturnCode stat; // Status from image-reading functions
Serial.begin(9600);
#if !defined(ESP32)
while(!Serial); // Wait for Serial Monitor before continuing
#endif
while(!Serial) delay(100); // Wait for Serial Monitor before continuing
tft.begin(); // Initialize screen
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// accepts an uninitialized SdFat or FatVolume object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)
// SD card is pretty straightforward, a single call...
if(!SD.begin(SD_CS, SD_SCK_MHZ(25))) { // ESP32 requires 25 MHz limit
// M0 max SPI is 12 MHz
// ESP32 can handl 25 MHz
if(!SD.begin(SD_CS, SD_SCK_MHZ(12))) {
Serial.println(F("SD begin() failed"));
for(;;); // Fatal error, do not continue
}

View file

@ -10,7 +10,7 @@
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SdFat.h> // SD card & FAT filesystem library
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions
#include <Adafruit_miniTFTWing.h> // Part of Seesaw library
@ -41,7 +41,7 @@
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
FatVolume filesys;
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif
@ -71,12 +71,14 @@ void setup(void) {
Serial.println(F("TFT initialized."));
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// accepts an uninitialized SdFat or FatVolume object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)
// SD card is pretty straightforward, a single call...
if(!SD.begin(SD_CS, SD_SCK_MHZ(25))) { // ESP32 requires 25 MHz limit
// M0 max SPI is 12 MHz
// ESP32 can handl 25 MHz
if(!SD.begin(SD_CS, SD_SCK_MHZ(12))) {
Serial.println(F("SD begin() failed"));
for(;;); // Fatal error, do not continue
}

View file

@ -38,7 +38,7 @@
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
FatVolume filesys;
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif
Adafruit_ILI9341 tft(tft8bitbus, TFT_D0, TFT_WR, TFT_DC, TFT_CS, TFT_RST, TFT_RD);
@ -60,7 +60,7 @@ void setup(void) {
tft.begin(); // Initialize screen
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// accepts an uninitialized SdFat or FatVolume object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)

View file

@ -9,7 +9,7 @@
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ILI9341.h> // Hardware-specific library
#include <SdFat.h> // SD card & FAT filesystem library
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions
@ -39,7 +39,7 @@
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
FatVolume filesys;
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif
@ -60,7 +60,7 @@ void setup(void) {
tft.begin(); // Initialize screen
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// accepts an uninitialized SdFat or FatVolume object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)

View file

View file

@ -10,7 +10,7 @@
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SdFat.h> // SD card & FAT filesystem library
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions
#include <Adafruit_seesaw.h> // IF EARLY TFT SHIELD (no Seesaw),
@ -43,7 +43,7 @@
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
FatVolume filesys;
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif
@ -73,7 +73,7 @@ void setup(void) {
tft.initR(INITR_BLACKTAB); // Initialize screen
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// accepts an uninitialized SdFat or FatVolume object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)

View file

@ -37,7 +37,7 @@
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
FatVolume filesys;
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
Adafruit_ST7789 tft = Adafruit_ST7789(spi, TFT_CS, TFT_DC, TFT_RST);
@ -58,7 +58,7 @@ void setup(void) {
digitalWrite(TFT_BACKLIGHT, HIGH); // Backlight on
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// accepts an uninitialized SdFat or FatVolume object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
// SPI or QSPI flash requires two steps, one to access the bare flash

View file

@ -6,7 +6,7 @@
#include <Adafruit_GFX.h> // Core graphics library
#include "Adafruit_ThinkInk.h"
#include <SdFat.h> // SD card & FAT filesystem library
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader_EPD.h> // Image-reading functions
@ -26,6 +26,7 @@
//ThinkInk_213_Mono_B72 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
//ThinkInk_213_Mono_B73 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
//ThinkInk_213_Mono_BN display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
//ThinkInk_290_Mono_M06 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
//ThinkInk_420_Mono_BN display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
// Tri-Color Displays
@ -36,6 +37,8 @@
//ThinkInk_270_Tricolor_C44 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
ThinkInk_290_Tricolor_Z10 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
//ThinkInk_420_Tricolor_RW display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
//ThinkInk_290_Tricolor_Z13 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
//ThinkInk_290_Tricolor_Z94 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
// Grayscale Displays
//ThinkInk_154_Grayscale4_T8 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
@ -60,7 +63,7 @@ ThinkInk_290_Tricolor_Z10 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
FatVolume filesys;
Adafruit_ImageReader_EPD reader(filesys); // Image-reader, pass in flash filesys
#endif
@ -84,7 +87,7 @@ void setup(void) {
#endif
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// accepts an uninitialized SdFat or FatVolume object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
// SPI or QSPI flash requires two steps, one to access the bare flash

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

BIN
images/adabot240x135.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

BIN
images/adabot240x280.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 KiB

BIN
images/adabot320x170.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

BIN
images/adabot320x172.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

View file

@ -1,5 +1,5 @@
name=Adafruit ImageReader Library
version=2.5.2
version=2.10.0
author=Adafruit
maintainer=Adafruit <info@adafruit.com>
sentence=Companion library for Adafruit_GFX and Adafruit_EPD to load images from SD card.