我一直无法让此代码正常工作。我的目标是在 LCD 上显示放置在 PROGMEM 中的字符串。带有指向这些字符串的指针的数组也在 PROGMEM 中。该函数使用一个变量调用,该变量又被转换为一个索引号以读取数组。当然 pgmspace.h 包含在代码中。
我不断收到的错误是:数组下标的类型为 'char' [-Wchar-subscripts] - 初始化使指针从整数而不进行强制转换 [默认启用]
有人可以指出我在这里缺少什么吗?
为 AVR GCC 编写代码,我的 IDE 是 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'
}
}