SBK_HT16K33 library 1.0.0
Standalone Arduino library to control HT16K33 LED matrices or bar meters via I2C. Can be used directly or as a driver for SBK_BarDrive animations.
Loading...
Searching...
No Matches
SBK_HT16K33.h
Go to the documentation of this file.
1
23
24/**********************************************************************
25 * This library is a modified version of the original HT16K33 Arduino driver
26 * from MikeS11's ProtonPack repository:
27 * https://github.com/MikeS11/ProtonPack/tree/master/Source/Libraries/ht16k33-arduino-master
28 *
29 * Modifications were made specifically to drive vertical bar meters for use in
30 * SBK projects such as the Wrist Blaster.
31 *
32 * All credit for the original implementation goes to Mike S11.
33 **********************************************************************/
34
35#pragma once
36
37#define SBK_HT16K33_IS_DEFINED
38
39#include <Arduino.h>
40#include <Wire.h>
41
42// HT16K33 Command Definitions
43#define HT16K33_CMD_RAM 0x00
44#define HT16K33_CMD_KEYS 0x40
45#define HT16K33_CMD_SETUP 0x80
46#define HT16K33_CMD_ROWINT 0xA0
47#define HT16K33_CMD_DIMMING 0xE0
48
49#define HT16K33_DISPLAY_OFF 0x00
50#define HT16K33_DISPLAY_ON 0x01
51#define HT16K33_BLINK_OFF 0x00
52#define HT16K33_BLINK_1HZ 0x02
53#define HT16K33_BLINK_2HZ 0x04
54#define HT16K33_BLINK_0HZ5 0x06
55
61{
62public:
67 SBK_HT16K33(uint8_t addr);
68
73
77 void begin();
78
83 void clear(uint8_t device);
87 void clear();
88
94 void setBrightness(uint8_t device, uint8_t brightness);
95
100 void setBrightness(uint8_t brightness);
101
109 void setLed(uint8_t device, uint8_t row, uint8_t col, bool state);
110
117 void setLed(uint8_t row, uint8_t col, bool state);
118
126 bool getLed(uint8_t device, uint8_t row, uint8_t col) const;
127
134 bool getLed(uint8_t row, uint8_t col) const;
135
140 void show(uint8_t device);
141
145 void show();
146
147private:
148 uint8_t _i2c_addr;
149 uint16_t *_buffer;
150
151 void _write();
152 void _writeRow(uint8_t row);
153};
~SBK_HT16K33()
Destructor. Frees allocated buffer memory.
Definition SBK_HT16K33.cpp:25
void setBrightness(uint8_t device, uint8_t brightness)
Set the brightness level (0–15) of the device (API-compatible wrapper).
Definition SBK_HT16K33.cpp:73
void setLed(uint8_t device, uint8_t row, uint8_t col, bool state)
Set an individual LED on or off (device-specific call) (API-compatible wrapper).
Definition SBK_HT16K33.cpp:90
SBK_HT16K33(uint8_t addr)
Construct a new SBK_HT16K33 instance.
Definition SBK_HT16K33.cpp:23
void clear()
Clear the internal display buffer.
Definition SBK_HT16K33.cpp:64
void begin()
Initialize the HT16K33 device at a given I2C address.
Definition SBK_HT16K33.cpp:34
bool getLed(uint8_t device, uint8_t row, uint8_t col) const
Get the current state of an LED in the buffer (API-compatible wrapper).
Definition SBK_HT16K33.cpp:107
void show()
Push internal buffer to the display.
Definition SBK_HT16K33.cpp:145