Weird LCD issue
hi!
i'm trying find solution days now, forum last chance.
description: try make "hardware" 2x16 lcd, stores fixed 16char long strings in eeprom. @ program start loads eeprom array, , writes 1 selected rotary switch. here piece of code.
i made writing out lcd @ loading eeprom, debugging.
this how declared memoryname array:
this how load eeprom data (maxmem number of strings 3 in case, string1 stored @ eeprom 24-39, string2: 44-59, etcetc):
when runs @ startup, can see correct strings on both of lines on lcd.
in loop{} if try write theese strings lcd messy characters:
memapointer stores, mode in. changed via rotary encoder values can 1..3.
why messy characters in main loop (see attached picture, string should in lower line)?
thanks
i'm trying find solution days now, forum last chance.
description: try make "hardware" 2x16 lcd, stores fixed 16char long strings in eeprom. @ program start loads eeprom array, , writes 1 selected rotary switch. here piece of code.
i made writing out lcd @ loading eeprom, debugging.
this how declared memoryname array:
code: [select]
char* memoryname[]={" ",
" ",
" ",
" "};
this how load eeprom data (maxmem number of strings 3 in case, string1 stored @ eeprom 24-39, string2: 44-59, etcetc):
code: [select]
void read_eeprom_memory (){
byte = 0;
byte j = 0;
char tempstring[16] ;
maxmem = eeprom.read(9);
(i = 1; i<=maxmem; i++){
(j=0; j<16; j++){
tempstring[j] = eeprom.read((i*20)+4+j);
}
lcd.clear();
lcd.setcursor(0,0);
lcd.print(tempstring);
memoryname[i] = tempstring;
lcd.setcursor(0,1);
lcd.print(memoryname[i]);
delay(3000);
}
}
when runs @ startup, can see correct strings on both of lines on lcd.
in loop{} if try write theese strings lcd messy characters:
code: [select]
lcd.print(memoryname[memapointer]);
memapointer stores, mode in. changed via rotary encoder values can 1..3.
why messy characters in main loop (see attached picture, string should in lower line)?
thanks
code: [select]
memoryname[i] = tempstring; this saving address of tempstring pointer, replacing address of string of blanks. since tempstring allocated on stack address won't of use once function exits.
try:
code: [select]
const int maxmem = 4;
char memoryname[maxmem][16]; and:
code: [select]
for (i = 0; i<=maxmem; i++){
for (j=0; j<16; j++){
memoryname[i][j] = eeprom.read(24 + (i*20) + j);
}
Arduino Forum > Using Arduino > Programming Questions > Weird LCD issue
arduino
Comments
Post a Comment