Go Down

Topic: ANN: TallFont Library for LiquidCrystal (HD44780) (Read 1 time) previous topic - next topic

tylernt

Sep 01, 2013, 11:42 pm Last Edit: Sep 02, 2013, 06:08 am by tylernt Reason: 1
There's a few BigFont implementations floating around, but they're rather wide -- what if you want more big numbers than will fit on your display? Enter TallFont -- double-height, but standard width, numbers!

This library will let you print individual digits (printTallDigit()) as well as signed integers up to 16 bits (printTallNumber()). You could easily extend it to display longs if you chose.

You can specify a length argument and include leading zeros or leading spaces (right justify); it also supports a double-height colon "character": I added these features to make the implementation of a clock easier. You can also specify trailing spaces, which lets you overprint numbers of various lengths to the display without any flicker-inducing calls to lcd.clear(). Or, simply pass a 0 for the length argument to get a plain number without any padding.

The library has no error-checking of any sort; send it bad or silly data, and you'll get bad or silly results.

If you edit the library source, you'll find that you can choose an alternate rendering for the '9' digit if you like.

This library takes about 3.5K of flash (2.5K if you use only printTallDigit() and not printTallnumber()). It is designed to work with the Arduino IDE version 1.0.5.

It's written for the standard LiquidCrystal library, but could easily be adapted to work with any other HD44780 LCD library that supports setCursor, write, and of course createChar methods.

Code snippet (full examples in attached library zip file):
Code: [Select]

byte cursorpos = 0;
cursorpos = printTallNumber(12,2,LEADINGSPACES,cursorpos,1); // assign = cursor when using printTallNumber. it returns absolute
cursorpos += printTallDigit(COLONglyph,cursorpos,1); // increment += cursor when using printTallDigit, it returns relative
cursorpos = printTallNumber(59,2,LEADINGZEROS,cursorpos,1);
// cursor is already in the right place -- no need to lcd.setCursor()
lcd.print("pm");

tylernt

More screenshots -- thick, thin, and fancy font faces as well as the alternate '9' digit render.

marco_c

Looks a lot like mine (see link below - code repository).

Amazing how we get to the same place from different angles.
Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

tylernt

#3
Sep 02, 2013, 05:05 am Last Edit: Sep 02, 2013, 05:06 am by tylernt Reason: 1
Interesting, I was not aware of your work or I might not have re-invented the wheel! :smiley-roll-sweat: I guess if nothing else, I learned how to write a library (something I've been meaning to do for a while now). It seems like there's always a library for just about everything else I want to do, so this was my chance to "pay it forward" a little.

...aaand it seems I was beaten to the punch not once but twice. To make the other one easier for others to find, I've included a link here:

http://forum.arduino.cc/index.php?topic=150226

robtillaart


More screenshots -- thick, thin, and fancy font faces as well as the alternate '9' digit render.

I really like the thin one, with one remark the middle - of the 2 should be in the upper part.
That way the numbers are in one line (beauty is subjective I know)
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

tylernt


I really like the thin one, with one remark the middle - of the 2 should be in the upper part.
That way the numbers are in one line (beauty is subjective I know)
Thank you, and I agree with you on the 2. Unfortunately, these numbers consume all 8 of the custom character slots in a HD44780 display so there's no room for a ninth Lglyph.

The good news is, you could modify the library source to be:
Code: [Select]

case 2:
    TallFontLcd->write((uint8_t)Cglyph);
    break;

for the upper, and

Code: [Select]

case 2:
    TallFontLcd->write("L");
    break;

for the lower. Though of course, this would only look right for the Thin font (a happy coincidence :) ).

Go Up