Skip to content

Commit

Permalink
Merge pull request #743 from bmorcelli/main
Browse files Browse the repository at this point in the history
1.8.1 fixes
  • Loading branch information
pr3y authored Jan 29, 2025
2 parents bbbe7c0 + c5dfa42 commit 494192d
Show file tree
Hide file tree
Showing 36 changed files with 422 additions and 601 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/buil_parallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ jobs:
family: "ESP32",
partitions: { bootloader_addr: "0x1000" },
}
- {
vendor: "CYD",
name: "CYD-2432W328R",
env: "CYD-2432W328R",
family: "ESP32",
partitions: { bootloader_addr: "0x1000" },
}
- {
vendor: "CYD",
name: "CYD-2432W328C(inv_colors)_and_CYD-2432S024C",
Expand Down
36 changes: 27 additions & 9 deletions boards/CYD-2432S028.ini
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ build_flags =
-DILI9341_2_DRIVER=1
-DUSE_HSPI_PORT=1
-DTFT_HEIGHT=320
-DTFT_WIDTH=240 ;240-20 lower margin
-DTFT_WIDTH=240
-DTFT_MISO=12
-DTFT_MOSI=13
-DTFT_SCLK=14
Expand Down Expand Up @@ -213,21 +213,39 @@ build_flags =
-DLITE_VERSION=1


[env:CYD-2432W328R]
extends = env:CYD-2432S028
build_flags =
${env:CYD-2432S028.build_flags}
-DTFT_INVERSION_ON # TFT is not color inverted
-DTFT_BL=27
# from https://github.com/pr3y/Bruce/issues/690#issuecomment-2602933450
# uses the same driver as CYD-2432S024R, but with different calibration Data, trying same as 2432S028R
-DESP32DMA
-DTOUCH_OFFSET_ROTATION=1
-DSPI_FREQUENCY=55000000
-DSPI_READ_FREQUENCY=20000000
-DSPI_TOUCH_FREQUENCY=2500000
-DUSE_TFT_eSPI_TOUCH
-DTOUCH_CONFIG_INT_GPIO_NUM=36
-DCYD2432W328R


[env:CYD-2432S024R] # CYD-2432S024R
extends = env:CYD-2432S028
build_flags =
${env:CYD-2432S028.build_flags}
;-DTFT_INVERSION_ON TFT is not color inverted
-DTFT_INVERSION_ON # TFT is not color inverted
-DTFT_BL=27

-DTOUCH_XPT2046_SPI
-DXPT2046_SPI_BUS_MOSI_IO_NUM=13
-DXPT2046_SPI_BUS_MISO_IO_NUM=12
-DXPT2046_SPI_BUS_SCLK_IO_NUM=14
-DXPT2046_SPI_CONFIG_CS_GPIO_NUM=33
-DXPT2046_TOUCH_CONFIG_INT_GPIO_NUM=36
# https://github.com/Fr4nkFletcher/ESP32-Marauder-Cheap-Yellow-Display/blob/master/User_Setup_cyd24.h
-DESP32DMA
-DTOUCH_OFFSET_ROTATION=1
-DSPI_FREQUENCY=55000000
-DSPI_READ_FREQUENCY=20000000
-DSPI_TOUCH_FREQUENCY=2500000
-DUSE_TFT_eSPI_TOUCH
-DTOUCH_CONFIG_INT_GPIO_NUM=36
-DCYD2432S024R


################################# END OF CYD MODELS ####################################################
65 changes: 55 additions & 10 deletions boards/CYD-2432S028/interface.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#include "interface.h"
#include "core/powerSave.h"
#include "core/utils.h"
#include <Arduino.h>

#if defined(HAS_CAPACITIVE_TOUCH)
#include "CYD28_TouchscreenC.h"
#define CYD28_DISPLAY_HOR_RES_MAX 240
#define CYD28_DISPLAY_VER_RES_MAX 320
CYD28_TouchC touch(CYD28_DISPLAY_HOR_RES_MAX, CYD28_DISPLAY_VER_RES_MAX);
#elif defined(USE_TFT_eSPI_TOUCH)
#define XPT2046_CS TOUCH_CS
bool _IH_touched = false;
void IRAM_ATTR _IH_touch(void){
_IH_touched=true;
}
#else
#include "CYD28_TouchscreenR.h"
#define CYD28_DISPLAY_HOR_RES_MAX 320
Expand All @@ -24,20 +31,23 @@
** Location: main.cpp
** Description: initial setup for the device
***************************************************************************************/
SPIClass touchSPI;
void _setup_gpio() {
#ifndef HAS_CAPACITIVE_TOUCH // Capacitive Touchscreen uses I2C to communicate
pinMode(XPT2046_CS, OUTPUT);
digitalWrite(XPT2046_CS, HIGH);
#endif
//touchSPI.begin(XPT2046_CLK, XPT2046_MISO, XPT2046_MOSI, XPT2046_CS);

#if !defined(USE_TFT_eSPI_TOUCH) // Use libraries
if(!touch.begin()) {
Serial.println("Touch IC not Started");
log_i("Touch IC not Started");
} else log_i("Touch IC Started");

#ifndef HAS_CAPACITIVE_TOUCH // Capacitive Touchscreen uses I2C to communicate
digitalWrite(XPT2046_CS, LOW);
#endif

#if defined(USE_TFT_eSPI_TOUCH)
pinMode(TOUCH_CS, OUTPUT);
attachInterrupt(TOUCH_CONFIG_INT_GPIO_NUM,_IH_touch,FALLING);
#endif
}

/***************************************************************************************
Expand Down Expand Up @@ -76,9 +86,44 @@ void _setBrightness(uint8_t brightval) {
** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress
**********************************************************************/
void InputHandler(void) {
if (touch.touched()) { //touch.tirqTouched() &&
static long tmp=0;
if (millis()-tmp>200) { // I know R3CK.. I Should NOT nest if statements..
// but it is needed to not keep SPI bus used without need, it save resources

#if defined(USE_TFT_eSPI_TOUCH)
#if defined(CYD2432S024R)
//uint16_t calData[5] = { 481, 3053, 433, 3296, 3 }; // from https://github.com/Fr4nkFletcher/ESP32-Marauder-Cheap-Yellow-Display/blob/3eed991e9336d3e711e3eb5d6ece7ba023132fef/esp32_marauder/Display.cpp#L43
#elif defined(CYD2432W328R)
//uint16_t calData[5] = { 350, 3465, 188, 3431, 2 }; // from https://github.com/Fr4nkFletcher/ESP32-Marauder-Cheap-Yellow-Display/blob/3eed991e9336d3e711e3eb5d6ece7ba023132fef/esp32_marauder/Display.cpp#L40
#endif
uint16_t calData[5] = { 391, 3491, 266, 3505, 7 };
tft.setTouch(calData);
TouchPoint t;
checkPowerSaveTime();

if(_IH_touched) {
NextPress=false;
PrevPress=false;
UpPress=false;
DownPress=false;
SelPress=false;
EscPress=false;
AnyKeyPress=false;
NextPagePress=false;
PrevPagePress=false;
touchPoint.pressed=false;
_IH_touched=false;
digitalWrite(TFT_CS,HIGH);
digitalWrite(TOUCH_CS,LOW);
tft.getTouch(&t.x, &t.y,50);
digitalWrite(TOUCH_CS,HIGH);
Serial.printf("Touched with Z=%d", tft.getTouchRawZ());
#else
if(touch.touched()) {
auto t = touch.getPointScaled();
t = touch.getPointScaled();
#endif

if(bruceConfig.rotation==3) {
t.y = (tftHeight+20)-t.y;
t.x = tftWidth-t.x;
Expand All @@ -93,6 +138,7 @@ void InputHandler(void) {
t.x = t.y;
t.y = (tftHeight+20)-tmp;
}
Serial.printf("Touch Pressed on x=%d, y=%d\n",t.x, t.y);

if(!wakeUpScreen()) AnyKeyPress = true;
else goto END;
Expand All @@ -103,12 +149,11 @@ void InputHandler(void) {
touchPoint.pressed=true;
touchHeatMap(touchPoint);

tmp=millis();
}
}
END:
if(AnyKeyPress) {
long tmp=millis();
while((millis()-tmp)<200 && (touch.touched()));
}
delay(0);
}

/*********************************************************************
Expand Down
2 changes: 1 addition & 1 deletion boards/lilygo-t-embed-cc1101.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ build_flags =

lib_deps =
${env.lib_deps}
lewisxhe/XPowersLib @0.2.6
lewisxhe/XPowersLib @0.2.7
mathertel/RotaryEncoder @1.5.3
fastled/FastLED @3.9.4
12 changes: 7 additions & 5 deletions boards/lilygo-t-embed-cc1101/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ IRAM_ATTR void checkPosition();
#if defined(T_EMBED_1101)
// Power handler for battery detection
#include <Wire.h>
// Charger chip
#define XPOWERS_CHIP_BQ25896
#include <XPowersLib.h>
#include <esp32-hal-dac.h>
XPowersPPM PPM;
Expand Down Expand Up @@ -54,15 +56,14 @@ void _setup_gpio() {
PPM.setInputCurrentLimit(3250);
Serial.printf("getInputCurrentLimit: %d mA\n",PPM.getInputCurrentLimit());
PPM.disableCurrentLimitPin();
PPM.setChargeTargetVoltage(4208);
PPM.setChargeTargetVoltage(4608);
PPM.setPrechargeCurr(64);
PPM.setChargerConstantCurr(832);
PPM.getChargerConstantCurr();
Serial.printf("getChargerConstantCurr: %d mA\n",PPM.getChargerConstantCurr());
PPM.enableADCMeasure();
PPM.enableCharge();
PPM.enableOTG();
PPM.enableMeasure(PowersBQ25896::CONTINUOUS);
PPM.disableOTG();
PPM.enableCharge();
}
#else
pinMode(BAT_PIN,INPUT); // Battery value
Expand Down Expand Up @@ -92,7 +93,8 @@ void _setup_gpio() {
int getBattery() {
int percent=0;
#if defined(USE_BQ27220_VIA_I2C)
percent=bq.getChargePcnt();
//percent=bq.getChargePcnt(); // this function runs bq.getRemainCap()/bq.getFullChargeCap().... bq.getFullChargeCap() is hardcoded int 3000.
percent=bq.getRemainCap()/10.7; // My battery is 1300mAh and bq.getRemainCap() doesn't go upper than 1083, that is why i'm dividing by 10.7 (var/1070)*100
#elif defined(T_EMBED)
uint8_t _batAdcCh = ADC1_GPIO4_CHANNEL;
uint8_t _batAdcUnit = 1;
Expand Down
2 changes: 1 addition & 1 deletion boards/m5stack-core.ini
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ build_flags =

lib_deps =
${env.lib_deps}
m5stack/M5Unified @ ^0.2.2
m5stack/M5Unified @ 0.2.2

[env:m5stack-core4mb]
extends=m5stack-core_base
Expand Down
2 changes: 1 addition & 1 deletion boards/m5stack-core2.ini
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ build_flags =

lib_deps =
${env.lib_deps}
m5stack/M5Unified @ ^0.2.2
m5stack/M5Unified @ 0.2.2
2 changes: 1 addition & 1 deletion boards/m5stack-cores3.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ build_flags =
-DRF_RX_PINS='{{"M5 RF433R", GROVE_SCL}, {"Groove W", GROVE_SCL}, {"GROVE Y", GROVE_SDA}}'
lib_deps =
${env.lib_deps}
m5stack/M5Unified @ ^0.2.2
m5stack/M5Unified @ 0.2.2

11 changes: 11 additions & 0 deletions include/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,24 @@ extern volatile bool PrevPagePress;

extern TaskHandle_t xHandle;
extern inline bool check(volatile bool &btn) {

#ifndef USE_TFT_eSPI_TOUCH
if(!btn) return false;
vTaskSuspend( xHandle );
btn=false;
AnyKeyPress=false;
delay(10);
vTaskResume( xHandle );
return true;
#else

InputHandler();
if(!btn) return false;
btn=false;
AnyKeyPress=false;
return true;

#endif
}

#endif
1 change: 1 addition & 0 deletions lib/Bad_Usb_Lib/BleKeyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ extern const uint8_t KeyboardLayout_sv_SE[];
extern const uint8_t KeyboardLayout_da_DK[];
extern const uint8_t KeyboardLayout_hu_HU[];
extern const uint8_t KeyboardLayout_tr_TR[];
extern const uint8_t KeyboardLayout_pl_PL[];

// Low level key report: up to 6 keys and shift, ctrl etc at once
typedef struct
Expand Down
1 change: 1 addition & 0 deletions lib/Bad_Usb_Lib/CH9329_Keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ extern const uint8_t KeyboardLayout_sv_SE[];
extern const uint8_t KeyboardLayout_da_DK[];
extern const uint8_t KeyboardLayout_hu_HU[];
extern const uint8_t KeyboardLayout_tr_TR[];
extern const uint8_t KeyboardLayout_pl_PL[];

// Low level key report: up to 6 keys and shift, ctrl etc at once
typedef struct CH9329_KeyReport
Expand Down
2 changes: 1 addition & 1 deletion lib/Bad_Usb_Lib/KeyboardLayout_en_UK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Standard US keyboard layout.
*/

#include "Keyboard_en_UK.h"
#include "KeyboardLayout.h"

extern const uint8_t KeyboardLayout_en_UK[128] PROGMEM =
{
Expand Down
Loading

0 comments on commit 494192d

Please sign in to comment.