Skip to content

Commit a3a44a0

Browse files
committed
Added support for LilyGo T5 S3 4.7 Pro
1 parent 2772603 commit a3a44a0

File tree

2 files changed

+103
-11
lines changed

2 files changed

+103
-11
lines changed

src/FastEPD.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ enum {
6868
BB_PANEL_EPDIY_V7_16,
6969
BB_PANEL_V7_RAW,
7070
BB_PANEL_V7_103,
71+
BB_PANEL_LILYGO_T5PRO,
7172
BB_PANEL_CUSTOM,
7273
BB_PANEL_VIRTUAL,
7374
BB_PANEL_COUNT

src/FastEPD.inl

Lines changed: 102 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,16 @@ const BBPANELDEF panelDefs[] = {
194194
// D8 15 D0 D7 STV,CKV,XSTL,OE,XLE
195195
{1872, 1404, 20000000, BB_PANEL_FLAG_MIRROR_X, {8,18,17,16,15,7,6,5,47,21,14,13,12,11,10,9}, 16, 11, 41, 42, 45, 8, 48,
196196
4, 14, 39, 40, BB_NOT_USED, 0, 46, u8GrayMatrix, sizeof(u8GrayMatrix), 0}, // BB_PANEL_V7_103
197+
{960, 540, 20000000, BB_PANEL_FLAG_SLOW_SPH, {11,12,13,14,21,47,45,38}, 8, BB_NOT_USED, BB_NOT_USED, 39, 9, 0, 0,
198+
10, 0, 2, 42, 1, 0, 46 /* LoRa CS */, u8M5Matrix, sizeof(u8M5Matrix), 0}, // BB_PANEL_LILYGO_T5PRO
197199
};
198200
//
199201
// Forward references for panel callback functions
200202
//
203+
// LilyGo T5S3-Pro
204+
int LilyGoEinkPower(void *pBBEP, int bOn);
205+
int LilyGoIOInit(void *pBBEP);
206+
void LilyGoRowControl(void *pBBEP, int iMode);
201207
// M5Stack PaperS3
202208
int PaperS3EinkPower(void *pBBEP, int bOn);
203209
int PaperS3IOInit(void *pBBEP);
@@ -232,6 +238,7 @@ const BBPANELPROCS panelProcs[] = {
232238
{EPDiyV7EinkPower, EPDiyV7IOInit, EPDiyV7RowControl, EPDiyV7IODeInit, EPDiyV7ExtIO}, // BB_PANEL_EPDIY_V7_16
233239
{EPDiyV7RAWEinkPower, EPDiyV7RAWIOInit, EPDiyV7RowControl, NULL, NULL}, // BB_PANEL_V7_RAW
234240
{EPDiyV7EinkPower, EPDiyV7IOInit, EPDiyV7RowControl, EPDiyV7IODeInit, EPDiyV7ExtIO}, // BB_PANEL_V7_103
241+
{LilyGoEinkPower, LilyGoIOInit, LilyGoRowControl, NULL, NULL},// BB_PANEL_LILYGO_T5PRO
235242
};
236243

237244
uint8_t ioRegs[24]; // MCP23017 copy of I/O register state so that we can just write new bits
@@ -539,7 +546,7 @@ uint8_t Inkplate5V2ExtIO(uint8_t iOp, uint8_t iPin, uint8_t iVal)
539546
void bbepSendShiftData(FASTEPDSTATE *pState)
540547
{
541548
uint8_t uc = pState->shift_data;
542-
//Serial.printf("Sending shift data: 0x%02x\n", uc);
549+
// Serial.printf("Sending shift data: 0x%02x\n", uc);
543550
// Clear STR (store) to allow updating the value
544551
gpio_set_level((gpio_num_t)pState->panelDef.ioShiftSTR, 0);
545552
for (int i=0; i<8; i++) { // bits get pushed in reverse order (bit 7 first)
@@ -550,24 +557,108 @@ void bbepSendShiftData(FASTEPDSTATE *pState)
550557
gpio_set_level((gpio_num_t)pState->panelDef.ioSDA, 0);
551558
uc <<= 1;
552559
gpio_set_level((gpio_num_t)pState->panelDef.ioSCL, 1);
553-
delayMicroseconds(1);
554560
}
555561
// set STR to write the new data to the output to pins
556562
gpio_set_level((gpio_num_t)pState->panelDef.ioShiftSTR, 1);
557563
} /* bbepSendShiftData() */
558564
//
559-
// change the state of a bit in the shift register mask, and update the outputs
565+
// LilyGo T5S3 Pro control functions
560566
//
561-
void bbepSetShiftBit(FASTEPDSTATE *pBBEP, uint8_t u8Bit, uint8_t u8State)
567+
int LilyGoEinkPower(void *pBBEP, int bOn)
562568
{
563-
if (u8State) { // set it
564-
pBBEP->shift_data |= (1 << u8Bit);
565-
} else {
566-
pBBEP->shift_data &= ~(1 << u8Bit);
569+
FASTEPDSTATE *pState = (FASTEPDSTATE *)pBBEP;
570+
if (bOn == pState->pwr_on) return BBEP_SUCCESS; // already on
571+
if (bOn) {
572+
pState->shift_data |= 0x80; // OE on
573+
bbepSendShiftData(pState);
574+
delayMicroseconds(100);
575+
pState->shift_data &= ~0x02; // !power_disable
576+
bbepSendShiftData(pState);
577+
delayMicroseconds(100);
578+
pState->shift_data |= 0x08; // neg_power_enable
579+
bbepSendShiftData(pState);
580+
delayMicroseconds(500);
581+
pState->shift_data |= 0x04; // pos_power_enable
582+
bbepSendShiftData(pState);
583+
delayMicroseconds(100);
584+
pState->shift_data |= 0x10; // stv = true
585+
bbepSendShiftData(pState);
586+
delayMicroseconds(100);
587+
gpio_set_level((gpio_num_t)pState->panelDef.ioSPH, 1);
588+
pState->pwr_on = 1;
589+
} else { // off
590+
pState->shift_data &= ~0x04; // pos_power_enable = false
591+
bbepSendShiftData(pState);
592+
delayMicroseconds(10);
593+
pState->shift_data &= ~0x08; // neg_power_enable = false
594+
bbepSendShiftData(pState);
595+
delayMicroseconds(100);
596+
pState->shift_data |= 0x02; // power_disable = true
597+
bbepSendShiftData(pState);
598+
delayMicroseconds(100);
599+
pState->shift_data &= ~0x80; // OE off
600+
bbepSendShiftData(pState);
601+
delayMicroseconds(100);
602+
pState->shift_data &= ~0x10; // stv = false
603+
bbepSendShiftData(pState);
604+
pState->pwr_on = 0;
567605
}
568-
bbepSendShiftData(pBBEP);
569-
}
570-
//
606+
return BBEP_SUCCESS;
607+
} /* LilyGoEinkPower() */
608+
609+
int LilyGoIOInit(void *pBBEP)
610+
{
611+
FASTEPDSTATE *pState = (FASTEPDSTATE *)pBBEP;
612+
bbepPinMode(pState->panelDef.ioSDA, OUTPUT);
613+
bbepPinMode(pState->panelDef.ioSCL, OUTPUT);
614+
gpio_set_level((gpio_num_t)pState->panelDef.ioSCL, 0);
615+
bbepPinMode(pState->panelDef.ioShiftSTR, OUTPUT);
616+
gpio_set_level((gpio_num_t)pState->panelDef.ioShiftSTR, 0);
617+
bbepPinMode(pState->panelDef.ioCKV, OUTPUT);
618+
bbepPinMode(pState->panelDef.ioSPH, OUTPUT);
619+
bbepPinMode(pState->panelDef.ioCL, OUTPUT);
620+
pState->shift_data = 0x2; // power disable
621+
pState->shift_data |= 0x20; // ep_scan_direction
622+
pState->shift_data |= 0x10; // ep_stv
623+
bbepSendShiftData(pState);
624+
return BBEP_SUCCESS;
625+
626+
} /* LilyGoIOInit() */
627+
628+
void LilyGoRowControl(void *pBBEP, int iMode)
629+
{
630+
FASTEPDSTATE *pState = (FASTEPDSTATE *)pBBEP;
631+
if (iMode == ROW_START) {
632+
pState->shift_data |= 0x40; // ep_mode = true
633+
bbepSendShiftData(pState);
634+
gpio_set_level((gpio_num_t)pState->panelDef.ioCKV, 1); // CKV on
635+
delayMicroseconds(7);
636+
pState->shift_data &= ~0x10; // spv = off
637+
bbepSendShiftData(pState);
638+
delayMicroseconds(10);
639+
gpio_set_level((gpio_num_t)pState->panelDef.ioCKV, 0); // CKV off
640+
delayMicroseconds(0);
641+
gpio_set_level((gpio_num_t)pState->panelDef.ioCKV, 1); // CKV on
642+
delayMicroseconds(8);
643+
pState->shift_data |= 0x10; // spv = on
644+
bbepSendShiftData(pState);
645+
delayMicroseconds(10);
646+
gpio_set_level((gpio_num_t)pState->panelDef.ioCKV, 0); // CKV off
647+
delayMicroseconds(0);
648+
gpio_set_level((gpio_num_t)pState->panelDef.ioCKV, 1); // CKV on
649+
delayMicroseconds(18);
650+
gpio_set_level((gpio_num_t)pState->panelDef.ioCKV, 0); // CKV off
651+
delayMicroseconds(0);
652+
gpio_set_level((gpio_num_t)pState->panelDef.ioCKV, 1); // CKV on
653+
} else if (iMode == ROW_STEP) {
654+
gpio_set_level((gpio_num_t)pState->panelDef.ioCKV, 0); // CKV off
655+
pState->shift_data |= 0x01; // latch_enable = true
656+
bbepSendShiftData(pState);
657+
pState->shift_data &= ~0x01; // latch_enable = false
658+
bbepSendShiftData(pState);
659+
}
660+
} /* LilyGoRowControl() */
661+
571662
// Control the DC/DC power circuit of the M5Stack PaperS3
572663
//
573664
int PaperS3EinkPower(void *pBBEP, int bOn)

0 commit comments

Comments
 (0)