Skip to content

Commit 4eb3c51

Browse files
committed
feat: update
1 parent ea1f506 commit 4eb3c51

11 files changed

+28
-30
lines changed

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ idf_component_register(
99
REQUIRES driver esp_lcd
1010
)
1111

12-
target_compile_options(${COMPONENT_LIB} PUBLIC -Wno-missing-field-initializers)
12+
target_compile_options(${COMPONENT_LIB}
13+
PUBLIC -Wno-missing-field-initializers
14+
PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-std=gnu++17>
15+
)

micropython.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ target_include_directories(usermod_esp_display_panel INTERFACE ${SRC_DIR} ${MPY_
2121
# Add compile options. Since the target is not created by `idf_component_register()`, we need to add the `ESP_PLATFORM` define manually.
2222
target_compile_options(usermod_esp_display_panel
2323
INTERFACE
24-
-Wno-missing-field-initializers -DESP_PLATFORM $<$<COMPILE_LANGUAGE:CXX>:-std=gnu++2b>
24+
-Wno-missing-field-initializers -DESP_PLATFORM $<$<COMPILE_LANGUAGE:CXX>:-std=gnu++17>
2525
)
2626

2727
# Link INTERFACE library to the usermod target.

src/drivers/io_expander/esp_panel_io_expander_adapter.hpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,17 @@
1313

1414
namespace esp_panel::drivers {
1515

16-
/**
17-
* @brief Concept to check whether a type is derived from `esp_expander::Base`
18-
*
19-
* @tparam T Type to be checked
20-
*/
21-
template<class T>
22-
concept CheckIsIO_ExpanderAdaptee = std::is_base_of_v<esp_expander::Base, T>;
2316

2417
/**
2518
* @brief Adapter class template for IO expander devices
2619
*
2720
* @tparam T Type of the IO expander device, must satisfy CheckIsIO_ExpanderAdaptee concept
2821
*/
2922
template <class T>
30-
requires CheckIsIO_ExpanderAdaptee<T>
3123
class IO_ExpanderAdapter: public IO_Expander, public T {
3224
public:
25+
static_assert(std::is_base_of_v<esp_expander::Base, T>, "`T` must be derived from `esp_expander::Base`");
26+
3327
/**
3428
* @brief Construct a new IO expander adapter
3529
*
@@ -94,7 +88,6 @@ class IO_ExpanderAdapter: public IO_Expander, public T {
9488
};
9589

9690
template <class T>
97-
requires CheckIsIO_ExpanderAdaptee<T>
9891
IO_ExpanderAdapter<T>::~IO_ExpanderAdapter()
9992
{
10093
ESP_UTILS_LOG_TRACE_ENTER_WITH_THIS();
@@ -105,7 +98,6 @@ IO_ExpanderAdapter<T>::~IO_ExpanderAdapter()
10598
}
10699

107100
template <class T>
108-
requires CheckIsIO_ExpanderAdaptee<T>
109101
bool IO_ExpanderAdapter<T>::init()
110102
{
111103
ESP_UTILS_LOG_TRACE_ENTER_WITH_THIS();
@@ -137,7 +129,6 @@ bool IO_ExpanderAdapter<T>::init()
137129
}
138130

139131
template <class T>
140-
requires CheckIsIO_ExpanderAdaptee<T>
141132
bool IO_ExpanderAdapter<T>::begin()
142133
{
143134
ESP_UTILS_LOG_TRACE_ENTER_WITH_THIS();
@@ -162,7 +153,6 @@ bool IO_ExpanderAdapter<T>::begin()
162153
}
163154

164155
template <class T>
165-
requires CheckIsIO_ExpanderAdaptee<T>
166156
bool IO_ExpanderAdapter<T>::del()
167157
{
168158
ESP_UTILS_LOG_TRACE_ENTER_WITH_THIS();

src/drivers/lcd/esp_panel_lcd.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
#include <algorithm>
78
#include <memory>
89
#include <numeric>
910
#include "sdkconfig.h"
@@ -801,10 +802,8 @@ bool LCD::colorBarTest(uint16_t width, uint16_t height)
801802
int res_line_count = 0;
802803

803804
/* Malloc memory for a single color bar */
804-
auto single_bar_buf_ptr = utils::make_shared<uint8_t[]>(row_per_bar * width * bytes_per_piexl);
805-
ESP_UTILS_CHECK_NULL_RETURN(single_bar_buf_ptr, false, "Alloc color buffer failed");
806-
807-
auto single_bar_buf = single_bar_buf_ptr.get();
805+
utils::vector<uint8_t> single_bar(row_per_bar * width * bytes_per_piexl);
806+
auto single_bar_buf = single_bar.data();
808807
auto bus_type = getBus()->getBasicAttributes().type;
809808
/* Draw color bar from top left to bottom right, the order is B - G - R */
810809
for (int j = 0; j < bits_per_piexl; j++) {

src/drivers/touch/esp_panel_touch.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -534,23 +534,23 @@ bool Touch::readRawDataPoints(int points_num)
534534
}
535535
ESP_UTILS_LOGD("Try to read %d points", points_num);
536536

537-
auto x_ptr = utils::make_shared<uint16_t[]>(points_num);
538-
auto y_ptr = utils::make_shared<uint16_t[]>(points_num);
539-
auto strength_ptr = utils::make_shared<uint16_t[]>(points_num);
540-
auto x = x_ptr.get();
541-
auto y = y_ptr.get();
542-
auto strength = strength_ptr.get();
537+
utils::vector<uint16_t> x(points_num);
538+
utils::vector<uint16_t> y(points_num);
539+
utils::vector<uint16_t> strength(points_num);
540+
auto x_buf = x.data();
541+
auto y_buf = y.data();
542+
auto strength_buf = strength.data();
543543
uint8_t ret_points_num = 0;
544544

545545
// Get the point coordinates from the raw data
546-
esp_lcd_touch_get_coordinates(touch_panel, x, y, strength, &ret_points_num, points_num);
546+
esp_lcd_touch_get_coordinates(touch_panel, x_buf, y_buf, strength_buf, &ret_points_num, points_num);
547547
ESP_UTILS_LOGD("Get %d points number", ret_points_num);
548548

549549
// Update the points
550550
std::unique_lock lock(_resource_mutex);
551551
_points.clear();
552552
for (int i = 0; i < ret_points_num; i++) {
553-
_points.emplace_back(x[i], y[i], strength[i]);
553+
_points.emplace_back(static_cast<int>(x_buf[i]), static_cast<int>(y_buf[i]), static_cast<int>(strength_buf[i]));
554554
}
555555
lock.unlock();
556556

src/drivers/touch/esp_panel_touch.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ namespace esp_panel::drivers {
2525
* Contains x/y coordinates and touch strength information for a single touch point
2626
*/
2727
struct TouchPoint {
28+
TouchPoint() = default;
29+
TouchPoint(int x, int y, int strength) : x(x), y(y), strength(strength) {}
30+
2831
/**
2932
* @brief Compare if two touch points are equal
3033
*

src/esp_display_panel.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#include "esp_panel_versions.h"
1111
#include "esp_panel_conf_internal.h"
1212

13+
/* Utils */
14+
#include "utils/esp_panel_utils_cxx.hpp"
15+
1316
/* Drivers */
1417
#include "drivers/bus/esp_panel_bus_factory.hpp"
1518
#include "drivers/lcd/esp_panel_lcd_factory.hpp"

src/utils/esp_panel_utils_map.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#pragma once
77

88
#include <unordered_map>
9-
#include "memory/esp_utils_mem.h"
9+
#include "esp_lib_utils.h"
1010

1111
namespace esp_panel::utils {
1212

src/utils/esp_panel_utils_memory.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#pragma once
77

88
#include <memory>
9-
#include "memory/esp_utils_mem.h"
9+
#include "esp_lib_utils.h"
1010

1111
namespace esp_panel::utils {
1212

src/utils/esp_panel_utils_string.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <string>
1111
#include <memory>
1212
#include <stdexcept>
13-
#include "memory/esp_utils_mem.h"
13+
#include "esp_lib_utils.h"
1414

1515
namespace esp_panel::utils {
1616

src/utils/esp_panel_utils_vector.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#pragma once
77

88
#include <vector>
9-
#include "memory/esp_utils_mem.h"
9+
#include "esp_lib_utils.h"
1010

1111
namespace esp_panel::utils {
1212

0 commit comments

Comments
 (0)