TM1638 STM8S Library

LCD text displays such as the common HD44780 based ones are not as readable as plain 7 segment LED displays. The problem with driving the latter however is the "support electronics" necessary to drive them. Most of the time, one uses a series of HC595 shift registers, but the problem with them is that they cannot deliver an adequate amount of current to end up with a good brightness of the characters. There are solutions for this but in the end you end up with something far more complex.

Fortunately, a simple Chinese IC is available that is really useful for the hobbyist, the TM1638 (and 1640). They are not available seperately, but on ebay and dealextreme, one can find pre-made boards. Even an Arduino library is available making these displays super-easy to use.

I wanted to combine this display with an STM8S Discovery board for my CNC speed control project, and modified the Arduino library for use with the COSMIC compiler. All credit for the original code goes to Ricardo Batista.

Note that I have deliberately used unsigned 16 bit integers instead of the 32 bit ones that are needed for big numbers that fill the whole display. If needed, this can be easily changed.