ESPHome  2024.2.1
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  void set_contrast(float contrast);
40  void init_brightness(float brightness) { this->brightness_ = brightness; }
41  void set_brightness(float brightness);
42  void init_flip_x(bool flip_x) { this->flip_x_ = flip_x; }
43  void init_flip_y(bool flip_y) { this->flip_y_ = flip_y; }
44  void init_offset_x(uint8_t offset_x) { this->offset_x_ = offset_x; }
45  void init_offset_y(uint8_t offset_y) { this->offset_y_ = offset_y; }
46  void init_invert(bool invert) { this->invert_ = invert; }
47  void set_invert(bool invert);
48  bool is_on();
49  void turn_on();
50  void turn_off();
51  float get_setup_priority() const override { return setup_priority::PROCESSOR; }
52  void fill(Color color) override;
53 
55 
56  protected:
57  virtual void command(uint8_t value) = 0;
58  virtual void write_display_data() = 0;
59  void init_reset_();
60 
61  bool is_sh1106_() const;
62  bool is_sh1107_() const;
63  bool is_ssd1305_() const;
64 
65  void draw_absolute_pixel_internal(int x, int y, Color color) override;
66 
67  int get_height_internal() override;
68  int get_width_internal() override;
69  size_t get_buffer_length_();
70  const char *model_str_();
71 
73  GPIOPin *reset_pin_{nullptr};
74  bool external_vcc_{false};
75  bool is_on_{false};
76  float contrast_{1.0};
77  float brightness_{1.0};
78  bool flip_x_{true};
79  bool flip_y_{true};
80  uint8_t offset_x_{0};
81  uint8_t offset_y_{0};
82  bool invert_{false};
83 };
84 
85 } // namespace ssd1306_base
86 } // namespace esphome
void init_flip_x(bool flip_x)
Definition: ssd1306_base.h:42
void set_model(SSD1306Model model)
Definition: ssd1306_base.h:35
void init_offset_y(uint8_t offset_y)
Definition: ssd1306_base.h:45
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:43
void init_brightness(float brightness)
Definition: ssd1306_base.h:40
void init_offset_x(uint8_t offset_x)
Definition: ssd1306_base.h:44
float get_setup_priority() const override
Definition: ssd1306_base.h:51
const float PROCESSOR
For components that use data from sensors like displays.
Definition: component.cpp:19
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:54
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
virtual void command(uint8_t value)=0
void init_invert(bool invert)
Definition: ssd1306_base.h:46
void fill(Color color) override
void set_brightness(float brightness)