8static const char *
const TAG =
"tm1621";
25constexpr char TM1621_KCHAR[]
PROGMEM = {
"0|1|2|3|4|5|6|7|8|9|-| "};
27const uint8_t
TM1621_DIGIT_ROW[2][12] = {{0x5F, 0x50, 0x3D, 0x79, 0x72, 0x6B, 0x6F, 0x51, 0x7F, 0x7B, 0x20, 0x00},
28 {0xF5, 0x05, 0xB6, 0x97, 0x47, 0xD3, 0xF3, 0x85, 0xF7, 0xD7, 0x02, 0x00}};
57 for (
uint32_t segment = 0; segment < 16; segment++) {
62 snprintf(this->
row_[0],
sizeof(this->
row_[0]),
"----");
63 snprintf(this->
row_[1],
sizeof(this->
row_[1]),
"----");
68 ESP_LOGCONFIG(TAG,
"TM1621:");
69 LOG_PIN(
" CS Pin: ", this->
cs_pin_);
73 LOG_UPDATE_INTERVAL(
this);
98 uint8_t buffer[8] = {0};
104 int row_idx =
len - 3;
106 dp = strchr(this->
row_[j],
'.');
108 }
else if (
len > 6) {
109 snprintf(this->
row_[j],
sizeof(this->
row_[j]),
"9999");
112 row[3] = (row_idx >= 0) ? this->
row_[j][row_idx--] :
' ';
113 if ((row_idx >= 0) && dp) {
116 row[2] = (row_idx >= 0) ? this->
row_[j][row_idx--] :
' ';
117 row[1] = (row_idx >= 0) ? this->
row_[j][row_idx--] :
' ';
118 row[0] = (row_idx >= 0) ? this->
row_[j][row_idx--] :
' ';
123 char needle[2] = {0};
126 int index = this->
get_command_code_(command,
sizeof(command), (
const char *) needle, TM1621_KCHAR);
130 uint32_t bidx = (0 == j) ? i : 7 - i;
161 for (uint8_t i : buffer) {
168 uint16_t full_command = (0x0400 | command) << 5;
173 if (full_command & 0x8000) {
204 uint16_t full_address = (
address | 0x0140) << 7;
209 if (full_address & 0x8000) {
224 return snprintf(this->
row_[start_pos],
sizeof(this->
row_[start_pos]),
"%s", str);
231 int ret = vsnprintf(buffer,
sizeof(buffer),
format, arg);
234 return this->
print(pos, buffer);
241 int ret = vsnprintf(buffer,
sizeof(buffer),
format, arg);
244 return this->
print(buffer);
249 const char *haystack) {
253 const char *read = haystack;
254 char *write = destination;
258 size_t size = destination_size - 1;
261 while ((ch !=
'\0') && (ch !=
'|')) {
263 if (
size && (ch !=
'|')) {
269 if (!strcasecmp(needle, destination)) {
virtual void digital_write(bool value)=0
int get_command_code_(char *destination, size_t destination_size, const char *needle, const char *haystack)
void dump_config() override
bool send_command_(uint16_t command)
uint8_t printf(uint8_t pos, const char *format,...) __attribute__((format(printf
Evaluate the printf-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.
bool send_common_(uint8_t common)
bool send_address_(uint16_t address)
float get_setup_priority() const override
constexpr float PROCESSOR
For components that use data from sensors like displays.
const uint8_t TM1621_LCD_ON
const uint8_t TM1621_WDT_DIS
const uint8_t TM1621_SYS_EN
const uint8_t TM1621_TONE_OFF
const uint8_t TM1621_TIMER_DIS
const uint8_t TM1621_PULSE_WIDTH
const uint8_t TM1621_BIAS
const uint8_t TM1621_IRQ_DIS
const uint8_t TM1621_DIGIT_ROW[2][12]
constexpr char TM1621_KCHAR[] PROGMEM
const uint8_t TM1621_COMMANDS[]
const char int const __FlashStringHelper * format
void IRAM_ATTR HOT delayMicroseconds(uint32_t us)
size_t size_t const char va_start(args, fmt)