A u8g2 function like u8glib u8g.drawStrP #2261
Unanswered
MikeKitchen
asked this question in
Q&A
Replies: 1 comment
-
Good point. However meanwhile there is a better support for flash memory in Arduino, so maybe this will work: void u8g2_drawSringP(uint8_t x, uint8_t y, const char * progmem_ptr) {
u8g2.setCursor(x, y);
u8g2.print((const __FlashStringHelper *)progmem_ptr); // use arduino progmem print
}
If the above code doesn't work (I have not tested this), then maybe this u8g2 code will work better (also not tested): void u8g2_drawSringP(uint8_t x, uint8_t y, const char * progmem_ptr) {
uint16_t c;
for(;;) {
c = u8x8_pgm_read(progmem_ptr); // use u8g2 build-in progmem read function
if ( c == 0 )
break;
progmem_ptr++;
x += u8g2.drawGlyph(x, y, c);
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I’m trying to migrate my projects from u8glib to u8g2, but I would like a replacement for u8g.drawStrP with AVR processors using with multiple menus stored in flash memory.
In u8glib you’d use something like :
I’ve got a near-equivalent working in u8g2, but I was hoping to have a better replacement where I could just cut and paste it in and the below does not seem as elegant as u8glib, is there a better solution?
Thanks for your help
Mike
Beta Was this translation helpful? Give feedback.
All reactions