I keep having trouble with getting this code to work properly. My goal is to show strings which are placed in PROGMEM on a LCD. The array with pointers to these strings is also in PROGMEM. The function is called with a variable which in turn is translated to an index number for reading out the array. Ofcourse pgmspace.h is included in the code.
The errors I keep getting are: array subscript has type 'char' [-Wchar-subscripts] - initialization makes pointer from integer without a cast [enabled by default]
Could someone point out what i'm missing here?
Working on code for AVR GCC, my IDE is Eclipse.
const char wf0[] PROGMEM= "OFF ";
const char wf1[] PROGMEM= "SIN ";
const char wf2[] PROGMEM= "TRI ";
const char wf3[] PROGMEM= "S+T ";
const char wf4[] PROGMEM= "PUL ";
const char wf5[] PROGMEM= "P+S ";
const char wf6[] PROGMEM= "P+T ";
const char wf7[] PROGMEM= "P+ST";
const char wf8[] PROGMEM= "NOI ";
const char wf9[] PROGMEM= "N+S ";
const char wf10[] PROGMEM= "N+T ";
const char wf11[] PROGMEM= "NST ";
const char wf12[] PROGMEM= "N+P ";
const char wf13[] PROGMEM= "NPS ";
const char wf14[] PROGMEM= "NPT ";
const char wf15[] PROGMEM= "NPTS";
const char * const arrayWaveform[] PROGMEM= {wf0,wf1,wf2,wf3,wf4,wf5,wf6,wf7,wf8,wf9,wf10,wf11,wf12,wf13,wf14,wf15};
...
void showWaveform (char ctrlValue)
{
char hex = (ctrlValue & 0xf0)>>4;
char tempText[4];
char* data = pgm_read_byte(&arrayWaveform[hex]); // <<shows up both errors here
strcpy_P (tempText, data);
for (char x=0;x<4;x++)
{
char2LCD(tempText[x]); // <<shows up error: array subscript has type 'char'
}
}