Fixed SD example

This commit is contained in:
sumotoy 2015-03-05 22:15:09 +01:00
parent 1d7ce616fb
commit 682590386c

View file

@ -15,10 +15,22 @@ An SD bmp image load example. (extracted and modded by Adafruit old library http
#include <Adafruit_GFX.h>
#include <TFT_ILI9163C.h>
//PINS
#define __CS 10
#define __DC 9
#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);
SdFat SD;
SdFile myFile;
@ -35,6 +47,7 @@ void setup(void) {
if (!SD.begin(__SDCS,SPI_HALF_SPEED)) {
tft.setCursor(0,0);
tft.print("sd failed!");
SDInited = false;
}
Serial.println("OK!");
//your image here!
@ -44,17 +57,10 @@ void setup(void) {
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;
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.print("file unrecognized!");
}
}
}