Pages: [1]   Go Down
Author Topic: ANN: TallFont Library for LiquidCrystal (HD44780)  (Read 893 times)
0 Members and 1 Guest are viewing this topic.
Idaho, US
Offline Offline
God Member
*****
Karma: 19
Posts: 859
Special User
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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");


* standard.jpg (25.59 KB, 640x286 - viewed 48 times.)
* TallFont.zip (3.99 KB - downloaded 35 times.)
« Last Edit: September 01, 2013, 11:08:07 pm by tylernt » Logged

Idaho, US
Offline Offline
God Member
*****
Karma: 19
Posts: 859
Special User
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


* thick.jpg (22.45 KB, 640x283 - viewed 27 times.)

* thin.jpg (22.83 KB, 640x283 - viewed 32 times.)

* fancy.jpg (18.77 KB, 640x288 - viewed 34 times.)

* alternate9.jpg (12.34 KB, 480x189 - viewed 33 times.)
Logged

Sydney, Australia
Offline Offline
Edison Member
*
Karma: 27
Posts: 1184
Big things come in large packages
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Amazing how we get to the same place from different angles.
Logged

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Idaho, US
Offline Offline
God Member
*****
Karma: 19
Posts: 859
Special User
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: September 01, 2013, 10:06:45 pm by tylernt » Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12456
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

Rob Tillaart

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

Idaho, US
Offline Offline
God Member
*****
Karma: 19
Posts: 859
Special User
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
case 2:
    TallFontLcd->write((uint8_t)Cglyph);
    break;
for the upper, and

Code:
case 2:
    TallFontLcd->write("L");
    break;
for the lower. Though of course, this would only look right for the Thin font (a happy coincidence smiley ).
Logged

Pages: [1]   Go Up
Jump to: