Support for the DKE screen version of LilyGo-TTGO-T5 V2.3 (#1969)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Branimir Lambov 2021-08-11 06:14:17 +01:00 committed by GitHub
parent 46f17bea66
commit 8c41fc2b1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 165 additions and 2 deletions

View File

@ -43,6 +43,9 @@ WaveshareEPaper7P5In = waveshare_epaper_ns.class_(
WaveshareEPaper7P5InV2 = waveshare_epaper_ns.class_( WaveshareEPaper7P5InV2 = waveshare_epaper_ns.class_(
"WaveshareEPaper7P5InV2", WaveshareEPaper "WaveshareEPaper7P5InV2", WaveshareEPaper
) )
WaveshareEPaper2P13InDKE = waveshare_epaper_ns.class_(
"WaveshareEPaper2P13InDKE", WaveshareEPaper
)
WaveshareEPaperTypeAModel = waveshare_epaper_ns.enum("WaveshareEPaperTypeAModel") WaveshareEPaperTypeAModel = waveshare_epaper_ns.enum("WaveshareEPaperTypeAModel")
WaveshareEPaperTypeBModel = waveshare_epaper_ns.enum("WaveshareEPaperTypeBModel") WaveshareEPaperTypeBModel = waveshare_epaper_ns.enum("WaveshareEPaperTypeBModel")
@ -64,13 +67,14 @@ MODELS = {
"5.83in": ("b", WaveshareEPaper5P8In), "5.83in": ("b", WaveshareEPaper5P8In),
"7.50in": ("b", WaveshareEPaper7P5In), "7.50in": ("b", WaveshareEPaper7P5In),
"7.50inv2": ("b", WaveshareEPaper7P5InV2), "7.50inv2": ("b", WaveshareEPaper7P5InV2),
"2.13in-ttgo-dke": ("c", WaveshareEPaper2P13InDKE),
} }
def validate_full_update_every_only_type_a(value): def validate_full_update_every_only_type_a(value):
if CONF_FULL_UPDATE_EVERY not in value: if CONF_FULL_UPDATE_EVERY not in value:
return value return value
if MODELS[value[CONF_MODEL]][0] != "a": if MODELS[value[CONF_MODEL]][0] == "b":
raise cv.Invalid( raise cv.Invalid(
"The 'full_update_every' option is only available for models " "The 'full_update_every' option is only available for models "
"'1.54in', '1.54inV2', '2.13in', '2.90in', and '2.90inV2'." "'1.54in', '1.54inV2', '2.13in', '2.90in', and '2.90inV2'."
@ -101,7 +105,7 @@ async def to_code(config):
if model_type == "a": if model_type == "a":
rhs = WaveshareEPaperTypeA.new(model) rhs = WaveshareEPaperTypeA.new(model)
var = cg.Pvariable(config[CONF_ID], rhs, WaveshareEPaperTypeA) var = cg.Pvariable(config[CONF_ID], rhs, WaveshareEPaperTypeA)
elif model_type == "b": elif model_type in ("b", "c"):
rhs = model.new() rhs = model.new()
var = cg.Pvariable(config[CONF_ID], rhs, model) var = cg.Pvariable(config[CONF_ID], rhs, model)
else: else:

View File

@ -1080,5 +1080,136 @@ void WaveshareEPaper7P5InV2::dump_config() {
LOG_PIN(" Busy Pin: ", this->busy_pin_); LOG_PIN(" Busy Pin: ", this->busy_pin_);
LOG_UPDATE_INTERVAL(this); LOG_UPDATE_INTERVAL(this);
} }
static const uint8_t LUT_SIZE_TTGO_DKE_PART = 153;
static const uint8_t PART_UPDATE_LUT_TTGO_DKE[LUT_SIZE_TTGO_DKE_PART] = {
0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x40, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x0, 0x0, 0x0,
// 0x22, 0x17, 0x41, 0x0, 0x32, 0x32
};
void WaveshareEPaper2P13InDKE::initialize() {}
void HOT WaveshareEPaper2P13InDKE::display() {
bool partial = this->at_update_ != 0;
this->at_update_ = (this->at_update_ + 1) % this->full_update_every_;
if (partial)
ESP_LOGI(TAG, "Performing partial e-paper update.");
else
ESP_LOGI(TAG, "Performing full e-paper update.");
// start and set up data format
this->command(0x12);
this->wait_until_idle_();
this->command(0x11);
this->data(0x03);
this->command(0x44);
this->data(1);
this->data(this->get_width_internal() / 8);
this->command(0x45);
this->data(0);
this->data(0);
this->data(this->get_height_internal());
this->data(0);
this->command(0x4e);
this->data(1);
this->command(0x4f);
this->data(0);
this->data(0);
if (!partial) {
// send data
this->command(0x24);
this->start_data_();
this->write_array(this->buffer_, this->get_buffer_length_());
this->end_data_();
// commit
this->command(0x20);
this->wait_until_idle_();
} else {
// set up partial update
this->command(0x32);
for (uint8_t v : PART_UPDATE_LUT_TTGO_DKE)
this->data(v);
this->command(0x3F);
this->data(0x22);
this->command(0x03);
this->data(0x17);
this->command(0x04);
this->data(0x41);
this->data(0x00);
this->data(0x32);
this->command(0x2C);
this->data(0x32);
this->command(0x37);
this->data(0x00);
this->data(0x00);
this->data(0x00);
this->data(0x00);
this->data(0x00);
this->data(0x40);
this->data(0x00);
this->data(0x00);
this->data(0x00);
this->data(0x00);
this->command(0x3C);
this->data(0x80);
this->command(0x22);
this->data(0xC0);
this->command(0x20);
this->wait_until_idle_();
// send data
this->command(0x24);
this->start_data_();
this->write_array(this->buffer_, this->get_buffer_length_());
this->end_data_();
// commit as partial
this->command(0x22);
this->data(0xCF);
this->command(0x20);
this->wait_until_idle_();
// data must be sent again on partial update
delay(300); // NOLINT
this->command(0x24);
this->start_data_();
this->write_array(this->buffer_, this->get_buffer_length_());
this->end_data_();
delay(300); // NOLINT
}
ESP_LOGI(TAG, "Completed e-paper update.");
}
int WaveshareEPaper2P13InDKE::get_width_internal() { return 128; }
int WaveshareEPaper2P13InDKE::get_height_internal() { return 250; }
int WaveshareEPaper2P13InDKE::idle_timeout_() { return 5000; }
void WaveshareEPaper2P13InDKE::dump_config() {
LOG_DISPLAY("", "Waveshare E-Paper", this);
ESP_LOGCONFIG(TAG, " Model: 2.13inDKE");
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 WaveshareEPaper2P13InDKE::set_full_update_every(uint32_t full_update_every) {
this->full_update_every_ = full_update_every;
}
} // namespace waveshare_epaper } // namespace waveshare_epaper
} // namespace esphome } // namespace esphome

View File

@ -301,5 +301,33 @@ class WaveshareEPaper7P5InV2 : public WaveshareEPaper {
int get_height_internal() override; int get_height_internal() override;
}; };
class WaveshareEPaper2P13InDKE : public WaveshareEPaper {
public:
void initialize() override;
void display() override;
void dump_config() override;
void deep_sleep() override {
// COMMAND POWER DOWN
this->command(0x10);
this->data(0x01);
// cannot wait until idle here, the device no longer responds
}
void set_full_update_every(uint32_t full_update_every);
protected:
int get_width_internal() override;
int get_height_internal() override;
int idle_timeout_() override;
uint32_t full_update_every_{30};
uint32_t at_update_{0};
};
} // namespace waveshare_epaper } // namespace waveshare_epaper
} // namespace esphome } // namespace esphome