Skip to content

Not treating float numbers correctly #29

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

Open
gonzabrusco opened this issue Aug 30, 2018 · 2 comments
Open

Not treating float numbers correctly #29

gonzabrusco opened this issue Aug 30, 2018 · 2 comments

Comments

@gonzabrusco
Copy link

gonzabrusco commented Aug 30, 2018

Hello. I was stydying your library to see if I could adapt it to work with TM1637 modules with decimal dot and I've found out it does not handle well floats.

For example.
If I print -1 (as int) the display shows correctly -1
If I print "-1" (as string) the display shows correctly -1
But if I print -1.0 (as float) the display shows -_0

Something similar happens with positive numbers. 1.0 prints as _0

I'm looking at the Print.cpp file and at your library but I yet have to figure out where the error is. But there's definitely an error.

Anyway, thanks for this amazing library. I hope to improve it for decimal dots but first I have to undestand it!! haha

@gonzabrusco gonzabrusco changed the title Not treating negative numbers correctly Not treating negative float numbers correctly Aug 30, 2018
@gonzabrusco gonzabrusco changed the title Not treating negative float numbers correctly Not treating float numbers correctly Aug 30, 2018
@gonzabrusco
Copy link
Author

gonzabrusco commented Aug 30, 2018

It looks that the problem comes from the way you implemented the write functions. In one write function you use the buffer _rawBuffer but in the others you don't. So when the Print function mixes both write functions, this problems arise.

For example:

display.print('h');
display.print('o');
display.print("l");
display.print('a');
while(1);

Prints "hola" on the display.

But:

display.print('h');
display.print('o');
display.print("-");
display.print('a');
while(1);

prints "hoa". Because the string function does not stores the printed chars on _rawBuffer and does not increment the cursor.

@bremme
Copy link
Owner

bremme commented Sep 29, 2018

Hi @Chinoforest thanks for looking in to this problem! You are more then welcome to make a pull request. Always too much things to do with too little time. I will try to solve this issue when I find some time to improve the library. In the meantime, perhaps I should add some current limitation to the README, there are a couple more things which don't work the way I like.

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

2 participants