This is a quick and dirty library providing a relatively easy-to-use interface for driving the Holtek HT16K33 16×8 LED driver IC.
The API commands are, in no particular order:
init(uint8_t i2c_addr)
- specifies the I2C address of the IC
setBrightness(uint8_t b)
- sets the brightness of the display (0–15)
setBlink(uint8_t)
- sets the blink rate of the display (see note below)
resetOrientation()
- resets the orientation of the display to the defaults
reverse()
- reverses the order of the two 8×8 sub-matrices (again, see note below)
flipVertical()
- flips the matrix data vertically before writing to the IC
flipHorizontal()
- flips the matrix data horizontally before writing to the IC
clear()
- clears the matrix completely†
setPixel(uint8_t row, uint8_t col, uint8_t onoff)
- sets the state of a single pixel.
onoff
should be either 0 (off) or 1 (on)† setRow(uint8_t row, uint16_t value)
- sets the content of an entire row (16 bits)†
getRow(uint8_t row)
- gets the content of an entire row (16 bits)†
setColumn(uint8_t col, uint8_t value)
- sets the content of an entire column (8 bits)†
write()
- writes the display buffer to the IC (updates the display)
† note: none of these will write anything to the IC—you will still need to call write()
.
For various reasons, blink rates are #define-d as a set of constants:
HT16K33_BLINK_OFF
- disable blinking (default)
HT16K33_BLINK_1HZ
- set blink rate to 1Hz
HT16K33_BLINK_2HZ
- set blink rate to 2Hz
HT16K33_BLINK_0HZ5
- set blink rate to 0.5Hz
This only really makes sense if you’re using a 16×8 matrix made of two discrete 8×8 matrixes. If you’re rolling it yourself or using a single 16×8, you may as well ignore this section.
This library assumes that, if you’re using two 8×8 matrixes, you’ve wired them correctly with ROW0 on the left-hand edge of the left-most matrix, and ROW15 on the right-most edge, thus:
0 7 8 15 +--------+--------+ | | | | | | | | | +--------+--------+
However, just occasionally your concentration will slip and you’ll end up with something like this:
8 15 0 7 +--------+--------+ | | | | | | | | | +--------+--------+
Rather than having to rewire everything/rework your PCBs, you can just call reverse()
, and the library will cover for you…
(no, this didn’t happen to me. I don’t know why you would think that /s)