DerSchatten
14.02.2010, 17:24
Ich möchte gerne mittels der Funktion lcd_puts_p von Peter Fleury's LCD-Library Daten aus dem Flash auslesen, die ich von verschiedenen Variablen bereitstelle:
const char menu_000[] PROGMEM = " Multifunktions "; //
const char menu_001[] PROGMEM = "ArcadeController"; //
const char menu_002[] PROGMEM = "** HAUPTMENUE **"; //
const char menu_100[] PROGMEM = "Tastenzuordnung "; // 0
const char menu_101[] PROGMEM = "[X ] 1"; // 1
const char menu_102[] PROGMEM = "[XX ] 2"; // 2
const char menu_103[] PROGMEM = "[XXX ] 3"; // 3
const char menu_104[] PROGMEM = "[XXXX ] 4"; // 4
const char menu_105[] PROGMEM = "[XXXXX ] 5"; // 5
const char menu_106[] PROGMEM = "[XXXXXX ] 6"; // 6
const char menu_107[] PROGMEM = "[XXXXXXX ] 7"; // 7
const char menu_108[] PROGMEM = "[XXXXXXXX ] 8"; // 8
const char menu_109[] PROGMEM = "[XXXXXXXXX] 9"; // 9
const char menu_200[] PROGMEM = " Dauerfeuer "; // 10
const char menu_201[] PROGMEM = "[ ] AUS"; // 11
const char menu_202[] PROGMEM = "[X ] 1"; // 12
const char menu_203[] PROGMEM = "[XX ] 2"; // 13
const char menu_204[] PROGMEM = "[XXX ] 3"; // 14
const char menu_205[] PROGMEM = "[XXXX ] 4"; // 15
const char menu_206[] PROGMEM = "[XXXXX ] 5"; // 16
const char menu_207[] PROGMEM = "[XXXXXX ] 6"; // 17
const char menu_208[] PROGMEM = "[XXXXXXX ] 7"; // 18
const char menu_209[] PROGMEM = "[XXXXXXXX ] 8"; // 19
const char menu_210[] PROGMEM = "[XXXXXXXXX] 9"; // 20
const char menu_300[] PROGMEM = " Beleuchtung "; // 21
const char menu_301[] PROGMEM = "[ ] AUS"; // 22
const char menu_302[] PROGMEM = "[X ] 1"; // 23
const char menu_303[] PROGMEM = "[XX ] 2"; // 24
const char menu_304[] PROGMEM = "[XXX ] 3"; // 25
const char menu_305[] PROGMEM = "[XXXX ] 4"; // 26
const char menu_306[] PROGMEM = "[XXXXX ] 5"; // 27
const char menu_307[] PROGMEM = "[XXXXXX ] 6"; // 28
const char menu_308[] PROGMEM = "[XXXXXXX ] 7"; // 29
const char menu_309[] PROGMEM = "[XXXXXXXX ] 8"; // 30
const char menu_310[] PROGMEM = "[XXXXXXXXX ] 9"; // 31
const char menu_311[] PROGMEM = "[XXXXXXXXXX] 10"; // 32
const char menu_400[] PROGMEM = " LED-Test "; // 33
const char menu_401[] PROGMEM = " [EIN] AUS "; // 34
const char menu_402[] PROGMEM = " EIN [AUS] "; // 35
const char menu_500[] PROGMEM = " Speichern "; // 36
const char menu_600[] PROGMEM = " Beenden "; // 37
typedef struct def_menustruktur
{
const char *text;
unsigned char next;
unsigned char previous;
unsigned char sub;
unsigned char up;
unsigned char ActionCode;
uint8_t ActionValue;
}menustruktur;
// Tabelle von Zeigern auf die Texte erstellen
// ===========================================
menustruktur menu[] PROGMEM =
{
{menu_100, 10, 0, 1, 0, NO_ACTION, 0},
{menu_101, 2, 1, 0, 0, DEF_KEY_ACTION, 1},
{menu_102, 3, 1, 0, 0, DEF_KEY_ACTION, 2},
{menu_103, 4, 2, 0, 0, DEF_KEY_ACTION, 3},
{menu_104, 5, 3, 0, 0, DEF_KEY_ACTION, 4},
{menu_105, 6, 4, 0, 0, DEF_KEY_ACTION, 5},
{menu_106, 7, 5, 0, 0, DEF_KEY_ACTION, 6},
{menu_107, 8, 6, 0, 0, DEF_KEY_ACTION, 7},
{menu_108, 9, 7, 0, 0, DEF_KEY_ACTION, 8},
{menu_109, 9, 8, 0, 0, DEF_KEY_ACTION, 9},
{menu_200, 21, 0, 11, 10, NO_ACTION, 0},
{menu_201, 12, 11, 10, 10, DEF_REPEAT_ACTION, 0},
{menu_202, 13, 11, 10, 10, DEF_REPEAT_ACTION, 1},
{menu_203, 14, 12, 10, 10, DEF_REPEAT_ACTION, 2},
{menu_204, 15, 13, 10, 10, DEF_REPEAT_ACTION, 3},
{menu_205, 16, 14, 10, 10, DEF_REPEAT_ACTION, 4},
{menu_206, 17, 15, 10, 10, DEF_REPEAT_ACTION, 5},
{menu_207, 18, 16, 10, 10, DEF_REPEAT_ACTION, 6},
{menu_208, 19, 17, 10, 10, DEF_REPEAT_ACTION, 7},
{menu_209, 20, 18, 10, 10, DEF_REPEAT_ACTION, 8},
{menu_210, 20, 19, 10, 10, DEF_REPEAT_ACTION, 9},
{menu_300, 33, 10, 22, 21, NO_ACTION, 0},
{menu_301, 23, 22, 21, 21, LCD_ACTION, 0},
{menu_302, 24, 22, 21, 21, LCD_ACTION, 25},
{menu_303, 25, 23, 21, 21, LCD_ACTION, 50},
{menu_304, 26, 24, 21, 21, LCD_ACTION, 75},
{menu_305, 27, 25, 21, 21, LCD_ACTION, 100},
{menu_306, 28, 26, 21, 21, LCD_ACTION, 125},
{menu_307, 29, 27, 21, 21, LCD_ACTION, 150},
{menu_308, 30, 28, 21, 21, LCD_ACTION, 175},
{menu_309, 31, 29, 21, 21, LCD_ACTION, 200},
{menu_310, 32, 30, 21, 21, LCD_ACTION, 225},
{menu_311, 32, 31, 21, 21, LCD_ACTION, 255},
{menu_400, 36, 21, 34, 33, NO_ACTION, 0},
{menu_401, 35, 34, 33, 33, LED_ACTION, 0},
{menu_402, 35, 34, 33, 33, LED_ACTION, 1},
{menu_500, 37, 33, 36, 36, SAVE_ACTION, 1},
{menu_600, 37, 36, 37, 37, EXIT_ACTION, 1}
};
unsigned char menu_index = 0;
Wenn ich jetzt versuche das ganze mittels:
menu_index = menu[menu_index].up;
lcd_puts_p(menu[menu_index].text);
auszulesen bekomme ich nur verstümmelte Zeichen.
Ich vermute das der Fehler bei einer falschen deklaration einer Variable liegt. Nur ich finde den Fehler nicht.
Laut der Funktion lcd_puts_p müssen die Werte ein const char sein.
Was bei mir ja auch zutrifft, oder nicht?
const char menu_000[] PROGMEM = " Multifunktions "; //
const char menu_001[] PROGMEM = "ArcadeController"; //
const char menu_002[] PROGMEM = "** HAUPTMENUE **"; //
const char menu_100[] PROGMEM = "Tastenzuordnung "; // 0
const char menu_101[] PROGMEM = "[X ] 1"; // 1
const char menu_102[] PROGMEM = "[XX ] 2"; // 2
const char menu_103[] PROGMEM = "[XXX ] 3"; // 3
const char menu_104[] PROGMEM = "[XXXX ] 4"; // 4
const char menu_105[] PROGMEM = "[XXXXX ] 5"; // 5
const char menu_106[] PROGMEM = "[XXXXXX ] 6"; // 6
const char menu_107[] PROGMEM = "[XXXXXXX ] 7"; // 7
const char menu_108[] PROGMEM = "[XXXXXXXX ] 8"; // 8
const char menu_109[] PROGMEM = "[XXXXXXXXX] 9"; // 9
const char menu_200[] PROGMEM = " Dauerfeuer "; // 10
const char menu_201[] PROGMEM = "[ ] AUS"; // 11
const char menu_202[] PROGMEM = "[X ] 1"; // 12
const char menu_203[] PROGMEM = "[XX ] 2"; // 13
const char menu_204[] PROGMEM = "[XXX ] 3"; // 14
const char menu_205[] PROGMEM = "[XXXX ] 4"; // 15
const char menu_206[] PROGMEM = "[XXXXX ] 5"; // 16
const char menu_207[] PROGMEM = "[XXXXXX ] 6"; // 17
const char menu_208[] PROGMEM = "[XXXXXXX ] 7"; // 18
const char menu_209[] PROGMEM = "[XXXXXXXX ] 8"; // 19
const char menu_210[] PROGMEM = "[XXXXXXXXX] 9"; // 20
const char menu_300[] PROGMEM = " Beleuchtung "; // 21
const char menu_301[] PROGMEM = "[ ] AUS"; // 22
const char menu_302[] PROGMEM = "[X ] 1"; // 23
const char menu_303[] PROGMEM = "[XX ] 2"; // 24
const char menu_304[] PROGMEM = "[XXX ] 3"; // 25
const char menu_305[] PROGMEM = "[XXXX ] 4"; // 26
const char menu_306[] PROGMEM = "[XXXXX ] 5"; // 27
const char menu_307[] PROGMEM = "[XXXXXX ] 6"; // 28
const char menu_308[] PROGMEM = "[XXXXXXX ] 7"; // 29
const char menu_309[] PROGMEM = "[XXXXXXXX ] 8"; // 30
const char menu_310[] PROGMEM = "[XXXXXXXXX ] 9"; // 31
const char menu_311[] PROGMEM = "[XXXXXXXXXX] 10"; // 32
const char menu_400[] PROGMEM = " LED-Test "; // 33
const char menu_401[] PROGMEM = " [EIN] AUS "; // 34
const char menu_402[] PROGMEM = " EIN [AUS] "; // 35
const char menu_500[] PROGMEM = " Speichern "; // 36
const char menu_600[] PROGMEM = " Beenden "; // 37
typedef struct def_menustruktur
{
const char *text;
unsigned char next;
unsigned char previous;
unsigned char sub;
unsigned char up;
unsigned char ActionCode;
uint8_t ActionValue;
}menustruktur;
// Tabelle von Zeigern auf die Texte erstellen
// ===========================================
menustruktur menu[] PROGMEM =
{
{menu_100, 10, 0, 1, 0, NO_ACTION, 0},
{menu_101, 2, 1, 0, 0, DEF_KEY_ACTION, 1},
{menu_102, 3, 1, 0, 0, DEF_KEY_ACTION, 2},
{menu_103, 4, 2, 0, 0, DEF_KEY_ACTION, 3},
{menu_104, 5, 3, 0, 0, DEF_KEY_ACTION, 4},
{menu_105, 6, 4, 0, 0, DEF_KEY_ACTION, 5},
{menu_106, 7, 5, 0, 0, DEF_KEY_ACTION, 6},
{menu_107, 8, 6, 0, 0, DEF_KEY_ACTION, 7},
{menu_108, 9, 7, 0, 0, DEF_KEY_ACTION, 8},
{menu_109, 9, 8, 0, 0, DEF_KEY_ACTION, 9},
{menu_200, 21, 0, 11, 10, NO_ACTION, 0},
{menu_201, 12, 11, 10, 10, DEF_REPEAT_ACTION, 0},
{menu_202, 13, 11, 10, 10, DEF_REPEAT_ACTION, 1},
{menu_203, 14, 12, 10, 10, DEF_REPEAT_ACTION, 2},
{menu_204, 15, 13, 10, 10, DEF_REPEAT_ACTION, 3},
{menu_205, 16, 14, 10, 10, DEF_REPEAT_ACTION, 4},
{menu_206, 17, 15, 10, 10, DEF_REPEAT_ACTION, 5},
{menu_207, 18, 16, 10, 10, DEF_REPEAT_ACTION, 6},
{menu_208, 19, 17, 10, 10, DEF_REPEAT_ACTION, 7},
{menu_209, 20, 18, 10, 10, DEF_REPEAT_ACTION, 8},
{menu_210, 20, 19, 10, 10, DEF_REPEAT_ACTION, 9},
{menu_300, 33, 10, 22, 21, NO_ACTION, 0},
{menu_301, 23, 22, 21, 21, LCD_ACTION, 0},
{menu_302, 24, 22, 21, 21, LCD_ACTION, 25},
{menu_303, 25, 23, 21, 21, LCD_ACTION, 50},
{menu_304, 26, 24, 21, 21, LCD_ACTION, 75},
{menu_305, 27, 25, 21, 21, LCD_ACTION, 100},
{menu_306, 28, 26, 21, 21, LCD_ACTION, 125},
{menu_307, 29, 27, 21, 21, LCD_ACTION, 150},
{menu_308, 30, 28, 21, 21, LCD_ACTION, 175},
{menu_309, 31, 29, 21, 21, LCD_ACTION, 200},
{menu_310, 32, 30, 21, 21, LCD_ACTION, 225},
{menu_311, 32, 31, 21, 21, LCD_ACTION, 255},
{menu_400, 36, 21, 34, 33, NO_ACTION, 0},
{menu_401, 35, 34, 33, 33, LED_ACTION, 0},
{menu_402, 35, 34, 33, 33, LED_ACTION, 1},
{menu_500, 37, 33, 36, 36, SAVE_ACTION, 1},
{menu_600, 37, 36, 37, 37, EXIT_ACTION, 1}
};
unsigned char menu_index = 0;
Wenn ich jetzt versuche das ganze mittels:
menu_index = menu[menu_index].up;
lcd_puts_p(menu[menu_index].text);
auszulesen bekomme ich nur verstümmelte Zeichen.
Ich vermute das der Fehler bei einer falschen deklaration einer Variable liegt. Nur ich finde den Fehler nicht.
Laut der Funktion lcd_puts_p müssen die Werte ein const char sein.
Was bei mir ja auch zutrifft, oder nicht?