mirror of
https://github.com/esphome/esphome.git
synced 2025-01-09 06:11:44 +01:00
Add support for TTGO ePaper module (#730)
* Add support for TTGO ePaper module Use 2.13in-ttgo as type. Only different LUTs were needed, everything else is the same. relates to issue #233. * fix styling errors * styling fixes Co-authored-by: null <mandy.klingbeil@student.hpi.uni-potsdam.de>
This commit is contained in:
parent
aae633277f
commit
3bb6430495
3 changed files with 55 additions and 10 deletions
|
@ -21,6 +21,7 @@ WaveshareEPaperTypeBModel = waveshare_epaper_ns.enum('WaveshareEPaperTypeBModel'
|
||||||
MODELS = {
|
MODELS = {
|
||||||
'1.54in': ('a', WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_1_54_IN),
|
'1.54in': ('a', WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_1_54_IN),
|
||||||
'2.13in': ('a', WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_13_IN),
|
'2.13in': ('a', WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_13_IN),
|
||||||
|
'2.13in-ttgo': ('a', WaveshareEPaperTypeAModel.TTGO_EPAPER_2_13_IN),
|
||||||
'2.90in': ('a', WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_9_IN),
|
'2.90in': ('a', WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_9_IN),
|
||||||
'2.70in': ('b', WaveshareEPaper2P7In),
|
'2.70in': ('b', WaveshareEPaper2P7In),
|
||||||
'4.20in': ('b', WaveshareEPaper4P2In),
|
'4.20in': ('b', WaveshareEPaper4P2In),
|
||||||
|
|
|
@ -8,13 +8,45 @@ namespace waveshare_epaper {
|
||||||
|
|
||||||
static const char *TAG = "waveshare_epaper";
|
static const char *TAG = "waveshare_epaper";
|
||||||
|
|
||||||
static const uint8_t FULL_UPDATE_LUT[30] = {0x02, 0x02, 0x01, 0x11, 0x12, 0x12, 0x22, 0x22, 0x66, 0x69,
|
static const uint8_t LUT_SIZE_WAVESHARE = 30;
|
||||||
|
static const uint8_t FULL_UPDATE_LUT[LUT_SIZE_WAVESHARE] = {0x02, 0x02, 0x01, 0x11, 0x12, 0x12, 0x22, 0x22, 0x66, 0x69,
|
||||||
0x69, 0x59, 0x58, 0x99, 0x99, 0x88, 0x00, 0x00, 0x00, 0x00,
|
0x69, 0x59, 0x58, 0x99, 0x99, 0x88, 0x00, 0x00, 0x00, 0x00,
|
||||||
0xF8, 0xB4, 0x13, 0x51, 0x35, 0x51, 0x51, 0x19, 0x01, 0x00};
|
0xF8, 0xB4, 0x13, 0x51, 0x35, 0x51, 0x51, 0x19, 0x01, 0x00};
|
||||||
|
|
||||||
static const uint8_t PARTIAL_UPDATE_LUT[30] = {0x10, 0x18, 0x18, 0x08, 0x18, 0x18, 0x08, 0x00, 0x00, 0x00,
|
static const uint8_t PARTIAL_UPDATE_LUT[LUT_SIZE_WAVESHARE] = {
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x10, 0x18, 0x18, 0x08, 0x18, 0x18, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x13, 0x14, 0x44, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x14, 0x44, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||||
|
|
||||||
|
static const uint8_t LUT_SIZE_TTGO = 70;
|
||||||
|
static const uint8_t FULL_UPDATE_LUT_TTGO[LUT_SIZE_TTGO] = {
|
||||||
|
0x80, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, // LUT0: BB: VS 0 ~7
|
||||||
|
0x10, 0x60, 0x20, 0x00, 0x00, 0x00, 0x00, // LUT1: BW: VS 0 ~7
|
||||||
|
0x80, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, // LUT2: WB: VS 0 ~7
|
||||||
|
0x10, 0x60, 0x20, 0x00, 0x00, 0x00, 0x00, // LUT3: WW: VS 0 ~7
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT4: VCOM: VS 0 ~7
|
||||||
|
0x03, 0x03, 0x00, 0x00, 0x02, // TP0 A~D RP0
|
||||||
|
0x09, 0x09, 0x00, 0x00, 0x02, // TP1 A~D RP1
|
||||||
|
0x03, 0x03, 0x00, 0x00, 0x02, // TP2 A~D RP2
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, // TP3 A~D RP3
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, // TP4 A~D RP4
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, // TP5 A~D RP5
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, // TP6 A~D RP6
|
||||||
|
};
|
||||||
|
|
||||||
|
static const uint8_t PARTIAL_UPDATE_LUT_TTGO[LUT_SIZE_TTGO] = {
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT0: BB: VS 0 ~7
|
||||||
|
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT1: BW: VS 0 ~7
|
||||||
|
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT2: WB: VS 0 ~7
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT3: WW: VS 0 ~7
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT4: VCOM: VS 0 ~7
|
||||||
|
0x0A, 0x00, 0x00, 0x00, 0x00, // TP0 A~D RP0
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, // TP1 A~D RP1
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, // TP2 A~D RP2
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, // TP3 A~D RP3
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, // TP4 A~D RP4
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, // TP5 A~D RP5
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, // TP6 A~D RP6
|
||||||
|
};
|
||||||
|
|
||||||
void WaveshareEPaper::setup_pins_() {
|
void WaveshareEPaper::setup_pins_() {
|
||||||
this->init_internal_(this->get_buffer_length_());
|
this->init_internal_(this->get_buffer_length_());
|
||||||
|
@ -134,6 +166,9 @@ void WaveshareEPaperTypeA::dump_config() {
|
||||||
case WAVESHARE_EPAPER_2_13_IN:
|
case WAVESHARE_EPAPER_2_13_IN:
|
||||||
ESP_LOGCONFIG(TAG, " Model: 2.13in");
|
ESP_LOGCONFIG(TAG, " Model: 2.13in");
|
||||||
break;
|
break;
|
||||||
|
case TTGO_EPAPER_2_13_IN:
|
||||||
|
ESP_LOGCONFIG(TAG, " Model: 2.13in (TTGO)");
|
||||||
|
break;
|
||||||
case WAVESHARE_EPAPER_2_9_IN:
|
case WAVESHARE_EPAPER_2_9_IN:
|
||||||
ESP_LOGCONFIG(TAG, " Model: 2.9in");
|
ESP_LOGCONFIG(TAG, " Model: 2.9in");
|
||||||
break;
|
break;
|
||||||
|
@ -154,7 +189,11 @@ void HOT WaveshareEPaperTypeA::display() {
|
||||||
bool prev_full_update = this->at_update_ == 1;
|
bool prev_full_update = this->at_update_ == 1;
|
||||||
bool full_update = this->at_update_ == 0;
|
bool full_update = this->at_update_ == 0;
|
||||||
if (full_update != prev_full_update) {
|
if (full_update != prev_full_update) {
|
||||||
this->write_lut_(full_update ? FULL_UPDATE_LUT : PARTIAL_UPDATE_LUT);
|
if (this->model_ == TTGO_EPAPER_2_13_IN) {
|
||||||
|
this->write_lut_(full_update ? FULL_UPDATE_LUT_TTGO : PARTIAL_UPDATE_LUT_TTGO, LUT_SIZE_TTGO);
|
||||||
|
} else {
|
||||||
|
this->write_lut_(full_update ? FULL_UPDATE_LUT : PARTIAL_UPDATE_LUT, LUT_SIZE_WAVESHARE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this->at_update_ = (this->at_update_ + 1) % this->full_update_every_;
|
this->at_update_ = (this->at_update_ + 1) % this->full_update_every_;
|
||||||
}
|
}
|
||||||
|
@ -206,6 +245,8 @@ int WaveshareEPaperTypeA::get_width_internal() {
|
||||||
return 200;
|
return 200;
|
||||||
case WAVESHARE_EPAPER_2_13_IN:
|
case WAVESHARE_EPAPER_2_13_IN:
|
||||||
return 128;
|
return 128;
|
||||||
|
case TTGO_EPAPER_2_13_IN:
|
||||||
|
return 128;
|
||||||
case WAVESHARE_EPAPER_2_9_IN:
|
case WAVESHARE_EPAPER_2_9_IN:
|
||||||
return 128;
|
return 128;
|
||||||
}
|
}
|
||||||
|
@ -217,15 +258,17 @@ int WaveshareEPaperTypeA::get_height_internal() {
|
||||||
return 200;
|
return 200;
|
||||||
case WAVESHARE_EPAPER_2_13_IN:
|
case WAVESHARE_EPAPER_2_13_IN:
|
||||||
return 250;
|
return 250;
|
||||||
|
case TTGO_EPAPER_2_13_IN:
|
||||||
|
return 250;
|
||||||
case WAVESHARE_EPAPER_2_9_IN:
|
case WAVESHARE_EPAPER_2_9_IN:
|
||||||
return 296;
|
return 296;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
void WaveshareEPaperTypeA::write_lut_(const uint8_t *lut) {
|
void WaveshareEPaperTypeA::write_lut_(const uint8_t *lut, const uint8_t size) {
|
||||||
// COMMAND WRITE LUT REGISTER
|
// COMMAND WRITE LUT REGISTER
|
||||||
this->command(0x32);
|
this->command(0x32);
|
||||||
for (uint8_t i = 0; i < 30; i++)
|
for (uint8_t i = 0; i < size; i++)
|
||||||
this->data(lut[i]);
|
this->data(lut[i]);
|
||||||
}
|
}
|
||||||
WaveshareEPaperTypeA::WaveshareEPaperTypeA(WaveshareEPaperTypeAModel model) : model_(model) {}
|
WaveshareEPaperTypeA::WaveshareEPaperTypeA(WaveshareEPaperTypeAModel model) : model_(model) {}
|
||||||
|
|
|
@ -67,6 +67,7 @@ enum WaveshareEPaperTypeAModel {
|
||||||
WAVESHARE_EPAPER_1_54_IN = 0,
|
WAVESHARE_EPAPER_1_54_IN = 0,
|
||||||
WAVESHARE_EPAPER_2_13_IN,
|
WAVESHARE_EPAPER_2_13_IN,
|
||||||
WAVESHARE_EPAPER_2_9_IN,
|
WAVESHARE_EPAPER_2_9_IN,
|
||||||
|
TTGO_EPAPER_2_13_IN,
|
||||||
};
|
};
|
||||||
|
|
||||||
class WaveshareEPaperTypeA : public WaveshareEPaper {
|
class WaveshareEPaperTypeA : public WaveshareEPaper {
|
||||||
|
@ -88,7 +89,7 @@ class WaveshareEPaperTypeA : public WaveshareEPaper {
|
||||||
void set_full_update_every(uint32_t full_update_every);
|
void set_full_update_every(uint32_t full_update_every);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void write_lut_(const uint8_t *lut);
|
void write_lut_(const uint8_t *lut, uint8_t size);
|
||||||
|
|
||||||
int get_width_internal() override;
|
int get_width_internal() override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue