avishorp / TM1637

Arduino library for TM1637 (LED Driver)
GNU Lesser General Public License v3.0
428 stars 218 forks source link

Propositions (and code) for new functions #58

Closed vince2corte closed 3 years ago

vince2corte commented 5 years ago

Hello, First of all, thank you for this library which allows us to use TM1637-based displays. While studying this library, it seemed to me that it was not very easy to display basic data without taking care about their formatting. So I developed an extension for your library for my personal use. As it works well, I suggest that you make it available to everyone by integrating it into your own code. A simple copy and paste and a small optimization should suffice. I didn't know C++ at all before that, so there must be some optimizations to be made. That extension adds these functions: -> SEG_mot // SIZE_mot : these constants define the words to be displayed with the display_message function. -> display_message(const uint8_t segments[], int size) displays a message on the display. -> bool display_number(double number, int ndecdigits = -1) displays a number with or without decimal part. If optional ndecdigits is defined, the number of digits after the decimal point will be fixed at this value. -> bool display_seconds (unsigned long time, int base_seconds = 60) displays a value with seconds and hundredths of seconds from a timestamp (millis() for instance). base_seconds is used to know at which value the seconds restart start from zero. -> bool display_minutes (unsigned long time, int base_minutes = 60) displays a value with minutes and seconds. base_minutes is used to know at which value the minutes start again at zero. -> bool display_heures (unsigned long time, int base_hours = 24) displays a value with hours and minutes. base_hours is used to know at which value the hours start from zero. -> void display_all(uint8_t segment) is only used to display the same value on all displays. This can be used to test them or simulate an initialization sequence. I am at your disposal to translate the comments if you have any problems with French. Feel free to modify and use it as you want.

TM1637Evo.zip

avishorp commented 3 years ago

Thank you, but I think it's a little too specialized for this kind of library.