hey poeple!
i newbie arduino (i love it!), , have problem!
i trying program arduino wave shield version 1.1 play sound, there error in code not know how fix! here is:
#include <wavehc.h>
#include <waveutil.h>
sdreader card;
fatvolume vol;
fatreader root;
wavehc wave;
uint8_t dirlevel;
dir_t dirbuf;
const int keypin = 12;
#define error(msg) error_p(pstr(msg)) <-------------this line said have error
according ide. read bottom
of text!
void play(fatreader &dir); l
v
void setup() {
serial.begin(9600);
pinmode(keypin, input);
putstring_nl("\nwave test!");
putstring("free ram: ");
serial.println(freeram());
if(!card.init()) {
error("card init. failed!");
}
card.partialblockread(true);
uint8_t part;
for(part = 0; part < 5; part++) {
if(vol.init(card, part))
break;
}
if(part == 5) {
error("no valid fat partition!");
}
putstring("using partition ");
serial.print(part, dec);
putstring(", type fat");
serial.println(vol.fattype(), dec);
if(!root.openroot(vol)) {
error("can't open root dir!");
}
putstring_nl("file found (* = fragmented):");
root.ls(ls_r | ls_fag_fragmented);
}
void loop() {
if(digitalwrite(keypin == high) {
root.rewind();
play(root);
}
void error_p(const char *str){
pgmprint("error: ");
serialprint_p(str);
sderrorcheck();
while(1);
}
void sderrorcheck(void) {
if(!card.errorcode()) return;
pgmprint("\r\nsd i/o error: ");
serial.print(card.errorcode(), hex);
pgmprint(", ");
serial.println(card.errordata(), hex);
while(1);
}
void play(fatreader &dir) {
fatreader file;
while (dir.readdir(dirbuf) > 0) {
if(!dir_is_subdir(dirbuf)
&& strncmp_p((char *)&dirbuf.name[8], pstr("wav"), 3)) {
continue;
}
serial.println();
for(uint*_t = 0; < dirlevel; i++) {
serial.print(' ');
}
if(!file.open(vol, dirbuf)) {
error("file.open failed");
}
if(file.isdir()) {
putstring("subdir: ");
printentryname(dirbuf);
dirlevel += 2;
play (file);
dirlevel -= 2;
} else {
putstring("playing ");
printentryname(dirbuf);
if(!wave.create(file)) {
putstring("not valid wav");
} else {
serial.println();
wave.play();
putstring(".");
if(!(++n % 32)) serial.println();
delay(100);
}
sderrorcheck();
}
}
}
}
the error check in ide said:
error: expected ';' before '}' token
'error_p' not declared in scope
please me!!!
thanks,
arduinofreaklol
i newbie arduino (i love it!), , have problem!
i trying program arduino wave shield version 1.1 play sound, there error in code not know how fix! here is:
#include <wavehc.h>
#include <waveutil.h>
sdreader card;
fatvolume vol;
fatreader root;
wavehc wave;
uint8_t dirlevel;
dir_t dirbuf;
const int keypin = 12;
#define error(msg) error_p(pstr(msg)) <-------------this line said have error
according ide. read bottom
of text!
void play(fatreader &dir); l
v
void setup() {
serial.begin(9600);
pinmode(keypin, input);
putstring_nl("\nwave test!");
putstring("free ram: ");
serial.println(freeram());
if(!card.init()) {
error("card init. failed!");
}
card.partialblockread(true);
uint8_t part;
for(part = 0; part < 5; part++) {
if(vol.init(card, part))
break;
}
if(part == 5) {
error("no valid fat partition!");
}
putstring("using partition ");
serial.print(part, dec);
putstring(", type fat");
serial.println(vol.fattype(), dec);
if(!root.openroot(vol)) {
error("can't open root dir!");
}
putstring_nl("file found (* = fragmented):");
root.ls(ls_r | ls_fag_fragmented);
}
void loop() {
if(digitalwrite(keypin == high) {
root.rewind();
play(root);
}
void error_p(const char *str){
pgmprint("error: ");
serialprint_p(str);
sderrorcheck();
while(1);
}
void sderrorcheck(void) {
if(!card.errorcode()) return;
pgmprint("\r\nsd i/o error: ");
serial.print(card.errorcode(), hex);
pgmprint(", ");
serial.println(card.errordata(), hex);
while(1);
}
void play(fatreader &dir) {
fatreader file;
while (dir.readdir(dirbuf) > 0) {
if(!dir_is_subdir(dirbuf)
&& strncmp_p((char *)&dirbuf.name[8], pstr("wav"), 3)) {
continue;
}
serial.println();
for(uint*_t = 0; < dirlevel; i++) {
serial.print(' ');
}
if(!file.open(vol, dirbuf)) {
error("file.open failed");
}
if(file.isdir()) {
putstring("subdir: ");
printentryname(dirbuf);
dirlevel += 2;
play (file);
dirlevel -= 2;
} else {
putstring("playing ");
printentryname(dirbuf);
if(!wave.create(file)) {
putstring("not valid wav");
} else {
serial.println();
wave.play();
putstring(".");
if(!(++n % 32)) serial.println();
delay(100);
}
sderrorcheck();
}
}
}
}
the error check in ide said:
error: expected ';' before '}' token
'error_p' not declared in scope
please me!!!
thanks,
arduinofreaklol
quote
the error check in ide said:get rid of stupid # define statement. if error happens, "wasting" few bytes of sram hold error message not end of world. saving few bytes not make difference between success , failure.
error: expected ';' before '}' token
'error_p' not declared in scope
please me!!!
Arduino Forum > Using Arduino > Programming Questions > wave shield error
arduino
Comments
Post a Comment