ESPHome 2025.5.0
Loading...
Searching...
No Matches
st7920.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome {
8namespace st7920 {
9
10class ST7920;
11
12using st7920_writer_t = std::function<void(ST7920 &)>;
13
15 public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_HIGH, spi::CLOCK_PHASE_TRAILING,
16 spi::DATA_RATE_200KHZ> {
17 public:
18 void set_writer(st7920_writer_t &&writer) { this->writer_local_ = writer; }
19 void set_height(uint16_t height) { this->height_ = height; }
20 void set_width(uint16_t width) { this->width_ = width; }
21
22 // ========== INTERNAL METHODS ==========
23 // (In most use cases you won't need these)
24 void setup() override;
25 void dump_config() override;
26 float get_setup_priority() const override;
27 void update() override;
28 void fill(Color color) override;
29 void write_display_data();
30
32
33 protected:
34 void draw_absolute_pixel_internal(int x, int y, Color color) override;
35 int get_height_internal() override;
36 int get_width_internal() override;
37 size_t get_buffer_length_();
38 void display_init_();
39 void command_(uint8_t value);
40 void data_(uint8_t value);
41 void send_(uint8_t type, uint8_t value);
42 void goto_xy_(uint16_t x, uint16_t y);
45
46 int16_t width_ = 128, height_ = 64;
48};
49
50} // namespace st7920
51} // namespace esphome
The SPIDevice is what components using the SPI will create.
Definition spi.h:421
display::DisplayType get_display_type() override
Definition st7920.h:31
optional< st7920_writer_t > writer_local_
Definition st7920.h:47
void send_(uint8_t type, uint8_t value)
Definition st7920.cpp:54
void dump_config() override
Definition st7920.cpp:95
void draw_absolute_pixel_internal(int x, int y, Color color) override
Definition st7920.cpp:119
void command_(uint8_t value)
Definition st7920.cpp:42
void set_writer(st7920_writer_t &&writer)
Definition st7920.h:18
void goto_xy_(uint16_t x, uint16_t y)
Definition st7920.cpp:60
int get_height_internal() override
Definition st7920.cpp:113
void set_width(uint16_t width)
Definition st7920.h:20
float get_setup_priority() const override
Definition st7920.cpp:102
void fill(Color color) override
Definition st7920.cpp:93
void setup() override
Definition st7920.cpp:34
void update() override
Definition st7920.cpp:104
void data_(uint8_t value)
Definition st7920.cpp:48
void set_height(uint16_t height)
Definition st7920.h:19
size_t get_buffer_length_()
Definition st7920.cpp:115
int get_width_internal() override
Definition st7920.cpp:111
uint8_t type
std::function< void(ST7920 &)> st7920_writer_t
Definition st7920.h:12
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6