Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GoogleCodeExporter opened this issue Apr 13, 2015 · 3 comments
Open

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

GoogleCodeExporter opened this issue Apr 13, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

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

  • Changed state: Started
  • Added labels: Milestone-1.18, Type-Enhancement
  • Removed labels: Type-Defect

@GoogleCodeExporter
Copy link
Author

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant