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

how to display a arduino int variable #1060

Closed
lelibreauquotidien opened this issue Nov 26, 2019 · 9 comments
Closed

how to display a arduino int variable #1060

lelibreauquotidien opened this issue Nov 26, 2019 · 9 comments
Labels

Comments

@lelibreauquotidien
Copy link

Hello.
All ils a tittle :-).
llaq.

@olikraus
Copy link
Owner

olikraus commented Nov 26, 2019

And the answer is a link to the manual:

https://github.com/olikraus/u8g2/wiki/u8g2reference#print

you can just use "u8g2.print(variablename);"

@lelibreauquotidien
Copy link
Author

Thanks,and for float variable ?

@olikraus
Copy link
Owner

Any variable type will work.

@lelibreauquotidien
Copy link
Author

Yes,it's no work.
No error on compilation but nothing on screen.
llaq.

@olikraus
Copy link
Owner

Can you print strings or something else? Do the u8g2 exaples work?

@spase74
Copy link

spase74 commented Nov 29, 2019

Try this

float f = 1.23f; char buffer[6]; dtostrf(f, 4 /*total length*/, 2 /*precision*/, buffer); u8g2.print(buffer);
Got from
https://stackoverflow.com/questions/27651012/arduino-sprintf-float-not-formatting

@olikraus
Copy link
Owner

u8g2.print() is exactly the same as serial.print(), so float should work...

Nevertheless, closing this issue...

@shakil1740
Copy link

void loop(void){
int x =12864;
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_osb29_tr); // set fonts
u8g2.setCursor(10,45); // set cursor position
u8g2.print(x); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}

@shakil1740
Copy link

void loop(void){
float x =128.64;
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_ncenB08_tr); // set fonts
u8g2.setCursor(30,30); // set cursor position lcd
u8g2.print(x,2); // write variable to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(1000);
}

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

No branches or pull requests

4 participants