ESPHome  2024.10.2
ssd1306_base.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/hal.h"
6 
7 namespace esphome {
8 namespace ssd1306_base {
9 
25 };
26 
28  public:
29  void setup() override;
30 
31  void display();
32 
33  void update() override;
34 
35  void set_model(SSD1306Model model) { this->model_ = model; }
36  void set_reset_pin(GPIOPin *reset_pin) { this->reset_pin_ = reset_pin; }
37  void set_external_vcc(bool external_vcc) { this->external_vcc_ = external_vcc; }
38  void init_contrast(float contrast) { this->contrast_ = contrast; }
39  float get_contrast();
40  void set_contrast(float contrast);
41  float get_brightness();
42  void init_brightness(float brightness) { this->brightness_ = brightness; }
43  void set_brightness(float brightness);
44  void init_flip_x(bool flip_x) { this->flip_x_ = flip_x; }
45  void init_flip_y(bool flip_y) { this->flip_y_ = flip_y; }
46  void init_offset_x(uint8_t offset_x) { this->offset_x_ = offset_x; }
47  void init_offset_y(uint8_t offset_y) { this->offset_y_ = offset_y; }
48  void init_invert(bool invert) { this->invert_ = invert; }
49  void set_invert(bool invert);
50  bool is_on();
51  void turn_on();
52  void turn_off();
53  float get_setup_priority() const override { return setup_priority::PROCESSOR; }
54  void fill(Color color) override;
55 
57 
58  protected:
59  virtual void command(uint8_t value) = 0;
60  virtual void write_display_data() = 0;
61  void init_reset_();
62 
63  bool is_sh1106_() const;
64  bool is_sh1107_() const;
65  bool is_ssd1305_() const;
66 
67  void draw_absolute_pixel_internal(int x, int y, Color color) override;
68 
69  int get_height_internal() override;
70  int get_width_internal() override;
71  size_t get_buffer_length_();
72  const char *model_str_();
73 
75  GPIOPin *reset_pin_{nullptr};
76  bool external_vcc_{false};
77  bool is_on_{false};
78  float contrast_{1.0};
79  float brightness_{1.0};
80  bool flip_x_{true};
81  bool flip_y_{true};
82  uint8_t offset_x_{0};
83  uint8_t offset_y_{0};
84  bool invert_{false};
85 };
86 
87 } // namespace ssd1306_base
88 } // namespace esphome
void init_flip_x(bool flip_x)
Definition: ssd1306_base.h:44
void set_model(SSD1306Model model)
Definition: ssd1306_base.h:35
void init_offset_y(uint8_t offset_y)
Definition: ssd1306_base.h:47
void set_reset_pin(GPIOPin *reset_pin)
Definition: ssd1306_base.h:36
uint16_t x
Definition: tt21100.cpp:17
void set_external_vcc(bool external_vcc)
Definition: ssd1306_base.h:37
virtual void write_display_data()=0
void set_contrast(float contrast)
uint16_t y
Definition: tt21100.cpp:18
void init_flip_y(bool flip_y)
Definition: ssd1306_base.h:45
void init_brightness(float brightness)
Definition: ssd1306_base.h:42
void init_offset_x(uint8_t offset_x)
Definition: ssd1306_base.h:46
float get_setup_priority() const override
Definition: ssd1306_base.h:53
const float PROCESSOR
For components that use data from sensors like displays.
Definition: component.cpp:20
void draw_absolute_pixel_internal(int x, int y, Color color) override
void init_contrast(float contrast)
Definition: ssd1306_base.h:38
display::DisplayType get_display_type() override
Definition: ssd1306_base.h:56
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
virtual void command(uint8_t value)=0
void init_invert(bool invert)
Definition: ssd1306_base.h:48
void fill(Color color) override
void set_brightness(float brightness)