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
OLED 0,96 - problem with displaying a variable #44
Comments
Please, try: display.setTextCursor(0,0);
display.print( temp ); The function supports only int variables |
The temperature is displayed. Thank you. However, there is no decimal value. Is there a way to do this? |
I'm sorry for the delay. Actually you can display any numbers you want like this: char str[10];
sprintf( str, "%.2f", temp );
display.print( str ); |
No problem :) But it doesn't help. The value of 1266 is displayed all the time. Fortunately, I managed differently with decimal values. |
Have an idea why the value 1266 is displayed? |
Hi, I'm sorry, that was the wrong location of Anyway, there is very rich documentation on |
No, the only supported feature is for monochrome displays. |
After your answer, I did so. The code looks fine, and so on it returns 1266. For example, if I change str [10] to str [15], the value is 1249. Can you take a look at what's wrong with the code? `#include "lcdgfx.h" OneWire oneWire(A0); DisplaySH1107_64x128_I2C display(-1); float temp; void setup() void loop() sensors.requestTemperatures(); display.setTextCursor(0, 64); delay (5000); }` |
Which version of Arduino IDE are you using? Does it display any warnings / errors? Try this code: char str[10];
sprintf( str, "%.2f", temp );
display.write( str ); |
Arduino IDE 1.8.13
Summary after upload: Sketch uses 10044 bytes (70%) of program storage space. Maximum is 14336 bytes.
After this change, the display only shows a question mark :( |
I don't have all those sensors. so I commented out the code reading the temperature, and replaced it with single assignment. And it works. So the issue somewhere in another library, and not in lcdgfx #include "lcdgfx.h"
#include "lcdgfx_gui.h"
//#include <Arduino.h>
//#include <OneWire.h>
//#include <DallasTemperature.h>
//#include <Wire.h>
//OneWire oneWire(A0);
//DallasTemperature sensors(&oneWire);
DisplaySH1107_64x128_I2C display(-1);
float temp;
void setup()
{
display.begin();
display.setFixedFont(ssd1306xled_font6x8);
display.clear();
display.fill(0x00);
// sensors.begin();
}
void loop()
{
// sensors.requestTemperatures();
temp = 23.23; // sensors.getTempCByIndex(0);
display.setTextCursor(0, 64);
char str[10];
sprintf( str, "%.2f", temp );
display.write( str );
delay (5000);
} |
An interesting thing. When I do what you did, it still displayed a question mark. Maybe my display is broken. |
@szymonsmolka What about direct_draw/draw_text example? Can you capture the result for that example for me? |
https://github.com/lexus2k/lcdgfx/blob/master/examples/direct_draw/draw_text/draw_text.ino Not working. The same result. Question mark. |
Hello, |
include "lcdgfx.h" /* LCD */ float temp; void setup() void loop() // sensors.requestTemperatures(); display.setTextCursor(20, 20); delay (5000); }
|
Hi, I apologize for this inconvenience. However the library has some limitations to reduce flash ram usage. Best regards, |
Ask any question, you have, regarding the library
Hi. I'm trying to use the lcdgfx library to run a 0.96 64x128 OLED display with the SH1107 driver. I wanted to make a simple thermometer. The temperature is assigned to the float variable, but the display does not show it.
display.printFixed (0, 0, temp, STYLE_BOLD);
How do I enter such a code for example
display.printFixed (0, 0, "TEST", STYLE_BOLD);
The display works and shows TEST
Where is the problem? Please help.
The text was updated successfully, but these errors were encountered: