10static const char *
const TAG =
"display.tm1638";
11static const uint8_t TM1638_REGISTER_FIXEDADDRESS = 0x44;
12static const uint8_t TM1638_REGISTER_AUTOADDRESS = 0x40;
13static const uint8_t TM1638_REGISTER_READBUTTONS = 0x42;
14static const uint8_t TM1638_REGISTER_DISPLAYOFF = 0x80;
15static const uint8_t TM1638_REGISTER_DISPLAYON = 0x88;
16static const uint8_t TM1638_REGISTER_7SEG_0 = 0xC0;
17static const uint8_t TM1638_REGISTER_LED_0 = 0xC1;
18static const uint8_t TM1638_UNKNOWN_CHAR = 0b11111111;
20static const uint8_t TM1638_SHIFT_DELAY = 4;
45 LOG_PIN(
" CLK Pin: ", this->
clk_pin_);
46 LOG_PIN(
" DIO Pin: ", this->
dio_pin_);
47 LOG_PIN(
" STB Pin: ", this->
stb_pin_);
48 LOG_UPDATE_INTERVAL(
this);
57 listener->keys_update(keys);
71 for (uint8_t i = 0; i < 4; i++) {
94 for (uint8_t i = 0; i < 8; i++) {
100 uint8_t num_commands = 16;
101 uint8_t commands[num_commands];
103 for (uint8_t i = 0; i < num_commands; i++) {
117 commands[0] = TM1638_REGISTER_LED_0 + (led_pos << 1);
118 commands[1] = led_on_off;
126 uint8_t commands[2] = {};
128 commands[0] = TM1638_REGISTER_7SEG_0 + (seg_pos << 1);
129 commands[1] = seg_bits;
139 if (brightness_level > 0) {
149 uint8_t
pos = start_pos;
151 bool last_was_dot =
false;
153 for (; *str !=
'\0'; str++) {
154 uint8_t data = TM1638_UNKNOWN_CHAR;
156 if (*str >=
' ' && *str <=
'~') {
158 }
else if (data == TM1638_UNKNOWN_CHAR) {
159 ESP_LOGW(TAG,
"Encountered character '%c' with no TM1638 representation while translating string!", *str);
164 if (
pos != start_pos &&
174 ESP_LOGI(TAG,
"TM1638 String is too long for the display!");
178 last_was_dot =
false;
183 return pos - start_pos;
194 int ret = vsnprintf(buffer,
sizeof(buffer), format, arg);
197 return this->
print(pos, buffer);
204 int ret = vsnprintf(buffer,
sizeof(buffer), format, arg);
207 return this->
print(buffer);
213 size_t ret = time.
strftime(buffer,
sizeof(buffer), format);
215 return this->
print(pos, buffer);
232 for (uint8_t i = 0; i < num_commands; i++) {
233 uint8_t command = commands[i];
248 for (uint8_t i = 0; i < num_commands; i++) {
258 for (
int i = 0; i < 8; ++i) {
270 for (
int i = 0; i < 8; i++) {
virtual void pin_mode(gpio::Flags flags)=0
virtual void digital_write(bool value)=0
virtual bool digital_read()=0
void set_7seg_(int seg_pos, uint8_t seg_bits)
float get_setup_priority() const override
std::vector< KeyListener * > listeners_
uint8_t strftime(uint8_t pos, const char *format, ESPTime time) __attribute__((format(strftime
Evaluate the strftime-format and print the result at the given position.
GPIOPin * clk_pin_
brghtness of the display 0 through 7
void send_command_leave_open_(uint8_t value)
void dump_config() override
void send_command_sequence_(uint8_t commands[], uint8_t num_commands, uint8_t starting_address)
uint8_t printf(uint8_t pos, const char *format,...) __attribute__((format(printf
Evaluate the printf-format and print the result at the given position.
void set_intensity(uint8_t brightness_level)
uint8_t uint8_t void set_led(int led_pos, bool led_on_off)
void send_commands_(uint8_t const commands[], uint8_t num_commands)
void shift_out_(uint8_t value)
void send_command_(uint8_t value)
uint8_t uint8_t uint8_t print(uint8_t pos, const char *str)
Print str at the given position.
const float PROCESSOR
For components that use data from sensors like displays.
Providing packet encoding functions for exchanging data with a remote host.
void IRAM_ATTR HOT delayMicroseconds(uint32_t us)
size_t size_t const char va_start(args, fmt)
uint8_t progmem_read_byte(const uint8_t *addr)
A more user-friendly version of struct tm from time.h.
size_t strftime(char *buffer, size_t buffer_len, const char *format)
Convert this ESPTime struct to a null-terminated c string buffer as specified by the format argument.