ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
st7567_base.h
Go to the documentation of this file.
1#pragma once
2
4#include "esphome/core/hal.h"
6
7namespace esphome::st7567_base {
8
9static const uint8_t ST7567_BOOSTER_ON = 0x2C; // internal power supply on
10static const uint8_t ST7567_REGULATOR_ON = 0x2E; // internal power supply on
11static const uint8_t ST7567_POWER_ON = 0x2F; // internal power supply on
12
13static const uint8_t ST7567_DISPLAY_ON = 0xAF; // Display ON. Normal Display Mode.
14static const uint8_t ST7567_DISPLAY_OFF = 0xAE; // Display OFF. All SEGs/COMs output with VSS
15static const uint8_t ST7567_SET_START_LINE = 0x40;
16static const uint8_t ST7567_POWER_CTL = 0x28;
17static const uint8_t ST7567_SEG_NORMAL = 0xA0; //
18static const uint8_t ST7567_SEG_REVERSE = 0xA1; // mirror X axis (horizontal)
19static const uint8_t ST7567_COM_NORMAL = 0xC0; //
20static const uint8_t ST7567_COM_REMAP = 0xC8; // mirror Y axis (vertical)
21static const uint8_t ST7567_PIXELS_NORMAL = 0xA4; // display ram content
22static const uint8_t ST7567_PIXELS_ALL_ON = 0xA5; // all pixels on
23static const uint8_t ST7567_INVERT_OFF = 0xA6; // normal pixels
24static const uint8_t ST7567_INVERT_ON = 0xA7; // inverted pixels
25static const uint8_t ST7567_SCAN_START_LINE = 0x40; // scrolling = 0x40 + (0..63)
26static const uint8_t ST7567_COL_ADDR_H = 0x10; // x pos (0..95) 4 MSB
27static const uint8_t ST7567_COL_ADDR_L = 0x00; // x pos (0..95) 4 LSB
28static const uint8_t ST7567_PAGE_ADDR = 0xB0; // y pos, 8.5 rows (0..8)
29static const uint8_t ST7567_BIAS_9 = 0xA2;
30static const uint8_t ST7567_CONTRAST = 0x80; // 0x80 + (0..31)
31static const uint8_t ST7567_SET_EV_CMD = 0x81;
32static const uint8_t ST7567_SET_EV_PARAM = 0x00;
33static const uint8_t ST7567_RESISTOR_RATIO = 0x20;
34static const uint8_t ST7567_SW_REFRESH = 0xE2;
35
37 public:
38 void setup() override;
39
40 void update() override;
41
42 void set_reset_pin(GPIOPin *reset_pin) { this->reset_pin_ = reset_pin; }
43 void init_mirror_x(bool mirror_x) { this->mirror_x_ = mirror_x; }
44 void init_mirror_y(bool mirror_y) { this->mirror_y_ = mirror_y; }
45 void init_invert_colors(bool invert_colors) { this->invert_colors_ = invert_colors; }
46
47 void set_invert_colors(bool invert_colors); // inversion of screen colors
48 void set_contrast(uint8_t val); // 0..63, 27-30 normal
49 void set_brightness(uint8_t val); // 0..7, 5 normal
50 void set_all_pixels_on(bool enable); // turn on all pixels, this doesn't affect RAM
51 void set_scroll(uint8_t line); // set display start line: for screen scrolling w/o affecting RAM
52
53 bool is_on();
54 void turn_on();
55 void turn_off();
56
57 void request_refresh(); // from datasheet: It is recommended to use the refresh sequence regularly in a specified
58 // interval.
59
60 float get_setup_priority() const override { return setup_priority::PROCESSOR; }
61 void fill(Color color) override;
62
64
65 protected:
66 virtual void command(uint8_t value) = 0;
67 virtual void write_display_data() = 0;
68
69 void init_reset_();
70 void display_init_();
73
74 void draw_absolute_pixel_internal(int x, int y, Color color) override;
75
76 int get_height_internal() override;
77 int get_width_internal() override;
78 size_t get_buffer_length_();
79
80 int get_offset_x_() { return mirror_x_ ? 4 : 0; };
81
82 const char *model_str_();
83
85 bool is_on_{false};
86 // float contrast_{1.0};
87 // float brightness_{1.0};
88 uint8_t contrast_{27};
89 uint8_t brightness_{5};
90 bool mirror_x_{true};
91 bool mirror_y_{true};
92 bool invert_colors_{false};
93 bool all_pixels_on_{false};
94 uint8_t start_line_{0};
95 bool refresh_requested_{false};
96};
97
98} // namespace esphome::st7567_base
void init_mirror_x(bool mirror_x)
Definition st7567_base.h:43
void draw_absolute_pixel_internal(int x, int y, Color color) override
void init_mirror_y(bool mirror_y)
Definition st7567_base.h:44
void set_reset_pin(GPIOPin *reset_pin)
Definition st7567_base.h:42
void set_invert_colors(bool invert_colors)
float get_setup_priority() const override
Definition st7567_base.h:60
void set_scroll(uint8_t line)
void init_invert_colors(bool invert_colors)
Definition st7567_base.h:45
void set_all_pixels_on(bool enable)
virtual void command(uint8_t value)=0
void fill(Color color) override
void set_brightness(uint8_t val)
void set_contrast(uint8_t val)
virtual void write_display_data()=0
display::DisplayType get_display_type() override
Definition st7567_base.h:63
mopeka_std_values val[3]
constexpr float PROCESSOR
For components that use data from sensors like displays.
Definition component.h:45
const char int line
Definition log.h:74
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6