Fixed SD example
This commit is contained in:
parent
1d7ce616fb
commit
682590386c
1 changed files with 92 additions and 85 deletions
|
|
@ -15,10 +15,22 @@ An SD bmp image load example. (extracted and modded by Adafruit old library http
|
||||||
#include <Adafruit_GFX.h>
|
#include <Adafruit_GFX.h>
|
||||||
#include <TFT_ILI9163C.h>
|
#include <TFT_ILI9163C.h>
|
||||||
|
|
||||||
|
//PINS
|
||||||
#define __CS 10
|
#define __CS 10
|
||||||
#define __DC 9
|
#define __DC 9
|
||||||
#define __SDCS 2
|
#define __SDCS 2
|
||||||
|
|
||||||
|
// This function opens a Windows Bitmap (BMP) file and
|
||||||
|
// displays it at the given coordinates. It's sped up
|
||||||
|
// by reading many pixels worth of data at a time
|
||||||
|
// (rather than pixel by pixel). Increasing the buffer
|
||||||
|
// size takes more of the Arduino's precious RAM but
|
||||||
|
// makes loading a little faster. 20 pixels seems a
|
||||||
|
// good balance.
|
||||||
|
#define BUFFPIXEL 20
|
||||||
|
|
||||||
|
boolean SDInited = true;
|
||||||
|
|
||||||
TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC);
|
TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC);
|
||||||
SdFat SD;
|
SdFat SD;
|
||||||
SdFile myFile;
|
SdFile myFile;
|
||||||
|
|
@ -35,6 +47,7 @@ void setup(void) {
|
||||||
if (!SD.begin(__SDCS,SPI_HALF_SPEED)) {
|
if (!SD.begin(__SDCS,SPI_HALF_SPEED)) {
|
||||||
tft.setCursor(0,0);
|
tft.setCursor(0,0);
|
||||||
tft.print("sd failed!");
|
tft.print("sd failed!");
|
||||||
|
SDInited = false;
|
||||||
}
|
}
|
||||||
Serial.println("OK!");
|
Serial.println("OK!");
|
||||||
//your image here!
|
//your image here!
|
||||||
|
|
@ -44,17 +57,10 @@ void setup(void) {
|
||||||
void loop() {
|
void loop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function opens a Windows Bitmap (BMP) file and
|
|
||||||
// displays it at the given coordinates. It's sped up
|
|
||||||
// by reading many pixels worth of data at a time
|
|
||||||
// (rather than pixel by pixel). Increasing the buffer
|
|
||||||
// size takes more of the Arduino's precious RAM but
|
|
||||||
// makes loading a little faster. 20 pixels seems a
|
|
||||||
// good balance.
|
|
||||||
|
|
||||||
#define BUFFPIXEL 20
|
|
||||||
|
|
||||||
void bmpDraw(char *filename, uint8_t x, uint16_t y) {
|
void bmpDraw(const char *filename, uint8_t x, uint16_t y) {
|
||||||
|
if (SDInited){
|
||||||
|
|
||||||
File bmpFile;
|
File bmpFile;
|
||||||
uint16_t bmpWidth, bmpHeight; // W+H in pixels
|
uint16_t bmpWidth, bmpHeight; // W+H in pixels
|
||||||
|
|
@ -137,6 +143,7 @@ void bmpDraw(char *filename, uint8_t x, uint16_t y) {
|
||||||
tft.setCursor(0,0);
|
tft.setCursor(0,0);
|
||||||
tft.print("file unrecognized!");
|
tft.print("file unrecognized!");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue