1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-26 07:02:21 +01:00

Add more efficient SPI implementation (#622)

* Add more efficient SPI implementation

* Lint

* Add 200KHZ

* Updates

* Fix write_byte

* Update from datasheet

* Shift clock

* Fix calculation
This commit is contained in:
Otto Winter
2019-06-07 14:25:57 +02:00
committed by GitHub
parent 88ccd60a08
commit 726b0e73d9
14 changed files with 300 additions and 111 deletions

View File

@@ -42,7 +42,6 @@ void WaveshareEPaper::data(uint8_t value) {
this->write_byte(value);
this->end_data_();
}
bool WaveshareEPaper::is_device_msb_first() { return true; }
bool WaveshareEPaper::wait_until_idle_() {
if (this->busy_pin_ == nullptr) {
return true;
@@ -81,7 +80,6 @@ void HOT WaveshareEPaper::draw_absolute_pixel_internal(int x, int y, int color)
this->buffer_[pos] &= ~(0x80 >> subpos);
}
uint32_t WaveshareEPaper::get_buffer_length_() { return this->get_width_internal() * this->get_height_internal() / 8u; }
bool WaveshareEPaper::is_device_high_speed() { return true; }
void WaveshareEPaper::start_command_() {
this->dc_pin_->digital_write(false);
this->enable();
@@ -495,7 +493,6 @@ void HOT WaveshareEPaper4P2In::display() {
}
int WaveshareEPaper4P2In::get_width_internal() { return 400; }
int WaveshareEPaper4P2In::get_height_internal() { return 300; }
bool WaveshareEPaper4P2In::is_device_high_speed() { return false; }
void WaveshareEPaper4P2In::dump_config() {
LOG_DISPLAY("", "Waveshare E-Paper", this);
ESP_LOGCONFIG(TAG, " Model: 4.2in");

View File

@@ -7,14 +7,16 @@
namespace esphome {
namespace waveshare_epaper {
class WaveshareEPaper : public PollingComponent, public spi::SPIDevice, public display::DisplayBuffer {
class WaveshareEPaper : public PollingComponent,
public display::DisplayBuffer,
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW,
spi::CLOCK_PHASE_LEADING, spi::DATA_RATE_2MHZ> {
public:
void set_dc_pin(GPIOPin *dc_pin) { dc_pin_ = dc_pin; }
float get_setup_priority() const override;
void set_reset_pin(GPIOPin *reset) { this->reset_pin_ = reset; }
void set_busy_pin(GPIOPin *busy) { this->busy_pin_ = busy; }
bool is_device_msb_first() override;
void command(uint8_t value);
void data(uint8_t value);
@@ -51,8 +53,6 @@ class WaveshareEPaper : public PollingComponent, public spi::SPIDevice, public d
uint32_t get_buffer_length_();
bool is_device_high_speed() override;
void start_command_();
void end_command_();
void start_data_();
@@ -166,8 +166,6 @@ class WaveshareEPaper4P2In : public WaveshareEPaper {
int get_width_internal() override;
int get_height_internal() override;
bool is_device_high_speed() override;
};
class WaveshareEPaper7P5In : public WaveshareEPaper {