Skip to content

Commit b091405

Browse files
committed
Add support for showing/hiding the colon
Allow showing or hiding the colon separator via a lambda call. Also update the README
1 parent a3cc01f commit b091405

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

components/ht16k33_alpha/README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# HT16K33 4 character alphanumeric display
1+
# HT16K33 4 character display
2+
3+
This component supports both the 4 character 14 segment alphanumeric display and the 4 character (plus colon) 7 segment character display. Use the `type` parameter to select which kind of display you have.
24

35
There are no print functions for addressing rows and columns. With such a small display I didn't see any point.
46
All the print functions without the row and column parameters are available.
@@ -7,14 +9,17 @@ All the same parameters for the i2c display can be used other than the dimension
79
There are also lambda functions `get_brightness` and `set_brightness` for adjusting the brightness of the display.
810
You can extend the display across multiple units.
911

12+
For the 7-segment displays with colon, there is also the `show_colon` lambda function, that can be used to select whether the colon between the second and third digits should be lit or not.
13+
1014
Example:
1115
```yaml
12-
i2c:
16+
i2c:
1317
sda: D0
1418
scl: D1
1519

1620
display:
1721
- platform: ht16k33_alpha
22+
type: alpha
1823
address: 0x70
1924
scroll: true
2025
scroll_speed: 250ms
@@ -25,6 +30,9 @@ display:
2530
secondary_displays:
2631
- address: 0x71
2732
```
33+
# Required parameters
34+
35+
`type:` choose between `alpha` or `7segment`, depending on which kind of display you have
2836

2937
# Optional parameters
3038

components/ht16k33_alpha/ht16k33_display.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,11 @@ void HT16K337SegmentDisplay::display_() {
6262
constexpr uint8_t size = 10;
6363
uint8_t buffer[size];
6464
memcpy(buffer, this->buffer_ + offset, 4);
65-
// TODO: implement method to show/hide colon symbol
66-
// if (this->show_colon()) {
67-
// buffer[4] = 0x02;
68-
// } else {
65+
if (this->show_colon_) {
66+
buffer[4] = 0x02;
67+
} else {
6968
buffer[4] = 0;
70-
// }
69+
}
7170
buffer[5] = 0;
7271
memcpy(buffer + 6, this->buffer_ + offset + 4, 4);
7372

components/ht16k33_alpha/ht16k33_display.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class HT16K33BaseDisplay : public PollingComponent, public i2c::I2CDevice {
4040
void strftime(const char *format, ESPTime time) __attribute__((format(strftime, 2, 0)));
4141
#endif
4242

43+
void show_colon(bool show) { this->show_colon_ = show; }
44+
4345
protected:
4446
void command_(uint8_t value);
4547
void call_writer() { this->writer_(*this); }
@@ -58,6 +60,7 @@ class HT16K33BaseDisplay : public PollingComponent, public i2c::I2CDevice {
5860
int buffer_fill_ {0};
5961
int offset_ {0};
6062
uint8_t brightness_ = 16;
63+
bool show_colon_ {false};
6164
};
6265

6366
class HT16K33AlphaDisplay : public HT16K33BaseDisplay {

0 commit comments

Comments
 (0)