ESPHome 2025.12.0-dev
Loading...
Searching...
No Matches
tm1621.h
Go to the documentation of this file.
1#pragma once
2
5#include "esphome/core/hal.h"
7
8namespace esphome {
9namespace tm1621 {
10
11class TM1621Display;
12
14
16 public:
17 void set_writer(tm1621_writer_t &&writer) { this->writer_ = writer; }
18
19 void setup() override;
20
21 void dump_config() override;
22
23 void set_cs_pin(GPIOPin *pin) { cs_pin_ = pin; }
24 void set_data_pin(GPIOPin *pin) { data_pin_ = pin; }
25 void set_read_pin(GPIOPin *pin) { read_pin_ = pin; }
26 void set_write_pin(GPIOPin *pin) { write_pin_ = pin; }
27
28 void display_celsius(bool d) { celsius_ = d; }
29 void display_fahrenheit(bool d) { fahrenheit_ = d; }
30 void display_humidity(bool d) { humidity_ = d; }
31 void display_voltage(bool d) { voltage_ = d; }
32 void display_kwh(bool d) { kwh_ = d; }
33
34 float get_setup_priority() const override;
35
36 void update() override;
37
39 uint8_t printf(uint8_t pos, const char *format, ...) __attribute__((format(printf, 3, 4)));
41 uint8_t printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
42
44 uint8_t print(uint8_t pos, const char *str);
46 uint8_t print(const char *str);
47
48 void display();
49
50 protected:
51 void bit_delay_();
53 bool send_command_(uint16_t command);
54 bool send_common_(uint8_t common);
55 bool send_address_(uint16_t address);
56 void stop_();
57 int get_command_code_(char *destination, size_t destination_size, const char *needle, const char *haystack);
58
64 char row_[2][12];
65 uint8_t state_;
66 uint8_t device_;
71 bool kwh_;
72};
73
74} // namespace tm1621
75} // namespace esphome
uint8_t address
Definition bl0906.h:4
This class simplifies creating components that periodically check a state.
Definition component.h:437
int get_command_code_(char *destination, size_t destination_size, const char *needle, const char *haystack)
Definition tm1621.cpp:249
void dump_config() override
Definition tm1621.cpp:68
bool send_command_(uint16_t command)
Definition tm1621.cpp:168
void display_fahrenheit(bool d)
Definition tm1621.h:29
void set_read_pin(GPIOPin *pin)
Definition tm1621.h:25
uint8_t printf(uint8_t pos, const char *format,...) __attribute__((format(printf
Evaluate the printf-format and print the result at the given position.
Definition tm1621.cpp:228
void display_celsius(bool d)
Definition tm1621.h:28
void set_data_pin(GPIOPin *pin)
Definition tm1621.h:24
void set_cs_pin(GPIOPin *pin)
Definition tm1621.h:23
bool send_common_(uint8_t common)
Definition tm1621.cpp:188
tm1621_writer_t writer_
Definition tm1621.h:63
void display_voltage(bool d)
Definition tm1621.h:31
bool send_address_(uint16_t address)
Definition tm1621.cpp:204
void set_write_pin(GPIOPin *pin)
Definition tm1621.h:26
void set_writer(tm1621_writer_t &&writer)
Definition tm1621.h:17
float get_setup_priority() const override
Definition tm1621.cpp:84
void display_humidity(bool d)
Definition tm1621.h:30
struct @65::@66 __attribute__
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
std::string print()