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

Not floating point display #8

Closed
jcmadrioso opened this issue Jan 10, 2021 · 26 comments
Closed

Not floating point display #8

jcmadrioso opened this issue Jan 10, 2021 · 26 comments

Comments

@jcmadrioso
Copy link
Contributor

When displaying a floating point value (12.3456, f.e.), a blank digit is displayed instead of decimal point.

@AKJ7
Copy link
Owner

AKJ7 commented Jan 12, 2021

I have the same issue too. It seemed to me that some displays either have the semi-colon or the dots, according to some research i did on the web. Did it work before the latest update?

@jcmadrioso
Copy link
Contributor Author

jcmadrioso commented Jan 12, 2021

No, with the former version displaying "1.65" the result is "1 :65" with a blank between 1 and : (my display only have a semi-colon). Trying to display "12.65" results in "2 :65"

@jcmadrioso
Copy link
Contributor Author

I think that the problem is in file TM1637.h, line 77 and following. It is necessary to detect the dot character, then set dp in that position and not decrement position in buffer.

@AKJ7
Copy link
Owner

AKJ7 commented Jan 12, 2021

I have had this issue before. Some displays don't let the user enable the dot led other don't let enable the colon (Google search). This is usually also mentioned somewhere on the purchase page.
In the source code 1.23 would turn to "1.23", then to their appropiate ASCII code, then to the 7 segment display's equivalent. '.' turns to 0x80 = 0b1000000. To turn on the dot LED. This turns the colon LED because your (mine too) version of the display is built as so. For others it will turn the dot LED on.

@jcmadrioso
Copy link
Contributor Author

Yes, I agree, dot is eight bit in the display, that must be "or-ed" with the 7-segment code to display the digit and turn the dot on.

@AKJ7
Copy link
Owner

AKJ7 commented Jan 12, 2021

About the "or"-ed part. Yeah i thought of it, but i found it nicer to have a separate spot for the dot entirely. I suppose i could change this during the next update.

@jcmadrioso
Copy link
Contributor Author

The problem, I think, is that a "." in the argument of display method is leaving a blank because expected variable is decremented anyway.

@AKJ7
Copy link
Owner

AKJ7 commented Jan 12, 2021

I think i am misunderstanding you.
It is to be expected that there is a blank digit, because the program sends 0x80 to the display to enable the dot LED, but because the display hasn't actually connected the dot LED, nothing happens (blank digit). However, for 1.23, the dot is at position 2. So 0x80 sent at digit 2 turns the colon on, instead of the dot because your display and mine only support the colon. On other displays, it would have turned the dot LED on.

Could you maybe implement what you are trying to tell me and submit a pull request if you have time? I still don't understand.

@jcmadrioso
Copy link
Contributor Author

Yes, the dot led should be turned on, but only the dot, not the others leds of the segments.
I will try to implement it.

@AKJ7
Copy link
Owner

AKJ7 commented Jan 12, 2021

I am more confused than ever.
The displayRawBytes() method could be used:
What should happen if i did:

#include <TM1637.h>


TM1637 tm;

void setup()
{
tm.begin();
}

void loop()
{
tm.displayRawBytes({DisplayDigit().setDot()}, 1);

delay(5000);
}

?
Nothing.
Do you mean that something else should happen, on our display?

@madbarber
Copy link

There are two types of 4 digits 7 segment displays, please find photo attached. On first kind you can use colon and on the second kind you can use dot for each digit. Please find photo with all possible segments turned on.
IMG_3305
I think if you define, that you have display with dots, it should work different for floats. For example if you want to display 12.3 it should display [1][2.][3][ ] and not [1][2][.][3]

@AKJ7
Copy link
Owner

AKJ7 commented Jan 19, 2021

Ok. I will change it.

@AKJ7
Copy link
Owner

AKJ7 commented Jan 21, 2021

Added. Can you test it?

@madbarber
Copy link

I tried and it works. I also checked with padding and offset. I think that you can close this issue :)

@AKJ7
Copy link
Owner

AKJ7 commented Jan 21, 2021

Yup. Thanks.

@AKJ7 AKJ7 closed this as completed Jan 21, 2021
@VVIERV00
Copy link

VVIERV00 commented Jul 6, 2021

Hi, I am facing a similar issue, but with a screen with both dots and colon. The library uses a colon as a dot for decimals. The colonOff() won't work. I would like to know how to implement a solution, maybe one that specifies the type of screen (dot, colon, both)

@AKJ7
Copy link
Owner

AKJ7 commented Jul 6, 2021

Interesting ... Does displaying floating point values with decimal digits work?
Does colonOn() work? Does switchColon() work? Could you share a link of where you bought the display?

@AKJ7 AKJ7 reopened this Jul 6, 2021
@VVIERV00
Copy link

VVIERV00 commented Jul 6, 2021

Interesting ... Does displaying floating point values with decimal digits work?
float x = 3.132 is represented as 31:32
Does colonOn() work? Does switchColon() work? Could you share a link of where you bought the display?
Nothing changed between display(), colonOn() and switchColon()
The link is this

@AKJ7
Copy link
Owner

AKJ7 commented Jul 6, 2021

A priori, i would say that the display from the link that you have provided doesn't support decimal digits (Even though they are physically present).
Could you try the clock example and tell me if the colons blink?

@VVIERV00
Copy link

VVIERV00 commented Jul 6, 2021

That could be the case.
I have tried the clock example: at first, it varies, I have recorded a video

@AKJ7
Copy link
Owner

AKJ7 commented Jul 6, 2021

Wow cool video. The program is working as expected. What did you mean with "it varies"?

As far as i know the TM1637 can only either support the decimal LEDs or the Colon. (Had to learn the hard way. It is usually mentioned on the decription page of the display). One way to similate a dot/decimal LED, is to use a space: 1.23 => 1 23. Or 1.23 => 1_23 .

@VVIERV00
Copy link

VVIERV00 commented Jul 6, 2021

"It varies" is part of a comment I deleted sorry!
I can see the switch only works if there is something displayed on the second digit. Maybe I should consider another display. I pretend to represent natural numbers (4-digit co2 measurements), clock-like (with colon), and dot (for temp readings, 23.10)

@AKJ7
Copy link
Owner

AKJ7 commented Jul 6, 2021

"It varies" is part of a comment I deleted sorry!
I can see the switch only works if there is something displayed on the second digit.

Maybe I should consider another display.

You could get the same display, just with dot support instead.

I pretend to represent natural numbers (4-digit co2 measurements), clock-like (with colon), and dot (for temp readings, 23.10)

A hot fix would be to convert the values to string, modify them, then display.
Something like so (untested).

String convertValue(double value)
{
    String val = value;
    val.replace(".", "_");
    return val;
}

then

tm1637.display(convertValue(1.1));

Weird that the switch works if there is something displayed on the second digit. I will take a look at what is happening later.

@AKJ7
Copy link
Owner

AKJ7 commented Jul 6, 2021

Typ => Original value => on Display

pad => 1 => 1000
offset => 1 => 01
overflow => 1334443 => 1334443

Try the example custom_digit

@VVIERV00
Copy link

VVIERV00 commented Jul 6, 2021

Thank you very much for your help. Now I have it clear what I can do and what not. I will do something as you describe to replace the dots (which clearly don't work by any means).
A display with dot support will lack colons right? At least using this TM1637 chip.

@AKJ7
Copy link
Owner

AKJ7 commented Jul 6, 2021

Thank you very much for your help. Now I have it clear what I can do and what not. I will do something as you describe to replace the dots (which clearly don't work by any means).

Welcome.

A display with dot support will lack colons right? At least using this TM1637 chip.

I think so. Read the schematic of the TM1637. It can multiplex either the colon or the dots. Despite this, the display still comes with both, probably to save manufacturing costs.

@AKJ7 AKJ7 closed this as completed Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants