Functions |
static void | tm1638_send_raw (const tm1638_p t, uint8_t x) |
static uint8_t | tm1638_receive_raw (const tm1638_p t) |
static void | tm1638_send_command (const tm1638_p t, uint8_t x) |
static void | tm1638_send_data (const tm1638_p t, uint8_t addr, uint8_t data) |
static void | tm1638_send_config (const tm1638_p t) |
static uint8_t | tm1638_calc_config (const tm1638_p t) |
tm1638_p | tm1638_alloc (uint8_t data, uint8_t clock, uint8_t strobe) |
void | tm1638_free (tm1638_p *t) |
void | tm1638_enable (tm1638_p t, bool enable) |
void | tm1638_set_intensity (tm1638_p t, uint8_t intensity) |
void | tm1638_set_7seg_raw (const tm1638_p t, uint8_t digit, uint8_t n) |
void | tm1638_set_7seg_text (const tm1638_p t, const char *str, uint8_t dots) |
void | tm1638_set_led (const tm1638_p t, uint8_t led, uint8_t cols) |
void | tm1638_set_8leds (const tm1638_p t, uint8_t red, uint8_t green) |
void | tm1638_send_cls (const tm1638_p t) |
uint8_t | tm1638_font (char c) |
uint32_t | tm1638_read_buttons (const tm1638_p t) |
uint8_t | tm1638_read_8buttons (const tm1638_p t) |
A simple interface to TM1638 based displays for the Raspberry Pi.
- Author:
- Martin Oldfield ex-tm.nosp@m.1638.nosp@m.@mjo..nosp@m.tc
- Version:
- 0.1
DESCRIPTION
A simple interface to the TM1638 based displays for the Raspberry Pi.
Dealextreme, doubtless amongst others, sell small boards with eight seven-segment displays, eight red-green LEDs and eight push buttons for less than $10.
The boards are basically just the LEDs and switches, and a TM1638 driver chip. This sits on a two-wire serial bus which makes it fairly easy to connect the boards to a computer/microcontroller of your choice. Of course, one needs a little bit of software. This is such a library for the Raspberry Pi.
This is the C source file implementing the library, and so this documentation includes information only relevant to the implementation. If you're just using the library, read the tm1638.h documentation instead.
ISSUES
- The code makes the data line into an output by default, turning it into an input only when reading data. It should probably be the other way round: an input unless we're actually driving something.
- Some delays are needed or some pulses are too fast. The delays are all somewhat arbitrary, and whilst they work for me, I don't claim that they are optimal.
- The packaging is rather clunky: I don't grok autotools very well!
REFERENCES
Inevitably people have already done all this for with an Arduino, and that made it easier to write this:
- John Boxall wrote a blog about it.
- Ricardo Batista wrote a library to do it.
- Marc (via John above) found a datasheet.
This isn't really a port of Ricardo's code: I wanted a different API. However, I did copy his nice 7-segment font, and his code was very helpful when it came to understanding the data-sheet.
Thank you to everyone.
LICENSE
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/copyleft/gpl.html
Definition in file tm1638.c.