9 static const char *
const TAG =
"tm1621";
26 const char TM1621_KCHAR[]
PROGMEM = {
"0|1|2|3|4|5|6|7|8|9|-| "};
28 const 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}};
32 ESP_LOGCONFIG(TAG,
"Setting up TM1621...");
55 for (uint8_t tm1621_command : TM1621_COMMANDS) {
60 for (uint32_t segment = 0; segment < 16; segment++) {
65 snprintf(this->
row_[0],
sizeof(this->
row_[0]),
"----");
66 snprintf(this->
row_[1],
sizeof(this->
row_[1]),
"----");
71 ESP_LOGCONFIG(TAG,
"TM1621:");
72 LOG_PIN(
" CS Pin: ", this->
cs_pin_);
76 LOG_UPDATE_INTERVAL(
this);
101 uint8_t buffer[8] = {0};
103 for (uint32_t j = 0; j < 2; j++) {
105 uint32_t
len = strlen(this->
row_[j]);
107 int row_idx = len - 3;
109 dp = strchr(this->
row_[j],
'.');
111 }
else if (len > 6) {
112 snprintf(this->
row_[j],
sizeof(this->
row_[j]),
"9999");
115 row[3] = (row_idx >= 0) ? this->
row_[j][row_idx--] :
' ';
116 if ((row_idx >= 0) && dp) {
119 row[2] = (row_idx >= 0) ? this->
row_[j][row_idx--] :
' ';
120 row[1] = (row_idx >= 0) ? this->
row_[j][row_idx--] :
' ';
121 row[0] = (row_idx >= 0) ? this->
row_[j][row_idx--] :
' ';
126 char needle[2] = {0};
127 for (uint32_t i = 0; i < 4; i++) {
129 int index = this->
get_command_code_(command,
sizeof(command), (
const char *) needle, TM1621_KCHAR);
133 uint32_t bidx = (0 == j) ? i : 7 - i;
134 buffer[bidx] = TM1621_DIGIT_ROW[j][index];
164 for (uint8_t i : buffer) {
171 uint16_t full_command = (0x0400 | command) << 5;
174 for (uint32_t i = 0; i < 12; i++) {
176 if (full_command & 0x8000) {
191 for (uint32_t i = 0; i < 8; i++) {
207 uint16_t full_address = (address | 0x0140) << 7;
210 for (uint32_t i = 0; i < 9; i++) {
212 if (full_address & 0x8000) {
227 return snprintf(this->
row_[start_pos],
sizeof(this->
row_[start_pos]),
"%s", str);
232 va_start(arg, format);
234 int ret = vsnprintf(buffer,
sizeof(buffer), format, arg);
237 return this->
print(pos, buffer);
242 va_start(arg, format);
244 int ret = vsnprintf(buffer,
sizeof(buffer), format, arg);
247 return this->
print(buffer);
252 const char *haystack) {
256 const char *read = haystack;
257 char *write = destination;
261 size_t size = destination_size - 1;
264 while ((ch !=
'\0') && (ch !=
'|')) {
266 if (size && (ch !=
'|')) {
272 if (!strcasecmp(needle, destination)) {
const char TM1621_KCHAR [] PROGMEM
virtual void digital_write(bool value)=0
int get_command_code_(char *destination, size_t destination_size, const char *needle, const char *haystack)
const uint8_t TM1621_WDT_DIS
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 uint8_t TM1621_TONE_OFF
optional< tm1621_writer_t > writer_
const uint8_t TM1621_SYS_EN
bool send_common_(uint8_t common)
const uint8_t TM1621_BIAS
bool send_address_(uint16_t address)
const uint8_t TM1621_TIMER_DIS
void dump_config() override
const float PROCESSOR
For components that use data from sensors like displays.
const uint8_t TM1621_IRQ_DIS
const uint8_t TM1621_COMMANDS[]
const uint8_t TM1621_LCD_ON
uint8_t uint8_t uint8_t print(uint8_t pos, const char *str)
Print str at the given position.
bool send_command_(uint16_t command)
const uint8_t TM1621_PULSE_WIDTH
Implementation of SPI Controller mode.
void IRAM_ATTR HOT delayMicroseconds(uint32_t us)
float get_setup_priority() const override
const uint8_t TM1621_DIGIT_ROW[2][12]