Skip to content

Commit 8115ca4

Browse files
Merge develop into main (#392)
- Refactor `Ili934xDisplay` to use `EspLcdSpiDisplay` as base class - Update `St7789Display` for changes to `EspLcdDisplayV2` related to ILI934x driver - Updated all board driver implementations for ILI934x driver changes - Simplified board configurations: - All boards now have a `Configuration.cpp` - All board config's headers are removed - Removed `Boards.h` - Fix for untar-ing large files - Increase main task stack size to avoid stackoverflow when downloading apps in App Hub - Reduce SPI frequency for ST7789 displays (according to spec)
1 parent db6d3b4 commit 8115ca4

File tree

126 files changed

+572
-915
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+572
-915
lines changed

Boards/CYD-2432S024C/Source/CYD2432S024C.h

Lines changed: 0 additions & 6 deletions
This file was deleted.

Boards/CYD-2432S024C/Source/CYD2432S024C.cpp renamed to Boards/CYD-2432S024C/Source/Configuration.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
#include "CYD2432S024C.h"
21
#include "devices/Display.h"
32
#include "devices/SdCard.h"
43

4+
#include <Tactility/hal/Configuration.h>
55
#include <Tactility/lvgl/LvglSync.h>
66
#include <PwmBacklight.h>
77

8-
#define CYD_SPI_TRANSFER_SIZE_LIMIT (TWODOTFOUR_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8)
9-
108
static bool initBoot() {
11-
return driver::pwmbacklight::init(TWODOTFOUR_LCD_PIN_BACKLIGHT);
9+
// Set the RGB LED Pins to output and turn them off
10+
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT)); // Red
11+
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_16, GPIO_MODE_OUTPUT)); // Green
12+
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_17, GPIO_MODE_OUTPUT)); // Blue
13+
14+
// 0 on, 1 off
15+
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_4, 1)); // Red
16+
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_16, 1)); // Green
17+
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_17, 1)); // Blue
18+
19+
return driver::pwmbacklight::init(LCD_PIN_BACKLIGHT);
1220
}
1321

1422
static tt::hal::DeviceVector createDevices() {
@@ -18,7 +26,7 @@ static tt::hal::DeviceVector createDevices() {
1826
};
1927
}
2028

21-
const tt::hal::Configuration cyd_2432s024c_config = {
29+
extern const tt::hal::Configuration hardwareConfiguration = {
2230
.initBoot = initBoot,
2331
.createDevices = createDevices,
2432
.i2c = {
@@ -72,7 +80,7 @@ const tt::hal::Configuration cyd_2432s024c_config = {
7280
.data6_io_num = GPIO_NUM_NC,
7381
.data7_io_num = GPIO_NUM_NC,
7482
.data_io_default_level = false,
75-
.max_transfer_sz = CYD_SPI_TRANSFER_SIZE_LIMIT,
83+
.max_transfer_sz = LCD_SPI_TRANSFER_SIZE_LIMIT,
7684
.flags = 0,
7785
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
7886
.intr_flags = 0

Boards/CYD-2432S024C/Source/devices/Display.cpp

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,30 @@ static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
1616
}
1717

1818
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
19-
20-
auto touch = createTouch();
21-
22-
auto configuration = std::make_unique<Ili934xDisplay::Configuration>(
23-
TWODOTFOUR_LCD_SPI_HOST,
24-
TWODOTFOUR_LCD_PIN_CS,
25-
TWODOTFOUR_LCD_PIN_DC,
26-
TWODOTFOUR_LCD_HORIZONTAL_RESOLUTION,
27-
TWODOTFOUR_LCD_VERTICAL_RESOLUTION,
28-
touch
29-
);
30-
31-
configuration->mirrorX = true;
32-
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
33-
34-
auto display = std::make_shared<Ili934xDisplay>(std::move(configuration));
35-
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
19+
Ili934xDisplay::Configuration panel_configuration = {
20+
.horizontalResolution = LCD_HORIZONTAL_RESOLUTION,
21+
.verticalResolution = LCD_VERTICAL_RESOLUTION,
22+
.gapX = 0,
23+
.gapY = 0,
24+
.swapXY = false,
25+
.mirrorX = true,
26+
.mirrorY = false,
27+
.invertColor = false,
28+
.swapBytes = true,
29+
.bufferSize = LCD_BUFFER_SIZE,
30+
.touch = createTouch(),
31+
.backlightDutyFunction = driver::pwmbacklight::setBacklightDuty,
32+
.resetPin = GPIO_NUM_NC,
33+
.rgbElementOrder = LCD_RGB_ELEMENT_ORDER_BGR
34+
};
35+
36+
auto spi_configuration = std::make_shared<Ili934xDisplay::SpiConfiguration>(Ili934xDisplay::SpiConfiguration {
37+
.spiHostDevice = LCD_SPI_HOST,
38+
.csPin = LCD_PIN_CS,
39+
.dcPin = LCD_PIN_DC,
40+
.pixelClockFrequency = 40'000'000,
41+
.transactionQueueDepth = 10
42+
});
43+
44+
return std::make_shared<Ili934xDisplay>(panel_configuration, spi_configuration, true);
3645
}
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
#pragma once
22

3-
#include "Tactility/hal/display/DisplayDevice.h"
3+
#include <Tactility/hal/display/DisplayDevice.h>
4+
#include <driver/gpio.h>
5+
#include <driver/spi_common.h>
46
#include <memory>
57

6-
#define TWODOTFOUR_LCD_PIN_BACKLIGHT GPIO_NUM_27
7-
88
// Display
9-
#define TWODOTFOUR_LCD_SPI_HOST SPI2_HOST
10-
#define TWODOTFOUR_LCD_HORIZONTAL_RESOLUTION 240
11-
#define TWODOTFOUR_LCD_VERTICAL_RESOLUTION 320
12-
#define TWODOTFOUR_LCD_DRAW_BUFFER_HEIGHT (TWODOTFOUR_LCD_VERTICAL_RESOLUTION / 10)
13-
#define TWODOTFOUR_LCD_DRAW_BUFFER_SIZE (TWODOTFOUR_LCD_HORIZONTAL_RESOLUTION * TWODOTFOUR_LCD_DRAW_BUFFER_HEIGHT)
14-
#define TWODOTFOUR_LCD_PIN_CS GPIO_NUM_15
15-
#define TWODOTFOUR_LCD_PIN_DC GPIO_NUM_2
9+
constexpr auto LCD_PIN_BACKLIGHT = GPIO_NUM_27;
10+
constexpr auto LCD_SPI_HOST = SPI2_HOST;
11+
constexpr auto LCD_PIN_CS = GPIO_NUM_15;
12+
constexpr auto LCD_PIN_DC = GPIO_NUM_2;
13+
constexpr auto LCD_HORIZONTAL_RESOLUTION = 240;
14+
constexpr auto LCD_VERTICAL_RESOLUTION = 320;
15+
constexpr auto LCD_BUFFER_HEIGHT = LCD_VERTICAL_RESOLUTION / 10;
16+
constexpr auto LCD_BUFFER_SIZE = LCD_HORIZONTAL_RESOLUTION * LCD_BUFFER_HEIGHT;
17+
constexpr auto LCD_SPI_TRANSFER_SIZE_LIMIT = LCD_BUFFER_SIZE * LV_COLOR_DEPTH / 8;
1618

1719
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

Boards/CYD-2432S028R/Source/CYD2432S028R.h

Lines changed: 0 additions & 6 deletions
This file was deleted.

Boards/CYD-2432S028RV3/Source/CYD2432S028RV3.cpp renamed to Boards/CYD-2432S028R/Source/Configuration.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
#include "CYD2432S028RV3.h"
21
#include "devices/Display.h"
32
#include "devices/SdCard.h"
3+
4+
#include <Tactility/hal/Configuration.h>
45
#include <Tactility/lvgl/LvglSync.h>
56
#include <PwmBacklight.h>
6-
#include <Tactility/hal/Configuration.h>
77

88
using namespace tt::hal;
99

1010
static bool initBoot() {
1111
// Set the RGB LED Pins to output and turn them off
12-
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT)); //Red
13-
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_16, GPIO_MODE_OUTPUT)); //Green
14-
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_17, GPIO_MODE_OUTPUT)); //Blue
12+
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT)); // Red
13+
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_16, GPIO_MODE_OUTPUT)); // Green
14+
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_17, GPIO_MODE_OUTPUT)); // Blue
1515

16-
// 0 on, 1 off... yep it's backwards.
17-
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_4, 1)); //Red
18-
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_16, 1)); //Green
19-
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_17, 1)); //Blue
16+
// 0 on, 1 off
17+
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_4, 1)); // Red
18+
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_16, 1)); // Green
19+
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_17, 1)); // Blue
2020

2121
return driver::pwmbacklight::init(LCD_PIN_BACKLIGHT);
2222
}
@@ -28,7 +28,7 @@ static DeviceVector createDevices() {
2828
};
2929
}
3030

31-
const Configuration cyd_2432s028rv3_config = {
31+
extern const Configuration hardwareConfiguration = {
3232
.initBoot = initBoot,
3333
.createDevices = createDevices,
3434
.i2c = {

Boards/CYD-2432S028R/Source/devices/Display.cpp

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,47 @@
33
#include <Ili934xDisplay.h>
44
#include <PwmBacklight.h>
55

6-
constexpr auto* TAG = "CYD";
7-
86
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
97
auto configuration = std::make_unique<Xpt2046SoftSpi::Configuration>(
10-
CYD_TOUCH_MOSI_PIN,
11-
CYD_TOUCH_MISO_PIN,
12-
CYD_TOUCH_SCK_PIN,
13-
CYD_TOUCH_CS_PIN,
14-
CYD2432S028R_LCD_HORIZONTAL_RESOLUTION, // 240
15-
CYD2432S028R_LCD_VERTICAL_RESOLUTION, // 320
8+
TOUCH_MOSI_PIN,
9+
TOUCH_MISO_PIN,
10+
TOUCH_SCK_PIN,
11+
TOUCH_CS_PIN,
12+
LCD_HORIZONTAL_RESOLUTION,
13+
LCD_VERTICAL_RESOLUTION,
1614
false, // swapXY
1715
true, // mirrorX
1816
false // mirrorY
1917
);
2018

21-
// Allocate the driver
22-
auto touch = std::make_shared<Xpt2046SoftSpi>(std::move(configuration));
23-
24-
// Start the driver
25-
if (!touch->start()) {
26-
ESP_LOGE(TAG, "Touch driver start failed");
27-
return nullptr;
28-
}
29-
30-
return touch;
19+
return std::make_shared<Xpt2046SoftSpi>(std::move(configuration));
3120
}
3221

3322
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
34-
auto touch = createTouch();
35-
36-
auto configuration = std::make_unique<Ili934xDisplay::Configuration>(
37-
CYD2432S028R_LCD_SPI_HOST,
38-
CYD2432S028R_LCD_PIN_CS,
39-
CYD2432S028R_LCD_PIN_DC,
40-
CYD2432S028R_LCD_HORIZONTAL_RESOLUTION,
41-
CYD2432S028R_LCD_VERTICAL_RESOLUTION,
42-
touch,
43-
false, // swapXY
44-
true, // mirrorX
45-
false, // mirrorY
46-
false,
47-
CYD2432S028R_LCD_DRAW_BUFFER_SIZE
48-
);
49-
50-
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
51-
52-
auto display = std::make_shared<Ili934xDisplay>(std::move(configuration));
53-
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
23+
Ili934xDisplay::Configuration panel_configuration = {
24+
.horizontalResolution = LCD_HORIZONTAL_RESOLUTION,
25+
.verticalResolution = LCD_VERTICAL_RESOLUTION,
26+
.gapX = 0,
27+
.gapY = 0,
28+
.swapXY = false,
29+
.mirrorX = true,
30+
.mirrorY = false,
31+
.invertColor = false,
32+
.swapBytes = true,
33+
.bufferSize = LCD_BUFFER_SIZE,
34+
.touch = createTouch(),
35+
.backlightDutyFunction = driver::pwmbacklight::setBacklightDuty,
36+
.resetPin = GPIO_NUM_NC,
37+
.rgbElementOrder = LCD_RGB_ELEMENT_ORDER_BGR
38+
};
39+
40+
auto spi_configuration = std::make_shared<Ili934xDisplay::SpiConfiguration>(Ili934xDisplay::SpiConfiguration {
41+
.spiHostDevice = LCD_SPI_HOST,
42+
.csPin = LCD_PIN_CS,
43+
.dcPin = LCD_PIN_DC,
44+
.pixelClockFrequency = 40'000'000,
45+
.transactionQueueDepth = 10
46+
});
47+
48+
return std::make_shared<Ili934xDisplay>(panel_configuration, spi_configuration, true);
5449
}
Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
#pragma once
22

3-
#include "Tactility/hal/display/DisplayDevice.h"
3+
#include <Tactility/hal/display/DisplayDevice.h>
4+
#include <driver/gpio.h>
5+
#include <driver/spi_common.h>
46
#include <memory>
57

68
// Display
7-
#define CYD2432S028R_LCD_SPI_HOST SPI2_HOST
8-
#define CYD2432S028R_LCD_HORIZONTAL_RESOLUTION 240
9-
#define CYD2432S028R_LCD_VERTICAL_RESOLUTION 320
10-
#define CYD2432S028R_LCD_DRAW_BUFFER_HEIGHT (CYD2432S028R_LCD_VERTICAL_RESOLUTION / 10)
11-
#define CYD2432S028R_LCD_DRAW_BUFFER_SIZE (CYD2432S028R_LCD_HORIZONTAL_RESOLUTION * CYD2432S028R_LCD_DRAW_BUFFER_HEIGHT)
12-
#define CYD2432S028R_LCD_PIN_CS GPIO_NUM_15
13-
#define CYD2432S028R_LCD_PIN_DC GPIO_NUM_2
9+
constexpr auto LCD_SPI_HOST = SPI2_HOST;
10+
constexpr auto LCD_PIN_CS = GPIO_NUM_15;
11+
constexpr auto LCD_PIN_DC = GPIO_NUM_2;
12+
constexpr auto LCD_HORIZONTAL_RESOLUTION = 240;
13+
constexpr auto LCD_VERTICAL_RESOLUTION = 320;
14+
constexpr auto LCD_BUFFER_HEIGHT = LCD_VERTICAL_RESOLUTION / 10;
15+
constexpr auto LCD_BUFFER_SIZE = LCD_HORIZONTAL_RESOLUTION * LCD_BUFFER_HEIGHT;
16+
constexpr auto LCD_SPI_TRANSFER_SIZE_LIMIT = LCD_BUFFER_SIZE * LV_COLOR_DEPTH / 8;
17+
18+
// Display backlight (PWM)
19+
constexpr auto LCD_PIN_BACKLIGHT = GPIO_NUM_21;
1420

1521
// Touch (Software SPI)
16-
#define CYD_TOUCH_MISO_PIN GPIO_NUM_39
17-
#define CYD_TOUCH_MOSI_PIN GPIO_NUM_32
18-
#define CYD_TOUCH_SCK_PIN GPIO_NUM_25
19-
#define CYD_TOUCH_CS_PIN GPIO_NUM_33
20-
#define CYD_TOUCH_IRQ_PIN GPIO_NUM_36
22+
constexpr auto TOUCH_MISO_PIN = GPIO_NUM_39;
23+
constexpr auto TOUCH_MOSI_PIN = GPIO_NUM_32;
24+
constexpr auto TOUCH_SCK_PIN = GPIO_NUM_25;
25+
constexpr auto TOUCH_CS_PIN = GPIO_NUM_33;
26+
constexpr auto TOUCH_IRQ_PIN = GPIO_NUM_36;
2127

2228
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

Boards/CYD-2432S028RV3/Source/CYD2432S028RV3.h

Lines changed: 0 additions & 6 deletions
This file was deleted.

Boards/CYD-2432S028R/Source/CYD2432S028R.cpp renamed to Boards/CYD-2432S028RV3/Source/Configuration.cpp

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
1-
#include "CYD2432S028R.h"
21
#include "devices/Display.h"
32
#include "devices/SdCard.h"
3+
4+
#include <Tactility/hal/Configuration.h>
45
#include <Tactility/lvgl/LvglSync.h>
56
#include <PwmBacklight.h>
6-
#include <Tactility/hal/Configuration.h>
7-
8-
// SPI Transfer
9-
#define CYD_SPI_TRANSFER_SIZE_LIMIT (CYD2432S028R_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8)
10-
// Display backlight (PWM)
11-
#define CYD2432S028R_LCD_PIN_BACKLIGHT GPIO_NUM_21
127

138
using namespace tt::hal;
149

1510
static bool initBoot() {
16-
//Set the RGB Led Pins to output and turn them off
17-
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT)); //Red
18-
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_16, GPIO_MODE_OUTPUT)); //Green
19-
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_17, GPIO_MODE_OUTPUT)); //Blue
11+
// Set the RGB LED Pins to output and turn them off
12+
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT)); // Red
13+
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_16, GPIO_MODE_OUTPUT)); // Green
14+
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_17, GPIO_MODE_OUTPUT)); // Blue
2015

21-
//0 on, 1 off... yep it's backwards.
22-
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_4, 1)); //Red
23-
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_16, 1)); //Green
24-
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_17, 1)); //Blue
16+
// 0 on, 1 off
17+
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_4, 1)); // Red
18+
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_16, 1)); // Green
19+
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_17, 1)); // Blue
2520

26-
return driver::pwmbacklight::init(CYD2432S028R_LCD_PIN_BACKLIGHT);
21+
return driver::pwmbacklight::init(LCD_PIN_BACKLIGHT);
2722
}
2823

2924
static DeviceVector createDevices() {
@@ -33,7 +28,7 @@ static DeviceVector createDevices() {
3328
};
3429
}
3530

36-
const Configuration cyd_2432s028r_config = {
31+
extern const Configuration hardwareConfiguration = {
3732
.initBoot = initBoot,
3833
.createDevices = createDevices,
3934
.i2c = {
@@ -71,7 +66,7 @@ const Configuration cyd_2432s028r_config = {
7166
.data6_io_num = GPIO_NUM_NC,
7267
.data7_io_num = GPIO_NUM_NC,
7368
.data_io_default_level = false,
74-
.max_transfer_sz = CYD_SPI_TRANSFER_SIZE_LIMIT,
69+
.max_transfer_sz = LCD_SPI_TRANSFER_SIZE_LIMIT,
7570
.flags = 0,
7671
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
7772
.intr_flags = 0

0 commit comments

Comments
 (0)