Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E paper #102

Merged
merged 4 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,18 @@
partitions: {
bootloader_addr: "0x1000",
},
}
}
- {
vendor: "M5Stack",
name: "Core4mb",
description: "",
link: "https://shop.m5stack.com/products/esp32-basic-core-lot-development-kit-v2-7?ref=Pirata",
family: "ESP32",
env: "m5stack-core-4Mb",
partitions: {
bootloader_addr: "0x1000",
},
}
- {
vendor: "M5Stack",
name: "CoreS3",
Expand Down Expand Up @@ -274,6 +285,17 @@
bootloader_addr: "0x0",
},
}
- {
vendor: "Lilygo",
name: "T5_E-Paper_S3_Pro",
description: "Pro Only!",
link: "https://lilygo.cc/products/t5-e-paper-s3-pro",
family: "ESP32-S3",
env: "lilygo-t5-epaper-s3-pro",
partitions: {
bootloader_addr: "0x0",
},
}

steps:
- uses: actions/checkout@v4
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ Sourcecode will be released in the future..
* UiFlow 1 doesn´t work with Launcher.. it uses an old MicroPython distro, that uses an old ESP-IDF distro with lots os secrets that I couldn´t figure out.

## Changelog
* 2.4.3:
* [x] Fixed buttons on Core devices
* [x] Fixed random restartings when dimming screen
* [x] Ported to Lilygo E-Paper S3 Pro (Only Pro for now)
* [x] Fixed T-Embed return from deepSleep

* 2.4.2:
* [x] UiFlow2 v2.2.0 compatibility https://github.com/bmorcelli/M5Stick-Launcher/issues/92
* [x] Fix for https://github.com/bmorcelli/M5Stick-Launcher/issues/93 https://github.com/bmorcelli/M5Stick-Launcher/issues/97 https://github.com/bmorcelli/M5Stick-Launcher/issues/95
Expand Down
4 changes: 2 additions & 2 deletions boards/lilygo-t-embed-cc1101/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#################################### EStart OF LILYGO MODELS #######################################
[env:lilygo-t-embed]
platform_packages =
framework-arduinoespressif32 @ https://github.com/bmorcelli/arduino-esp32/releases/download/2.0.17d/esp32-2.0.17d.zip
framework-arduinoespressif32 @ https://github.com/bmorcelli/arduino-esp32/releases/download/2.0.17f/esp32-2.0.17f.zip
board = lilygo-t-embed
board_build.arduino.memory_type = qio_opi
board_build.partitions = custom_16Mb.csv
Expand Down Expand Up @@ -94,7 +94,7 @@ lib_deps =

[env:lilygo-t-embed-cc1101]
platform_packages =
framework-arduinoespressif32 @ https://github.com/bmorcelli/arduino-esp32/releases/download/2.0.17d/esp32-2.0.17d.zip
framework-arduinoespressif32 @ https://github.com/bmorcelli/arduino-esp32/releases/download/2.0.17f/esp32-2.0.17f.zip
board = lilygo-t-embed-cc1101
board_build.arduino.memory_type = qio_opi
board_build.partitions = custom_16Mb.csv
Expand Down
50 changes: 50 additions & 0 deletions boards/lilygo-t5-epaper-s3-pro.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"build": {
"arduino": {
"ldscript": "esp32s3_out.ld",
"memory_type": "qio_opi",
"partitions": "default_16MB.csv"
},
"core": "esp32",
"extra_flags": [
"-DE_PAPER_DISPLAY",
"-DLYLYGO_T5S3_PRO",
"-DBOARD_HAS_PSRAM",
"-DARDUINO_RUNNING_CORE=0",
"-DARDUINO_EVENT_RUNNING_CORE=0",
"-DARDUINO_USB_MODE=1"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
"flash_mode": "qio",
"hwids": [
[
"0X303A",
"0x1001"
]
],
"mcu": "esp32s3",
"variant": "pinouts"
},
"connectivity": [
"wifi",
"bluetooth"
],
"debug": {
"openocd_target": "esp32s3.cfg"
},
"frameworks": [
"arduino",
"espidf"
],
"name": "LilyGo T5-ePaper-S3",
"upload": {
"flash_size": "16MB",
"maximum_ram_size": 327680,
"maximum_size": 16777216,
"require_upload_port": true,
"speed": 921600
},
"url": "https://www.lilygo.cc/products/t5-4-7-inch-e-paper-v2-3",
"vendor": "LILYGO"
}
202 changes: 202 additions & 0 deletions boards/lilygo-t5-epaper-s3-pro/interface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
#include <interface.h>
#include <Wire.h>
#include "powerSave.h"
#include <TouchDrvGT911.hpp>

#include "epd_driver.h"
#include "utilities.h"
TouchDrvGT911 touch;

#include <bq27220.h>
BQ27220 bq;

#include <XPowersLib.h>
XPowersPPM PPM;

#define BOARD_I2C_SDA 6
#define BOARD_I2C_SCL 5
#define BOARD_SENSOR_IRQ 15
#define BOARD_TOUCH_RST 41

/***************************************************************************************
** Function name: _setup_gpio()
** Location: main.cpp
** Description: initial setup for the device
***************************************************************************************/
void _setup_gpio() {
pinMode(SEL_BTN, INPUT);
pinMode(DW_BTN, INPUT);

// CS pins of SPI devices to HIGH
pinMode(46, OUTPUT); // LORA module
digitalWrite(46,HIGH);

Wire.begin(BOARD_SDA, BOARD_SCL);

// Assuming that the previous touch was in sleep state, wake it up
pinMode(TOUCH_INT, OUTPUT);
digitalWrite(TOUCH_INT, HIGH);

/*
* The touch reset pin uses hardware pull-up,
* and the function of setting the I2C device address cannot be used.
* Use scanning to obtain the touch device address.*/
uint8_t touchAddress = 0;
Wire.beginTransmission(0x14);
if (Wire.endTransmission() == 0) {
touchAddress = 0x14;
}
Wire.beginTransmission(0x5D);
if (Wire.endTransmission() == 0) {
touchAddress = 0x5D;
}
if (touchAddress == 0) {
while (1) {
Serial.println("Failed to find GT911 - check your wiring!");
delay(1000);
}
}
touch.setPins(-1, TOUCH_INT);
if (!touch.begin(Wire, touchAddress, BOARD_SDA, BOARD_SCL )) {
while (1) {
Serial.println("Failed to find GT911 - check your wiring!");
delay(1000);
}
}
touch.setMaxCoordinates(EPD_WIDTH, EPD_HEIGHT);
touch.setSwapXY(true);
touch.setMirrorXY(false, true);

Serial.println("Started Touchscreen poll...");


// BQ25896 --- 0x6B
Wire.beginTransmission(0x6B);
if (Wire.endTransmission() == 0)
{
// battery_25896.begin();
PPM.init(Wire, BOARD_SDA, BOARD_SCL, BQ25896_SLAVE_ADDRESS);
// Set the minimum operating voltage. Below this voltage, the PPM will protect
PPM.setSysPowerDownVoltage(3300);
// Set input current limit, default is 500mA
PPM.setInputCurrentLimit(3250);
Serial.printf("getInputCurrentLimit: %d mA\n",PPM.getInputCurrentLimit());
// Disable current limit pin
PPM.disableCurrentLimitPin();
// Set the charging target voltage, Range:3840 ~ 4608mV ,step:16 mV
PPM.setChargeTargetVoltage(4208);
// Set the precharge current , Range: 64mA ~ 1024mA ,step:64mA
PPM.setPrechargeCurr(64);
// The premise is that Limit Pin is disabled, or it will only follow the maximum charging current set by Limi tPin.
// Set the charging current , Range:0~5056mA ,step:64mA
PPM.setChargerConstantCurr(832);
// Get the set charging current
PPM.getChargerConstantCurr();
Serial.printf("getChargerConstantCurr: %d mA\n",PPM.getChargerConstantCurr());
PPM.enableADCMeasure();
PPM.enableCharge();
PPM.disableOTG();
}
}

/***************************************************************************************
** Function name: _post_setup_gpio()
** Location: main.cpp
** Description: second stage gpio setup to make a few functions work
***************************************************************************************/
#define TFT_BRIGHT_CHANNEL 0
#define TFT_BRIGHT_Bits 8
#define TFT_BRIGHT_FREQ 5000
#define TFT_BL 40
void _post_setup_gpio() {
// Brightness control must be initialized after tft in this case @Pirata
pinMode(TFT_BL,OUTPUT);
ledcSetup(TFT_BRIGHT_CHANNEL,TFT_BRIGHT_FREQ, TFT_BRIGHT_Bits); //Channel 0, 10khz, 8bits
ledcAttachPin(TFT_BL, TFT_BRIGHT_CHANNEL);
ledcWrite(TFT_BRIGHT_CHANNEL,125);
}


/***************************************************************************************
** Function name: getBattery()
** location: display.cpp
** Description: Delivers the battery value from 1-100
***************************************************************************************/
int getBattery() {
int percent=0;
percent=bq.getChargePcnt();

return (percent < 0) ? 0
: (percent >= 100) ? 100
: percent;
}


/*********************************************************************
** Function: setBrightness
** location: settings.cpp
** set brightness value
**********************************************************************/
void _setBrightness(uint8_t brightval) {
int dutyCycle;
if (brightval==100) dutyCycle=255;
else if (brightval==75) dutyCycle=130;
else if (brightval==50) dutyCycle=70;
else if (brightval==25) dutyCycle=20;
else if (brightval==0) dutyCycle=0;
else dutyCycle = ((brightval*255)/100);

log_i("dutyCycle for bright 0-255: %d",dutyCycle);
ledcWrite(TFT_BRIGHT_CHANNEL,dutyCycle); // Channel 0
}

struct TouchPointPro {
int16_t x=0;
int16_t y=0;
};

/*********************************************************************
** Function: InputHandler
** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress
**********************************************************************/
void InputHandler(void) {
static long _tmptmp;
TouchPointPro t;
uint8_t touched = 0;
touched = touch.getPoint(&t.x, &t.y);
if((millis()-_tmptmp)>150) { // one reading each 500ms

//Serial.printf("\nPressed x=%d , y=%d, rot: %d",t.x, t.y, rotation);
if (touched) {

Serial.printf("\nPressed x=%d , y=%d, rot: %d, millis=%d, tmp=%d",t.x, t.y, rotation, millis(), _tmptmp);
_tmptmp=millis();

// if(!wakeUpScreen()) AnyKeyPress = true;
// else goto END;

// Touch point global variable
touchPoint.x = t.x;
touchPoint.y = t.y;
touchPoint.pressed=true;
touchHeatMap(touchPoint);
touched=0;
}
END:
yield();
}
}

/*********************************************************************
** Function: powerOff
** location: mykeyboard.cpp
** Turns off the device (or try to)
**********************************************************************/
void powerOff() { }

/*********************************************************************
** Function: checkReboot
** location: mykeyboard.cpp
** Btn logic to tornoff the device (name is odd btw)
**********************************************************************/
void checkReboot() { }
59 changes: 59 additions & 0 deletions boards/lilygo-t5-epaper-s3-pro/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html


[env:lilygo-t5-epaper-s3-pro]
platform = https://github.com/bmorcelli/platform-espressif32/releases/download/0.0.3/platform-espressif32.zip
board = lilygo-t5-epaper-s3-pro
board_build.partitions = custom_16Mb.csv
build_src_filter =${env.build_src_filter} +<../boards/lilygo-t5-epaper-s3-pro>
build_flags =
${env.build_flags}
-Iboards/lilygo-t5-epaper-s3-pro
;-DCORE_DEBUG_LEVEL=5
-DARDUINO_USB_CDC_ON_BOOT=1

;-DPART_04MB =0
;-DPART_08MB =0
-DPART_16MB=1
-DROTATION=1 # 0,2 Portrait, 1,3 to landscape
-DHAS_BTN=1
-DSEL_BTN=0
-DUP_BTN=-1
-DDW_BTN=48
-DBTN_ACT=LOW
-DBAT_PIN=4
-DBTN_ALIAS='"Sel"'
-DMINBRIGHT=190
-DBACKLIGHT=40
-DLED=-1
-DLED_ON=HIGH

-DFP=1
-DFM=2
-DFG=3

-DLH=14
-DLW=11

-DHAS_TOUCH=1

-DTFT_WIDTH=500
-DTFT_HEIGHT=960

-DSDCARD_CS=16
-DSDCARD_SCK=18
-DSDCARD_MISO=8
-DSDCARD_MOSI=17

lib_deps =
${env.lib_deps}
lewisxhe/XPowersLib @0.2.6
https://github.com/bmorcelli/LilyGo-EPD47#esp32s3
Loading
Loading