9static const char *
const TAG =
"display.tm1637";
30const uint8_t TM1637_ASCII_TO_RAW[]
PROGMEM = {
128 ESP_LOGCONFIG(TAG,
"Running setup");
144 LOG_PIN(
" CLK Pin: ", this->
clk_pin_);
145 LOG_PIN(
" DIO Pin: ", this->
dio_pin_);
146 LOG_UPDATE_INTERVAL(
this);
149#ifdef USE_BINARY_SENSOR
153 tm1637_key->process(
val);
162 if (key_code != 0xFF) {
168 key_code = ~key_code;
173 key_code = (uint8_t) ((key_code & 0x80) >> 7 | (key_code & 0x40) >> 5 | (key_code & 0x20) >> 3 | (key_code & 0x08));
180 for (uint8_t &i : this->
buffer_)
217 for (int8_t i = this->
length_ - 1; i >= 0; i--) {
235 for (uint8_t i = 0; i < 8; i++) {
278 for (uint8_t bit = 0; bit < 8; bit++) {
304 uint8_t pos = start_pos;
305 bool use_dot =
false;
306 for (; *str !=
'\0'; str++) {
308 if (*str >=
' ' && *str <=
'~')
312 ESP_LOGW(TAG,
"Encountered character '%c' with no TM1637 representation while translating string!", *str);
318 data = ((data & 0x80) || use_dot ? 0x80 : 0) |
319 ((data & 0x40) ? 0x8 : 0) |
320 ((data & 0x20) ? 0x10 : 0) |
321 ((data & 0x10) ? 0x20 : 0) |
322 ((data & 0x8) ? 0x1 : 0) |
323 ((data & 0x4) ? 0x2 : 0) |
324 ((data & 0x2) ? 0x4 : 0) |
325 ((data & 0x1) ? 0x40 : 0);
328 data = ((data & 0x80) ? 0x80 : 0) |
329 ((data & 0x40) ? 0x1 : 0) |
330 ((data & 0x20) ? 0x2 : 0) |
331 ((data & 0x10) ? 0x4 : 0) |
332 ((data & 0x8) ? 0x8 : 0) |
333 ((data & 0x4) ? 0x10 : 0) |
334 ((data & 0x2) ? 0x20 : 0) |
335 ((data & 0x1) ? 0x40 : 0);
337 use_dot = *str ==
'.';
339 if ((!this->
inverted_) && (pos != start_pos)) {
340 this->
buffer_[pos - 1] |= 0b10000000;
344 ESP_LOGE(TAG,
"String is too long for the display!");
350 return pos - start_pos;
355 va_start(arg, format);
357 int ret = vsnprintf(buffer,
sizeof(buffer), format, arg);
360 return this->
print(pos, buffer);
365 va_start(arg, format);
367 int ret = vsnprintf(buffer,
sizeof(buffer), format, arg);
370 return this->
print(buffer);
376 size_t ret = time.
strftime(buffer,
sizeof(buffer), format);
378 return this->
print(pos, buffer);
virtual void pin_mode(gpio::Flags flags)=0
virtual void digital_write(bool value)=0
virtual bool digital_read()=0
optional< tm1637_writer_t > writer_
bool send_byte_(uint8_t b)
float get_setup_priority() const override
void dump_config() override
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.
uint8_t uint8_t uint8_t print(uint8_t pos, const char *str)
Print str at the given position.
std::vector< TM1637Key * > tm1637_keys_
uint8_t printf(uint8_t pos, const char *format,...) __attribute__((format(printf
Evaluate the printf-format and print the result at the given position.
const float PROCESSOR
For components that use data from sensors like displays.
const uint8_t TM1637_DATA_FIXED_ADDR
Fixed address.
const uint8_t TM1637_CMD_DATA
Display data command.
const uint8_t TM1637_CMD_ADDR
Display address command.
const uint8_t TM1637_DATA_AUTO_INC_ADDR
Auto increment address.
const uint8_t TM1637_DATA_READ_KEYS
Read keys.
const uint8_t TM1637_UNKNOWN_CHAR
const uint8_t TM1637_ASCII_TO_RAW[] PROGMEM
const uint8_t TM1637_DATA_WRITE
Write data.
const uint8_t TM1637_CMD_CTRL
Display control command.
Providing packet encoding functions for exchanging data with a remote host.
void IRAM_ATTR HOT delayMicroseconds(uint32_t us)
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.