Skip to content

Commit

Permalink
Add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
peteGSX committed Jan 1, 2025
1 parent c460d95 commit 87d2aef
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 1 deletion.
2 changes: 2 additions & 0 deletions DisplayManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ void DisplayManager::startDisplays() {
return;
}
for (auto *display = _firstDisplay; display; display = display->getNext()) {
_selectSPIDisplay(display);
display->begin();
_deselectSPIDisplay(display);
}
}

Expand Down
6 changes: 6 additions & 0 deletions TFT_eSPIDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ TFT_eSPI *TFT_eSPIDisplay::getTFT_eSPIInstance() {

bool TFT_eSPIDisplay::tftInitialised() { return _tftInitialised; }

TFT_eSPIDisplay *TFT_eSPIDisplay::create(uint8_t rotation, uint8_t textSize, uint16_t textColour,
uint16_t backgroundColour) {
TFT_eSPIDisplay *newDisplay = new TFT_eSPIDisplay(rotation, textSize, textColour, backgroundColour);
return newDisplay;
}

TFT_eSPIDisplay *TFT_eSPIDisplay::create(uint8_t rotation, uint8_t textSize, uint16_t textColour,
uint16_t backgroundColour, int csPin) {
TFT_eSPIDisplay *newDisplay = new TFT_eSPIDisplay(rotation, textSize, textColour, backgroundColour, csPin);
Expand Down
15 changes: 14 additions & 1 deletion TFT_eSPIDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,22 @@ class TFT_eSPIDisplay : public DisplayInterface {
bool tftInitialised();

/// @brief Static method to enable the compiler to generate create commands from myDevices.h entries
/// @param rotation
/// @param textSize
/// @param textColour
/// @param backgroundColour
/// @return Pointer to a new TFT_eSPIDisplay instance
static TFT_eSPIDisplay *create(uint8_t rotation, uint8_t textSize, uint16_t textColour, uint16_t backgroundColour);

/// @brief Alternate static method to enable the compiler to generate create commands from myDevices.h entries
/// @param rotation
/// @param textSize
/// @param textColour
/// @param backgroundColour
/// @param csPin
/// @return Pointer to a new TFT_eSPIDisplay instance
static TFT_eSPIDisplay *create(uint8_t rotation, uint8_t textSize, uint16_t textColour, uint16_t backgroundColour,
int csPin = -1);
int csPin);

/// @brief Destructor for the TFT_eSPIDisplay
~TFT_eSPIDisplay() override;
Expand Down
48 changes: 48 additions & 0 deletions myConfig.example.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* © 2024 Peter Cole
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* It is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this code. If not, see <https://www.gnu.org/licenses/>.
*/

/**
* @file myConfig.example.h
* @brief This is an example myConfig.h outlining the available options that can be set
* @details
* DO NOT EDIT THIS FILE! Copy it to myConfig.h and edit that.
* Each available option is listed here with all commented out.
* Uncomment and edit any options as required, noting you may not need to do this at all.
* Default options are commented as such and will be used if you do not have a myConfig.h file.
*/

/**
* @brief Options to define the log level which controls output to the EX-Display serial console.
*/
// #define LOG_LEVEL LOG_NONE // Do not display any output
// #define LOG_LEVEL LOG_ERROR // Display errors only
// #define LOG_LEVEL LOG_WARN // Display warnings and errors (this is the default)
// #define LOG_LEVEL LOG_INFO // Display information, warnings, and errors
// #define LOG_LEVEL LOG_DEBUG // Display absolutely everything

/**
* @brief Options to define which serial connections to use for the serial console and connecting to EX-CommandStation.
*/
// #define CONSOLE_STREAM Serial // Serial console defaults to Serial (default on all platforms)
// #define COMMANDSTATION_STREAM Serial // EX-CommandStation connected to Serial (default on Uno)
// #define COMMANDSTATION_STREAM Serial2 // EX-CommandStation connected to Serial2 (default on ESP32)
// #define COMMANDSTATION_STREAM Serial6 // EX-CommandStation connected to Serial6 (default on F411RE)

/**
* @brief Option to change how long the EX-Display version is displayed, in milliseconds.
*/
// #define STARTUP_INFO_DELAY 3000 // default is 3 seconds/3000ms - Increase/decrease if desired
80 changes: 80 additions & 0 deletions myDevices.example.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* © 2024 Peter Cole
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* It is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this code. If not, see <https://www.gnu.org/licenses/>.
*/

/**
* @file myDevices.example.h
* @brief This is an example myDevices.h outlining the available devices that can be configured
* @details
* DO NOT EDIT THIS FILE! Copy it to myDevices.h and edit that.
* Each available type has an example and description.
* Note that there are no default devices as there are too many available user options to provide a sensible default.
* Any parameters with prefaced by * are optional and can be ommitted as per the examples displayed.
*
* Each display has an auto generated ID starting at 0, and these are generated in the order the displays are defined in
* myDevices.h.
*/

/**
* Display devices using the TFT_eSPI display library
*
* USER_DISPLAY(TFT_eSPIDisplay, rotation, text size, text colour, background colour, *chip select pin)
*
* Example for a single display with rotation set to 1, text size 1, white text colour, and black background colour
* Omit the final chip select pin parameter for a single display
* USER_DISPLAY(TFT_eSPIDisplay, 1, 1, TFT_WHITE, TFT_BLACK)
*
* Example for two displays as above, but specifying the chip select pin to manually switch the displays
* This is necessary as the TFT_eSPI library doesn't directly support multiple displays
* USER_DISPLAY(TFT_eSPIDisplay, 1, 1, TFT_WHITE, TFT_BLACK, 15)
* USER_DISPLAY(TFT_eSPIDisplay, 1, 1, TFT_WHITE, TFT_BLACK, 16)
*
* Uncomment and edit one or more lines below as required for your setup.
*/

// USER_DISPLAY(TFT_eSPIDisplay, 1, 1, TFT_WHITE, TFT_BLACK)
// USER_DISPLAY(TFT_eSPIDisplay, 1, 1, TFT_WHITE, TFT_BLACK, 15)
// USER_DISPLAY(TFT_eSPIDisplay, 1, 1, TFT_WHITE, TFT_BLACK, 16)

/**
* Display devices using the MCUFRIEND_kbv display library
*
* USER_DISPLAY(MCU_Display, ......)
*
* Uncomment and edit one or more lines below as required for your setup.
*/

/**
* Display devices using **OLED**?? library
*
* USER_DISPLAY(OLED_Display, ......)
*
* Uncomment and edit one or more lines below as required for your setup.
*/

/**
* Input devices for touch screens using the TFT_eSPI display library by bodmer, which require an existing display
* instance to be defined
*
* USER_INPUT(TFT_eSPITouch, display ID)
*
* Example using the first defined TFT_eSPIDisplay instance which will have ID 0
* USER_INPUT(TFT_eSPITouch, 0)
*
* Uncomment and edit one or more lines below as required for your setup.
*/

// USER_INPUT(TFT_eSPITouch, 0)
35 changes: 35 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
[platformio]
default_envs =
Wemos_D1_Mini32_RPI_ILI9486
ESP32_Dev_RPI_ILI9486
ESP32_Dev_Multi_RPI_ILI9486
ESP32_SPI_ST7796_40
src_dir = .
include_dir = .

Expand Down Expand Up @@ -93,6 +96,38 @@ monitor_speed = 115200
monitor_echo = yes
test_ignore = *

[env:ESP32_Dev_Multi_RPI_ILI9486]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
${env.lib_deps}
build_flags =
${env.build_flags}
-DUSER_SETUP_LOADED=1
-DRPI_DISPLAY_TYPE=1
-DILI9486_DRIVER=1
-DTFT_MISO=23
-DTFT_MOSI=19
-DTFT_SCLK=18
; -DTFT_CS=-1
-DTFT_DC=2
-DTFT_RST=4
-DTOUCH_CS=22
-DLOAD_GLCD=1
-DLOAD_FONT2=1
-DLOAD_FONT4=1
-DLOAD_FONT6=1
-DLOAD_FONT7=1
-DLOAD_FONT8=1
-DLOAD_GFXFF=1
-DSMOOTH_FONT=1
-DSPI_FREQUENCY=26000000
-DSPI_TOUCH_FREQUENCY=2500000
monitor_speed = 115200
monitor_echo = yes
test_ignore = *

[env:ESP32_SPI_ST7796_40]
platform = espressif32
board = esp32dev
Expand Down

0 comments on commit 87d2aef

Please sign in to comment.