benderpirat / u8glib

Automatically exported from code.google.com/p/u8glib
Other
0 stars 0 forks source link

Idea: get the position of the 'cursor' #315

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Dear Developer,

when playing with the new OLED, i've realized i do not know where the cursor is 
after 'print'.

These to function in the "U8glib.h" can solve the problem:

u8g_uint_t getPrintCol(void) { return tx; }
u8g_uint_t getPrintRow(void) { return ty; }

So now, an output from get formatted correctly:

u8g.setFont(u8g_font_profont11);

cCursor = 1;
cRow = 25;
cCursor += u8g.drawStr(cCursor, cRow, "Boot #");

u8g.setFont(u8g_font_courB10);
u8g.setPrintPos(cCursor, cRow);
u8g.print(nBoot);
cCursor = u8g.getPrintCol();
u8g.setFont(u8g_font_profont11);
cCursor += u8g.drawStr(cCursor, cRow, " and " );

u8g.setFont(u8g_font_courB10);
u8g.setPrintPos(cCursor,cRow);
u8g.print(nRace);
cCursor = u8g.getPrintCol();
u8g.setFont(u8g_font_profont11);
cCursor += u8g.drawStr(cCursor, cRow, " races served "); 

Yet it would be nice 'drawStr*' could continue from the last position.

Original issue reported on code.google.com by Eugeniju...@gmail.com on 31 Jan 2015 at 10:43

GoogleCodeExporter commented 8 years ago
i have added
u8g_uint_t getPrintCol(void) { return tx; }
u8g_uint_t getPrintRow(void) { return ty; }

to U8glib.h

Thanks.

Original comment by olikr...@gmail.com on 31 Jan 2015 at 11:40

GoogleCodeExporter commented 8 years ago
Hi,

maybe 'drawStr*()' would be also handy:

u8g_uint_t drawStr(const char *s) { return u8g_DrawStr(&u8g, tx, ty, s); }
u8g_uint_t drawStr(const __FlashStringHelper *s) { return u8g_DrawStrP(&u8g, 
tx, ty, (u8g_pgm_uint8_t *)s); }
u8g_uint_t drawStr90(const char *s) { return u8g_DrawStr90(&u8g, tx, ty, s); }

Hmm, maybe all methods could catch the current point? Like 

void drawHLine(u8g_uint_t w) { u8g_DrawHLine(&u8g, tx, ty, w); }

Original comment by Eugeniju...@gmail.com on 1 Feb 2015 at 11:31

GoogleCodeExporter commented 8 years ago
Well, the idea is, to make the interface in c++ and c identical. Also, i assume 
that all people in the Arduino world will use "print" instead of drawStr.

If you really want such a feature, you can derive your own class from U8glib 
class and add these missing functions.

Original comment by olikr...@gmail.com on 1 Feb 2015 at 12:23