Subsection 10.4.12 HT16K33 Quick Reference
This page collects everything the driver needs, in one place. Page numbers are the HT16K33 datasheet’s.
| Command | Byte | Options |
|---|---|---|
| Display data address pointer |
0b0000 A3 A2 A1 A0 |
Where the following data bytes start; 0x00 for the whole display |
| System setup |
0b0010 X X X S |
S = 1 turns the internal oscillator on; 0x21 in full |
| Display setup |
0b1000 X B1 B0 D |
D = 1 is display on; B1 B0 is 00 steady, 01 at 2 Hz, 10 at 1 Hz, 11 at 0.5 Hz. 0x81 is on and steady |
| Dimming set |
0b1110 P3 P2 P1 P0 |
Duty cycle in sixteenths, 0000 for 1/16 up to 1111 for 16/16. 0xEF is full |
The display RAM is sixteen bytes, two per common line, of which we use the five even addresses 0x00, 0x02, 0x04, 0x06 and 0x08 (digit 1, digit 2, the colon, digit 3, digit 4). The odd addresses take a 0. Within a digit’s byte the bits are
0b DP g f e d c b a: bit 0 is segment a and bit 7 is the decimal point.
Writing the display is one page write from address 0x00 (datasheet p. 22): the pointer advances one address per byte received, so ten bytes in one transaction fill the whole thing. Two separate transactions do not work, because the pointer is set by the command byte at the start of a transaction and a STOP ends it.
One oddity in the given solutions, so it does not look like a mistake:
SevenSeg_dim() sends HT16K33_DISPLAY_CMD | HT16K33_BRIGHT_CMD | (brightness & 0xf), and the dimming command already contains every bit the display command has (0b1110 covers 0b1000), so the first term changes nothing. The value that goes out is 0xE0 ORed with the brightness either way.
