Compare commits
2 commits
master
...
fix-warnin
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a58a4a7cbc | ||
|
|
e5d5379269 |
43 changed files with 136 additions and 972 deletions
|
|
@ -1,22 +0,0 @@
|
|||
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
|
||||
17
.github/workflows/githubci.yml
vendored
17
.github/workflows/githubci.yml
vendored
|
|
@ -8,18 +8,17 @@ jobs:
|
|||
fail-fast: false
|
||||
matrix:
|
||||
arduino-platform: ["uno", "leonardo", "mega2560", "esp8266", "esp32",
|
||||
"zero", "metro_m4", "nrf52840", "pybadge",
|
||||
"hallowing_m4", "cpb", "cpx_ada", "pyportal",
|
||||
"feather_rp2040"]
|
||||
"zero", "metro_m4", "nrf52840", "pybadge", "hallowing_m4",
|
||||
"cpb", "cpx_ada", "pyportal"]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-python@v4
|
||||
- uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: '3.8'
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
repository: adafruit/ci-arduino
|
||||
path: ci
|
||||
|
|
@ -34,12 +33,12 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- uses: actions/setup-python@v4
|
||||
- uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
repository: adafruit/ci-arduino
|
||||
path: ci
|
||||
|
|
|
|||
|
|
@ -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(FatVolume &fs) { filesys = &fs; }
|
||||
Adafruit_ImageReader::Adafruit_ImageReader(FatFileSystem &fs) { filesys = &fs; }
|
||||
|
||||
/*!
|
||||
@brief Destructor.
|
||||
|
|
@ -308,7 +308,7 @@ ImageReturnCode Adafruit_ImageReader::loadBMP(const char *filename,
|
|||
completion, other values on failure).
|
||||
*/
|
||||
ImageReturnCode Adafruit_ImageReader::coreBMP(
|
||||
const 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...
|
||||
#ifdef ESP8266
|
||||
delay(1); // Keep ESP8266 happy
|
||||
#endif
|
||||
|
||||
yield(); // Keep ESP8266 happy
|
||||
|
||||
// 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;
|
||||
|
|
@ -628,9 +628,9 @@ ImageReturnCode Adafruit_ImageReader::bmpDimensions(const char *filename,
|
|||
}
|
||||
status = IMAGE_SUCCESS; // YAY.
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
file.close();
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
@ -643,7 +643,7 @@ ImageReturnCode Adafruit_ImageReader::bmpDimensions(const 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;
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ protected:
|
|||
*/
|
||||
class Adafruit_ImageReader {
|
||||
public:
|
||||
Adafruit_ImageReader(FatVolume &fs);
|
||||
Adafruit_ImageReader(FatFileSystem &fs);
|
||||
~Adafruit_ImageReader(void);
|
||||
ImageReturnCode drawBMP(const char *filename, Adafruit_SPITFT &tft, int16_t x,
|
||||
int16_t y, boolean transact = true);
|
||||
|
|
@ -103,11 +103,11 @@ public:
|
|||
void printStatus(ImageReturnCode stat, Stream &stream = Serial);
|
||||
|
||||
protected:
|
||||
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);
|
||||
FatFileSystem *filesys; ///< FAT FileSystem Object
|
||||
File 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);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,86 +6,6 @@
|
|||
#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
|
||||
|
|
@ -123,16 +43,24 @@ 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 =
|
||||
Adafruit_ImageReader_EPD::mapColorForDisplay(r, g, b, displayMode);
|
||||
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
|
||||
}
|
||||
|
||||
epd.writePixel(col, row, c);
|
||||
col++;
|
||||
|
|
@ -160,7 +88,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(FatVolume &fs)
|
||||
Adafruit_ImageReader_EPD::Adafruit_ImageReader_EPD(FatFileSystem &fs)
|
||||
: Adafruit_ImageReader(fs) {}
|
||||
|
||||
/*!
|
||||
|
|
@ -229,7 +157,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
|
||||
|
|
@ -241,7 +169,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 = 0, epd_row = 0;
|
||||
int16_t epd_col, epd_row;
|
||||
#if ((3 * BUFPIXELS) <= 255)
|
||||
uint8_t srcidx = sizeof sdbuf; // Current position in sdbuf
|
||||
#else
|
||||
|
|
@ -369,14 +297,23 @@ 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 = mapColorForDisplay(r, g, b, displayMode);
|
||||
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
|
||||
}
|
||||
quantized[c] = color;
|
||||
}
|
||||
}
|
||||
|
|
@ -454,8 +391,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
|
||||
|
|
@ -463,7 +400,18 @@ ImageReturnCode Adafruit_ImageReader_EPD::coreBMP(
|
|||
g = sdbuf[srcidx++];
|
||||
r = sdbuf[srcidx++];
|
||||
|
||||
color = mapColorForDisplay(r, g, b, displayMode);
|
||||
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
|
||||
}
|
||||
dest[destidx++] = color;
|
||||
} else {
|
||||
// Extract 1-bit color index
|
||||
|
|
@ -490,7 +438,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;
|
||||
|
|
@ -516,11 +464,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;
|
||||
|
|
|
|||
|
|
@ -44,13 +44,10 @@ protected:
|
|||
*/
|
||||
class Adafruit_ImageReader_EPD : public Adafruit_ImageReader {
|
||||
public:
|
||||
Adafruit_ImageReader_EPD(FatVolume &fs);
|
||||
Adafruit_ImageReader_EPD(FatFileSystem &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,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <Adafruit_GFX.h> // Core graphics library
|
||||
#include <Adafruit_SSD1331.h> // Hardware-specific library
|
||||
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
|
||||
#include <SdFat.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);
|
||||
FatVolume filesys;
|
||||
FatFileSystem 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 FatVolume object. This MUST
|
||||
// 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)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <Adafruit_GFX.h> // Core graphics library
|
||||
#include <Adafruit_SSD1351.h> // Hardware-specific library
|
||||
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
|
||||
#include <SdFat.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);
|
||||
FatVolume filesys;
|
||||
FatFileSystem 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 FatVolume object. This MUST
|
||||
// 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)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <Adafruit_GFX.h> // Core graphics library
|
||||
#include <Adafruit_ST7735.h> // Hardware-specific library
|
||||
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
|
||||
#include <SdFat.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);
|
||||
FatVolume filesys;
|
||||
FatFileSystem 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 FatVolume object. This MUST
|
||||
// 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)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <Adafruit_GFX.h> // Core graphics library
|
||||
#include <Adafruit_ST7735.h> // Hardware-specific library
|
||||
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
|
||||
#include <SdFat.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);
|
||||
FatVolume filesys;
|
||||
FatFileSystem 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 FatVolume object. This MUST
|
||||
// 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)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include <Adafruit_GFX.h> // Core graphics library
|
||||
#include <Adafruit_ST7735.h> // Hardware-specific library
|
||||
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
|
||||
#include <SdFat.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);
|
||||
FatVolume filesys;
|
||||
FatFileSystem 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 FatVolume object. This MUST
|
||||
// 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)
|
||||
|
|
|
|||
|
|
@ -1,149 +0,0 @@
|
|||
// 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.
|
||||
}
|
||||
}
|
||||
|
|
@ -1,149 +0,0 @@
|
|||
// 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.
|
||||
}
|
||||
}
|
||||
|
|
@ -1,149 +0,0 @@
|
|||
// 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.
|
||||
}
|
||||
}
|
||||
|
|
@ -1,148 +0,0 @@
|
|||
// 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.
|
||||
}
|
||||
}
|
||||
|
|
@ -1,148 +0,0 @@
|
|||
// 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.
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#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 <SdFat.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);
|
||||
FatVolume filesys;
|
||||
FatFileSystem 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 FatVolume object. This MUST
|
||||
// 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)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <Adafruit_GFX.h> // Core graphics library
|
||||
#include "Adafruit_EPD.h" // Hardware-specific library for EPD
|
||||
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
|
||||
#include <SdFat.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);
|
||||
FatVolume filesys;
|
||||
FatFileSystem 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 FatVolume object. This MUST
|
||||
// accepts an uninitialized SdFat or FatFileSystem 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
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <Adafruit_GFX.h> // Core graphics library
|
||||
#include "Adafruit_EPD.h" // Hardware-specific library for EPD
|
||||
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
|
||||
#include <SdFat.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);
|
||||
FatVolume filesys;
|
||||
FatFileSystem 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 FatVolume object. This MUST
|
||||
// accepts an uninitialized SdFat or FatFileSystem 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
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ ThinkInk_154_Tricolor_Z90 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
|
|||
#endif
|
||||
|
||||
Adafruit_SPIFlash flash(&flashTransport);
|
||||
FatVolume filesys;
|
||||
FatFileSystem filesys;
|
||||
Adafruit_ImageReader_EPD reader(filesys); // Image-reader, pass in flash filesys
|
||||
|
||||
Adafruit_Image_EPD img; // An image loaded into RAM
|
||||
|
|
@ -49,7 +49,7 @@ void setup(void) {
|
|||
display.setRotation(3);
|
||||
|
||||
// The Adafruit_ImageReader constructor call (above, before setup())
|
||||
// accepts an uninitialized SdFat or FatVolume object. This MUST
|
||||
// accepts an uninitialized SdFat or FatFileSystem 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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <Adafruit_GFX.h> // Core graphics library
|
||||
#include "Adafruit_ThinkInk.h"
|
||||
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
|
||||
#include <SdFat.h> // SD card & FAT filesystem library
|
||||
#include <Adafruit_ImageReader_EPD.h> // Image-reading functions
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <Adafruit_GFX.h> // Core graphics library
|
||||
#include <Adafruit_HX8357.h> // Hardware-specific library
|
||||
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
|
||||
#include <SdFat.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) && !defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2)
|
||||
#elif defined(ESP32)
|
||||
#define TFT_CS 15
|
||||
#define TFT_DC 33
|
||||
#define SD_CS 14
|
||||
|
|
@ -40,10 +40,6 @@
|
|||
#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
|
||||
|
|
@ -66,7 +62,7 @@
|
|||
#endif
|
||||
#endif
|
||||
Adafruit_SPIFlash flash(&flashTransport);
|
||||
FatVolume filesys;
|
||||
FatFileSystem filesys;
|
||||
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
|
||||
#endif
|
||||
|
||||
|
|
@ -87,14 +83,12 @@ void setup(void) {
|
|||
tft.begin(); // Initialize screen
|
||||
|
||||
// The Adafruit_ImageReader constructor call (above, before setup())
|
||||
// accepts an uninitialized SdFat or FatVolume object. This MUST
|
||||
// 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...
|
||||
// M0 max SPI is 12 MHz
|
||||
// ESP32 can handl 25 MHz
|
||||
if(!SD.begin(SD_CS, SD_SCK_MHZ(12))) {
|
||||
if(!SD.begin(SD_CS, SD_SCK_MHZ(25))) { // ESP32 requires 25 MHz limit
|
||||
Serial.println(F("SD begin() failed"));
|
||||
for(;;); // Fatal error, do not continue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <Adafruit_GFX.h> // Core graphics library
|
||||
#include <Adafruit_ILI9341.h> // Hardware-specific library
|
||||
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
|
||||
#include <SdFat.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) && !defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2)
|
||||
#elif defined(ESP32)
|
||||
#define TFT_CS 15
|
||||
#define TFT_DC 33
|
||||
#define SD_CS 14
|
||||
|
|
@ -40,10 +40,6 @@
|
|||
#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
|
||||
|
|
@ -66,7 +62,7 @@
|
|||
#endif
|
||||
#endif
|
||||
Adafruit_SPIFlash flash(&flashTransport);
|
||||
FatVolume filesys;
|
||||
FatFileSystem filesys;
|
||||
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
|
||||
#endif
|
||||
|
||||
|
|
@ -80,19 +76,19 @@ void setup(void) {
|
|||
ImageReturnCode stat; // Status from image-reading functions
|
||||
|
||||
Serial.begin(9600);
|
||||
while(!Serial) delay(100); // Wait for Serial Monitor before continuing
|
||||
#if !defined(ESP32)
|
||||
while(!Serial); // Wait for Serial Monitor before continuing
|
||||
#endif
|
||||
|
||||
tft.begin(); // Initialize screen
|
||||
|
||||
// The Adafruit_ImageReader constructor call (above, before setup())
|
||||
// accepts an uninitialized SdFat or FatVolume object. This MUST
|
||||
// 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...
|
||||
// M0 max SPI is 12 MHz
|
||||
// ESP32 can handl 25 MHz
|
||||
if(!SD.begin(SD_CS, SD_SCK_MHZ(12))) {
|
||||
if(!SD.begin(SD_CS, SD_SCK_MHZ(25))) { // ESP32 requires 25 MHz limit
|
||||
Serial.println(F("SD begin() failed"));
|
||||
for(;;); // Fatal error, do not continue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include <Adafruit_GFX.h> // Core graphics library
|
||||
#include <Adafruit_ST7735.h> // Hardware-specific library
|
||||
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
|
||||
#include <SdFat.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);
|
||||
FatVolume filesys;
|
||||
FatFileSystem filesys;
|
||||
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
|
||||
#endif
|
||||
|
||||
|
|
@ -71,14 +71,12 @@ void setup(void) {
|
|||
Serial.println(F("TFT initialized."));
|
||||
|
||||
// The Adafruit_ImageReader constructor call (above, before setup())
|
||||
// accepts an uninitialized SdFat or FatVolume object. This MUST
|
||||
// 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...
|
||||
// M0 max SPI is 12 MHz
|
||||
// ESP32 can handl 25 MHz
|
||||
if(!SD.begin(SD_CS, SD_SCK_MHZ(12))) {
|
||||
if(!SD.begin(SD_CS, SD_SCK_MHZ(25))) { // ESP32 requires 25 MHz limit
|
||||
Serial.println(F("SD begin() failed"));
|
||||
for(;;); // Fatal error, do not continue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
#endif
|
||||
#endif
|
||||
Adafruit_SPIFlash flash(&flashTransport);
|
||||
FatVolume filesys;
|
||||
FatFileSystem 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 FatVolume object. This MUST
|
||||
// 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)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <Adafruit_GFX.h> // Core graphics library
|
||||
#include <Adafruit_ILI9341.h> // Hardware-specific library
|
||||
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
|
||||
#include <SdFat.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);
|
||||
FatVolume filesys;
|
||||
FatFileSystem 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 FatVolume object. This MUST
|
||||
// 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)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include <Adafruit_GFX.h> // Core graphics library
|
||||
#include <Adafruit_ST7735.h> // Hardware-specific library
|
||||
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
|
||||
#include <SdFat.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);
|
||||
FatVolume filesys;
|
||||
FatFileSystem 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 FatVolume object. This MUST
|
||||
// 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)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
#endif
|
||||
|
||||
Adafruit_SPIFlash flash(&flashTransport);
|
||||
FatVolume filesys;
|
||||
FatFileSystem 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 FatVolume object. This MUST
|
||||
// accepts an uninitialized SdFat or FatFileSystem 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
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <Adafruit_GFX.h> // Core graphics library
|
||||
#include "Adafruit_ThinkInk.h"
|
||||
#include <SdFat_Adafruit_Fork.h> // SD card & FAT filesystem library
|
||||
#include <SdFat.h> // SD card & FAT filesystem library
|
||||
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
|
||||
#include <Adafruit_ImageReader_EPD.h> // Image-reading functions
|
||||
|
||||
|
|
@ -26,7 +26,6 @@
|
|||
//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
|
||||
|
|
@ -37,8 +36,6 @@
|
|||
//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);
|
||||
|
|
@ -63,7 +60,7 @@ ThinkInk_290_Tricolor_Z10 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
|
|||
#endif
|
||||
#endif
|
||||
Adafruit_SPIFlash flash(&flashTransport);
|
||||
FatVolume filesys;
|
||||
FatFileSystem filesys;
|
||||
Adafruit_ImageReader_EPD reader(filesys); // Image-reader, pass in flash filesys
|
||||
#endif
|
||||
|
||||
|
|
@ -87,7 +84,7 @@ void setup(void) {
|
|||
#endif
|
||||
|
||||
// The Adafruit_ImageReader constructor call (above, before setup())
|
||||
// accepts an uninitialized SdFat or FatVolume object. This MUST
|
||||
// accepts an uninitialized SdFat or FatFileSystem 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.
|
Before Width: | Height: | Size: 136 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 95 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 197 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 159 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 161 KiB |
|
|
@ -1,5 +1,5 @@
|
|||
name=Adafruit ImageReader Library
|
||||
version=2.10.0
|
||||
version=2.6.1
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <info@adafruit.com>
|
||||
sentence=Companion library for Adafruit_GFX and Adafruit_EPD to load images from SD card.
|
||||
|
|
|
|||
Loading…
Reference in a new issue