mirror of
				https://github.com/esphome/esphome.git
				synced 2025-11-04 09:01:49 +00:00 
			
		
		
		
	Extending Support to 5.83in Waveshare eink B/W displays (#1009)
* Extending Support to 5.83in Waveshare eink B/W displays * Fixed lint issues
This commit is contained in:
		@@ -14,6 +14,7 @@ WaveshareEPaperTypeA = waveshare_epaper_ns.class_('WaveshareEPaperTypeA', Wavesh
 | 
				
			|||||||
WaveshareEPaper2P7In = waveshare_epaper_ns.class_('WaveshareEPaper2P7In', WaveshareEPaper)
 | 
					WaveshareEPaper2P7In = waveshare_epaper_ns.class_('WaveshareEPaper2P7In', WaveshareEPaper)
 | 
				
			||||||
WaveshareEPaper2P9InB = waveshare_epaper_ns.class_('WaveshareEPaper2P9InB', WaveshareEPaper)
 | 
					WaveshareEPaper2P9InB = waveshare_epaper_ns.class_('WaveshareEPaper2P9InB', WaveshareEPaper)
 | 
				
			||||||
WaveshareEPaper4P2In = waveshare_epaper_ns.class_('WaveshareEPaper4P2In', WaveshareEPaper)
 | 
					WaveshareEPaper4P2In = waveshare_epaper_ns.class_('WaveshareEPaper4P2In', WaveshareEPaper)
 | 
				
			||||||
 | 
					WaveshareEPaper5P8In = waveshare_epaper_ns.class_('WaveshareEPaper5P8In', WaveshareEPaper)
 | 
				
			||||||
WaveshareEPaper7P5In = waveshare_epaper_ns.class_('WaveshareEPaper7P5In', WaveshareEPaper)
 | 
					WaveshareEPaper7P5In = waveshare_epaper_ns.class_('WaveshareEPaper7P5In', WaveshareEPaper)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WaveshareEPaperTypeAModel = waveshare_epaper_ns.enum('WaveshareEPaperTypeAModel')
 | 
					WaveshareEPaperTypeAModel = waveshare_epaper_ns.enum('WaveshareEPaperTypeAModel')
 | 
				
			||||||
@@ -28,6 +29,7 @@ MODELS = {
 | 
				
			|||||||
    '2.70in': ('b', WaveshareEPaper2P7In),
 | 
					    '2.70in': ('b', WaveshareEPaper2P7In),
 | 
				
			||||||
    '2.90in-b': ('b', WaveshareEPaper2P9InB),
 | 
					    '2.90in-b': ('b', WaveshareEPaper2P9InB),
 | 
				
			||||||
    '4.20in': ('b', WaveshareEPaper4P2In),
 | 
					    '4.20in': ('b', WaveshareEPaper4P2In),
 | 
				
			||||||
 | 
					    '5.83in': ('b', WaveshareEPaper5P8In),
 | 
				
			||||||
    '7.50in': ('b', WaveshareEPaper7P5In),
 | 
					    '7.50in': ('b', WaveshareEPaper7P5In),
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -657,6 +657,101 @@ void WaveshareEPaper4P2In::dump_config() {
 | 
				
			|||||||
  LOG_UPDATE_INTERVAL(this);
 | 
					  LOG_UPDATE_INTERVAL(this);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void WaveshareEPaper5P8In::initialize() {
 | 
				
			||||||
 | 
					  // COMMAND POWER SETTING
 | 
				
			||||||
 | 
					  this->command(0x01);
 | 
				
			||||||
 | 
					  this->data(0x37);
 | 
				
			||||||
 | 
					  this->data(0x00);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // COMMAND PANEL SETTING
 | 
				
			||||||
 | 
					  this->command(0x00);
 | 
				
			||||||
 | 
					  this->data(0xCF);
 | 
				
			||||||
 | 
					  this->data(0x0B);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // COMMAND BOOSTER SOFT START
 | 
				
			||||||
 | 
					  this->command(0x06);
 | 
				
			||||||
 | 
					  this->data(0xC7);
 | 
				
			||||||
 | 
					  this->data(0xCC);
 | 
				
			||||||
 | 
					  this->data(0x28);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // COMMAND POWER ON
 | 
				
			||||||
 | 
					  this->command(0x04);
 | 
				
			||||||
 | 
					  this->wait_until_idle_();
 | 
				
			||||||
 | 
					  delay(10);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // COMMAND PLL CONTROL
 | 
				
			||||||
 | 
					  this->command(0x30);
 | 
				
			||||||
 | 
					  this->data(0x3C);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // COMMAND TEMPERATURE SENSOR CALIBRATION
 | 
				
			||||||
 | 
					  this->command(0x41);
 | 
				
			||||||
 | 
					  this->data(0x00);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // COMMAND VCOM AND DATA INTERVAL SETTING
 | 
				
			||||||
 | 
					  this->command(0x50);
 | 
				
			||||||
 | 
					  this->data(0x77);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // COMMAND TCON SETTING
 | 
				
			||||||
 | 
					  this->command(0x60);
 | 
				
			||||||
 | 
					  this->data(0x22);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // COMMAND RESOLUTION SETTING
 | 
				
			||||||
 | 
					  this->command(0x61);
 | 
				
			||||||
 | 
					  this->data(0x02);
 | 
				
			||||||
 | 
					  this->data(0x58);
 | 
				
			||||||
 | 
					  this->data(0x01);
 | 
				
			||||||
 | 
					  this->data(0xC0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // COMMAND VCM DC SETTING REGISTER
 | 
				
			||||||
 | 
					  this->command(0x82);
 | 
				
			||||||
 | 
					  this->data(0x1E);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  this->command(0xE5);
 | 
				
			||||||
 | 
					  this->data(0x03);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					void HOT WaveshareEPaper5P8In::display() {
 | 
				
			||||||
 | 
					  // COMMAND DATA START TRANSMISSION 1
 | 
				
			||||||
 | 
					  this->command(0x10);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  this->start_data_();
 | 
				
			||||||
 | 
					  for (size_t i = 0; i < this->get_buffer_length_(); i++) {
 | 
				
			||||||
 | 
					    uint8_t temp1 = this->buffer_[i];
 | 
				
			||||||
 | 
					    for (uint8_t j = 0; j < 8; j++) {
 | 
				
			||||||
 | 
					      uint8_t temp2;
 | 
				
			||||||
 | 
					      if (temp1 & 0x80)
 | 
				
			||||||
 | 
					        temp2 = 0x03;
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					        temp2 = 0x00;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      temp2 <<= 4;
 | 
				
			||||||
 | 
					      temp1 <<= 1;
 | 
				
			||||||
 | 
					      j++;
 | 
				
			||||||
 | 
					      if (temp1 & 0x80)
 | 
				
			||||||
 | 
					        temp2 |= 0x03;
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					        temp2 |= 0x00;
 | 
				
			||||||
 | 
					      temp1 <<= 1;
 | 
				
			||||||
 | 
					      this->write_byte(temp2);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    App.feed_wdt();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  this->end_data_();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // COMMAND DISPLAY REFRESH
 | 
				
			||||||
 | 
					  this->command(0x12);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					int WaveshareEPaper5P8In::get_width_internal() { return 600; }
 | 
				
			||||||
 | 
					int WaveshareEPaper5P8In::get_height_internal() { return 448; }
 | 
				
			||||||
 | 
					void WaveshareEPaper5P8In::dump_config() {
 | 
				
			||||||
 | 
					  LOG_DISPLAY("", "Waveshare E-Paper", this);
 | 
				
			||||||
 | 
					  ESP_LOGCONFIG(TAG, "  Model: 5.83in");
 | 
				
			||||||
 | 
					  LOG_PIN("  Reset Pin: ", this->reset_pin_);
 | 
				
			||||||
 | 
					  LOG_PIN("  DC Pin: ", this->dc_pin_);
 | 
				
			||||||
 | 
					  LOG_PIN("  Busy Pin: ", this->busy_pin_);
 | 
				
			||||||
 | 
					  LOG_UPDATE_INTERVAL(this);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void WaveshareEPaper7P5In::initialize() {
 | 
					void WaveshareEPaper7P5In::initialize() {
 | 
				
			||||||
  // COMMAND POWER SETTING
 | 
					  // COMMAND POWER SETTING
 | 
				
			||||||
  this->command(0x01);
 | 
					  this->command(0x01);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -190,6 +190,29 @@ class WaveshareEPaper4P2In : public WaveshareEPaper {
 | 
				
			|||||||
  int get_height_internal() override;
 | 
					  int get_height_internal() override;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class WaveshareEPaper5P8In : public WaveshareEPaper {
 | 
				
			||||||
 | 
					 public:
 | 
				
			||||||
 | 
					  void initialize() override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void display() override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void dump_config() override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void deep_sleep() override {
 | 
				
			||||||
 | 
					    // COMMAND POWER OFF
 | 
				
			||||||
 | 
					    this->command(0x02);
 | 
				
			||||||
 | 
					    this->wait_until_idle_();
 | 
				
			||||||
 | 
					    // COMMAND DEEP SLEEP
 | 
				
			||||||
 | 
					    this->command(0x07);
 | 
				
			||||||
 | 
					    this->data(0xA5);  // check byte
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 protected:
 | 
				
			||||||
 | 
					  int get_width_internal() override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int get_height_internal() override;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class WaveshareEPaper7P5In : public WaveshareEPaper {
 | 
					class WaveshareEPaper7P5In : public WaveshareEPaper {
 | 
				
			||||||
 public:
 | 
					 public:
 | 
				
			||||||
  void initialize() override;
 | 
					  void initialize() override;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user