Skip to content

Commit

Permalink
Extending Support to 5.83in Waveshare eink B/W displays (esphome#1009)
Browse files Browse the repository at this point in the history
* Extending Support to 5.83in Waveshare eink B/W displays

* Fixed lint issues
  • Loading branch information
sredfern authored May 2, 2020
1 parent 4f2e2fa commit 7fa5cab
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 0 deletions.
2 changes: 2 additions & 0 deletions esphome/components/waveshare_epaper/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
WaveshareEPaper2P7In = waveshare_epaper_ns.class_('WaveshareEPaper2P7In', WaveshareEPaper)
WaveshareEPaper2P9InB = waveshare_epaper_ns.class_('WaveshareEPaper2P9InB', WaveshareEPaper)
WaveshareEPaper4P2In = waveshare_epaper_ns.class_('WaveshareEPaper4P2In', WaveshareEPaper)
WaveshareEPaper5P8In = waveshare_epaper_ns.class_('WaveshareEPaper5P8In', WaveshareEPaper)
WaveshareEPaper7P5In = waveshare_epaper_ns.class_('WaveshareEPaper7P5In', WaveshareEPaper)

WaveshareEPaperTypeAModel = waveshare_epaper_ns.enum('WaveshareEPaperTypeAModel')
Expand All @@ -28,6 +29,7 @@
'2.70in': ('b', WaveshareEPaper2P7In),
'2.90in-b': ('b', WaveshareEPaper2P9InB),
'4.20in': ('b', WaveshareEPaper4P2In),
'5.83in': ('b', WaveshareEPaper5P8In),
'7.50in': ('b', WaveshareEPaper7P5In),
}

Expand Down
95 changes: 95 additions & 0 deletions esphome/components/waveshare_epaper/waveshare_epaper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,101 @@ void WaveshareEPaper4P2In::dump_config() {
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() {
// COMMAND POWER SETTING
this->command(0x01);
Expand Down
23 changes: 23 additions & 0 deletions esphome/components/waveshare_epaper/waveshare_epaper.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,29 @@ class WaveshareEPaper4P2In : public WaveshareEPaper {
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 {
public:
void initialize() override;
Expand Down

0 comments on commit 7fa5cab

Please sign in to comment.