mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-08 22:22:05 +00:00
- use LovyanGFX for m5stack
- update some comments
This commit is contained in:
parent
f5d323fdd3
commit
0aef8703b6
@ -3,7 +3,7 @@
|
|||||||
#include <OLEDDisplay.h>
|
#include <OLEDDisplay.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An adapter class that allows using the TFT_eSPI library as if it was an OLEDDisplay implementation.
|
* An adapter class that allows using the GxEPD2 library as if it was an OLEDDisplay implementation.
|
||||||
*
|
*
|
||||||
* Remaining TODO:
|
* Remaining TODO:
|
||||||
* optimize display() to only draw changed pixels (see other OLED subclasses for examples)
|
* optimize display() to only draw changed pixels (see other OLED subclasses for examples)
|
||||||
|
@ -217,7 +217,96 @@ class LGFX : public lgfx::LGFX_Device
|
|||||||
|
|
||||||
static LGFX tft;
|
static LGFX tft;
|
||||||
|
|
||||||
#elif defined(ST7735_CS) || defined(ILI9341_DRIVER)
|
#elif defined(ILI9341_DRIVER)
|
||||||
|
|
||||||
|
#include <LovyanGFX.hpp> // Graphics and font library for ILI9341 driver chip
|
||||||
|
|
||||||
|
#if defined(ILI9341_BACKLIGHT_EN) && !defined(TFT_BL)
|
||||||
|
#define TFT_BL ILI9341_BACKLIGHT_EN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class LGFX : public lgfx::LGFX_Device
|
||||||
|
{
|
||||||
|
lgfx::Panel_ILI9341 _panel_instance;
|
||||||
|
lgfx::Bus_SPI _bus_instance;
|
||||||
|
lgfx::Light_PWM _light_instance;
|
||||||
|
|
||||||
|
public:
|
||||||
|
LGFX(void)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
auto cfg = _bus_instance.config();
|
||||||
|
|
||||||
|
// configure SPI
|
||||||
|
cfg.spi_host = ILI9341_SPI_HOST; // ESP32-S2,S3,C3 : SPI2_HOST or SPI3_HOST / ESP32 : VSPI_HOST or HSPI_HOST
|
||||||
|
cfg.spi_mode = 0;
|
||||||
|
cfg.freq_write = SPI_FREQUENCY; // SPI clock for transmission (up to 80MHz, rounded to the value obtained by dividing
|
||||||
|
// 80MHz by an integer)
|
||||||
|
cfg.freq_read = SPI_READ_FREQUENCY; // SPI clock when receiving
|
||||||
|
cfg.spi_3wire = false; // Set to true if reception is done on the MOSI pin
|
||||||
|
cfg.use_lock = true; // Set to true to use transaction locking
|
||||||
|
cfg.dma_channel = SPI_DMA_CH_AUTO; // SPI_DMA_CH_AUTO; // Set DMA channel to use (0=not use DMA / 1=1ch / 2=ch /
|
||||||
|
// SPI_DMA_CH_AUTO=auto setting)
|
||||||
|
cfg.pin_sclk = TFT_SCLK; // Set SPI SCLK pin number
|
||||||
|
cfg.pin_mosi = TFT_MOSI; // Set SPI MOSI pin number
|
||||||
|
cfg.pin_miso = TFT_MISO; // Set SPI MISO pin number (-1 = disable)
|
||||||
|
cfg.pin_dc = TFT_DC; // Set SPI DC pin number (-1 = disable)
|
||||||
|
|
||||||
|
_bus_instance.config(cfg); // applies the set value to the bus.
|
||||||
|
_panel_instance.setBus(&_bus_instance); // set the bus on the panel.
|
||||||
|
}
|
||||||
|
|
||||||
|
{ // Set the display panel control.
|
||||||
|
auto cfg = _panel_instance.config(); // Gets a structure for display panel settings.
|
||||||
|
|
||||||
|
cfg.pin_cs = TFT_CS; // Pin number where CS is connected (-1 = disable)
|
||||||
|
cfg.pin_rst = TFT_RST; // Pin number where RST is connected (-1 = disable)
|
||||||
|
cfg.pin_busy = TFT_BUSY; // Pin number where BUSY is connected (-1 = disable)
|
||||||
|
|
||||||
|
// The following setting values are general initial values for each panel, so please comment out any
|
||||||
|
// unknown items and try them.
|
||||||
|
|
||||||
|
cfg.panel_width = TFT_WIDTH; // actual displayable width
|
||||||
|
cfg.panel_height = TFT_HEIGHT; // actual displayable height
|
||||||
|
cfg.offset_x = TFT_OFFSET_X; // Panel offset amount in X direction
|
||||||
|
cfg.offset_y = TFT_OFFSET_Y; // Panel offset amount in Y direction
|
||||||
|
cfg.offset_rotation = 0; // Rotation direction value offset 0~7 (4~7 is upside down)
|
||||||
|
cfg.dummy_read_pixel = 8; // Number of bits for dummy read before pixel readout
|
||||||
|
cfg.dummy_read_bits = 1; // Number of bits for dummy read before non-pixel data read
|
||||||
|
cfg.readable = true; // Set to true if data can be read
|
||||||
|
cfg.invert = false; // Set to true if the light/darkness of the panel is reversed
|
||||||
|
cfg.rgb_order = false; // Set to true if the panel's red and blue are swapped
|
||||||
|
cfg.dlen_16bit =
|
||||||
|
false; // Set to true for panels that transmit data length in 16-bit units with 16-bit parallel or SPI
|
||||||
|
cfg.bus_shared = true; // If the bus is shared with the SD card, set to true (bus control with drawJpgFile etc.)
|
||||||
|
|
||||||
|
// Set the following only when the display is shifted with a driver with a variable number of pixels, such as the
|
||||||
|
// ST7735 or ILI9163.
|
||||||
|
cfg.memory_width = TFT_WIDTH; // Maximum width supported by the driver IC
|
||||||
|
cfg.memory_height = TFT_HEIGHT; // Maximum height supported by the driver IC
|
||||||
|
_panel_instance.config(cfg);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the backlight control
|
||||||
|
{
|
||||||
|
auto cfg = _light_instance.config(); // Gets a structure for backlight settings.
|
||||||
|
|
||||||
|
cfg.pin_bl = TFT_BL; // Pin number to which the backlight is connected
|
||||||
|
cfg.invert = false; // true to invert the brightness of the backlight
|
||||||
|
// cfg.freq = 44100; // PWM frequency of backlight
|
||||||
|
// cfg.pwm_channel = 1; // PWM channel number to use
|
||||||
|
|
||||||
|
_light_instance.config(cfg);
|
||||||
|
_panel_instance.setLight(&_light_instance); // Set the backlight on the panel.
|
||||||
|
}
|
||||||
|
|
||||||
|
setPanel(&_panel_instance);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static LGFX tft;
|
||||||
|
|
||||||
|
#elif defined(ST7735_CS)
|
||||||
#include <TFT_eSPI.h> // Graphics and font library for ILI9341 driver chip
|
#include <TFT_eSPI.h> // Graphics and font library for ILI9341 driver chip
|
||||||
|
|
||||||
static TFT_eSPI tft = TFT_eSPI(); // Invoke library, pins defined in User_Setup.h
|
static TFT_eSPI tft = TFT_eSPI(); // Invoke library, pins defined in User_Setup.h
|
||||||
@ -335,9 +424,9 @@ bool TFTDisplay::connect()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
tft.init();
|
tft.init();
|
||||||
#if defined(M5STACK) || defined(T_DECK)
|
#if defined(T_DECK)
|
||||||
tft.setRotation(1); // M5Stack/T-Deck have the TFT in landscape
|
tft.setRotation(1); // M5Stack/T-Deck have the TFT in landscape
|
||||||
#elif defined(T_WATCH_S3)
|
#elif defined(M5STACK) || defined(T_WATCH_S3)
|
||||||
tft.setRotation(0); // T-Watch S3 has the TFT in portrait
|
tft.setRotation(0); // T-Watch S3 has the TFT in portrait
|
||||||
#else
|
#else
|
||||||
tft.setRotation(3); // Orient horizontal and wide underneath the silkscreen name label
|
tft.setRotation(3); // Orient horizontal and wide underneath the silkscreen name label
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <OLEDDisplay.h>
|
#include <OLEDDisplay.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An adapter class that allows using the TFT_eSPI library as if it was an OLEDDisplay implementation.
|
* An adapter class that allows using the LovyanGFX library as if it was an OLEDDisplay implementation.
|
||||||
*
|
*
|
||||||
* Remaining TODO:
|
* Remaining TODO:
|
||||||
* optimize display() to only draw changed pixels (see other OLED subclasses for examples)
|
* optimize display() to only draw changed pixels (see other OLED subclasses for examples)
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
extends = esp32_base
|
extends = esp32_base
|
||||||
board = m5stack-core-esp32
|
board = m5stack-core-esp32
|
||||||
board_level = extra
|
board_level = extra
|
||||||
upload_port = COM8
|
|
||||||
monitor_port = COM8
|
|
||||||
monitor_filters = esp32_exception_decoder
|
monitor_filters = esp32_exception_decoder
|
||||||
build_src_filter =
|
build_src_filter =
|
||||||
${esp32_base.build_src_filter}
|
${esp32_base.build_src_filter}
|
||||||
@ -28,4 +26,4 @@ lib_ignore =
|
|||||||
m5stack-core
|
m5stack-core
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${esp32_base.lib_deps}
|
${esp32_base.lib_deps}
|
||||||
bodmer/TFT_eSPI@^2.4.76
|
lovyan03/LovyanGFX@^1.1.7
|
||||||
|
@ -34,8 +34,13 @@
|
|||||||
#define GPS_RX_PIN 16
|
#define GPS_RX_PIN 16
|
||||||
#define GPS_TX_PIN 17
|
#define GPS_TX_PIN 17
|
||||||
|
|
||||||
// Define if screen should be mirrored left to right
|
#define TFT_HEIGHT 240
|
||||||
#define SCREEN_ROTATE
|
#define TFT_WIDTH 320
|
||||||
|
#define TFT_OFFSET_X 0
|
||||||
|
#define TFT_OFFSET_Y 0
|
||||||
|
#define TFT_BUSY -1
|
||||||
|
|
||||||
// LCD screens are slow, so slowdown the wipe so it looks better
|
// LCD screens are slow, so slowdown the wipe so it looks better
|
||||||
#define SCREEN_TRANSITION_FRAMERATE 1 // fps
|
#define SCREEN_TRANSITION_FRAMERATE 1 // fps
|
||||||
|
|
||||||
|
#define ILI9341_SPI_HOST VSPI_HOST // VSPI_HOST or HSPI_HOST
|
||||||
|
@ -4,10 +4,6 @@ extends = nrf52840_base
|
|||||||
board = nano-g2-ultra
|
board = nano-g2-ultra
|
||||||
debug_tool = jlink
|
debug_tool = jlink
|
||||||
|
|
||||||
# add our variants files to the include and src paths
|
|
||||||
# define build flags for the TFT_eSPI library - NOTE: WE NOT LONGER USE TFT_eSPI, it was for an earlier version of the TTGO eink screens
|
|
||||||
# -DBUSY_PIN=3 -DRST_PIN=2 -DDC_PIN=28 -DCS_PIN=30
|
|
||||||
# add -DCFG_SYSVIEW if you want to use the Segger systemview tool for OS profiling.
|
|
||||||
build_flags = ${nrf52840_base.build_flags} -Ivariants/nano-g2-ultra -D NANO_G2_ULTRA
|
build_flags = ${nrf52840_base.build_flags} -Ivariants/nano-g2-ultra -D NANO_G2_ULTRA
|
||||||
-L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard"
|
-L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard"
|
||||||
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nano-g2-ultra>
|
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nano-g2-ultra>
|
||||||
|
@ -4,9 +4,6 @@ extends = nrf52840_base
|
|||||||
board = t-echo
|
board = t-echo
|
||||||
debug_tool = jlink
|
debug_tool = jlink
|
||||||
|
|
||||||
# add our variants files to the include and src paths
|
|
||||||
# define build flags for the TFT_eSPI library - NOTE: WE NOT LONGER USE TFT_eSPI, it was for an earlier version of the TTGO eink screens
|
|
||||||
# -DBUSY_PIN=3 -DRST_PIN=2 -DDC_PIN=28 -DCS_PIN=30
|
|
||||||
# add -DCFG_SYSVIEW if you want to use the Segger systemview tool for OS profiling.
|
# add -DCFG_SYSVIEW if you want to use the Segger systemview tool for OS profiling.
|
||||||
build_flags = ${nrf52840_base.build_flags} -Ivariants/t-echo
|
build_flags = ${nrf52840_base.build_flags} -Ivariants/t-echo
|
||||||
-L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard"
|
-L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard"
|
||||||
|
Loading…
Reference in New Issue
Block a user