9static const char *
const TAG =
"display.tm1638";
10static const uint8_t TM1638_REGISTER_FIXEDADDRESS = 0x44;
11static const uint8_t TM1638_REGISTER_AUTOADDRESS = 0x40;
12static const uint8_t TM1638_REGISTER_READBUTTONS = 0x42;
13static const uint8_t TM1638_REGISTER_DISPLAYOFF = 0x80;
14static const uint8_t TM1638_REGISTER_DISPLAYON = 0x88;
15static const uint8_t TM1638_REGISTER_7SEG_0 = 0xC0;
16static const uint8_t TM1638_REGISTER_LED_0 = 0xC1;
17static const uint8_t TM1638_UNKNOWN_CHAR = 0b11111111;
19static const uint8_t TM1638_SHIFT_DELAY = 4;
44 LOG_PIN(
" CLK Pin: ", this->
clk_pin_);
45 LOG_PIN(
" DIO Pin: ", this->
dio_pin_);
46 LOG_PIN(
" STB Pin: ", this->
stb_pin_);
47 LOG_UPDATE_INTERVAL(
this);
56 listener->keys_update(keys);
70 for (uint8_t i = 0; i < 4; i++) {
93 for (uint8_t i = 0; i < 8; i++) {
99 uint8_t num_commands = 16;
100 uint8_t commands[num_commands];
102 for (uint8_t i = 0; i < num_commands; i++) {
116 commands[0] = TM1638_REGISTER_LED_0 + (led_pos << 1);
117 commands[1] = led_on_off;
125 uint8_t commands[2] = {};
127 commands[0] = TM1638_REGISTER_7SEG_0 + (seg_pos << 1);
128 commands[1] = seg_bits;
138 if (brightness_level > 0) {
148 uint8_t
pos = start_pos;
149 bool last_was_dot =
false;
151 for (; *str !=
'\0'; str++) {
152 uint8_t data = TM1638_UNKNOWN_CHAR;
154 if (*str >=
' ' && *str <=
'~') {
158 ESP_LOGW(TAG,
"Encountered character '%c' with no TM1638 representation while translating string!", *str);
163 if (
pos != start_pos && !last_was_dot) {
167 ESP_LOGI(TAG,
"TM1638 String is too long for the display!");
176 ESP_LOGI(TAG,
"TM1638 String is too long for the display!");
180 last_was_dot =
false;
185 return pos - start_pos;
196 int ret = vsnprintf(buffer,
sizeof(buffer),
format, arg);
199 return this->
print(pos, buffer);
206 int ret = vsnprintf(buffer,
sizeof(buffer),
format, arg);
209 return this->
print(buffer);
217 return this->
print(pos, buffer);
234 for (uint8_t i = 0; i < num_commands; i++) {
235 uint8_t command = commands[i];
250 for (uint8_t i = 0; i < num_commands; i++) {
260 for (
int i = 0; i < 8; ++i) {
272 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.
constexpr float PROCESSOR
For components that use data from sensors like displays.
const char int const __FlashStringHelper * format
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.