diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 03c6fd9..aa7c8d2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -225,7 +225,18 @@ description: "", link: "https://lilygo.cc/products/t-display-s3?_pos=1&_sid=d7b2ebc22&_ss=r&variant=42589373268149", family: "ESP32-S3", - env: "lilygo-t-display-S3", + env: "lilygo-t-display-S3-touch", + partitions: { + bootloader_addr: "0x0", + }, + } + - { + vendor: "Lilygo", + name: "T-Display_S3_PRO", + description: "", + link: "https://lilygo.cc/products/t-display-s3?_pos=1&_sid=d7b2ebc22&_ss=r&variant=42589373268149", + family: "ESP32-S3", + env: "lilygo-t-display-S3-pro", partitions: { bootloader_addr: "0x0", }, diff --git a/README.md b/README.md index f88cdae..b7fa6cd 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,9 @@ Sourcecode will be released in the future.. ## Changelog * 2.4.1: - * [x] T-Deck SD Card fix (Disable LoRa Chip, CS pin to High state, to avoid conflicts) + * [x] T-Deck SD Card fix (Disable LoRa Chip, CS pin to High state, to avoid conflicts) https://github.com/bmorcelli/M5Stick-Launcher/issues/86 + * [x] Lilygo T-Display-S3-Pro port https://github.com/bmorcelli/M5Stick-Launcher/issues/73 + * 2.4.0: * [x] CYD-2432W328C port https://github.com/bmorcelli/M5Stick-Launcher/issues/80 * [x] Rolling texts for large SSIDs and large filenames diff --git a/platformio.ini b/platformio.ini index 1f4c5b0..e6b9169 100644 --- a/platformio.ini +++ b/platformio.ini @@ -17,7 +17,8 @@ default_envs = m5stack-cardputer #m5stack-c #m5stack-cores3 - #lilygo-t-display-S3 + #lilygo-t-display-S3-touch + #lilygo-t-display-S3-pro #lilygo-t-embed #lilygo-t-embed-cc1101 #lilygo-t-deck diff --git a/ports/lilygo-t-display-s3-pro/interface.cpp b/ports/lilygo-t-display-s3-pro/interface.cpp new file mode 100644 index 0000000..64d56ec --- /dev/null +++ b/ports/lilygo-t-display-s3-pro/interface.cpp @@ -0,0 +1,646 @@ +#include "interface.h" +#include "powerSave.h" +#include +#include +#include +static PowersSY6970 PMU; +#define TOUCH_MODULES_CST_SELF +#include +#include +#define LCD_MODULE_CMD_1 + +#include + +#define BOARD_I2C_SDA 5 +#define BOARD_I2C_SCL 6 +#define BOARD_SENSOR_IRQ 21 +#define BOARD_TOUCH_RST 13 +TouchDrvCSTXXX touch; + +void touchHomeKeyCallback(void *user_data) +{ + Serial.println("Home key pressed!"); + static uint32_t checkMs = 0; + if (millis() > checkMs) { + if (digitalRead(TFT_BL)) { + digitalWrite(TFT_BL, LOW); + } else { + digitalWrite(TFT_BL, HIGH); + } + } + checkMs = millis() + 200; +} + +/*************************************************************************************** +** Function name: _setup_gpio() +** Location: main.cpp +** Description: initial setup for the device +***************************************************************************************/ +void _setup_gpio() { + gpio_hold_dis((gpio_num_t)BOARD_TOUCH_RST);//PIN_TOUCH_RES + pinMode(SEL_BTN, INPUT); + pinMode(UP_BTN, INPUT); + pinMode(DW_BTN, INPUT); + + + pinMode(BOARD_TOUCH_RST, OUTPUT); //PIN_TOUCH_RES + digitalWrite(BOARD_TOUCH_RST, LOW);//PIN_TOUCH_RES + delay(500); + digitalWrite(BOARD_TOUCH_RST, HIGH);//PIN_TOUCH_RES + Wire.begin(BOARD_I2C_SDA, BOARD_I2C_SCL);//SDA, SCL + +// Initialize capacitive touch + touch.setPins(BOARD_TOUCH_RST, BOARD_SENSOR_IRQ); + touch.begin(Wire, CST226SE_SLAVE_ADDRESS, BOARD_I2C_SDA, BOARD_I2C_SCL); + touch.setMaxCoordinates(TFT_HEIGHT, TFT_WIDTH); + touch.setSwapXY(true); + touch.setMirrorXY(false, false); + //Set the screen to turn on or off after pressing the screen Home touch button + touch.setHomeButtonCallback(touchHomeKeyCallback); + + + bool hasPMU = PMU.init(Wire, BOARD_I2C_SDA, BOARD_I2C_SCL, SY6970_SLAVE_ADDRESS); + if (!hasPMU) { + Serial.println("PMU is not online..."); + } else { + PMU.disableOTG(); + PMU.enableADCMeasure(); + PMU.enableCharge(); + } + +} + +/*************************************************************************************** +** Function name: _post_setup_gpio() +** Location: main.cpp +** Description: second stage gpio setup to make a few functions work +***************************************************************************************/ +void _post_setup_gpio() { + // PWM backlight setup + ledcSetup(TFT_BRIGHT_CHANNEL,TFT_BRIGHT_FREQ, TFT_BRIGHT_Bits); //Channel 0, 10khz, 8bits + ledcAttachPin(TFT_BL, TFT_BRIGHT_CHANNEL); + ledcWrite(TFT_BRIGHT_CHANNEL,255); +} + + +/*************************************************************************************** +** Function name: getBattery() +** location: display.cpp +** Description: Delivers the battery value from 1-100 +***************************************************************************************/ +int getBattery() { + int percent=0; + percent=(PMU.getSystemVoltage()-3300)*100/(float)(4150-3350); + + 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=5; + else dutyCycle = ((brightval*255)/100); + + Serial.printf("dutyCycle for bright 0-255: %d",dutyCycle); + ledcWrite(TFT_BRIGHT_CHANNEL,dutyCycle); // Channel 0 +} + + +struct box_t +{ + int x; + int y; + int w; + int h; + std::uint16_t color; + int touch_id = -1; + char key; + char key_sh; + + void clear(void) + { + for (int i = 0; i < 8; ++i) + { + tft.fillRect(x, y, w, h,_BGCOLOR); + } + } + void draw(void) + { + int ie = touch_id < 0 ? 4 : 8; + for (int i = 0; i < ie; ++i) + { + tft.drawRect(x, y, w, h,color); + tft.setTextColor(color); + tft.drawChar(key,x+w/2-FONT_M*LW/2,y+h/2-FONT_M*LH/2); + } + } + bool contain(int x, int y) + { + return this->x <= x && x < (this->x + this->w) + && this->y <= y && y < (this->y + this->h); + } +}; + +static constexpr std::size_t box_count = 52; +static box_t box_list[box_count]; + +struct TouchPoint { + int16_t x[5]; + int16_t y[5]; +}; + +bool menuPress(int bot) { + //0 - prev + //1 - Sel + //2 - next + //3 - all + int terco=WIDTH/3; + TouchPoint t; + if (touch.getPoint(t.x, t.y, touch.getSupportTouchPoint()) && touch.isPressed()) { + if(rotation==3) t.x[0] = WIDTH-t.x[0]; + else if (rotation==1) t.y[0] = (HEIGHT+20)-t.y[0]; + + if(t.y[0]>(HEIGHT) && ((t.x[0]>terco*bot && t.x[0]' },//10 + { '?', '/' },//11 + { '/', '/' } //12 + } + }; + int _x = WIDTH/12; + int _y = (HEIGHT - 54)/4; + int _xo = _x/2-3; + + int k=0; + for(x2=0; x2<12;x2++) { + for(y2=0; y2<4; y2++) { + box_list[k].key=keys[y2][x2][0]; + box_list[k].key_sh=keys[y2][x2][1]; + box_list[k].color = ~_BGCOLOR; + box_list[k].x=x2*_x; + box_list[k].y=y2*_y+54; + box_list[k].w=_x; + box_list[k].h=_y; + k++; + } + } + // OK + box_list[k].key=' '; + box_list[k].key_sh=' '; + box_list[k].color = ~_BGCOLOR; + box_list[k].x=0; + box_list[k].y=0; + box_list[k].w=53; + box_list[k].h=22; + k++; + // CAP + box_list[k].key=' '; + box_list[k].key_sh=' '; + box_list[k].color = ~_BGCOLOR; + box_list[k].x=55; + box_list[k].y=0; + box_list[k].w=50; + box_list[k].h=22; + k++; + // DEL + box_list[k].key=' '; + box_list[k].key_sh=' '; + box_list[k].color = ~_BGCOLOR; + box_list[k].x=107; + box_list[k].y=0; + box_list[k].w=50; + box_list[k].h=22; + k++; + // SPACE + box_list[k].key=' '; + box_list[k].key_sh=' '; + box_list[k].color = ~_BGCOLOR; + box_list[k].x=159; + box_list[k].y=0; + box_list[k].w=WIDTH-164; + box_list[k].h=22; + + k=0; + x2=0; + y2=0; + + + int i=0; + int j=-1; + bool redraw=true; + delay(200); + int cX =0; + int cY =0; + tft.fillScreen(_BGCOLOR); + TouchPoint t; + while(1) { + if(redraw) { + tft.setCursor(0,0); + tft.setTextColor(~_BGCOLOR, _BGCOLOR); + tft.setTextSize(FM); + + //Draw the rectangles + if(y<0 || y2<0) { + tft.fillRect(0,1,WIDTH,22,_BGCOLOR); + tft.drawRect(7,2,46,20,~_BGCOLOR); // Ok Rectangle + tft.drawRect(55,2,50,20,~_BGCOLOR); // CAP Rectangle + tft.drawRect(107,2,50,20,~_BGCOLOR); // DEL Rectangle + tft.drawRect(159,2,74,20,~_BGCOLOR); // SPACE Rectangle + tft.drawRect(3,32,WIDTH-3,20,_FGCOLOR); // mystring Rectangle + + + if(x==0 && y==-1) { tft.setTextColor(_BGCOLOR, ~_BGCOLOR); tft.fillRect(7,2,50,20,~_BGCOLOR); } + else tft.setTextColor(~_BGCOLOR, _BGCOLOR); + tft.drawString("OK", 18, 4); + + + if(x==1 && y==-1) { tft.setTextColor(_BGCOLOR, ~_BGCOLOR); tft.fillRect(55,2,50,20,~_BGCOLOR); } + else if(caps) { tft.fillRect(55,2,50,20,TFT_DARKGREY); tft.setTextColor(~_BGCOLOR, TFT_DARKGREY); } + else tft.setTextColor(~_BGCOLOR, _BGCOLOR); + tft.drawString("CAP", 64, 4); + + + if(x==2 && y==-1) { tft.setTextColor(_BGCOLOR, ~_BGCOLOR); tft.fillRect(107,2,50,20,~_BGCOLOR); } + else tft.setTextColor(~_BGCOLOR, _BGCOLOR); + tft.drawString("DEL", 115, 4); + + if(x>2 && y==-1) { tft.setTextColor(_BGCOLOR, ~_BGCOLOR); tft.fillRect(159,2,74,20,~_BGCOLOR); } + else tft.setTextColor(~_BGCOLOR, _BGCOLOR); + tft.drawString("SPACE", 168, 4); + } + + tft.setTextSize(FP); + tft.setTextColor(~_BGCOLOR, 0x5AAB); + tft.drawString(msg.substring(0,38), 3, 24); + + tft.setTextSize(FM); + + // reseta o quadrado do texto + if (mytext.length() == 19 || mytext.length() == 20 || mytext.length() == 38 || mytext.length() == 39) tft.fillRect(3,32,WIDTH-3,20,_BGCOLOR); // mystring Rectangle + // escreve o texto + tft.setTextColor(~_BGCOLOR); + if(mytext.length()>19) { + tft.setTextSize(FP); + if(mytext.length()>38) { + tft.drawString(mytext.substring(0,38), 5, 34); + tft.drawString(mytext.substring(38,mytext.length()), 5, 42); + } + else { + tft.drawString(mytext, 5, 34); + } + } else { + tft.drawString(mytext, 5, 34); + } + //desenha o retangulo colorido + tft.drawRect(3,32,WIDTH-3,20,_FGCOLOR); // mystring Rectangle + + + tft.setTextColor(~_BGCOLOR, _BGCOLOR); + tft.setTextSize(FM); + + for(i=0;i<4;i++) { + for(j=0;j<12;j++) { + //use last coordenate to paint only this letter + if(x2==j && y2==i) { tft.setTextColor(~_BGCOLOR, _BGCOLOR); tft.fillRect(j*_x,i*_y+54,_x,_y,_BGCOLOR);} + /* If selected, change font color and draw Rectangle*/ + if(x==j && y==i) { tft.setTextColor(_BGCOLOR, ~_BGCOLOR); tft.fillRect(j*_x,i*_y+54,_x,_y,~_BGCOLOR);} + + + /* Print the letters */ + if(!caps) tft.drawChar(keys[i][j][0], (j*_x+_xo), (i*_y+56)); + else tft.drawChar(keys[i][j][1], (j*_x+_xo), (i*_y+56)); + + /* Return colors to normal to print the other letters */ + if(x==j && y==i) { tft.setTextColor(~_BGCOLOR, _BGCOLOR); } + } + } + // save actual key coordenate + x2=x; + y2=y; + redraw = false; + previousMillis=millis(); // reset dimmer without delaying 200ms after each keypress + + touch.getPoint(t.x, t.y, touch.getSupportTouchPoint()); + + TouchFooter(); + } + + + + //cursor handler + if(mytext.length()>19) { + tft.setTextSize(FP); + if(mytext.length()>38) { + cY=42; + cX=5+(mytext.length()-38)*LW; + } + else { + cY=34; + cX=5+mytext.length()*LW; + } + } else { + cY=34; + cX=5+mytext.length()*LW*2; + } + + int z=0; + + if (touch.getPoint(t.x, t.y, touch.getSupportTouchPoint()) && touch.isPressed()) + { + if(rotation==3) { + //t.y = HEIGHT-t.y; + t.x[0] = WIDTH-t.x[0]; + } else if (rotation==1) { + t.y[0] = (HEIGHT+20)-t.y[0]; + } + + if (box_list[48].contain(t.x[0], t.y[0])) { break; goto THIS_END; } // Ok + if (box_list[49].contain(t.x[0], t.y[0])) { caps=!caps; tft.fillRect(0,54,WIDTH,HEIGHT-54,_BGCOLOR); goto THIS_END; } // CAP + if (box_list[50].contain(t.x[0], t.y[0])) goto DEL; // DEL + if (box_list[51].contain(t.x[0], t.y[0])) { mytext += box_list[51].key; goto ADD; } // SPACE + for(k=0;k<48;k++){ + if (box_list[k].contain(t.x[0], t.y[0])) { + if(caps) mytext += box_list[k].key_sh; + else mytext += box_list[k].key; + } + } + THIS_END: + + t.x[0]=WIDTH+1; + t.y[0]=HEIGHT+11; + delay(250); + redraw=true; + } + if(checkSelPress()) { + tft.setCursor(cX,cY); + if(caps) z=1; + else z=0; + if(x==0 && y==-1) break; + else if(x==1 && y==-1) { caps=!caps; tft.fillRect(0,54,WIDTH,HEIGHT-54,_BGCOLOR); } + else if(x==2 && y==-1 && mytext.length() > 0) { + DEL: + mytext.remove(mytext.length()-1); + int fS=FM; + if(mytext.length()>19) { tft.setTextSize(FP); fS=FP; } + else tft.setTextSize(FM); + tft.setCursor((cX-fS*LW),cY); + tft.setTextColor(_FGCOLOR,_BGCOLOR); + tft.print(" "); + tft.setTextColor(~_BGCOLOR, 0x5AAB); + tft.setCursor(cX-fS*LW,cY); + cX=tft.getCursorX(); + cY=tft.getCursorY(); + } + else if(x>2 && y==-1 && mytext.length()-1 && mytext.length()3) x=0; + if(x>11) x=0; + else if (x<0) x=11; + redraw = true; + } + /* UP Btn to move in Y axis (Downwards) */ + if(checkPrevPress()) { + delay(250); + if(checkPrevPress()) { y--; delay(250); }// Long press + else y++; // short press + if(y>3) { y=-1; } + else if(y<-1) y=3; + redraw = true; + } + } + + //Resets screen when finished writing + tft.fillRect(0,0,tft.width(),tft.height(),_BGCOLOR); + resetTftDisplay(); + + return mytext; +} + + + + +/********************************************************************* +** 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() { } + + +/********************************************************************* +** Function: _checkKeyPress +** location: mykeyboard.cpp +** returns the key from the keyboard +**********************************************************************/ +keyStroke _getKeyPress() { + keyStroke key; + return key; + } // must return something that the keyboards won´t recognize by default + +/********************************************************************* +** Function: _checkNextPagePress +** location: mykeyboard.cpp +** returns the key from the keyboard +**********************************************************************/ +bool _checkNextPagePress() { return false; } + +/********************************************************************* +** Function: _checkPrevPagePress +** location: mykeyboard.cpp +** returns the key from the keyboard +**********************************************************************/ +bool _checkPrevPagePress() { return false; } \ No newline at end of file diff --git a/ports/lilygo-t-display-s3-pro/interface.h b/ports/lilygo-t-display-s3-pro/interface.h new file mode 100644 index 0000000..9ece87d --- /dev/null +++ b/ports/lilygo-t-display-s3-pro/interface.h @@ -0,0 +1,145 @@ +#pragma once +#include +#include + +//#define HAS_KEYBOARD //has keyboard to use +//#define HAS_KEYBOARD_HID //has keyboard to use +//#define KB_HID_EXIT_MSG "Mid Btn + Space to exit" +#if defined(LAUNCHER) + #define _BGCOLOR BGCOLOR + #define _FGCOLOR FGCOLOR +#elif defined(BRUCE_VERSION) + #define _BGCOLOR bruceConfig.bgcolor + #define _FGCOLOR bruceConfig.pricolor +#endif + + +/*************************************************************************************** +** Function name: _setup_gpio() +** Location: main.cpp +** Description: initial setup for the device +***************************************************************************************/ +void _setup_gpio(); + + +/*************************************************************************************** +** Function name: _post_setup_gpio() +** Location: main.cpp +** Description: second stage gpio setup to make a few functions work +***************************************************************************************/ +void _post_setup_gpio(); + +/*************************************************************************************** +** Function name: getBattery() +** location: display.cpp +** Description: Delivers the battery value from 1-100 +***************************************************************************************/ +int getBattery(); + + +/********************************************************************* +** Function: setBrightness +** location: settings.cpp +** set brightness value +**********************************************************************/ +void _setBrightness(uint8_t brightval); + + +/********************************************************************* +** Function: checkNextPress +** location: mykeyboard.cpp +** Verifies Upper Btn to go to previous item +**********************************************************************/ +bool checkNextPress(); + + +/********************************************************************* +** Function: checkPrevPress +** location: mykeyboard.cpp +** Verifies Down Btn to go to next item +**********************************************************************/ +bool checkPrevPress(); + + +/********************************************************************* +** Function: checkSelPress +** location: mykeyboard.cpp +** Verifies if Select or OK was pressed +**********************************************************************/ +bool checkSelPress(); + + +/********************************************************************* +** Function: checkEscPress +** location: mykeyboard.cpp +** Verifies if Escape btn was pressed +**********************************************************************/ +bool checkEscPress(); + + +/********************************************************************* +** Function: checkAnyKeyPress +** location: mykeyboard.cpp +** Verifies id any of the keys was pressed +**********************************************************************/ +bool checkAnyKeyPress(); + + +/********************************************************************* +** Function: keyboard +** location: mykeyboard.cpp +** Starts keyboard to type data +**********************************************************************/ +String keyboard(String mytext, int maxSize, String msg); + + +/********************************************************************* +** 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(); + +struct keyStroke { // DO NOT CHANGE IT!!!!! + bool pressed=false; + bool exit_key=false; + bool fn = false; + bool del = false; + bool enter = false; + uint8_t modifiers = 0; + std::vector word; + std::vector hid_keys; + std::vector modifier_keys; +}; +#if defined(HAS_KEYBOARD) // related functions + +/********************************************************************* +** Function: _checkKeyPress +** location: mykeyboard.cpp +** returns the key from the keyboard +**********************************************************************/ +keyStroke _getKeyPress(); // must return something that the keyboards won´t recognize by default + +/********************************************************************* +** Function: _checkNextPagePress +** location: mykeyboard.cpp +** returns the key from the keyboard +**********************************************************************/ +bool _checkNextPagePress(); + +/********************************************************************* +** Function: _checkPrevPagePress +** location: mykeyboard.cpp +** returns the key from the keyboard +**********************************************************************/ +bool _checkPrevPagePress(); + +#endif diff --git a/ports/lilygo-t-display-s3-pro/platformio.ini b/ports/lilygo-t-display-s3-pro/platformio.ini new file mode 100644 index 0000000..feb3b6b --- /dev/null +++ b/ports/lilygo-t-display-s3-pro/platformio.ini @@ -0,0 +1,90 @@ +; 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-t-display-S3-pro] +platform = https://github.com/bmorcelli/platform-espressif32/releases/download/0.0.3/platform-espressif32.zip +board = lilygo-t-display-s3 +framework = arduino +monitor_speed = 115200 +board_build.partitions = custom_16Mb.csv +build_src_filter =${env.build_src_filter} +<../ports/lilygo-t-display-s3-pro> +build_flags = + ${env.build_flags} + -Iports/lilygo-t-display-s3-pro + ;-DCORE_DEBUG_LEVEL=5 + -DBOARD_HAS_PSRAM=1 + -DARDUINO_USB_CDC_ON_BOOT=1 + + -DT_DISPLAY_S3=1 + -DREDRAW_DELAY=200 + + ;-DPART_04MB =0 + ;-DPART_08MB =0 + -DPART_16MB=1 + -DROTATION=3 # Portrait, 3 to landscape + -DHAS_BTN=1 + -DSEL_BTN=0 + -DUP_BTN=12 + -DDW_BTN=16 + -DBTN_ACT=LOW + -DBAT_PIN=4 + -DBTN_ALIAS='"Sel"' + -DMINBRIGHT=190 + -DBACKLIGHT=TFT_BL + -DWIDTH=480 + -DHEIGHT=202 ;222 - 20 para a margem inferior + -DLED=-1 + -DLED_ON=HIGH + + -DFONT_P=1 + -DFONT_M=2 + -DFONT_G=3 + + -DHAS_TOUCH=1 + + ;TFT_eSPI display + -DUSER_SETUP_LOADED=1 + -DUSE_HSPI_PORT=1 + -DST7796_DRIVER # Configure all registers + + -DTFT_WIDTH=222 + -DTFT_HEIGHT=480 + -DCGRAM_OFFSET # Library will add offsets required + -DTFT_RGB_ORDER=TFT_BGR # Colour order Blue-Green-Red + -DTFT_INVERSION_ON + -DTFT_MISO=8 + -DTFT_MOSI=17 + -DTFT_SCLK=18 + -DTFT_CS=39 # or 6 + -DTFT_DC=9 + -DTFT_RST=47 + -DTFT_BL=48 + -DTFT_BACKLIGHT_ON=HIGH + -DSMOOTH_FONT=1 + -DSPI_FREQUENCY=40000000 + -DTOUCH_CS=9 + + -DSDCARD_CS=14 + -DSDCARD_SCK=18 + -DSDCARD_MISO=8 + -DSDCARD_MOSI=17 + + + -DTFT_BRIGHT_CHANNEL=0 + -DTFT_BRIGHT_Bits=8 + -DTFT_BRIGHT_FREQ=10000 + +lib_deps = + ${env.lib_deps} + https://github.com/mmMicky/TouchLib.git + lewisxhe/SensorLib @ 0.2.2 + lewisxhe/XPowersLib @ 0.2.1 + bxparks/AceButton @ 1.10.1 diff --git a/ports/lilygo-t-display-s3-touch/interface.cpp b/ports/lilygo-t-display-s3-touch/interface.cpp index bb52a08..533e433 100644 --- a/ports/lilygo-t-display-s3-touch/interface.cpp +++ b/ports/lilygo-t-display-s3-touch/interface.cpp @@ -38,6 +38,17 @@ void _setup_gpio() { ledcWrite(TFT_BRIGHT_CHANNEL,255); } +/*************************************************************************************** +** Function name: _post_setup_gpio() +** Location: main.cpp +** Description: second stage gpio setup to make a few functions work +***************************************************************************************/ +void _post_setup_gpio() { + // PWM backlight setup + ledcSetup(TFT_BRIGHT_CHANNEL,TFT_BRIGHT_FREQ, TFT_BRIGHT_Bits); //Channel 0, 10khz, 8bits + ledcAttachPin(TFT_BL, TFT_BRIGHT_CHANNEL); + ledcWrite(TFT_BRIGHT_CHANNEL,255); +} /*************************************************************************************** ** Function name: getBattery() @@ -68,7 +79,18 @@ int getBattery() { ** location: settings.cpp ** set brightness value **********************************************************************/ -void _setBrightness(uint8_t brightval) { } +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=5; + else dutyCycle = ((brightval*255)/100); + + Serial.printf("dutyCycle for bright 0-255: %d",dutyCycle); + ledcWrite(TFT_BRIGHT_CHANNEL,dutyCycle); // Channel 0 +} struct box_t @@ -439,10 +461,10 @@ String keyboard(String mytext, int maxSize, String msg) { previousMillis=millis(); // reset dimmer without delaying 200ms after each keypress touch.read(); - + TouchFooter(); } - TouchFooter(); + //cursor handler if(mytext.length()>19) { @@ -487,7 +509,7 @@ String keyboard(String mytext, int maxSize, String msg) { t.x=WIDTH+1; t.y=HEIGHT+11; - + delay(250); redraw=true; } if(checkSelPress()) { @@ -519,7 +541,7 @@ String keyboard(String mytext, int maxSize, String msg) { cY=tft.getCursorY(); } redraw = true; - delay(200); + delay(250); } /* Down Btn to move in X axis (to the right) */ diff --git a/ports/lilygo-t-display-s3-touch/interface.h b/ports/lilygo-t-display-s3-touch/interface.h index 3f3fb1e..36d90f0 100644 --- a/ports/lilygo-t-display-s3-touch/interface.h +++ b/ports/lilygo-t-display-s3-touch/interface.h @@ -13,6 +13,12 @@ ***************************************************************************************/ void _setup_gpio(); +/*************************************************************************************** +** Function name: _post_setup_gpio() +** Location: main.cpp +** Description: second stage gpio setup to make a few functions work +***************************************************************************************/ +void _post_setup_gpio(); /*************************************************************************************** ** Function name: getBattery() diff --git a/ports/lilygo-t-display-s3-touch/platformio.ini b/ports/lilygo-t-display-s3-touch/platformio.ini index e6a8ac0..765cdc9 100644 --- a/ports/lilygo-t-display-s3-touch/platformio.ini +++ b/ports/lilygo-t-display-s3-touch/platformio.ini @@ -9,7 +9,7 @@ ; https://docs.platformio.org/page/projectconf.html -[env:lilygo-t-display-S3] +[env:lilygo-t-display-S3-touch] platform = https://github.com/bmorcelli/platform-espressif32/releases/download/0.0.3/platform-espressif32.zip board = lilygo-t-display-s3 framework = arduino