9static const char *
const TAG =
"tm1621";
26const char TM1621_KCHAR[]
PROGMEM = {
"0|1|2|3|4|5|6|7|8|9|-| "};
28const uint8_t
TM1621_DIGIT_ROW[2][12] = {{0x5F, 0x50, 0x3D, 0x79, 0x72, 0x6B, 0x6F, 0x51, 0x7F, 0x7B, 0x20, 0x00},
29 {0xF5, 0x05, 0xB6, 0x97, 0x47, 0xD3, 0xF3, 0x85, 0xF7, 0xD7, 0x02, 0x00}};
58 for (uint32_t segment = 0; segment < 16; segment++) {
63 snprintf(this->
row_[0],
sizeof(this->
row_[0]),
"----");
64 snprintf(this->
row_[1],
sizeof(this->
row_[1]),
"----");
69 ESP_LOGCONFIG(TAG,
"TM1621:");
70 LOG_PIN(
" CS Pin: ", this->
cs_pin_);
74 LOG_UPDATE_INTERVAL(
this);
99 uint8_t buffer[8] = {0};
101 for (uint32_t j = 0; j < 2; j++) {
103 uint32_t
len = strlen(this->
row_[j]);
105 int row_idx =
len - 3;
107 dp = strchr(this->
row_[j],
'.');
109 }
else if (
len > 6) {
110 snprintf(this->
row_[j],
sizeof(this->
row_[j]),
"9999");
113 row[3] = (row_idx >= 0) ? this->
row_[j][row_idx--] :
' ';
114 if ((row_idx >= 0) && dp) {
117 row[2] = (row_idx >= 0) ? this->
row_[j][row_idx--] :
' ';
118 row[1] = (row_idx >= 0) ? this->
row_[j][row_idx--] :
' ';
119 row[0] = (row_idx >= 0) ? this->
row_[j][row_idx--] :
' ';
124 char needle[2] = {0};
125 for (uint32_t i = 0; i < 4; i++) {
127 int index = this->
get_command_code_(command,
sizeof(command), (
const char *) needle, TM1621_KCHAR);
131 uint32_t bidx = (0 == j) ? i : 7 - i;
162 for (uint8_t i : buffer) {
169 uint16_t full_command = (0x0400 | command) << 5;
172 for (uint32_t i = 0; i < 12; i++) {
174 if (full_command & 0x8000) {
189 for (uint32_t i = 0; i < 8; i++) {
205 uint16_t full_address = (
address | 0x0140) << 7;
208 for (uint32_t i = 0; i < 9; i++) {
210 if (full_address & 0x8000) {
225 return snprintf(this->
row_[start_pos],
sizeof(this->
row_[start_pos]),
"%s", str);
230 va_start(arg, format);
232 int ret = vsnprintf(buffer,
sizeof(buffer), format, arg);
235 return this->
print(pos, buffer);
240 va_start(arg, format);
242 int ret = vsnprintf(buffer,
sizeof(buffer), format, arg);
245 return this->
print(buffer);
250 const char *haystack) {
254 const char *read = haystack;
255 char *write = destination;
259 size_t size = destination_size - 1;
262 while ((ch !=
'\0') && (ch !=
'|')) {
264 if (size && (ch !=
'|')) {
270 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
optional< tm1621_writer_t > writer_
const float PROCESSOR
For components that use data from sensors like displays.
const uint8_t TM1621_LCD_ON
const uint8_t TM1621_WDT_DIS
const char TM1621_KCHAR[] PROGMEM
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]
const uint8_t TM1621_COMMANDS[]
Providing packet encoding functions for exchanging data with a remote host.
void IRAM_ATTR HOT delayMicroseconds(uint32_t us)