Ciao a tutti,
immagino sia una stupidata dato che sono alle prime armi, ma mi succede una cosa strana con una variabile all'interno del ciclo for.
Copio e incollo la parte del codice dove riscontro il problema.
Praticamente una volta finito il ciclo, GLCD.print(ch_Menu) stampa inspiegabilmete il numero 7 sul display.....non dovrebbe essere sempre 0 ?
#include "glcd.h"
#include "fonts/allFonts.h"
#include "Button.h"
int y = 0;
const int nr_item = 2; //compreso lo 0
int x[nr_item]; //centro colonna menu
int ch_Menu1 = 0;
gText index; //titolo menu
gText t1[nr_item];
gText t2;
Button b_enter = Button(45,PULLDOWN);
Button b_esc = Button(47,PULLDOWN);
Button b_ok = Button(49,PULLDOWN);
Button b_down = Button(51,PULLDOWN);
Button b_up = Button(53,PULLDOWN);
char * t_index="MENU";
char * t1_1[] = {" Gestione LED ", " Gestione ", " Modifica Data/Ora "};
void setup()
{
GLCD.Init(NON_INVERTED);
GLCD.SelectFont(System5x7);
for (int i = 0; i <= nr_item; i++)
{
y = y + 10;
t1[i].DefineArea(0, y, 21 ,1,System5x7);
//t1[i].DefineArea(0, y, GLCD.Width,y + 10);
//t1[i].SelectFont(System5x7, BLACK);
}
}
void loop()
{
for (int m = 0; m <= nr_item; m++)
{
x[m] = GLCD.Width/2 - GLCD.StringWidth(t1_1[m])/2; //Calcolo per centrare il testo nelle righe
t1[m].CursorToXY(x[m], 2);
t1[m].Puts(t1_1[m]);
GLCD.print(ch_Menu1);
delay(500);
}
}