9 static const char *
const TAG =
"display.tm1637";
30 const uint8_t TM1637_ASCII_TO_RAW[]
PROGMEM = {
128 ESP_LOGCONFIG(TAG,
"Setting up TM1637...");
138 ESP_LOGCONFIG(TAG,
"TM1637:");
139 ESP_LOGCONFIG(TAG,
" Intensity: %d", this->
intensity_);
140 ESP_LOGCONFIG(TAG,
" Inverted: %d", this->
inverted_);
141 ESP_LOGCONFIG(TAG,
" Length: %d", this->
length_);
142 LOG_PIN(
" CLK Pin: ", this->
clk_pin_);
143 LOG_PIN(
" DIO Pin: ", this->
dio_pin_);
144 LOG_UPDATE_INTERVAL(
this);
147 #ifdef USE_BINARY_SENSOR 151 tm1637_key->process(val);
156 this->
send_byte_(TM1637_CMD_DATA | TM1637_DATA_READ_KEYS);
160 if (key_code != 0xFF) {
166 key_code = ~key_code;
171 key_code = (uint8_t) ((key_code & 0x80) >> 7 | (key_code & 0x40) >> 5 | (key_code & 0x20) >> 3 | (key_code & 0x08));
178 for (uint8_t &i : this->
buffer_)
215 for (int8_t i = this->
length_ - 1; i >= 0; i--) {
233 for (uint8_t i = 0; i < 8; i++) {
276 for (uint8_t bit = 0; bit < 8; bit++) {
302 uint8_t pos = start_pos;
303 bool use_dot =
false;
304 for (; *str !=
'\0'; str++) {
306 if (*str >=
' ' && *str <=
'~')
309 if (data == TM1637_UNKNOWN_CHAR) {
310 ESP_LOGW(TAG,
"Encountered character '%c' with no TM1637 representation while translating string!", *str);
316 data = ((data & 0x80) || use_dot ? 0x80 : 0) |
317 ((data & 0x40) ? 0x8 : 0) |
318 ((data & 0x20) ? 0x10 : 0) |
319 ((data & 0x10) ? 0x20 : 0) |
320 ((data & 0x8) ? 0x1 : 0) |
321 ((data & 0x4) ? 0x2 : 0) |
322 ((data & 0x2) ? 0x4 : 0) |
323 ((data & 0x1) ? 0x40 : 0);
326 data = ((data & 0x80) ? 0x80 : 0) |
327 ((data & 0x40) ? 0x1 : 0) |
328 ((data & 0x20) ? 0x2 : 0) |
329 ((data & 0x10) ? 0x4 : 0) |
330 ((data & 0x8) ? 0x8 : 0) |
331 ((data & 0x4) ? 0x10 : 0) |
332 ((data & 0x2) ? 0x20 : 0) |
333 ((data & 0x1) ? 0x40 : 0);
335 use_dot = *str ==
'.';
337 if ((!this->
inverted_) && (pos != start_pos)) {
338 this->
buffer_[pos - 1] |= 0b10000000;
342 ESP_LOGE(TAG,
"String is too long for the display!");
348 return pos - start_pos;
353 va_start(arg, format);
355 int ret = vsnprintf(buffer,
sizeof(buffer), format, arg);
358 return this->
print(pos, buffer);
363 va_start(arg, format);
365 int ret = vsnprintf(buffer,
sizeof(buffer), format, arg);
368 return this->
print(buffer);
374 size_t ret = time.
strftime(buffer,
sizeof(buffer), format);
376 return this->
print(pos, buffer);
virtual void digital_write(bool value)=0
bool send_byte_(uint8_t b)
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.
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...
float get_setup_priority() const override
A more user-friendly version of struct tm from time.h.
optional< tm1637_writer_t > writer_
virtual void pin_mode(gpio::Flags flags)=0
const uint8_t TM1637_DATA_FIXED_ADDR
Fixed address.
const uint8_t TM1637_ASCII_TO_RAW [] PROGMEM
const uint8_t TM1637_UNKNOWN_CHAR
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_CMD_ADDR
Display address command.
virtual bool digital_read()=0
const uint8_t TM1637_DATA_WRITE
Write data.
uint8_t progmem_read_byte(const uint8_t *addr)
const uint8_t TM1637_CMD_DATA
Display data command.
uint8_t uint8_t uint8_t print(uint8_t pos, const char *str)
Print str at the given position.
Implementation of SPI Controller mode.
void dump_config() override
void IRAM_ATTR HOT delayMicroseconds(uint32_t us)
std::vector< TM1637Key * > tm1637_keys_
const uint8_t TM1637_DATA_READ_KEYS
Read keys.
const uint8_t TM1637_DATA_AUTO_INC_ADDR
Auto increment address.
const uint8_t TM1637_CMD_CTRL
Display control command.