Dear All,
I want show the float data on ssd1306 128x64 OLED. I find the library and the code just default to show the two digit integer value.
The website for reference below:
How to change the setting to show the more digit for float value?
Dear All,
I want show the float data on ssd1306 128x64 OLED. I find the library and the code just default to show the two digit integer value.
The website for reference below:
How to change the setting to show the more digit for float value?
Same way you'd do it if it were a Serial.print?
I don't know how to change. The code I use to show the value below.
void draw(void) {
// u8g.drawBitmapP( 76, 5, 6, 50, brainy_bitmap); // put bitmap
u8g.setFont(u8g_font_unifont); // select font
u8g.drawStr(0, 15, "Temp: "); // put string of display at position X, Y
u8g.drawStr(0, 30, "Hum: ");
u8g.drawStr(0, 45, "Lig: ");
u8g.drawStr(0, 60, "Air: ");
u8g.setPrintPos(44, 15); // set position
u8g.print(floatTem, 0); // display temperature from DHT22
u8g.drawStr(60, 15, "c ");
u8g.setPrintPos(44, 30);
u8g.print(floatHum, 0); // display humidity from DHT22
u8g.drawStr(60, 30, "% ");
u8g.setPrintPos(44, 45); // set position
u8g.print(floatLig, 0); // display light level from BH1750 Light sensor
u8g.drawStr(60, 45, "lux ");
u8g.setPrintPos(44, 60);
u8g.print(floatAir, 0); // display air speed from MPVX7002 pressure sensor
u8g.drawStr(60, 60, "m/s ");
}
u8g.print(floatTem, 0);
I don't have this library, so I'm going to have to ask what the zero there does?
Thank you very much.
The problem fixed.
u8g.print(floatTem, 0); // display temperature from DHT22
u8g.drawStr(85, 15, "c ");
u8g.setPrintPos(44, 30);
u8g.print(floatHum, 1); // display humidity from DHT22
u8g.drawStr(85, 30, "% ");
Just change the "floatTem, 0 " to 1
The 0 means the digit of Decimal point.
value 1: 0.0
value 2: 0.00