Okay so i am trying to make a menu on a 4x20 LCD screen. On the top of the screen i would like to be able to tell the user what level he is on. To do this i will need the number of elements of the char array, which would correspond to the line. I could of course add the number manually, but that would be annoying when adding sub menues etc.
so far i have tried these options i could find through a search and none of them seems to work.
strLength = strlen(GUI); // ERROR!
strLength = sizeof(GUI)/sizeof(int); // strLength =1!
strLength = sizeof(GUI)/sizeof(GUI[0]); // strLength =1!
Here are my whole code. As you can see i would like it to give me the answer of 5 elements!
/* Written by Kristoffer P. Sminge 2014*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <string>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
char* mainMenu[] = {
"Main Menu", "Seperation", "Options", "Manual Move", "Statisticks"};
void setup() /*----( SETUP: RUNS ONCE )----*/
{
Serial.begin(9600);
lcd.begin(20,4);
}
void loop() /*----( LOOP: RUNS CONSTANTLY )----*/
{
navLCD(mainMenu);
delay(10000);
}
void navLCD(char* GUI[]){
int cursor=1;
int strLength;
strLength = strlen(GUI);
Serial.print(strLength);
lcd.print("__________________/_");
lcd.setCursor(3,0);
lcd.print(GUI[0]);
lcd.setCursor(17,0);
lcd.print(cursor);
lcd.setCursor(19,0);
lcd.print(strLength);
for (int i = 1; i < 4; i++){
lcd.setCursor(0,i);
lcd.print(GUI[i]);
delay(500);
}
}
Anyone have an idea?