3.15. led_7seg_ht16k33
— LED 7-Segment HT16K33¶
This is a driver for `Adafruit 0.56” 4-Digit 7-Segment Display w/I2C Backpack`_ or compatible devices which uses the Holtek HT16K33 chip.
At this time the driver only supports using the i2c_soft — Software I2C driver to communicate with the HT16K33, not the i2c — I2C driver.
Source code: src/drivers/led_7seg_ht16k33.h, src/drivers/led_7seg_ht16k33.c
Defines
-
LED_7SEG_HT16K33_BRIGHTNESS_MIN
0¶ Minimum brightness.
-
LED_7SEG_HT16K33_BRIGHTNESS_MAX
0xf¶ Maximum brightness.
-
LED_7SEG_HT16K33_DEFAULT_I2C_ADDR
0x70¶ Default I2C address for HT16K33.
Functions
-
int
led_7seg_ht16k33_module_init
(void)¶ Initialize the driver module. This function must be called before calling any other function in this module.
The module will only be initialized once even if this function is called multiple times.
- Return
- zero(0) or negative error code.
-
int
led_7seg_ht16k33_init
(struct led_7seg_ht16k33_driver_t *self_p, struct i2c_soft_driver_t *i2c_p, int i2c_addr)¶ Initialize driver object. The driver object will be used for a single display.
- Return
- zero(0) or negative error code.
- Parameters
self_p
: Driver object to be initialize.i2c_p
: The I2C driver pointer.i2c_addr
: The address of the HT16K33 controller. Probably LED_7SEG_HT16K33_DEFAULT_I2C_ADDR.
-
int
led_7seg_ht16k33_start
(struct led_7seg_ht16k33_driver_t *self_p)¶ Start driver.
- Return
- zero(0) or negative error code.
- Parameters
self_p
: Driver object.
-
int
led_7seg_ht16k33_display
(struct led_7seg_ht16k33_driver_t *self_p)¶ Send content of display buffer to the display.
- Return
- zero(0) or negative error code.
- Parameters
self_p
: Driver object.
-
int
led_7seg_ht16k33_clear
(struct led_7seg_ht16k33_driver_t *self_p)¶ Clear content of display buffer.
- Return
- zero(0) or negative error code.
- Parameters
self_p
: Driver object.
-
int
led_7seg_ht16k33_brightness
(struct led_7seg_ht16k33_driver_t *self_p, int brightness)¶ Set display brightness.
- Return
- zero(0) or negative error code.
- Parameters
self_p
: Driver object.brightness
: Brightness from LED_7SEG_HT16K33_BRIGHTNESS_MIN to LED_7SEG_HT16K33_BRIGHTNESS_MAX.
-
int
led_7seg_ht16k33_set_num
(struct led_7seg_ht16k33_driver_t *self_p, int num, int base)¶ Set a number in the display buffer.
Number cannot be more than 4 digits AKA base^4 - 1.
- Return
- zero(0) or negative error code.
- Parameters
self_p
: Driver object.num
: Number to set.base
: Base of num.
-
int
led_7seg_ht16k33_show_colon
(struct led_7seg_ht16k33_driver_t *self_p, int show_colon)¶ Set show/hide of colon in the display buffer.
- Return
- zero(0) or negative error code.
- Parameters
self_p
: Driver object.show_colon
: If true light colon, otherwise turn off.
-
int
led_7seg_ht16k33_show_dot
(struct led_7seg_ht16k33_driver_t *self_p, int position, int show_colon)¶ Set show/hide of dot in the display buffer.
- Return
- zero(0) or negative error code.
- Parameters
self_p
: Driver object.position
: The position to light colon or not. Range: 0 to 3.show_dot
: If true light dot, otherwise turn off.
-
struct
led_7seg_ht16k33_driver_t
¶ - #include <led_7seg_ht16k33.h>