New lib: SegLCDLib

Hello
based on not allowed WorkInProgress merge request WIP: Added SegLCDLib for segment LCD displays by petrkr · Pull Request #6417 · arduino/library-registry · GitHub

I trying to post it here.

I work on library for LCD segment displays, which should be universal regardless on used chip or LCD screen.

Should be relatively easy extensible for new controllers or/and LCD screens.

I want to discuss about usage for users/developers, before I will release first "alpha"release.

But even for first release I want to have some "generic" name conventions, so I do not need to make too many breaking changes later.

Let me know, what you think about this library as-is now and I will be happy for some suggestions.

Regards Petr

You need to resolve this first

follow the style of the LCD API 1.0
It is meant for character LCDs but is a good base for all kind of displays.

(There should be a better / updated version also - but can't find it currently).

Further more, read about the common Print.h class and let your classes inherit from Print and use it to write characters to your display.

Don't forget to document your library. I would start with comments compatible with Doxygen and at least generate a first documenation with it.

Yes, i read reason on gh, that's why I am here, i post PR as reference, so I do not need to repeat things written there already.

Good point, even those LCD's are segmentc it does not mean segment is character, but some of them can inherit Print class. But really do not know where it will printc if such LCD have 3 sections of 7seg 'chars'.

Do not know if you look at actual state, because I have already some documentation even with pictures of actually supported LCD's and doxygen basic documentations.

That was actually part of that PRc which I linked.

But I'll link it here for more convinient access

Sources: GitHub - petrkr/SegLCDLib: Library for segment LCD. Including drivers and some LCD display implementations
Doxygen docs: SegLCDLib: SegLCDlib

may be you can reuse "setCursor".
One parameter for the digit on a "virtual" section, the other parameter for the section itself.

Very similar like column and row on character LCD with several rows (= sections).

Two further links to read:

Arduino Style Guide for Creating Libraries | Arduino Documentation

and

How to Write A Great Arduino Library - News - SparkFun Electronics

In that case why didn't you fix the issue yourself?

Seems you not read this post. Because it is NOT about fixing issue on pull request, not about fixing issue on library to be able to merge it.

It is about

I want to discuss about usage for users/developers, before I will release first "alpha"release.

and

Let me know, what you think about this library as-is now and I will be happy for some suggestions.

Regards :slight_smile:

publish it and you will know

Yes, good point, also rename display/noDisplay for on/off as in lcdapi,. that Print.h I will think, because that is something very hard to implement by logic on segment char display. They are very specific, if you use those with symbols or pre-writen labels. Of course for those, which are just 6 digits 7seg or 14seg that setCursor and print will work just fine, because I can claim them as single row 6 column char lcd.

but in LCDAPI is mandatory for example blinking cursor, that is something, what those segment LCD does not supports at all.. but if I will use LCD API only as "starting reference point" and not as "must be it like that", then I can just omit that.

for now I will try somehow to replace writeChar and writeFloat with print for that segment parts.

But do not know if you look for that library as-is now, because I have there writeChar, which use LCD Section (like top, clock, temp,...) in order where to print. If I will use setCursor, how it will confuse users about what is row 0, row 1 if for example one segment has 1st row 4 digits with : in middle for clock, space, 1 digit for day of week
2nd row 4 digits for temperature 1
3rd row 4 digits for temperature 2

also what will happen if someone will set cursor to 0, 0 and will write 10 chars? Asking because now I have section CLOCK and I will not allow to print there more than 4 chars (or I will show just first 4), because in RAM/Memory map of this LCD if I will continue writing in memory, it will overflow to symbols like T1: symbol or % symbol or clock symbol on this T1T2 LCD for example.

maybe I can do something like
setCursor 0,0
print 1234
setCursor 0,5 (or 0,1?)
print 5
setCursor 1,0
print 23.4
setCursor 2,0
print 51.2

Really have to think about compatibility with Print.h class and meaning of those very specific Segment displays

It is available already at github. Anyone can clone it from master and include even without Arduino library manager.

I would keep track of the cursor position of each section (line) in the code and for example avoid a overwriting of other sections or even symbols.

Whether you handle each section as line or make a separate function to activate a specific section is up to you. But for me to think about "lines" for these sections is fine.

Imho you should not think about compatibility with Print.h - but inherit Print.h.
"Compatibility" will come out of the box.

I have written several "7 segment" display libraries for different hardware (MAX7219, HT16K33, Neopixel) and some stand alone class for shift registers. The integration of Print.h is straight forward. You need ONE member function write() which shows exact one character. All the rest like support of numbers, DEC/HEX/BIN, floats with fixed decimals, F-Makro,.. all comes by inheritance of Print.h.

That I already have, writeChar, so it should be rename it and change littlebit logic with 'digit' number.

For numbers I would like to use right-justify, as it's more nature, how that I can achieve? Use some 'setAligment' method before calling print?

For now i prefer text (boot, load,..) left-aliged but temperature 1C, 10C, 10.3C, -3.70C right aligned, because most of those LCD have C or F symbol on right and would looks bad if there wil be 1.2 space, space, C

Can I somewhere take a look, for that Print implementation/usage? So I do not need develop wheel again? Thx

take any other Liquid Crystal library and see what write() is supposed to do:

LiquidCrystal/src/LiquidCrystal.cpp at master · arduino-libraries/LiquidCrystal · GitHub

basically it sends the character to the display and returns 1 on success.

I would rely on printf/sprintf.

if you need to write your own function, check the numbers to be printed and set the cursor accordingly. I had a thread on that some years ago, I have to search it...

edit:
it is in German, but #43 contains several variants to compare:

Stellen eines (signed) integer ermitteln - International / Deutsch - Arduino Forum

(remark: take care about negative numbers also!)

Yes I do for now.

that is also what make difficult for those segment displays. For example ThemHum display have minus symbol, others not. Also decimal points are only at some segments or colon char also, some have, some not. so sometimes you can use it as symbol othertime you have to use it as top and bottom segment on (which will eat digit) so for example string "test" is 4 chars, but "t.e.s.t." is 8 chars, but on some segment LCD you can treat it as 4 chars with dots, if dot is available on that segment

That is what makes write very complex on every kind of LCD. Also if someone will write for example "25.5*C" I can show it as 5 digits, or (if LCD has) light up *C symbol and use just 3 digits. But for example T1T2 LCD have two *C symbols on Row 1 (on top and bottom)

So maybe I will stick with print somehow easily and those symbols I will keep some setLabel or setSymbol functions.

Now I look to ligquid display lib. it is funny in LCD API is written you have to use on/off to make display on/off,, but in liquid library is display and noDisplay (as I had and just changed it regarding to LCD API)

Thank you very much. I should work for while now also to work and take look for rest at evening

oh, you will find out more "funny" things. For example check the setCursor() how it is documented in the API 1.0 vs. most libraries so far use the parameters also as column, row.

Interesting! Some time ago I added LCD support to my TM16xx library. For years the library supported LED only, but after buying some TM1621 chips and LCD display modules (HT1621, TM1622) it now supports some LCD. Generic support follows the LED API. For two modules I made jodule specific derived classes.

If I can find some time I will look at your Github repo and give you some feedback.

@noiasca @maxint-rd

I just merged LCDApi compatible interface to master.
So you can check it and try if you have some kind of those LCD. Or can try to implement new one by inspiration of already done classes.

Regards Petr