ESPHome 2025.12.0-dev
Loading...
Searching...
No Matches
tm1638.h
Go to the documentation of this file.
1#pragma once
2
6#include "esphome/core/hal.h"
7#include "esphome/core/time.h"
9
10#include <vector>
11
12namespace esphome {
13namespace tm1638 {
14
16 public:
17 virtual void keys_update(uint8_t keys){};
18};
19
20class TM1638Component;
21
23
25 public:
26 void set_writer(tm1638_writer_t &&writer) { this->writer_ = writer; }
27 void setup() override;
28 void dump_config() override;
29 void update() override;
30 float get_setup_priority() const override;
31 void set_intensity(uint8_t brightness_level);
32 void display();
33
34 void set_clk_pin(GPIOPin *pin) { this->clk_pin_ = pin; }
35 void set_dio_pin(GPIOPin *pin) { this->dio_pin_ = pin; }
36 void set_stb_pin(GPIOPin *pin) { this->stb_pin_ = pin; }
37
38 void register_listener(KeyListener *listener) { this->listeners_.push_back(listener); }
39
41 uint8_t printf(uint8_t pos, const char *format, ...) __attribute__((format(printf, 3, 4)));
43 uint8_t printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
44
46 uint8_t print(uint8_t pos, const char *str);
48 uint8_t print(const char *str);
49
50 void loop() override;
51 uint8_t get_keys();
52
54 uint8_t strftime(uint8_t pos, const char *format, ESPTime time) __attribute__((format(strftime, 3, 0)));
56 uint8_t strftime(const char *format, ESPTime time) __attribute__((format(strftime, 2, 0)));
57
58 void set_led(int led_pos, bool led_on_off);
59
60 protected:
61 void set_7seg_(int seg_pos, uint8_t seg_bits);
62 void send_command_(uint8_t value);
63 void send_command_leave_open_(uint8_t value);
64 void send_commands_(uint8_t const commands[], uint8_t num_commands);
65 void send_command_sequence_(uint8_t commands[], uint8_t num_commands, uint8_t starting_address);
66 void shift_out_(uint8_t value);
67 void reset_();
68 uint8_t shift_in_();
69 uint8_t intensity_{};
73 uint8_t *buffer_ = new uint8_t[8];
75 std::vector<KeyListener *> listeners_{};
76};
77
78} // namespace tm1638
79} // namespace esphome
This class simplifies creating components that periodically check a state.
Definition component.h:437
virtual void keys_update(uint8_t keys)
Definition tm1638.h:17
void set_7seg_(int seg_pos, uint8_t seg_bits)
Definition tm1638.cpp:126
float get_setup_priority() const override
Definition tm1638.cpp:94
std::vector< KeyListener * > listeners_
Definition tm1638.h:75
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.
Definition tm1638.cpp:214
GPIOPin * clk_pin_
brghtness of the display 0 through 7
Definition tm1638.h:70
void register_listener(KeyListener *listener)
Definition tm1638.h:38
void send_command_leave_open_(uint8_t value)
Definition tm1638.cpp:242
void set_stb_pin(GPIOPin *pin)
Definition tm1638.h:36
void set_clk_pin(GPIOPin *pin)
Definition tm1638.h:34
void send_command_sequence_(uint8_t commands[], uint8_t num_commands, uint8_t starting_address)
Definition tm1638.cpp:247
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 tm1638.cpp:193
void set_writer(tm1638_writer_t &&writer)
Definition tm1638.h:26
void set_intensity(uint8_t brightness_level)
Definition tm1638.cpp:137
uint8_t uint8_t void set_led(int led_pos, bool led_on_off)
Definition tm1638.cpp:115
void set_dio_pin(GPIOPin *pin)
Definition tm1638.h:35
void send_commands_(uint8_t const commands[], uint8_t num_commands)
Definition tm1638.cpp:232
void shift_out_(uint8_t value)
Definition tm1638.cpp:272
void send_command_(uint8_t value)
Definition tm1638.cpp:225
struct @65::@66 __attribute__
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
A more user-friendly version of struct tm from time.h.
Definition time.h:15
std::string print()