Library for many 7, 14 & 16 segment serial displays

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

Someone most certainly has been pounding on eBay! :grinning:

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.

Like the idea of a universal library!

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

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?

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.

I really like that this library:

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.

Thanks for the reply!

HKJ-lygte:
Print is for streaming output, here you do not stream output.

I disagree :wink: 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.

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.

HKJ-lygte:
Overloading do not require the use of print, I am using overloading.

Don't just read half of my sentence :wink: I talk about print.

HKJ-lygte:
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 :slight_smile: And I was just curious why not to do it 'the Arduino way". No hard feelings!

septillion:
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 :slight_smile: 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

HKJ-lygte:
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.

septillion:
Why would it? It does not exclude a show() method.

I did not see a show method in the LCD API

septillion:
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.

HKJ-lygte:
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().

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

I added support for another HT16K33 based display:

This display supports displaying both decimal point and colon.

And the driver can now handle multiple HT16K33 displays on the same connections.

Added another HT16K33 display:

This display is fairly large with 1.2" or 3cm high digits, it would be fine for a wall clock. The display only has one colon, the 3 other dots are indicators.

I also added a TM1637 driver that supports indicators for colon for compatibility reasons.

See manual for full description: Manual and download

Care to cite where those last two displays are available? I don't mind just playing with them if they are cheap. Even better if other than red.

Paul__B:
Care to cite where those last two displays are available? I don't mind just playing with them if they are cheap. Even better if other than red.

The first one is easy to find, use "ht16k33 module segment" as search on Ebay or Aliexpress, only in red.
For the other use "1.2 segment display" on Ebay, in red, yellow or green.

Hmmm. Big one a bit pricey for my liking, but in the search I came across this:

Though it seems that particular seller does not want to ship it to most of the world! :astonished: