Using the F() macro to save text for LCD in flash
i've run problem library i'm using, i'm guessing it's little detail fix, i'm @ loss.
normally, lcds , libraries, this:
lcd.println(f("hello worl"));
i have lcd/keyboard controller comes library manufacturer wrote. works (so far) except can't save text flash memory via f(). example be:
in example, need this, won't work:
it this lcd/keypad controller seen here:
i'm using i2c, , the library here, wrote. talked him it, , wasn't familiar flash () function.
is hard implement library? have lot of text display , have have f() function.
thanks,
 
 							normally, lcds , libraries, this:
lcd.println(f("hello worl"));
i have lcd/keyboard controller comes library manufacturer wrote. works (so far) except can't save text flash memory via f(). example be:
code: [select]
disp.lcd_cls(); // clear display
disp.lcd_rowcol(0, 2); //row, col
disp.lcd_print("drill table menu");in example, need this, won't work:
code: [select]
disp.lcd_print(f("drill table menu"));it this lcd/keypad controller seen here:
i'm using i2c, , the library here, wrote. talked him it, , wasn't familiar flash () function.
is hard implement library? have lot of text display , have have f() function.
thanks,
quote
is hard implement library?no... although haven't looked @ code, because won't download external sites. if attach post, take look. there 2 easy ways:
1) derived class print class. you must make sure single-character write method overridden in class:
virtual size_t write(uint8_t c);
the print class use method provide other print methods (int, float, char *, etc.).
2) add method class, using print.cpp example:
code: [select]
size_t lcdclassname::print(const __flashstringhelper *ifsh)
{
  pgm_p p = reinterpret_cast<pgm_p>(ifsh);
  size_t n = 0;
  while (1) {
    unsigned char c = pgm_read_byte(p++);
    if (c == 0) break;
    if (write(c)) n++;
    else break;
  }
  return n;
}the f macro result of type const __flashstringhelper *, that's method need provide.
the first technique best, may able eliminate bunch of code library, duplicating print class providing. the second technique may quicker if aren't familiar c++ classes.
cheers,
/dev
p.s. print class source code, print.h , print.cpp, in arduino install directory, under hardware/arduino/avr/cores/arduino.
            						 					Arduino Forum  						 						 							 >   					Using Arduino  						 						 							 >   					Programming Questions  						 						 							 >   					Using the F() macro to save text for LCD in flash  						 					
arduino
 
  
Comments
Post a Comment