Gast
#1754278
Hallo,
ich bin mir nicht sicher, ob Variante 1 ok ist.
Ich möchte Texte und Array im Flash liegen haben und von dort später
auslesen. Es soll kein
SRAM verbraucht werden.
Es kompliliert fehlerfrei in einem anderen Context, ich bin mir aber
nicht sicher, ob wirklich kein SRAM verbraucht
wird.
//
----------------------------------------------------------------------
// Variante 1
// Diese Variante wäre mir am liebsten, falls ok bezüglich SRAM
Verbrauch
//
----------------------------------------------------------------------
struct mystruct
{
prog_char* pText;
};
const struct mystruct test[] PROGMEM =
{
{ "Test 1" },
{ "Test 2" },
{ "Test 3" },
{ "Test 4" }
};
//
----------------------------------------------------------------------
// Variante 2
// Diese Alternative wirft den Kompilerfehler:
// error: braced-group within expression allowed only inside a function
//
----------------------------------------------------------------------
struct mystruct
{
prog_char* pText;
};
const struct mystruct test[] PROGMEM =
{
{ PSTR ( "Test 1" ) },
{ PSTR ( "Test 2" ) },
{ PSTR ( "Test 3" ) },
{ PSTR ( "Test 4" ) }
};
//
----------------------------------------------------------------------
// Variante 3
// Oder muss das ganze getrennt werden?
//
----------------------------------------------------------------------
prog_char* text1[] = "Test 1";
prog_char* text2[] = "Test 2";
prog_char* text3[] = "Test 3";
prog_char* text4[] = "Test 4";
struct mystruct
{
char* pText;
};
const struct mystruct test[] PROGMEM =
{
{ text1 },
{ text2 },
{ text2 },
{ text2 }
};
Wäre super, wenn mir dazu mal jemand einen Kommentar geben könnte.
Vielen Dank.
mfg
Darki
PS.: Wie kann man kontrollieren, ob SRAM verbraucht wird, bzw.
feststellen, wieviel noch frei ist?