Skip to content

Commit 4f91d9d

Browse files
authored
Merge branch 'main' into feat/icm42670-imu
2 parents 68c55a4 + 7281900 commit 4f91d9d

File tree

36 files changed

+137
-57
lines changed

36 files changed

+137
-57
lines changed

.github/workflows/static_analysis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ jobs:
1414
steps:
1515
- name: Checkout repo
1616
uses: actions/checkout@v4
17-
with:
18-
submodules: 'recursive'
1917

2018
- name: Run static analysis
2119
uses: esp-cpp/StaticAnalysis@master
2220
with:
21+
language: c++
22+
2323
# Do not build the project and do not use cmake to generate compile_commands.json
2424
use_cmake: false
2525

2626
# Use the 5.4 release version since it's what we build with
2727
esp_idf_version: release/v5.4
2828

2929
# (Optional) cppcheck args
30-
cppcheck_args: -i$GITHUB_WORKSPACE/lib -i$GITHUB_WORKSPACE/external -i$GITHUB_WORKSPACE/components/binary-log/detail -i$GITHUB_WORKSPACE/components/esp_littlefs -i$GITHUB_WORKSPACE/components/esp-nimble-cpp -i$GITHUB_WORKSPACE/components/hid-rp/include/hid -i$GITHUB_WORKSPACE/components/lvgl -i$GITHUB_WORKSPACE/components/esp-dsp --force --enable=all --inline-suppr --inconclusive --platform=mips32 --suppressions-list=$GITHUB_WORKSPACE/suppressions.txt
30+
cppcheck_args: -i$GITHUB_WORKSPACE/lib -i$GITHUB_WORKSPACE/components/state_machine/example/main -i$GITHUB_WORKSPACE/components/hid-rp/include/hid --check-level=exhaustive --force --enable=all --inline-suppr --inconclusive --platform=mips32 --suppressions-list=$GITHUB_WORKSPACE/suppressions.txt

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ the example
1313

1414
If you have questions or would like to chat, feel free to hop over to our discord!
1515

16-
<img src="https://discord.com/api/guilds/1345508990716743741/widget.png?style=banner2" alt="Discord Banner 2"/>
16+
[<img src="https://discord.com/api/guilds/1345508990716743741/widget.png?style=banner2" alt="Discord Banner 2"/>](https://discord.gg/dvcQw37xAY)
1717

1818
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->
1919
**Table of Contents**

components/adc/include/continuous_adc.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class ContinuousAdc : public espp::BaseComponent {
170170
return static_cast<int>(unit) * 32 + static_cast<int>(channel);
171171
}
172172

173-
bool update_task(std::mutex &task_m, std::condition_variable &task_cv, bool &task_notified) {
173+
bool update_task(std::mutex &, std::condition_variable &, bool &) {
174174
task_handle_ = xTaskGetCurrentTaskHandle();
175175
static auto previous_timestamp = std::chrono::high_resolution_clock::now();
176176
// wait until conversion is ready (will be notified by the registered

components/adc/include/oneshot_adc.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class OneshotAdc : public BaseComponent {
150150
memset(&init_config, 0, sizeof(init_config));
151151
init_config.unit_id = config.unit;
152152
ESP_ERROR_CHECK(adc_oneshot_new_unit(&init_config, &adc_handle_));
153-
for (auto &conf : config.channels) {
153+
for (const auto &conf : config.channels) {
154154
auto channel = conf.channel;
155155
auto attenuation = conf.attenuation;
156156
auto channel_unit = conf.unit;

components/ads7138/example/main/ads7138_example.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ extern "C" void app_main(void) {
125125

126126
// start the gpio task
127127
auto alert_task = espp::Task::make_unique({
128-
.callback = [&ads](auto &m, auto &cv) -> bool {
128+
.callback = [&ads](auto &, auto &) -> bool {
129129
static uint32_t io_num;
130130
// block until we get a message from the interrupt handler
131131
if (xQueueReceive(gpio_evt_queue, &io_num, portMAX_DELAY)) {

components/ble_gatt_server/example/main/ble_gatt_server_example.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ extern "C" void app_main(void) {
2424
std::string device_name = "Espp BLE GATT Server";
2525
ble_gatt_server.set_log_level(espp::Logger::Verbosity::INFO);
2626
ble_gatt_server.set_callbacks({
27-
.connect_callback = [&](NimBLEConnInfo &conn_info) { logger.info("Device connected"); },
28-
.disconnect_callback = [&](auto &conn_info,
27+
.connect_callback =
28+
[&](const NimBLEConnInfo &conn_info) { logger.info("Device connected"); },
29+
.disconnect_callback = [&](const auto &conn_info,
2930
auto reason) { logger.info("Device disconnected: {}", reason); },
3031
.authentication_complete_callback =
3132
[&](const NimBLEConnInfo &conn_info) { logger.info("Device authenticated"); },

components/bm8563/example/main/bm8563_example.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ using namespace std::chrono_literals;
1010

1111
extern "C" void app_main(void) {
1212
{
13-
std::atomic<bool> quit_test = false;
1413
fmt::print("Starting tt2100 example\n");
1514
//! [bm8563 example]
1615
// make the I2C that we'll use to communicate

components/button/example/main/button_example.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ extern "C" void app_main(void) {
3131
//! [button example]
3232
static auto start = std::chrono::high_resolution_clock::now();
3333
std::string button_topic = "button/state";
34-
std::string button_component_name = "button";
3534

3635
// create a button
3736
espp::Button button({

components/chsc6x/example/main/chsc6x_example.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ using namespace std::chrono_literals;
1010

1111
extern "C" void app_main(void) {
1212
{
13-
std::atomic<bool> quit_test = false;
1413
fmt::print("Starting chsc6x example\n");
1514
//! [chsc6x example]
1615
// make the I2C that we'll use to communicate

components/cli/include/line_input.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class LineInput {
8484
* @brief Get the input history.
8585
* @return The input that has been entered so far, as History.
8686
*/
87-
History get_history() const { return input_history_; }
87+
const History &get_history() const { return input_history_; }
8888

8989
/**
9090
* @brief Replace any existing input history with \p history.

components/cst816/example/main/cst816_example.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ using namespace std::chrono_literals;
1010

1111
extern "C" void app_main(void) {
1212
{
13-
std::atomic<bool> quit_test = false;
1413
fmt::print("Starting cst816 example\n");
1514
//! [cst816 example]
1615
// make the I2C that we'll use to communicate

components/display/include/display.hpp

+74-11
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,18 @@ template <typename Pixel> class Display : public BaseComponent {
4444
/**
4545
* @brief Callback for lvgl to flush segments of pixel data from the pixel
4646
* buffers to the display.
47+
* @param disp The display to flush data to.
48+
* @param area The area of the display to flush data to.
49+
* @param color_map The color data to flush to the display.
4750
*/
48-
using flush_fn = lv_display_flush_cb_t;
51+
typedef std::function<void(lv_display_t *disp, const lv_area_t *area, uint8_t *color_map)>
52+
flush_fn;
4953

5054
/**
5155
* @brief Callback for lvgl event handler to reconfigure the display hardware.
56+
* @param rotation The new rotation setting for the display.
5257
*/
53-
typedef void (*rotation_fn)(const DisplayRotation &rotation);
58+
typedef std::function<void(const DisplayRotation &rotation)> rotation_fn;
5459

5560
/**
5661
* @brief Callback for setting the display brightness.
@@ -325,20 +330,64 @@ template <typename Pixel> class Display : public BaseComponent {
325330
*/
326331
size_t vram_size_bytes() const { return display_buffer_px_size_ * sizeof(Pixel); }
327332

333+
/**
334+
* @brief Set the rotation of the display.
335+
* @note This function is called by the event handler when the display
336+
* resolution changes, so that the display hardware can be reconfigured
337+
* to match the new software rotation setting.
338+
* @param rotation The new rotation setting for the display.
339+
*/
340+
void set_rotation(DisplayRotation rotation) {
341+
if (rotation_callback_ != nullptr) {
342+
rotation_callback_(rotation);
343+
}
344+
}
345+
346+
/**
347+
* @brief Flush the data to the display.
348+
* @warning This function is called by the LVGL flush callback, so it is
349+
* recommended to not call this function directly.
350+
* @param disp The display to flush data to.
351+
* @param area The area of the display to flush data to.
352+
* @param color_map The color data to flush to the display.
353+
*/
354+
void flush(lv_display_t *disp, const lv_area_t *area, uint8_t *color_map) {
355+
if (flush_callback_ != nullptr) {
356+
flush_callback_(disp, area, color_map);
357+
}
358+
}
359+
328360
protected:
329361
/**
330362
* @brief LVGL event handler.
363+
* @param event The event to handle.
331364
*/
332365
static void event_cb(lv_event_t *event) {
333366
if (lv_event_get_code(event) == LV_EVENT_RESOLUTION_CHANGED) {
334-
auto rotation = lv_display_get_rotation(lv_display_get_default());
335-
auto rotation_callback = reinterpret_cast<rotation_fn>(lv_event_get_user_data(event));
336-
if (rotation_callback != nullptr) {
337-
rotation_callback(static_cast<DisplayRotation>(rotation));
367+
auto rotation =
368+
static_cast<DisplayRotation>(lv_display_get_rotation(lv_display_get_default()));
369+
auto display = static_cast<Display *>(lv_display_get_user_data(lv_disp_get_default()));
370+
if (display != nullptr) {
371+
display->set_rotation(rotation);
338372
}
339373
}
340374
};
341375

376+
/**
377+
* @brief Callback for the LVGL flush function to call when it needs to flush
378+
* data to the display.
379+
* @param disp The display to flush data to.
380+
* @param area The area of the display to flush data to.
381+
* @param color_map The color data to flush to the display.
382+
*/
383+
static void flush_cb(lv_display_t *disp, const lv_area_t *area, uint8_t *color_map) {
384+
// use the display to call the registered flush callback appropriately
385+
auto display = static_cast<Display *>(lv_display_get_user_data(disp));
386+
if (display != nullptr) {
387+
display->flush(disp, area, color_map);
388+
}
389+
}
390+
342391
/**
343392
* @brief Initialize the lvgl subsystem, display buffer configuration, and
344393
* display driver. Start the task to run the high-priority lvgl
@@ -350,19 +399,31 @@ template <typename Pixel> class Display : public BaseComponent {
350399
*/
351400
void init_gfx(const flush_fn flush_callback, const rotation_fn rotation_callback,
352401
DisplayRotation rotation, const Task::BaseConfig &task_config) {
402+
// save the callbacks
403+
if (flush_callback == nullptr) {
404+
logger_.error("No flush callback provided, cannot initialize display!");
405+
assert(false); // cannot continue without a flush callback
406+
}
407+
flush_callback_ = flush_callback;
408+
if (rotation_callback == nullptr) {
409+
logger_.warn("No rotation callback provided, resolution changed event will not automatically "
410+
"update the display hardware rotation.");
411+
}
412+
rotation_callback_ = rotation_callback;
413+
353414
lv_init();
354415

355416
display_ = lv_display_create(width_, height_);
417+
// store a pointer to this object in the display user data, so that we can
418+
// access it in the flush callback
419+
lv_display_set_user_data(display_, this);
356420

357421
// Configure the lvgl display buffer with our pixel buffers
358422
lv_display_set_buffers(display_, vram_0_, vram_1_, vram_size_bytes(),
359423
LV_DISPLAY_RENDER_MODE_PARTIAL);
360-
lv_display_set_flush_cb(display_, flush_callback);
424+
lv_display_set_flush_cb(display_, Display::flush_cb);
361425

362-
if (rotation_callback != nullptr) {
363-
lv_display_add_event_cb(display_, event_cb, LV_EVENT_RESOLUTION_CHANGED,
364-
reinterpret_cast<void *>(rotation_callback));
365-
}
426+
lv_display_add_event_cb(display_, event_cb, LV_EVENT_RESOLUTION_CHANGED, this);
366427

367428
lv_display_set_rotation(display_, static_cast<lv_display_rotation_t>(rotation));
368429

@@ -449,6 +510,8 @@ template <typename Pixel> class Display : public BaseComponent {
449510
std::unique_ptr<Task> task_;
450511
size_t width_;
451512
size_t height_;
513+
flush_fn flush_callback_{nullptr};
514+
rotation_fn rotation_callback_{nullptr};
452515
size_t display_buffer_px_size_;
453516
Pixel *vram_0_{nullptr};
454517
Pixel *vram_1_{nullptr};

components/display_drivers/example/main/display_drivers_example.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ static constexpr int DC_LEVEL_BIT = (1 << (int)espp::display_drivers::Flags::DC_
5656
// (DC_LEVEL_BIT).
5757
// Except for the T-Encoder Pro, which does not have a D/C line.
5858
#ifndef CONFIG_T_ENCODER_PRO
59+
// cppcheck-suppress constParameterCallback
5960
static void IRAM_ATTR lcd_spi_pre_transfer_callback(spi_transaction_t *t) {
6061
uint32_t user_flags = (uint32_t)(t->user);
6162
bool dc_level = user_flags & DC_LEVEL_BIT;
@@ -68,6 +69,8 @@ static void IRAM_ATTR lcd_spi_pre_transfer_callback(spi_transaction_t *t) {
6869
// This function is called (in irq context!) just after a transmission ends. It
6970
// will indicate to lvgl that the next flush is ready to be done if the
7071
// FLUSH_BIT is set.
72+
//
73+
// cppcheck-suppress constParameterCallback
7174
static void IRAM_ATTR lcd_spi_post_transfer_callback(spi_transaction_t *t) {
7275
uint16_t user_flags = (uint32_t)(t->user);
7376
bool should_flush = user_flags & FLUSH_BIT;

components/esp-box/example/main/esp_box_example.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ static size_t load_audio() {
243243
}
244244

245245
// these are configured in the CMakeLists.txt file
246-
extern const char wav_start[] asm("_binary_click_wav_start");
247-
extern const char wav_end[] asm("_binary_click_wav_end");
246+
extern const char wav_start[] asm("_binary_click_wav_start"); // cppcheck-suppress syntaxError
247+
extern const char wav_end[] asm("_binary_click_wav_end"); // cppcheck-suppress syntaxError
248248

249249
// -1 due to the size being 1 byte too large, I think because end is the byte
250250
// immediately after the last byte in the memory but I'm not sure - cmm 2022-08-20

components/esp-box/src/video.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ static constexpr int DC_LEVEL_BIT = (1 << (int)espp::display_drivers::Flags::DC_
1515
// This function is called (in irq context!) just before a transmission starts.
1616
// It will set the D/C line to the value indicated in the user field
1717
// (DC_LEVEL_BIT).
18+
//
19+
// cppcheck-suppress constParameterCallback
1820
static void lcd_spi_pre_transfer_callback(spi_transaction_t *t) {
1921
static auto lcd_dc_io = EspBox::get_lcd_dc_gpio();
2022
uint32_t user_flags = (uint32_t)(t->user);
@@ -25,6 +27,8 @@ static void lcd_spi_pre_transfer_callback(spi_transaction_t *t) {
2527
// This function is called (in irq context!) just after a transmission ends. It
2628
// will indicate to lvgl that the next flush is ready to be done if the
2729
// FLUSH_BIT is set.
30+
//
31+
// cppcheck-suppress constParameterCallback
2832
static void lcd_spi_post_transfer_callback(spi_transaction_t *t) {
2933
uint16_t user_flags = (uint32_t)(t->user);
3034
bool should_flush = user_flags & FLUSH_BIT;

components/ft5x06/example/main/ft5x06_example.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ using namespace std::chrono_literals;
1010

1111
extern "C" void app_main(void) {
1212
{
13-
std::atomic<bool> quit_test = false;
1413
fmt::print("Starting ft5x06 example\n");
1514
//! [ft5x06 example]
1615
// make the I2C that we'll use to communicate

components/gfps_service/example/main/gfps_service_example.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ extern "C" void app_main(void) {
2121
std::string device_name = "ESP++ GFPS";
2222
ble_gatt_server.set_log_level(espp::Logger::Verbosity::INFO);
2323
ble_gatt_server.set_callbacks({
24-
.connect_callback = [&](NimBLEConnInfo &conn_info) { logger.info("Device connected"); },
25-
.disconnect_callback = [&](auto &conn_info,
24+
.connect_callback = [&](const NimBLEConnInfo &conn_info) { logger.info("Device connected"); },
25+
.disconnect_callback = [&](const auto &conn_info,
2626
auto reason) { logger.info("Device disconnected: {}", reason); },
2727
.authentication_complete_callback =
2828
[&](const NimBLEConnInfo &conn_info) { logger.info("Device authenticated"); },

components/gfps_service/src/nearby_audio.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ bool nearby_platform_AutoReconnected() {
6363
// For example, if there are 5 bonded devices, then |length| should be set to 1.
6464
// Call |nearby_platform_AudioCallbacks::on_state_change| when this state
6565
// changes.
66-
void nearby_platform_GetConnectionBitmap(uint8_t *bitmap, size_t *length) {
66+
void nearby_platform_GetConnectionBitmap(uint8_t *, size_t *) {
6767
// TODO: implement
6868
}
6969

components/gfps_service/src/nearby_battery.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
// Gets battery and charging info
44
//
55
// battery_info - Battery status structure.
6-
nearby_platform_status nearby_platform_GetBatteryInfo(nearby_platform_BatteryInfo *battery_info) {
6+
nearby_platform_status nearby_platform_GetBatteryInfo(nearby_platform_BatteryInfo *) {
77
// TODO: Implement
88
return kNearbyStatusOK;
99
}
1010

1111
// Initializes battery module
1212
//
1313
// battery_interface - Battery status callback events.
14-
nearby_platform_status
15-
nearby_platform_BatteryInit(nearby_platform_BatteryInterface *battery_interface) {
14+
nearby_platform_status nearby_platform_BatteryInit(nearby_platform_BatteryInterface *) {
1615
// TODO: Implement
1716
return kNearbyStatusOK;
1817
}

components/gt911/example/main/gt911_example.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ using namespace std::chrono_literals;
1010

1111
extern "C" void app_main(void) {
1212
{
13-
std::atomic<bool> quit_test = false;
1413
fmt::print("Starting gt911 example\n");
1514
//! [gt911 example]
1615
// make the I2C that we'll use to communicate

components/hid-rp/include/hid-rp-switch-pro.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class SwitchProGamepadInputReport : public hid::report::base<hid::report::type::
192192
// fill all 0s
193193
std::fill(raw_report, raw_report + sizeof(raw_report), 0);
194194
// now set the counter to the previous value
195-
counter = prev_counter;
195+
counter = prev_counter; // cppcheck-suppress redundantAssignment
196196
// set the joysticks to 0 since their config may not put them at 0
197197
set_left_joystick(0, 0);
198198
set_right_joystick(0, 0);

components/hid_service/example/main/hid_service_example.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ extern "C" void app_main(void) {
6969
std::string device_name = "ESP++ HID";
7070
ble_gatt_server.set_log_level(espp::Logger::Verbosity::INFO);
7171
ble_gatt_server.set_callbacks({
72-
.connect_callback = [&](NimBLEConnInfo &conn_info) { logger.info("Device connected"); },
73-
.disconnect_callback = [&](auto &conn_info,
72+
.connect_callback = [&](const NimBLEConnInfo &conn_info) { logger.info("Device connected"); },
73+
.disconnect_callback = [&](const auto &conn_info,
7474
auto reason) { logger.info("Device disconnected: {}", reason); },
7575
.authentication_complete_callback =
7676
[&](const NimBLEConnInfo &conn_info) { logger.info("Device authenticated"); },

components/interrupt/include/interrupt.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ class Interrupt : public BaseComponent {
407407
return level == static_cast<int>(active_level);
408408
}
409409

410-
bool task_callback(std::mutex &m, std::condition_variable &cv, bool &task_notified) {
410+
bool task_callback(std::mutex &, std::condition_variable &, bool &) {
411411
EventData event_data;
412412
// record the min number of free spaces in the queue
413413
size_t free_spaces = uxQueueSpacesAvailable(queue_);

0 commit comments

Comments
 (0)