Go Down

Topic: Library for many 7, 14 & 16 segment serial displays (Read 7083 times) previous topic - next topic

Jun 03, 2019, 08:02 am Last Edit: Nov 02, 2019, 10:22 am by HKJ-lygte


I needed a library for a 7 segment display, but was not satisfied with the Arduino libraries, as a result I have made a new "library" that can handle nearly every cheap display on Ebay (See above picture, they are all supported) and has functions to display int/long/float/double/hex/binary/text. The library is fast and fairly compact.

The displays supported include: HC164, HC595, HT1621, HT16K33, MAX7219, TM1637 and TM1638

Manual and download

Paul__B

Someone most certainly has been pounding on eBay!  :smiley-lol:

When working on it I decided that I wanted a universal 7-seg library. It is very useful that I can select the best (i.e. digit size, number of digits, power consumption) display for each project, without having any extra software work and if I decides to switch display later on it is hardly more work than moving the wires to another display.

septillion

Like the idea of a universal library!

But uhm, why deviate from Arduino standards and not simply use print()? ::)

I also don't like it if a library uses very ambitious names like 'digit0'. This is asking for trouble.

And a thing I miss, how does it handle displays which use multiplexing (in software)?

And is it possible to use multiple displays as one large display easily?
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

Print is for streaming output, here you do not stream output.

For me a digit is a digit.

Multiplexing is controlled from interrupt, either the library can set it up or you can make you own interrupt and just call the updateIntr() handler. You could also call it from a loop if you do not want to use interrupts. Its own interrupt handler will only work on Mega processor and includes code for interrupt 1, 2, 3 and 4.

As long as the displays is controlled from one instance, they will be handled as one long display, you can, of course, use parameters to split it up. This means with static HC595 or MAX7219 you can make very long displays. But both modules has a border and do not fit seamless together.
I was thinking about a options for linking multiple instances to the same frame buffer, but I decided against it for now.

pert

I really like that this library:
https://github.com/bremme/arduino-tm1637
uses Arduino's Print class (which allows it to share the Arduino core library's code for printing any common type) and also follows the API of the LiquidCrystal library.

I haven't had the time to check out HKJ-lygte's library yet, but I think it's really great to have a library that supports such an array of 7 segment displays. To me, there's something so awesome about the 7 segment LED displays. In addition to a stock of the TM1637 4 digit modules I have already used in several projects, I recently bought a TM1638 module to play with. The first Chinese eBay seller I tried to buy the TM1638 from sent me a MAX7219 module instead so I now have a decent collection of different 7 segment modules.

septillion

#6
Jun 04, 2019, 01:18 pm Last Edit: Jun 04, 2019, 04:14 pm by septillion
Thanks for the reply!

Print is for streaming output, here you do not stream output.
I disagree ;) I think being able to print() all kinds of stuff with the help of function overloading is one of the more powerful things. Agreed, it has it's shortcomings (for examples alignment r leading zeroes) but you could implement this with separate calls.
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

Overloading do not require the use of print, I am using overloading.

The library pert linked to uses print for streaming and it was exactly that kind of interface I did not want. When I show numbers on a LED display I want them right adjusted without any extra work.

I did not want the library to be depend on other libraries (Except standard Arduino stuff) and I wanted it to be compact and fast. The fast part is also the reason it is possible to split display buffer updates and actual display refresh.

And with my library it doesn't matter if you use a TM1638 or MAX7219 display, but the TM1638 may be a bit tricky because there the digits and segments are not always connected the same way, I have 3 different configurations.

septillion

#8
Jun 04, 2019, 04:15 pm Last Edit: Jun 04, 2019, 04:15 pm by septillion
Overloading do not require the use of print, I am using overloading.
Don't just read half of my sentence ;) I talk about print.

The library pert linked to uses print for streaming and it was exactly that kind of interface I did not want. When I show numbers on a LED display I want them right adjusted without any extra work.
You have the extra work by having different functions. It indeed works and great if that is what you want! But the whole fact it breaks one of the very useful Arduino concepts makes it that I would not use it or recommend it, especially not for newbies. But again, that's preference :) And I was just curious why not to do it 'the Arduino way". No hard feelings!
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

You have the extra work by having different functions. It indeed works and great if that is what you want! But the whole fact it breaks one of the very useful Arduino concepts makes it that I would not use it or recommend it, especially not for newbies. But again, that's preference :) And I was just curious why not to do it 'the Arduino way". No hard feelings!
I don't get you point about different functions. Using a streaming function for a few digits is a very silly concept, but for large displays, communication streams and files it is often fine.
As I said above, I wanted something that was simple and easy to use for a 7 segment display and in my opinion I got it.

Some of the silly problems with streaming:
clear();print(123);  // Display will flicker between clear and print, may or may not be visible
setcursor(0,0);print(123);setcursor(0,0);print(56); // Display will show 563

And in both cases the number will be left adjusted, not right adjusted. I do not believe I have any equipment with left adjusted 7 segment displays.

Some newbies will probably love this kind of problems.

I have added a small extension class called "LEDLCDAPIDriver", it implements the LCD API.
I added a little trick to make it better for float: a point or comma will be move to previous digit.

See manual for full description: Manual and download

septillion

clear();print(123);  // Display will flicker between clear and print, may or may not be visible
Why would it? It does not exclude a show() method.

I do agree the setCursor() can be confusing. But that's no different in your library except the fact you have to call it more explicitly aka are forced to think about it before. But if the documentation of a library is written well (and yeah, I know most are not...) this should be noted right away.
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

Why would it? It does not exclude a show() method.
I did not see a show method in the LCD API


I do agree the setCursor() can be confusing. But that's no different in your library except the fact you have to call it more explicitly aka are forced to think about it before. But if the documentation of a library is written well (and yeah, I know most are not...) this should be noted right away.
For small sized LED display you do not have to think about it, you just have to show the value and it will be correctly right aligned with empty digits before the number. My library is designed to make it easy to use a 7 segment display without needing lot of other code.
But if you like the print you can just use my secondary class now, it supports exactly the same displays.

septillion

I did not see a show method in the LCD API
I don't say all have, but I just say it's not a reason to shoot print(). For example, the excellent U8G2 library or (most) Adafruit libraries do have a show()/update()/alike().
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

#14
Jun 10, 2019, 08:30 pm Last Edit: Jun 10, 2019, 08:32 pm by HKJ-lygte
I took a look at my interrupt routines due to another project, now I also support Timer1 to Timer5 on the Arduino Mega. This is only relevant with interrupt drive display (HC164 & HC595).
I also did a few other changes, but they are very minor.
Manual is update.

Manual and download

Go Up