simplify TFT display definition

This commit is contained in:
cyberman54 2022-08-19 16:35:02 +02:00
parent 9791333b0e
commit 4b216fb564
10 changed files with 45 additions and 27 deletions

View File

@ -2,6 +2,7 @@
#define _DISPLAY_H #define _DISPLAY_H
#include <libpax_api.h> #include <libpax_api.h>
#include <Wire.h>
#include "cyclic.h" #include "cyclic.h"
#include "qrcode.h" #include "qrcode.h"
#include "power.h" #include "power.h"
@ -48,7 +49,7 @@ extern BB_SPI_LCD *dp;
#endif #endif
// settings for TFT display library // settings for TFT display library
#elif (HAS_DISPLAY == 2) #elif (HAS_DISPLAY) == 2
#define MY_FONT_SMALL 2 #define MY_FONT_SMALL 2
#define MY_FONT_NORMAL 2 #define MY_FONT_NORMAL 2
@ -74,10 +75,6 @@ extern BB_SPI_LCD *dp;
#define OLED_TYPE OLED_128x64 #define OLED_TYPE OLED_128x64
#endif #endif
#ifndef MY_DISPLAY_INVERT
#define MY_DISPLAY_INVERT 0
#endif
#ifndef MY_DISPLAY_FLIP #ifndef MY_DISPLAY_FLIP
#define MY_DISPLAY_FLIP 0 #define MY_DISPLAY_FLIP 0
#endif #endif

View File

@ -12,7 +12,10 @@
#include <set> #include <set>
#include <array> #include <array>
#include <algorithm> #include <algorithm>
#ifdef HAS_BME680
#include <bsec.h> #include <bsec.h>
#endif
#define _bit(b) (1U << (b)) #define _bit(b) (1U << (b))
#define _bitl(b) (1UL << (b)) #define _bitl(b) (1UL << (b))

View File

@ -2,6 +2,7 @@
#define _I2C_H #define _I2C_H
#include <Arduino.h> #include <Arduino.h>
#include <Wire.h>
#include <BitBang_I2C.h> #include <BitBang_I2C.h>
#define SSD1306_PRIMARY_ADDRESS (0x3D) #define SSD1306_PRIMARY_ADDRESS (0x3D)

View File

@ -1,8 +1,12 @@
#ifndef _LED_H #ifndef _LED_H
#define _LED_H #define _LED_H
#ifdef RGB_LED_COUNT
#include <SmartLeds.h> #include <SmartLeds.h>
#endif
#ifdef HAS_LORA
#include "lorawan.h" #include "lorawan.h"
#endif
#ifndef RGB_LED_COUNT #ifndef RGB_LED_COUNT
#define RGB_LED_COUNT 1 #define RGB_LED_COUNT 1

View File

@ -68,16 +68,13 @@ void dp_setup(int contrast) {
dp->setRotation( dp->setRotation(
MY_DISPLAY_FLIP ? 2 : 0); // 0 = no rotation, 1 = 90°, 2 = 180°, 3 = 280° MY_DISPLAY_FLIP ? 2 : 0); // 0 = no rotation, 1 = 90°, 2 = 180°, 3 = 280°
#elif (HAS_DISPLAY) == 2 // SPI TFT #elif (HAS_DISPLAY) == 2 // TFT LCD
dp = new BB_SPI_LCD; dp = new BB_SPI_LCD;
dp->begin(TFT_TYPE, FLAGS_NONE, TFT_FREQUENCY, TFT_CS, TFT_DC, TFT_RST, dp->begin(TFT_TYPE);
TFT_BL, TFT_MISO, TFT_MOSI, TFT_SCLK);
dp->allocBuffer(); // render all outputs to lib internal backbuffer dp->allocBuffer(); // render all outputs to lib internal backbuffer
dp->setRotation( dp->setRotation(
MY_DISPLAY_FLIP ? 1 : 3); // 0 = no rotation, 1 = 90°, 2 = 180°, 3 = 280° MY_DISPLAY_FLIP ? 1 : 3); // 0 = no rotation, 1 = 90°, 2 = 180°, 3 = 280°
// dp->invertDisplay(MY_DISPLAY_INVERT ? true : false);
// dp->setTextWrap(false);
dp->setTextColor(MY_DISPLAY_FGCOLOR, MY_DISPLAY_BGCOLOR); dp->setTextColor(MY_DISPLAY_FGCOLOR, MY_DISPLAY_BGCOLOR);
#endif #endif

View File

@ -48,8 +48,6 @@
//#define MY_DISPLAY_FLIP 1 // use if display is rotated //#define MY_DISPLAY_FLIP 1 // use if display is rotated
#define MY_DISPLAY_WIDTH 320 #define MY_DISPLAY_WIDTH 320
#define MY_DISPLAY_HEIGHT 240 #define MY_DISPLAY_HEIGHT 240
#define MY_DISPLAY_INVERT 1
#define TFT_TYPE LCD_ILI9341
#define TFT_MOSI MOSI // SPI #define TFT_MOSI MOSI // SPI
#define TFT_MISO MISO // SPI #define TFT_MISO MISO // SPI
#define TFT_SCLK SCK // SPI #define TFT_SCLK SCK // SPI
@ -58,5 +56,6 @@
#define TFT_RST GPIO_NUM_33 // Reset #define TFT_RST GPIO_NUM_33 // Reset
#define TFT_BL GPIO_NUM_32 // LED back-light #define TFT_BL GPIO_NUM_32 // LED back-light
#define TFT_FREQUENCY 40000000 #define TFT_FREQUENCY 40000000
#define TFT_TYPE LCD_ILI9341, FLAGS_NONE, TFT_FREQUENCY, TFT_CS, TFT_DC, TFT_RST, TFT_BL, TFT_MISO, TFT_MOSI, TFT_SCLK
#endif #endif

View File

@ -53,8 +53,6 @@
//#define MY_DISPLAY_FLIP 1 // use if display is rotated //#define MY_DISPLAY_FLIP 1 // use if display is rotated
#define MY_DISPLAY_WIDTH 320 #define MY_DISPLAY_WIDTH 320
#define MY_DISPLAY_HEIGHT 240 #define MY_DISPLAY_HEIGHT 240
#define MY_DISPLAY_INVERT 1
#define TFT_TYPE LCD_ILI9341
#define TFT_MOSI MOSI // SPI #define TFT_MOSI MOSI // SPI
#define TFT_MISO MISO // SPI #define TFT_MISO MISO // SPI
#define TFT_SCLK SCK // SPI #define TFT_SCLK SCK // SPI
@ -63,5 +61,7 @@
#define TFT_RST GPIO_NUM_33 // Reset #define TFT_RST GPIO_NUM_33 // Reset
#define TFT_BL GPIO_NUM_32 // LED back-light #define TFT_BL GPIO_NUM_32 // LED back-light
#define TFT_FREQUENCY 40000000 #define TFT_FREQUENCY 40000000
#define TFT_TYPE LCD_ILI9341, FLAGS_NONE, TFT_FREQUENCY, TFT_CS, TFT_DC, TFT_RST, TFT_BL, TFT_MISO, TFT_MOSI, TFT_SCLK
#endif #endif

View File

@ -18,18 +18,9 @@
// Display Settings // Display Settings
#define HAS_DISPLAY 2 // TFT-LCD #define HAS_DISPLAY 2 // TFT-LCD
#define TFT_TYPE DISPLAY_T_DISPLAY
#define MY_DISPLAY_FLIP 1 // use if display is rotated #define MY_DISPLAY_FLIP 1 // use if display is rotated
#define MY_DISPLAY_WIDTH 135 #define MY_DISPLAY_WIDTH 135
#define MY_DISPLAY_HEIGHT 240 #define MY_DISPLAY_HEIGHT 240
#define MY_DISPLAY_INVERT 1
#define TFT_TYPE LCD_ST7789_135 // size 135x240 px
#define TFT_MOSI GPIO_NUM_19 // SPI
#define TFT_MISO NOT_A_PIN // SPI
#define TFT_SCLK GPIO_NUM_18 // SPI
#define TFT_CS GPIO_NUM_5 // Chip select control
#define TFT_DC GPIO_NUM_16 // Data Command control
#define TFT_RST GPIO_NUM_23 // Reset
#define TFT_BL GPIO_NUM_4 // LED back-light
#define TFT_FREQUENCY 40000000
#endif #endif

27
src/hal/ttgotdisplays3.h Normal file
View File

@ -0,0 +1,27 @@
// clang-format off
// upload_speed 1500000
// board ESP32-S3-DevKitC-1
#ifndef _TTGOTDISPLAYS3_H
#define _TTGOTDISPLAYS3_H
#include <stdint.h>
#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature
#define HAS_LED LED_BUILTIN
#define HAS_BUTTON 14 // on board button (right side)
// power management settings
//#define BAT_MEASURE_ADC ADC1_GPIO4_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_6
//#define BAT_VOLTAGE_DIVIDER 2.605f // voltage divider
// Display Settings
#define HAS_DISPLAY 2 // TFT-LCD parallel
#define TFT_TYPE DISPLAY_T_DISPLAY_S3
#define MY_DISPLAY_FLIP 1 // use if display is rotated
#define MY_DISPLAY_WIDTH 172
#define MY_DISPLAY_HEIGHT 320
#endif

View File

@ -21,8 +21,6 @@
#define MY_DISPLAY_FLIP 1 // use if display is rotated #define MY_DISPLAY_FLIP 1 // use if display is rotated
#define MY_DISPLAY_WIDTH 80 #define MY_DISPLAY_WIDTH 80
#define MY_DISPLAY_HEIGHT 160 #define MY_DISPLAY_HEIGHT 160
#define MY_DISPLAY_INVERT 1
#define TFT_TYPE LCD_ST7735S
#define TFT_MOSI GPIO_NUM_19 // SPI #define TFT_MOSI GPIO_NUM_19 // SPI
#define TFT_MISO NOT_A_PIN // SPI #define TFT_MISO NOT_A_PIN // SPI
#define TFT_SCLK GPIO_NUM_18 // SPI #define TFT_SCLK GPIO_NUM_18 // SPI
@ -31,6 +29,7 @@
#define TFT_RST GPIO_NUM_26 // Reset #define TFT_RST GPIO_NUM_26 // Reset
#define TFT_BL GPIO_NUM_27 // LED back-light #define TFT_BL GPIO_NUM_27 // LED back-light
#define TFT_FREQUENCY 27000000 #define TFT_FREQUENCY 27000000
#define TFT_TYPE LCD_ST7735S, FLAGS_NONE, TFT_FREQUENCY, TFT_CS, TFT_DC, TFT_RST, TFT_BL, TFT_MISO, TFT_MOSI, TFT_SCLK
#endif #endif