waste many ram

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a lcd put string function like this

void lcd_puts(char *s)
{
while (*s) {
lcd_putchar(*s);
s++;
}
}

and call it in main
int main(void)
{
...

lcd_puts("test test ");

...
}

I find that the "test test " is store to ram first after cpu reset.
If I send many many text to lcd, it will waste many many ram.
How can I do???

Thank you
Kamax

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You need to store these string in program memory (flash) and access it from there with special macros:

#include

void lcd_puts_p(const char *progmem_s)
/* print string from program memory on lcd (no auto linefeed) */
{
register char c;

while ( (c = PRG_RDB(progmem_s++)) ) {
lcd_putc(c);
}

}

static const char TEST[] PROGMEM = "test test"; /* string is stored in flash */

main()
{
...
lcd_puts_p(TEST);
...
}

Have a look at my lcd-library (http://jump.to/fleury).

Regards
Peter Fleury

admin's test signature