I am using IDE 1.6.4, in one of my sketches with the line
prog_char m00[] PROGMEM = "mrch0001.mp3";
on compiling I get an error 'prog_char' does not name a type, it used to work with the earlier IDEs. The avr/pgmspace.h is also been included in the sketch
request help
try putting const in front of it. seems to be a requirement for progmem now.
const is now required as CrossRoads mentioned. However the prog_xxx data types have been deprecated long ago and have been removed in the newer compiler.
Just simply use char instead of prog_char. All it did was add PROGMEM for you, which we all add anyway:
const char m00[] PROGMEM = "mrch0001.mp3";
You do not need to include pgmspace.h.
Thanks for your replies. The sketch compiled after after I made the suggested changes, however, when uploaded the sketch did not function. It functioned perfectly well with the previous version of IDE where I used
prog_char m00[] PROGMEM = "mrch0001.mp3";
In fact it now gave an error saying that the memory space was less and it may effect stability.
I had to download Arduino version 1.06 and load the sketch with it to make it function again which it did perfectly well again!
I am using the sketch on a cuckoo clock which does some activities on each hour and plays a MP3 track. I had also made the following change in the new IDE
replaced
PROGMEM const char *march[] = {m00,m01,m02,m03,m04,m05,m06,m07,m08,m09,m10,m11,m12,m13,m14,m15,m16,m17,m18,m19,m20,m21,m22,m23,m24};
with
const char* const march[] = {m00,m01,m02,m03,m04,m05,m06,m07,m08,m09,m10,m11,m12,m13,m14,m15,m16,m17,m18,m19,m20,m21,m22,m23,m24};
there were a number of statements of this type.
I am doing something wrong in the new IDE which I am unable to figure out. Can someone help me please.I am including a part of the code for new IDE. This compiles but does not work. The old code on old IDE works perfectly well. thanks
#include <avr/pgmspace.h>
#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h>
#include <SFEMP3Shield.h>
#include <Servo.h>
#include <Wire.h>
#include "RTClib.h"
#include <SoftwareSerial.h>
SdFat sd;
SFEMP3Shield MP3player;
RTC_DS1307 RTC;
DateTime TimeNow;
Servo myservo;
//const int motor1Pin = A0;
//changed to Pin 5 A0 used for temp
const int motor1Pin = 5;
const int motor2Pin = A1;
const int FwdStopPin= A3;
const int RearStopPin=A2;
const int softwareTx = 3;
const int softwareRx = 4;
SoftwareSerial s7s(softwareRx, softwareTx);
int FwdPinState;
int RearPinState;
int PinStateFwd;
int PinStateRear;
int PinStateMot1;
int PinStateMot2;
union twobyte mp3_vol;
const char m00[] PROGMEM = "mrch0001.mp3";
const char m01[] PROGMEM = "mrch0002.mp3";
// more statements of this type
const char m22[] PROGMEM = "mrch0002.mp3";
const char m23[] PROGMEM = "mrch0007.mp3";
const char m24[] PROGMEM = "aarti000.mp3";
const char t00[] PROGMEM = "zero0000.mp3";
const char t01[] PROGMEM = "n0000001.mp3";
const char t02[] PROGMEM = "n0000002.mp3";
const char t03[] PROGMEM = "n0000003.mp3";
const char t04[] PROGMEM = "n0000004.mp3";
// more statements of this type
const char w00[] PROGMEM = "sunday00.mp3";
const char w01[] PROGMEM = "monday00.mp3";
const char w02[] PROGMEM = "tuesday0.mp3";
const char w03[] PROGMEM = "wednesda.mp3";
const char w04[] PROGMEM = "thursday.mp3";
const char w05[] PROGMEM = "friday00.mp3";
const char w06[] PROGMEM = "saturday.mp3";
const char c00[] PROGMEM = "AM000000.mp3";
const char c01[] PROGMEM = "PM000000.mp3";
// more statements
const char c19[] PROGMEM = "happybir.mp3"; //"Dinner Time"
const char temp01[] PROGMEM = "Temp000.mp3";
const char temp02[] PROGMEM = "degcel00.mp3";
const char temp03[] PROGMEM = "point000.mp3";
const char temp04[] PROGMEM = "zero0000.mp3";
const char temp05[] PROGMEM = "minus000.mp3";
const char temp06[] PROGMEM = "nowtemp0.mp3";
const char temp07[] PROGMEM = "maxitemp.mp3";
const char temp08[] PROGMEM = "minitemp.mp3";
const char date00[] PROGMEM = "01st0000.mp3";
/....
const char date31[] PROGMEM = "31st0000.mp3";
const char month00[] PROGMEM = "month010.mp3";
const char month01[] PROGMEM = "month010.mp3";
//................
const char month11[] PROGMEM = "month110.mp3";
const char month12[] PROGMEM = "month120.mp3";
const char sun00[] PROGMEM = "sunrise0.mp3";
//......................
const char sun06[] PROGMEM = "hrsunris.mp3";
const char* const march[] = {m00,m01,m02,m03,m04,m05,m06,m07,m08,m09,m10,m11,m12,m13,m14,m15,m16,m17,m18,m19,m20,m21,m22,m23,m24};
const char* const times[] = {t00,t01,t02,t03,t04,t05,t06,t07,t08,t09,t10,t11,t12,t13,t14,t15,t16,t17,t18};
const char* const week[] = {w00,w01,w02,w03,w04,w05,w06};
const char* const clock[] = {c00,c01,c02,c03,c04,c05,c06,c07,c08,c09,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19};
const char* const temp[] = {temp01,temp02,temp03,temp04,temp05,temp06,temp07,temp08};
const char* const months[] = {month00,month01,month02,month03,month04,month05,month06,month07,month08,month09,month10,month11,month12};
const char* const dates[]={date00,date01,date02,date03,date04,date05,date06,date07,date08,date09,date10,date11,date12,date13,date14,date15,date16,
date17,date18,date19,date20,date21,date22,date23,date24,date25,date26,date27,date28,date29,date30,date31};
const char* const sun[] = {sun00,sun01,sun02,sun03,sun04,sun05,sun06};
char TuneNow[13];
void SelectSound(char typ,int i)
{
if (typ=='m') strcpy_P(TuneNow, (char*)pgm_read_word(&(march[i])));
if (typ=='t') strcpy_P(TuneNow, (char*)pgm_read_word(&(times[i])));
if( typ=='w') strcpy_P(TuneNow, (char*)pgm_read_word(&(week[i])));
if (typ=='c') strcpy_P(TuneNow, (char*)pgm_read_word(&(clock[i])));
if (typ=='d') strcpy_P(TuneNow, (char*)pgm_read_word(&(temp[i])));
if (typ=='p') strcpy_P(TuneNow, (char*)pgm_read_word(&(months[i])));
if (typ=='y') strcpy_P(TuneNow, (char*)pgm_read_word(&(dates[i])));
if (typ=='s') strcpy_P(TuneNow, (char*)pgm_read_word(&(sun[i])));
}
void PlaySelectedTune(char typ, int t)
{
SelectSound(typ,t);
sd.begin(SD_SEL, SPI_HALF_SPEED);
//Serial.print(" Playing ");
//Serial.println(TuneNow);
MP3player.begin();
mp3_vol.byte[1]=5;
MP3player.setVolume(mp3_vol.byte[1], mp3_vol.byte[1]);
MP3player.playMP3(TuneNow);
}
You are reading march, times, week, clock,... as if it is PROGMEM data, but you left PROGMEM off the declaration.
if (typ=='m') strcpy_P(TuneNow, (char*)pgm_read_word(&(march[ i ])));
This line expects it to be in PROGMEM.
const char* const march[] [b]PROGMEM[/b] = {m00,...};
Thanks, will revert back after trying
Will try PYro_65, but one question remains unanswered, how does it work properly with the previous IDE! thanks
The changes for the latest IDE (const & no prog_xxx vars) is compatible with both old and new versions. The later versions (1.5.7 and above) are more restrictive that's all.
If there is some other error you are encountering, post a small example.