ESPHome  2023.3.1
pcd_8544.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace pcd8544 {
9 
10 class PCD8544 : public PollingComponent,
12  public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_HIGH, spi::CLOCK_PHASE_TRAILING,
13  spi::DATA_RATE_8MHZ> {
14  public:
15  const uint8_t PCD8544_POWERDOWN = 0x04;
16  const uint8_t PCD8544_ENTRYMODE = 0x02;
17  const uint8_t PCD8544_EXTENDEDINSTRUCTION = 0x01;
18 
19  const uint8_t PCD8544_DISPLAYBLANK = 0x0;
20  const uint8_t PCD8544_DISPLAYNORMAL = 0x4;
21  const uint8_t PCD8544_DISPLAYALLON = 0x1;
22  const uint8_t PCD8544_DISPLAYINVERTED = 0x5;
23 
24  const uint8_t PCD8544_FUNCTIONSET = 0x20;
25  const uint8_t PCD8544_DISPLAYCONTROL = 0x08;
26  const uint8_t PCD8544_SETYADDR = 0x40;
27  const uint8_t PCD8544_SETXADDR = 0x80;
28 
29  const uint8_t PCD8544_SETTEMP = 0x04;
30  const uint8_t PCD8544_SETBIAS = 0x10;
31  const uint8_t PCD8544_SETVOP = 0x80;
32  uint8_t contrast_;
33 
34  void set_dc_pin(GPIOPin *dc_pin) { this->dc_pin_ = dc_pin; }
35  void set_reset_pin(GPIOPin *reset) { this->reset_pin_ = reset; }
36  void set_contrast(uint8_t contrast) { this->contrast_ = contrast; }
37  float get_setup_priority() const override { return setup_priority::PROCESSOR; }
38 
39  void command(uint8_t value);
40  void data(uint8_t value);
41 
42  void initialize();
43  void dump_config() override;
44  void HOT display();
45 
46  void update() override;
47 
48  void fill(Color color) override;
49 
50  void setup() override {
51  this->setup_pins_();
52  this->initialize();
53  }
54 
56 
57  protected:
58  void draw_absolute_pixel_internal(int x, int y, Color color) override;
59 
60  void setup_pins_();
61 
62  void init_reset_();
63 
64  size_t get_buffer_length_();
65 
66  void start_command_();
67  void end_command_();
68  void start_data_();
69  void end_data_();
70 
71  int get_width_internal() override;
72  int get_height_internal() override;
73 
76 };
77 
78 } // namespace pcd8544
79 } // namespace esphome
const uint8_t PCD8544_DISPLAYNORMAL
Definition: pcd_8544.h:20
void data(uint8_t value)
display::DisplayType get_display_type() override
Definition: pcd_8544.h:55
void set_dc_pin(GPIOPin *dc_pin)
Definition: pcd_8544.h:34
const uint8_t PCD8544_EXTENDEDINSTRUCTION
Definition: pcd_8544.h:17
void draw_absolute_pixel_internal(int x, int y, Color color) override
Definition: pcd_8544.cpp:87
float get_setup_priority() const override
Definition: pcd_8544.h:37
This class simplifies creating components that periodically check a state.
Definition: component.h:282
const uint8_t PCD8544_ENTRYMODE
Definition: pcd_8544.h:16
void set_contrast(uint8_t contrast)
Definition: pcd_8544.h:36
const uint8_t PCD8544_POWERDOWN
Definition: pcd_8544.h:15
void fill(Color color) override
Definition: pcd_8544.cpp:119
const uint8_t PCD8544_FUNCTIONSET
Definition: pcd_8544.h:24
void dump_config() override
Definition: pcd_8544.cpp:101
const uint8_t PCD8544_DISPLAYBLANK
Definition: pcd_8544.h:19
int get_width_internal() override
Definition: pcd_8544.cpp:58
const float PROCESSOR
For components that use data from sensors like displays.
Definition: component.cpp:19
void command(uint8_t value)
Definition: pcd_8544.cpp:108
const uint8_t PCD8544_SETXADDR
Definition: pcd_8544.h:27
const uint8_t PCD8544_DISPLAYINVERTED
Definition: pcd_8544.h:22
void update() override
Definition: pcd_8544.cpp:114
const uint8_t PCD8544_SETYADDR
Definition: pcd_8544.h:26
Definition: a4988.cpp:4
const uint8_t PCD8544_SETBIAS
Definition: pcd_8544.h:30
int get_height_internal() override
Definition: pcd_8544.cpp:59
void setup() override
Definition: pcd_8544.h:50
void set_reset_pin(GPIOPin *reset)
Definition: pcd_8544.h:35
const uint8_t PCD8544_DISPLAYCONTROL
Definition: pcd_8544.h:25
const uint8_t PCD8544_SETVOP
Definition: pcd_8544.h:31
const uint8_t PCD8544_SETTEMP
Definition: pcd_8544.h:29
const uint8_t PCD8544_DISPLAYALLON
Definition: pcd_8544.h:21