Closed yvesgarnier closed 1 year ago
Thanks for the issue. Quite busy so may take a few days before i investigate
A quick looks shows no problems in the code. Be aware that there are different displays. Does yours have a decimal point per digit? Please post a close up photo.
Do you have a datasheet of your specific display? Or a link where you bought it?
What appears on the display if you call
displayFloat(1.23123)
?
My hypothesis is that the display is a "time" variant. And it has 5 digits, where one is the semicolon.
like these - https://www.adafruit.com/product/1002 (this has a HT16K33 driver)
With these you have digit 0, 1 then digit 2 semicolon, followed by digit 3 and 4.
So I expect that the test displayFloat(1.23123)
will display 1. 2 : 1 2
Hey, thanks for investigating. I'm not at home so i can not post a picture. It is indeed a 4 digit variant with a colon in the middle, but it has also a dot between each digit.
Whats kind of strange is when i try to display just a float without it being a variable from the sensor it shows all the digits but without any dot or colon.
I will post a pic as soon as i get home. Thanks
Hypothesis The 2 dots of the semicolon are 2 leds of the 7 segment digit. (Digit[2] i assume) So depending on the digit "displayed" these leds are on or off.
Ok, I wait for the pics and link of the display.
Hypothesis 2 The two dots are connected to the decimal point of the 2nd digit.
test
displayFloat(1.111)
would not highlight the semicolon
displayFloat(11.11)
would highlight the semicolon
So i tried following code:
`void loop() { sensors.requestTemperatures(); //float temperature = sensors.getTempCByIndex(0); //int temperature_r = round(temperature); TM.displayFloat(1.111); delay(1000); TM.displayFloat(11.11); //Serial.println(temperature_r); delay(1000);
}`
this is the output.
So i think you were right asuming that the colon is connected to the center dot. But the other dots do not work yet. May be they are not meant to work?
here a picture of the board:
Thanks for the pictures, the display has both the time semicolon and the decimal point
What I notice is that printing a 4 digit float shows only 3 digits. Can you try ```printFloat(1111):```` no decimal point.
also try this
uint8_t data[4] = { 0xFF, 0xFF, 0xFF, 0xFF };
displayRaw(data, 1);
it should light all the leds including points.
so i tried both:
TM.displayFloat(1111);
uint8_t data[4] = { 0xFF, 0xFF, 0xFF, 0xFF }; TM.displayRaw(data, 1);
no output at all.
full code:
#include "TM1637.h"
#include <OneWire.h>
#include <DallasTemperature.h>
#include <math.h>
TM1637 TM;
uint32_t start, stop;
const int oneWireBus = 4;
OneWire oneWire(oneWireBus);
DallasTemperature sensors(&oneWire);
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("Locating devices...");
sensors.begin();
Serial.print("Found ");
Serial.print(sensors.getDeviceCount(), DEC);
Serial.println(" devices.");
TM.begin(2, 3, 4); // clockpin, datapin
TM.displayClear();
}
void loop()
{
sensors.requestTemperatures();
//float temperature = sensors.getTempCByIndex(0);
//int temperature_r = round(temperature);
TM.displayFloat(1111);
delay(2000);
uint8_t data[4] = { 0xFF, 0xFF, 0xFF, 0xFF };
TM.displayRaw(data, 1);
//Serial.println(temperature_r);
delay(2000);
}
no output at all.
???? how can that ???? ! inverted logic
what happens
uint8_t data[4] = { 0, 0, 0, 0 };
TM.displayRaw(data, 1);
rationale: A value of 0xFF = 11111111 => all lines HIGH, so maybe we need all lines low.
As each 7seg element has 7 leds and a decimal point it completely fills 4 bytes, => the semicolon must be a fifth byte
So the software should handle an extra byte to control this display
final test
displayFloat(1234);
I expect it to print 1240 (or 0124 )
This test would show which digit gets "eaten" by the semicolon.
(there is no such thing as a final test, sorry)
displayFloat(12345); // lets try 5 digits
test 1
uint8_t data[4] = { 0, 0, 0, 0 };
TM.displayRaw(data, 1);
result: 0 0 0 0
test 2
TM.displayFloat(1234);
result: 1 2 3 3
test 3
TM.displayFloat(12345);
result: 1 2 3 4
post final test 1
Integer seem to work normally. I tried:
TM.displayInt(1234);
result: 1 2 3 4
post final test 2
uint8_t data[4] = { 0x0a, 0x0b, 0x0c, 0x0d };
result: d C b A
post final test 3
TM.displayFloat(12340);
result: 1 2 3 3
TM.displayFloat(12341);
result: 1 2 3 4
post final test 4
TM.displayFloat(12.34);
result: 1 2 : 3 4
somehow when there is a dot in the third position everything else seems to work.
Thanks for all these tests.
So the decimal points with this display are not encoded in the digits like the other displays tested. So in the end additional code is needed to support this display correctly. How that would look like needs more investigation.
There are two options left in my mind.
To verify option 1 I need datasheet of this display. Do you have a link where you bought it?
To test option 2 the library needs a serious rewrite . Or we set the digits to 6 and hopes that allows us to shift in enough bytes.
Test Set digits to 6 - option in begin() DisplayFloat(88.8888).
The 8 is the digit that uses 7 leds so if a 5th byte is used at least some of the points should light up.
Hey rob. I can't find the site where i bought them anymore. It was at least 5 years ago on aliexpress or bangood.
It could really be that the dots are not connected.
TM.displayInt(888888);
Result: 8 8 8 8
TM.displayFloat(88.8888);
Result: 8 8:8 7
no decimal points showing up.
Did you set the digits to 6 in the test?
See begin()
yes
test sketch in which I tried all my thoughts
#include "TM1637.h"
TM1637 TM;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
TM.begin(2, 3, 6); // clockpin, datapin, # digits
TM.displayClear();
}
void loop()
{
TM.displayFloat(888888);
delay(2000);
// switch on semicolon ?
TM.displayClear();
delay(1000);
uint8_t data1[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
TM.displayRaw(data1, 2);
delay(2000);
// switch off semicolon ?
TM.displayClear();
delay(1000);
uint8_t data2[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
TM.displayRaw(data2, -1);
delay(2000);
// byte 5 = 1111 1111 - no semicolon
TM.displayClear();
delay(1000);
uint8_t data3[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00 };
TM.displayRaw(data3, 0);
delay(2000);
// byte 5 = 1100 0011 - no semicolon
TM.displayClear();
delay(1000);
uint8_t data4[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xC2, 0x00 };
TM.displayRaw(data4, 0);
delay(2000);
}
I have tried to google a similar display with both semicolon and decimal points and I found none with a datasheet or code or a youtube that would give any clue. So far nothing useful found.
Went through several TM1637 libraries I could find and no clue.
googled for TM1637 4 digit display (images) and found
Sofar I can not find any clue how to control the decimal points, so I'm sorry that I cannot solve it.
hei rob. Thanks you so much for investigating. I will tried with other libraries.
The result of the tests just in case:
#include "TM1637.h"
TM1637 TM;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
TM.begin(2, 3, 6); // clockpin, datapin, # digits
TM.displayClear();
}
void loop()
{
TM.displayInt(1);
delay(1000);
TM.displayFloat(888888);
delay(2000);
//result: 8 8 8 7 (_ = no digit)
TM.displayInt(2);
delay(1000);
// switch on semicolon ?
TM.displayClear();
delay(1000);
uint8_t data1[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
TM.displayRaw(data1, 2);
delay(2000);
//result: _ _ _ _ (_ = no digit)
TM.displayInt(3);
delay(1000);
// switch off semicolon ?
TM.displayClear();
delay(1000);
uint8_t data2[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
TM.displayRaw(data2, -1);
delay(2000);
//result: _ _ _ _ (_ = no digit)
TM.displayInt(4);
delay(1000);
// byte 5 = 1111 1111 - no semicolon
TM.displayClear();
delay(1000);
uint8_t data3[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00 };
TM.displayRaw(data3, 0);
delay(2000);
//result: _ _ 0 0 (_ = no digit)
TM.displayInt(5);
delay(1000);
// byte 5 = 1100 0011 - no semicolon
TM.displayClear();
delay(1000);
uint8_t data4[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xC2, 0x00 };
TM.displayRaw(data4, 0);
delay(2000);
//result: _ _ 0 0 (_ = no digit)
}
Thanks for testing, I assume those decimal points just aren't connected.
A trick I used in the past was to display the temperature in "deci degrees", multiply by 10 and print as an INT>
I learned at least that the connection of your display is different, so I need to think of an ENUM type to differentiate between different types of displays, someday next year.
You may close the issue, unless you have other questions,
Hey Rob, or anyone out there. Thank you so much for your effort in creating this library!
I would like to show a float generated by a temperature sensor. The digits are showing correctly but the decimal point is shown as a colon. Is there a solution for this problem?
I am using a 4 Digit Display.
here you can see my code:
updated code tags