diff --git a/src/main.cpp b/src/main.cpp index f372a26ad..4881e27a6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -840,7 +840,11 @@ void setup() // ESP32 SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS); LOG_DEBUG("SPI.begin(SCK=%d, MISO=%d, MOSI=%d, NSS=%d)", LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS); +#if defined(TBEAM_V10) && defined(USE_ST7796) + SPI.setFrequency(LORA_SPI_FREQUENCY); +#else SPI.setFrequency(4000000); +#endif #endif // Initialize the screen first so we can show the logo while we start up everything else. diff --git a/variants/tbeam-displayshield/platformio.ini b/variants/tbeam-displayshield/platformio.ini deleted file mode 100644 index f6d999e30..000000000 --- a/variants/tbeam-displayshield/platformio.ini +++ /dev/null @@ -1,14 +0,0 @@ -; The 1.0 release of the TBEAM board -[env:tbeam-displayshield] -extends = esp32_base -board = ttgo-t-beam -board_check = true -lib_deps = ${esp32_base.lib_deps} - https://github.com/Nasimovy/st7796/archive/refs/tags/1.0.5.zip ; display addon -build_flags = ${esp32_base.build_flags} - -DTBEAM_V10 - -Ivariants/tbeam-displayshield - -DGPS_POWER_TOGGLE ; comment this line to disable double press function on the user button to turn off gps entirely. - -DBOARD_HAS_PSRAM - -mfix-esp32-psram-cache-issue -upload_speed = 921600 \ No newline at end of file diff --git a/variants/tbeam-displayshield/variant.h b/variants/tbeam-displayshield/variant.h deleted file mode 100644 index dd1616a1f..000000000 --- a/variants/tbeam-displayshield/variant.h +++ /dev/null @@ -1,60 +0,0 @@ -// #define BUTTON_NEED_PULLUP // if set we need to turn on the internal CPU pullup during sleep - -#define I2C_SDA 21 -#define I2C_SCL 22 - -// Display addon -#define USE_ST7796 -#define ST7796_NSS 25 -#define ST7796_RS 13 // DC -#define ST7796_SDA 14 // MOSI -#define ST7796_SCK 15 -#define ST7796_RESET 2 -#define ST7796_MISO -1 -#define ST7796_BUSY -1 -#define VTFT_LEDA 4 -#define TFT_SPI_FREQUENCY 500000 -#define TFT_HEIGHT 222 -#define TFT_WIDTH 480 -#define BRIGHTNESS_DEFAULT 100 // Medium Low Brightnes - -#define BUTTON_PIN 38 // The middle button GPIO on the T-Beam -// #define BUTTON_PIN_ALT 13 // Alternate GPIO for an external button if needed. Does anyone use this? It is not documented -// anywhere. -// #define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module. - -// #define LED_STATE_ON 0 // State when LED is lit -// #define LED_PIN 4 // Newer tbeams (1.1) have an extra led on GPIO4 - -// TTGO uses a common pinout for their SX1262 vs RF95 modules - both can be enabled and we will probe at runtime for RF95 and if -// not found then probe for SX1262 -#define USE_RF95 // RFM95/SX127x -#define USE_SX1262 -#define USE_SX1268 - -#define LORA_DIO0 26 // a No connect on the SX1262 module -#define LORA_RESET 23 -#define LORA_DIO1 33 // SX1262 IRQ -#define LORA_DIO2 32 // SX1262 BUSY -#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262, if DIO3 is high the TXCO is enabled - -#ifdef USE_SX1262 -#define SX126X_CS LORA_CS // FIXME - we really should define LORA_CS instead -#define SX126X_DIO1 LORA_DIO1 -#define SX126X_BUSY LORA_DIO2 -#define SX126X_RESET LORA_RESET -// Not really an E22 but TTGO seems to be trying to clone that -#define SX126X_DIO2_AS_RF_SWITCH -#define SX126X_DIO3_TCXO_VOLTAGE 1.8 -// Internally the TTGO module hooks the SX1262-DIO2 in to control the TX/RX switch (which is the default for the sx1262interface -// code) -#endif - -// Leave undefined to disable our PMU IRQ handler. DO NOT ENABLE THIS because the pmuirq can cause sperious interrupts -// and waking from light sleep -// #define PMU_IRQ 35 -#define HAS_AXP192 -#define GPS_UBLOX -#define GPS_RX_PIN 34 -#define GPS_TX_PIN 12 -// #define GPS_DEBUG \ No newline at end of file diff --git a/variants/tbeam/platformio.ini b/variants/tbeam/platformio.ini index 4db99d1cb..d345b164b 100644 --- a/variants/tbeam/platformio.ini +++ b/variants/tbeam/platformio.ini @@ -5,9 +5,21 @@ board = ttgo-t-beam board_check = true lib_deps = ${esp32_base.lib_deps} build_flags = ${esp32_base.build_flags} - -DTBEAM_V10 - -Ivariants/tbeam - -DGPS_POWER_TOGGLE ; comment this line to disable double press function on the user button to turn off gps entirely. - -DBOARD_HAS_PSRAM + -D TBEAM_V10 + -I variants/tbeam + -D GPS_POWER_TOGGLE ; comment this line to disable double press function on the user button to turn off gps entirely. + -D BOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue -upload_speed = 921600 \ No newline at end of file +upload_speed = 921600 + +[env:tbeam-displayshield] +extends = env:tbeam + +build_flags = + ${env:tbeam.build_flags} + -D USE_ST7796 + +lib_deps = + ${env:tbeam.lib_deps} + https://github.com/Nasimovy/st7796/archive/refs/tags/1.0.5.zip ; display addon + lewisxhe/SensorLib@0.2.0 ; touchscreen addon diff --git a/variants/tbeam/variant.h b/variants/tbeam/variant.h index 8771c20d2..4e16e5c70 100644 --- a/variants/tbeam/variant.h +++ b/variants/tbeam/variant.h @@ -42,4 +42,26 @@ #define GPS_UBLOX #define GPS_RX_PIN 34 #define GPS_TX_PIN 12 -// #define GPS_DEBUG \ No newline at end of file +// #define GPS_DEBUG + +// Used when the diplay shield is chosen +#ifdef USE_ST7796 +#define LORA_SPI_FREQUENCY 1000000 + +#undef EXT_NOTIFY_OUT +#undef LED_STATE_ON +#undef LED_PIN + +#define ST7796_NSS 25 +#define ST7796_RS 13 // DC +#define ST7796_SDA 14 // MOSI +#define ST7796_SCK 15 +#define ST7796_RESET 2 +#define ST7796_MISO -1 +#define ST7796_BUSY -1 +#define VTFT_LEDA 4 +#define TFT_SPI_FREQUENCY 500000 +#define TFT_HEIGHT 222 +#define TFT_WIDTH 480 +#define BRIGHTNESS_DEFAULT 100 // Medium Low Brightnes +#endif \ No newline at end of file diff --git a/variants/tbeam_TFT/platformio.ini b/variants/tbeam_TFT/platformio.ini deleted file mode 100644 index 47f44ea26..000000000 --- a/variants/tbeam_TFT/platformio.ini +++ /dev/null @@ -1,14 +0,0 @@ -; The 1.0 release of the TBEAM board -[env:tbeam_TFT] -extends = esp32_base -board = ttgo-t-beam -board_check = true -lib_deps = ${esp32_base.lib_deps} - https://github.com/Nasimovy/st7796/archive/refs/tags/1.0.5.zip ; display addon -build_flags = ${esp32_base.build_flags} - -DTBEAM_V10 - -Ivariants/tbeam_TFT - -DGPS_POWER_TOGGLE ; comment this line to disable double press function on the user button to turn off gps entirely. - -DBOARD_HAS_PSRAM - -mfix-esp32-psram-cache-issue -upload_speed = 921600 \ No newline at end of file diff --git a/variants/tbeam_TFT/variant.h b/variants/tbeam_TFT/variant.h deleted file mode 100644 index dd1616a1f..000000000 --- a/variants/tbeam_TFT/variant.h +++ /dev/null @@ -1,60 +0,0 @@ -// #define BUTTON_NEED_PULLUP // if set we need to turn on the internal CPU pullup during sleep - -#define I2C_SDA 21 -#define I2C_SCL 22 - -// Display addon -#define USE_ST7796 -#define ST7796_NSS 25 -#define ST7796_RS 13 // DC -#define ST7796_SDA 14 // MOSI -#define ST7796_SCK 15 -#define ST7796_RESET 2 -#define ST7796_MISO -1 -#define ST7796_BUSY -1 -#define VTFT_LEDA 4 -#define TFT_SPI_FREQUENCY 500000 -#define TFT_HEIGHT 222 -#define TFT_WIDTH 480 -#define BRIGHTNESS_DEFAULT 100 // Medium Low Brightnes - -#define BUTTON_PIN 38 // The middle button GPIO on the T-Beam -// #define BUTTON_PIN_ALT 13 // Alternate GPIO for an external button if needed. Does anyone use this? It is not documented -// anywhere. -// #define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module. - -// #define LED_STATE_ON 0 // State when LED is lit -// #define LED_PIN 4 // Newer tbeams (1.1) have an extra led on GPIO4 - -// TTGO uses a common pinout for their SX1262 vs RF95 modules - both can be enabled and we will probe at runtime for RF95 and if -// not found then probe for SX1262 -#define USE_RF95 // RFM95/SX127x -#define USE_SX1262 -#define USE_SX1268 - -#define LORA_DIO0 26 // a No connect on the SX1262 module -#define LORA_RESET 23 -#define LORA_DIO1 33 // SX1262 IRQ -#define LORA_DIO2 32 // SX1262 BUSY -#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262, if DIO3 is high the TXCO is enabled - -#ifdef USE_SX1262 -#define SX126X_CS LORA_CS // FIXME - we really should define LORA_CS instead -#define SX126X_DIO1 LORA_DIO1 -#define SX126X_BUSY LORA_DIO2 -#define SX126X_RESET LORA_RESET -// Not really an E22 but TTGO seems to be trying to clone that -#define SX126X_DIO2_AS_RF_SWITCH -#define SX126X_DIO3_TCXO_VOLTAGE 1.8 -// Internally the TTGO module hooks the SX1262-DIO2 in to control the TX/RX switch (which is the default for the sx1262interface -// code) -#endif - -// Leave undefined to disable our PMU IRQ handler. DO NOT ENABLE THIS because the pmuirq can cause sperious interrupts -// and waking from light sleep -// #define PMU_IRQ 35 -#define HAS_AXP192 -#define GPS_UBLOX -#define GPS_RX_PIN 34 -#define GPS_TX_PIN 12 -// #define GPS_DEBUG \ No newline at end of file