i trying convert output "serial" "tft" using 2.8" inch tft lcd display touch screen module micro sd solt arduino uno.
i use sd card test library starting point, , working point directory listning starts.
i cal fine initialice, , read data micro sd disk, size, totals , so, when comes this:
root.openroot(volume);
// list files in card date , size
root.ls(ls_r | ls_date | ls_size);
... stops working...
program-listning:
/*
sd card test
example shows how use utility libraries on the'
sd library based in order info sd card.
useful testing card when you're not sure whether working or not.
circuit:
* sd card attached spi bus follows:
** mosi - pin 11 on arduino uno/duemilanove/diecimila
** miso - pin 12 on arduino uno/duemilanove/diecimila
** clk - pin 13 on arduino uno/duemilanove/diecimila
** cs - depends on sd card shield or module.
pin 4 used here consistency other arduino examples
created 28 mar 2011
limor fried
modified 9 apr 2012
tom igoe
*/
#include <adafruit_gfx.h> // core graphics library
#include <adafruit_tftlcd.h> // hardware-specific library
// include sd library:
#include <sd.h>
#define lcd_cs a3 // chip select goes analog 3
#define lcd_cd a2 // command/data goes analog 2
#define lcd_wr a1 // lcd write goes analog 1
#define lcd_rd a0 // lcd read goes analog 0
// set variables using sd utility library functions:
sd2card card;
sdvolume volume;
sdfile root;
// change match sd shield or module;
// arduino ethernet shield: pin 4
// adafruit sd shields , modules: pin 10
// sparkfun sd shield: pin 8
const int chipselect = 10;
#define sd_cs 10 // set chip select line whatever use (10 doesnt conflict library)
// in sd card, place 24 bit color bmp files (be sure 24-bit!)
// there examples in sketch folder
// our tft wiring
adafruit_tftlcd tft(lcd_cs, lcd_cd, lcd_wr, lcd_rd, a4);
void setup()
{
tft.reset();
tft.begin(0x9341);
tft.settextsize(1);
tft.fillscreen(0);
tft.setrotation(3);
sd.begin(sd_cs);
// open serial communications , wait port open:
// tft.begin(9600);
/* while (!tft) {
; // wait serial port connect. needed leonardo only
}
*/
tft.println("\ninitializing sd card...");
// on ethernet shield, cs pin 4. it's set output default.
// note if it's not used cs pin, hardware ss pin
// (10 on arduino boards, 53 on mega) must left output
// or sd library functions not work.
pinmode(10, output); // change 53 on mega
// we'll use initialization code utility libraries
// since we're testing if card working!
if (!card.init(spi_half_speed, chipselect)) {
tft.println("initialization failed. things check:");
tft.println("* card inserted?");
tft.println("* wiring correct?");
tft.println("* did change chipselect pin match shield or module?");
return;
} else {
tft.println("wiring correct , card present.");
}
// print type of card
tft.print("\ncard type: ");
switch(card.type()) {
case sd_card_type_sd1:
tft.println("sd1");
break;
case sd_card_type_sd2:
tft.println("sd2");
break;
case sd_card_type_sdhc:
tft.println("sdhc");
break;
default:
tft.println("unknown");
}
// try open 'volume'/'partition' - should fat16 or fat32
if (!volume.init(card)) {
tft.println("could not find fat16/fat32 partition.\nmake sure you've formatted card");
return;
}
// print type , size of first fat-type volume
uint32_t volumesize;
tft.print("\nvolume type fat");
tft.println(volume.fattype(), dec);
tft.println();
volumesize = volume.blockspercluster(); // clusters collections of blocks
volumesize *= volume.clustercount(); // we'll have lot of clusters
volumesize *= 512; // sd card blocks 512 bytes
tft.print("volume size (bytes): ");
tft.println(volumesize);
tft.print("volume size (kbytes): ");
volumesize /= 1024;
tft.println(volumesize);
tft.print("volume size (mbytes): ");
volumesize /= 1024;
tft.println(volumesize);
tft.println("\nfiles on card (name, date , size in bytes): ");
root.openroot(volume);
// list files in card date , size
root.ls(ls_r | ls_date | ls_size);
}
void loop(void) {
}
i use sd card test library starting point, , working point directory listning starts.
i cal fine initialice, , read data micro sd disk, size, totals , so, when comes this:
root.openroot(volume);
// list files in card date , size
root.ls(ls_r | ls_date | ls_size);
... stops working...
program-listning:
/*
sd card test
example shows how use utility libraries on the'
sd library based in order info sd card.
useful testing card when you're not sure whether working or not.
circuit:
* sd card attached spi bus follows:
** mosi - pin 11 on arduino uno/duemilanove/diecimila
** miso - pin 12 on arduino uno/duemilanove/diecimila
** clk - pin 13 on arduino uno/duemilanove/diecimila
** cs - depends on sd card shield or module.
pin 4 used here consistency other arduino examples
created 28 mar 2011
limor fried
modified 9 apr 2012
tom igoe
*/
#include <adafruit_gfx.h> // core graphics library
#include <adafruit_tftlcd.h> // hardware-specific library
// include sd library:
#include <sd.h>
#define lcd_cs a3 // chip select goes analog 3
#define lcd_cd a2 // command/data goes analog 2
#define lcd_wr a1 // lcd write goes analog 1
#define lcd_rd a0 // lcd read goes analog 0
// set variables using sd utility library functions:
sd2card card;
sdvolume volume;
sdfile root;
// change match sd shield or module;
// arduino ethernet shield: pin 4
// adafruit sd shields , modules: pin 10
// sparkfun sd shield: pin 8
const int chipselect = 10;
#define sd_cs 10 // set chip select line whatever use (10 doesnt conflict library)
// in sd card, place 24 bit color bmp files (be sure 24-bit!)
// there examples in sketch folder
// our tft wiring
adafruit_tftlcd tft(lcd_cs, lcd_cd, lcd_wr, lcd_rd, a4);
void setup()
{
tft.reset();
tft.begin(0x9341);
tft.settextsize(1);
tft.fillscreen(0);
tft.setrotation(3);
sd.begin(sd_cs);
// open serial communications , wait port open:
// tft.begin(9600);
/* while (!tft) {
; // wait serial port connect. needed leonardo only
}
*/
tft.println("\ninitializing sd card...");
// on ethernet shield, cs pin 4. it's set output default.
// note if it's not used cs pin, hardware ss pin
// (10 on arduino boards, 53 on mega) must left output
// or sd library functions not work.
pinmode(10, output); // change 53 on mega
// we'll use initialization code utility libraries
// since we're testing if card working!
if (!card.init(spi_half_speed, chipselect)) {
tft.println("initialization failed. things check:");
tft.println("* card inserted?");
tft.println("* wiring correct?");
tft.println("* did change chipselect pin match shield or module?");
return;
} else {
tft.println("wiring correct , card present.");
}
// print type of card
tft.print("\ncard type: ");
switch(card.type()) {
case sd_card_type_sd1:
tft.println("sd1");
break;
case sd_card_type_sd2:
tft.println("sd2");
break;
case sd_card_type_sdhc:
tft.println("sdhc");
break;
default:
tft.println("unknown");
}
// try open 'volume'/'partition' - should fat16 or fat32
if (!volume.init(card)) {
tft.println("could not find fat16/fat32 partition.\nmake sure you've formatted card");
return;
}
// print type , size of first fat-type volume
uint32_t volumesize;
tft.print("\nvolume type fat");
tft.println(volume.fattype(), dec);
tft.println();
volumesize = volume.blockspercluster(); // clusters collections of blocks
volumesize *= volume.clustercount(); // we'll have lot of clusters
volumesize *= 512; // sd card blocks 512 bytes
tft.print("volume size (bytes): ");
tft.println(volumesize);
tft.print("volume size (kbytes): ");
volumesize /= 1024;
tft.println(volumesize);
tft.print("volume size (mbytes): ");
volumesize /= 1024;
tft.println(volumesize);
tft.println("\nfiles on card (name, date , size in bytes): ");
root.openroot(volume);
// list files in card date , size
root.ls(ls_r | ls_date | ls_size);
}
void loop(void) {
}
Arduino Forum > Using Arduino > Storage > SD "dir"-command
arduino
Comments
Post a Comment