Skip to content

Commit 654374c

Browse files
authored
style: Apply style to all files (#327)
* style: Apply style to all files * lib: update readme and bindings * fix binding mods * fix numbering in readme
1 parent 0b907f2 commit 654374c

File tree

18 files changed

+645
-507
lines changed

18 files changed

+645
-507
lines changed

components/display_drivers/include/display_drivers.hpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ struct Config {
4343
command bits. */
4444
bool reset_value{false}; /**< The value to set the reset pin to when resetting the display (low to
4545
reset default). */
46-
bool invert_colors{false}; /**< Whether to invert the colors on the display. */
46+
bool invert_colors{false}; /**< Whether to invert the colors on the display. */
4747
bool swap_color_order{false}; /**< Whether to swap the color order (RGB/BGR) on the display. */
48-
int offset_x{0}; /**< X Gap / offset, in pixels. */
49-
int offset_y{0}; /**< Y Gap / offset, in pixels. */
50-
bool swap_xy{false}; /**< Swap row/column order. */
51-
bool mirror_x{false}; /**< Mirror the display horizontally. */
52-
bool mirror_y{false}; /**< Mirror the display vertically. */
53-
bool mirror_portrait{false}; /**< Mirror the display in portrait mode. */
48+
int offset_x{0}; /**< X Gap / offset, in pixels. */
49+
int offset_y{0}; /**< Y Gap / offset, in pixels. */
50+
bool swap_xy{false}; /**< Swap row/column order. */
51+
bool mirror_x{false}; /**< Mirror the display horizontally. */
52+
bool mirror_y{false}; /**< Mirror the display vertically. */
53+
bool mirror_portrait{false}; /**< Mirror the display in portrait mode. */
5454
};
5555

5656
/**

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

+15-12
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ extern "C" void app_main(void) {
6464
// set the pixel buffer to be 50 lines high
6565
static constexpr size_t pixel_buffer_size = box.lcd_width() * 50;
6666
espp::Task::BaseConfig display_task_config = {
67-
.name = "Display",
68-
.stack_size_bytes = 6 * 1024,
69-
.priority = 10,
70-
.core_id = 0,
67+
.name = "Display",
68+
.stack_size_bytes = 6 * 1024,
69+
.priority = 10,
70+
.core_id = 0,
7171
};
7272
// initialize the LVGL display for the esp-box
7373
if (!box.initialize_display(pixel_buffer_size, display_task_config)) {
@@ -100,14 +100,17 @@ extern "C" void app_main(void) {
100100
lv_label_set_text(label_btn, LV_SYMBOL_REFRESH);
101101
// center the text in the button
102102
lv_obj_align(label_btn, LV_ALIGN_CENTER, 0, 0);
103-
lv_obj_add_event_cb(btn, [](auto event) {
104-
std::lock_guard<std::recursive_mutex> lock(lvgl_mutex);
105-
clear_circles();
106-
static auto rotation = LV_DISPLAY_ROTATION_0;
107-
rotation = static_cast<lv_display_rotation_t>((static_cast<int>(rotation) + 1) % 4);
108-
lv_display_t *disp = _lv_refr_get_disp_refreshing();
109-
lv_disp_set_rotation(disp, rotation);
110-
}, LV_EVENT_PRESSED, nullptr);
103+
lv_obj_add_event_cb(
104+
btn,
105+
[](auto event) {
106+
std::lock_guard<std::recursive_mutex> lock(lvgl_mutex);
107+
clear_circles();
108+
static auto rotation = LV_DISPLAY_ROTATION_0;
109+
rotation = static_cast<lv_display_rotation_t>((static_cast<int>(rotation) + 1) % 4);
110+
lv_display_t *disp = _lv_refr_get_disp_refreshing();
111+
lv_disp_set_rotation(disp, rotation);
112+
},
113+
LV_EVENT_PRESSED, nullptr);
111114

112115
// disable scrolling on the screen (so that it doesn't behave weirdly when
113116
// rotated and drawing with your finger)

components/esp-box/src/esp-box.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,8 @@ bool EspBox::initialize_lcd() {
315315
return true;
316316
}
317317

318-
bool EspBox::initialize_display(size_t pixel_buffer_size, const espp::Task::BaseConfig &task_config, int update_period_ms) {
318+
bool EspBox::initialize_display(size_t pixel_buffer_size, const espp::Task::BaseConfig &task_config,
319+
int update_period_ms) {
319320
if (!lcd_handle_) {
320321
logger_.error(
321322
"LCD not initialized, you must call initialize_lcd() before initialize_display()!");

components/esp32-timer-cam/include/esp32-timer-cam.hpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class EspTimerCam : public BaseComponent {
6969
/// @brief Initialize the LED
7070
/// @param breathing_period The period of the LED breathing effect
7171
/// @return True if the LED was successfully initialized, false otherwise
72-
bool initialize_led(float breathing_period=3.5f);
72+
bool initialize_led(float breathing_period = 3.5f);
7373

7474
/// @brief Start the LED breathing effect
7575
void start_led_breathing();
@@ -207,7 +207,8 @@ class EspTimerCam : public BaseComponent {
207207
static constexpr gpio_num_t internal_i2c_scl = GPIO_NUM_14;
208208

209209
// Battery
210-
static constexpr float BATTERY_VOLTAGE_SCALE = 1.0f / 661.0f; // measured mV across divider to battery volts
210+
static constexpr float BATTERY_VOLTAGE_SCALE =
211+
1.0f / 661.0f; // measured mV across divider to battery volts
211212
static constexpr gpio_num_t battery_hold_pin = GPIO_NUM_33; // NOTE: unused
212213

213214
// Camera
@@ -258,14 +259,14 @@ class EspTimerCam : public BaseComponent {
258259

259260
// Battery ADC
260261
espp::AdcConfig battery_channel_{.unit = ADC_UNIT_1,
261-
.channel = ADC_CHANNEL_2, // GPIO 38
262-
.attenuation = ADC_ATTEN_DB_12};
262+
.channel = ADC_CHANNEL_2, // GPIO 38
263+
.attenuation = ADC_ATTEN_DB_12};
263264

264265
// NOTE: for some reason, I cannot use Continuous ADC in combination with
265266
// esp32-camera...
266267
espp::OneshotAdc adc_{{.unit = battery_channel_.unit,
267-
.channels = {battery_channel_},
268-
.log_level = espp::Logger::Verbosity::WARN}};
268+
.channels = {battery_channel_},
269+
.log_level = espp::Logger::Verbosity::WARN}};
269270

270271
}; // class EspTimerCam
271272
} // namespace espp

components/esp32-timer-cam/src/esp32-timer-cam.cpp

+20-27
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
using namespace espp;
44

5-
EspTimerCam::EspTimerCam() : BaseComponent("EspTimerCam") {
6-
}
5+
EspTimerCam::EspTimerCam()
6+
: BaseComponent("EspTimerCam") {}
77

88
////////////////////////
99
// LED //
@@ -20,7 +20,10 @@ bool EspTimerCam::initialize_led(float breathing_period) {
2020
.channels = led_channels_,
2121
.duty_resolution = LEDC_TIMER_10_BIT,
2222
});
23-
led_task_ = espp::Task::make_unique({.name = "breathe", .callback = std::bind(&EspTimerCam::led_task_callback, this, std::placeholders::_1, std::placeholders::_2)});
23+
led_task_ = espp::Task::make_unique(
24+
{.name = "breathe",
25+
.callback = std::bind(&EspTimerCam::led_task_callback, this, std::placeholders::_1,
26+
std::placeholders::_2)});
2427
set_led_breathing_period(breathing_period);
2528
return true;
2629
}
@@ -30,9 +33,7 @@ void EspTimerCam::start_led_breathing() {
3033
led_task_->start();
3134
}
3235

33-
void EspTimerCam::stop_led_breathing() {
34-
led_task_->stop();
35-
}
36+
void EspTimerCam::stop_led_breathing() { led_task_->stop(); }
3637

3738
bool EspTimerCam::set_led_brightness(float brightness) {
3839
if (led_ == nullptr) {
@@ -70,23 +71,17 @@ bool EspTimerCam::set_led_breathing_period(float breathing_period) {
7071
return true;
7172
}
7273

73-
float EspTimerCam::get_led_breathing_period() {
74-
return breathing_period_;
75-
}
74+
float EspTimerCam::get_led_breathing_period() { return breathing_period_; }
7675

77-
std::shared_ptr<espp::Led> EspTimerCam::led() {
78-
return led_;
79-
}
76+
std::shared_ptr<espp::Led> EspTimerCam::led() { return led_; }
8077

81-
espp::Gaussian &EspTimerCam::gaussian() {
82-
return gaussian_;
83-
}
78+
espp::Gaussian &EspTimerCam::gaussian() { return gaussian_; }
8479

8580
float EspTimerCam::led_breathe() {
86-
auto now = std::chrono::high_resolution_clock::now();
87-
auto elapsed = std::chrono::duration<float>(now - breathing_start_).count();
88-
float t = std::fmod(elapsed, breathing_period_) / breathing_period_;
89-
return gaussian_(t);
81+
auto now = std::chrono::high_resolution_clock::now();
82+
auto elapsed = std::chrono::duration<float>(now - breathing_start_).count();
83+
float t = std::fmod(elapsed, breathing_period_) / breathing_period_;
84+
return gaussian_(t);
9085
}
9186

9287
bool EspTimerCam::led_task_callback(std::mutex &m, std::condition_variable &cv) {
@@ -121,15 +116,13 @@ bool EspTimerCam::initialize_rtc() {
121116
return false;
122117
}
123118
rtc_ = std::make_shared<EspTimerCam::Rtc>(EspTimerCam::Rtc::Config{
124-
.write = std::bind(&espp::I2c::write, &internal_i2c_, std::placeholders::_1, std::placeholders::_2,
125-
std::placeholders::_3),
126-
.write_then_read =
127-
std::bind(&espp::I2c::write_read, &internal_i2c_, std::placeholders::_1, std::placeholders::_2,
128-
std::placeholders::_3, std::placeholders::_4, std::placeholders::_5),
119+
.write = std::bind(&espp::I2c::write, &internal_i2c_, std::placeholders::_1,
120+
std::placeholders::_2, std::placeholders::_3),
121+
.write_then_read = std::bind(&espp::I2c::write_read, &internal_i2c_, std::placeholders::_1,
122+
std::placeholders::_2, std::placeholders::_3,
123+
std::placeholders::_4, std::placeholders::_5),
129124
.log_level = espp::Logger::Verbosity::WARN});
130125
return true;
131126
}
132127

133-
std::shared_ptr<EspTimerCam::Rtc> EspTimerCam::rtc() {
134-
return rtc_;
135-
}
128+
std::shared_ptr<EspTimerCam::Rtc> EspTimerCam::rtc() { return rtc_; }

components/interrupt/include/interrupt.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ class Interrupt : public BaseComponent {
381381
// for printing the interrupt event using libfmt
382382
template <> struct fmt::formatter<espp::Interrupt::Event> {
383383
constexpr auto parse(format_parse_context &ctx) const { return ctx.begin(); }
384-
template <typename FormatContext> auto format(const espp::Interrupt::Event &t, FormatContext &ctx) const {
384+
template <typename FormatContext>
385+
auto format(const espp::Interrupt::Event &t, FormatContext &ctx) const {
385386
return fmt::format_to(ctx.out(), "Event{{gpio_num={}, active={}}}", t.gpio_num, t.active);
386387
}
387388
};

components/logger/include/logger.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ class Logger {
7474
#endif // CONFIG_ESPP_LOGGER_ENABLE_CURSOR_COMMANDS
7575
#endif // ESPP_LOGGER_CURSOR_COMMANDS_ENABLED
7676

77-
7877
public:
7978
/**
8079
* Verbosity levels for the logger, in order of increasing priority.

components/matouch-rotary-display/example/main/matouch_rotary_display_example.cpp

+11-8
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,17 @@ extern "C" void app_main(void) {
101101
lv_label_set_text(label_btn, LV_SYMBOL_REFRESH);
102102
// center the text in the button
103103
lv_obj_align(label_btn, LV_ALIGN_CENTER, 0, 0);
104-
lv_obj_add_event_cb(btn, [](auto event) {
105-
std::lock_guard<std::recursive_mutex> lock(lvgl_mutex);
106-
clear_circles();
107-
static auto rotation = LV_DISPLAY_ROTATION_0;
108-
rotation = static_cast<lv_display_rotation_t>((static_cast<int>(rotation) + 1) % 4);
109-
lv_display_t *disp = _lv_refr_get_disp_refreshing();
110-
lv_disp_set_rotation(disp, rotation);
111-
}, LV_EVENT_PRESSED, nullptr);
104+
lv_obj_add_event_cb(
105+
btn,
106+
[](auto event) {
107+
std::lock_guard<std::recursive_mutex> lock(lvgl_mutex);
108+
clear_circles();
109+
static auto rotation = LV_DISPLAY_ROTATION_0;
110+
rotation = static_cast<lv_display_rotation_t>((static_cast<int>(rotation) + 1) % 4);
111+
lv_display_t *disp = _lv_refr_get_disp_refreshing();
112+
lv_disp_set_rotation(disp, rotation);
113+
},
114+
LV_EVENT_PRESSED, nullptr);
112115

113116
// disable scrolling on the screen (so that it doesn't behave weirdly when
114117
// rotated and drawing with your finger)

components/matouch-rotary-display/src/matouch-rotary-display.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,9 @@ bool MatouchRotaryDisplay::initialize_lcd() {
279279
return true;
280280
}
281281

282-
bool MatouchRotaryDisplay::initialize_display(size_t pixel_buffer_size, const espp::Task::BaseConfig &task_config, int update_period_ms) {
282+
bool MatouchRotaryDisplay::initialize_display(size_t pixel_buffer_size,
283+
const espp::Task::BaseConfig &task_config,
284+
int update_period_ms) {
283285
if (!lcd_handle_) {
284286
logger_.error(
285287
"LCD not initialized, you must call initialize_lcd() before initialize_display()!");

components/t-dongle-s3/example/main/t_dongle_s3_example.cpp

+20-19
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,26 @@ extern "C" void app_main(void) {
4242
// initialize the button, which we'll use to cycle the rotation of the display
4343
espp::Button button(espp::Button::Config{
4444
.name = "Boot Button",
45-
.interrupt_config = espp::Interrupt::PinConfig{
46-
.gpio_num = GPIO_NUM_0,
47-
.callback = [](const auto &event) {
48-
if (event.active) {
49-
// lock the display mutex
50-
std::lock_guard<std::mutex> lock(lvgl_mutex);
51-
static auto rotation = LV_DISPLAY_ROTATION_0;
52-
rotation = static_cast<lv_display_rotation_t>((static_cast<int>(rotation) + 1) % 4);
53-
fmt::print("Setting rotation to {}\n", (int)rotation);
54-
lv_display_t *disp = _lv_refr_get_disp_refreshing();
55-
lv_disp_set_rotation(disp, rotation);
56-
}
57-
},
58-
.active_level = espp::Interrupt::ActiveLevel::LOW,
59-
.interrupt_type = espp::Interrupt::Type::ANY_EDGE,
60-
.pullup_enabled = false,
61-
.pulldown_enabled = false
62-
},
63-
});
45+
.interrupt_config =
46+
espp::Interrupt::PinConfig{.gpio_num = GPIO_NUM_0,
47+
.callback =
48+
[](const auto &event) {
49+
if (event.active) {
50+
// lock the display mutex
51+
std::lock_guard<std::mutex> lock(lvgl_mutex);
52+
static auto rotation = LV_DISPLAY_ROTATION_0;
53+
rotation = static_cast<lv_display_rotation_t>(
54+
(static_cast<int>(rotation) + 1) % 4);
55+
fmt::print("Setting rotation to {}\n", (int)rotation);
56+
lv_display_t *disp = _lv_refr_get_disp_refreshing();
57+
lv_disp_set_rotation(disp, rotation);
58+
}
59+
},
60+
.active_level = espp::Interrupt::ActiveLevel::LOW,
61+
.interrupt_type = espp::Interrupt::Type::ANY_EDGE,
62+
.pullup_enabled = false,
63+
.pulldown_enabled = false},
64+
});
6465

6566
// set the LED to be red
6667
espp::Hsv hsv(150.0f, 1.0f, 1.0f);

components/t-dongle-s3/include/t-dongle-s3.hpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,12 @@ class TDongleS3 : public BaseComponent {
8383
/// \param update_period_ms The update period of the display task
8484
/// \return true if the display was successfully initialized, false otherwise
8585
/// \note This will also allocate two full frame buffers in the SPIRAM
86-
bool initialize_display(size_t pixel_buffer_size, const espp::Task::BaseConfig &task_config = {.name="Display", .stack_size_bytes=4096, .priority=10, .core_id=0}, int update_period_ms = 16);
86+
bool initialize_display(size_t pixel_buffer_size,
87+
const espp::Task::BaseConfig &task_config = {.name = "Display",
88+
.stack_size_bytes = 4096,
89+
.priority = 10,
90+
.core_id = 0},
91+
int update_period_ms = 16);
8792

8893
/// Get the width of the LCD in pixels
8994
/// \return The width of the LCD in pixels

components/t-dongle-s3/src/t-dongle-s3.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ bool TDongleS3::initialize_lcd() {
168168
return true;
169169
}
170170

171-
bool TDongleS3::initialize_display(size_t pixel_buffer_size, const espp::Task::BaseConfig &task_config, int update_period_ms) {
171+
bool TDongleS3::initialize_display(size_t pixel_buffer_size,
172+
const espp::Task::BaseConfig &task_config,
173+
int update_period_ms) {
172174
if (!lcd_handle_) {
173175
logger_.error(
174176
"LCD not initialized, you must call initialize_lcd() before initialize_display()!");

components/wrover-kit/example/main/wrover_kit_example.cpp

+20-19
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,26 @@ extern "C" void app_main(void) {
3939
// initialize the button, which we'll use to cycle the rotation of the display
4040
espp::Button button(espp::Button::Config{
4141
.name = "Boot Button",
42-
.interrupt_config = espp::Interrupt::PinConfig{
43-
.gpio_num = GPIO_NUM_0,
44-
.callback = [](const auto &event) {
45-
if (event.active) {
46-
// lock the display mutex
47-
std::lock_guard<std::mutex> lock(lvgl_mutex);
48-
static auto rotation = LV_DISPLAY_ROTATION_0;
49-
rotation = static_cast<lv_display_rotation_t>((static_cast<int>(rotation) + 1) % 4);
50-
fmt::print("Setting rotation to {}\n", (int)rotation);
51-
lv_display_t *disp = _lv_refr_get_disp_refreshing();
52-
lv_disp_set_rotation(disp, rotation);
53-
}
54-
},
55-
.active_level = espp::Interrupt::ActiveLevel::LOW,
56-
.interrupt_type = espp::Interrupt::Type::ANY_EDGE,
57-
.pullup_enabled = false,
58-
.pulldown_enabled = false
59-
},
60-
});
42+
.interrupt_config =
43+
espp::Interrupt::PinConfig{.gpio_num = GPIO_NUM_0,
44+
.callback =
45+
[](const auto &event) {
46+
if (event.active) {
47+
// lock the display mutex
48+
std::lock_guard<std::mutex> lock(lvgl_mutex);
49+
static auto rotation = LV_DISPLAY_ROTATION_0;
50+
rotation = static_cast<lv_display_rotation_t>(
51+
(static_cast<int>(rotation) + 1) % 4);
52+
fmt::print("Setting rotation to {}\n", (int)rotation);
53+
lv_display_t *disp = _lv_refr_get_disp_refreshing();
54+
lv_disp_set_rotation(disp, rotation);
55+
}
56+
},
57+
.active_level = espp::Interrupt::ActiveLevel::LOW,
58+
.interrupt_type = espp::Interrupt::Type::ANY_EDGE,
59+
.pullup_enabled = false,
60+
.pulldown_enabled = false},
61+
});
6162

6263
// set the background color to black
6364
lv_obj_t *bg = lv_obj_create(lv_screen_active());

components/wrover-kit/include/wrover-kit.hpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ class WroverKit : public BaseComponent {
6666
/// \param update_period_ms The update period of the display task
6767
/// \return true if the display was successfully initialized, false otherwise
6868
/// \note This will also allocate two full frame buffers in the SPIRAM
69-
bool initialize_display(size_t pixel_buffer_size, const espp::Task::BaseConfig &task_config = {.name="Display", .stack_size_bytes=4096, .priority=10, .core_id=0}, int update_period_ms = 16);
69+
bool initialize_display(size_t pixel_buffer_size,
70+
const espp::Task::BaseConfig &task_config = {.name = "Display",
71+
.stack_size_bytes = 4096,
72+
.priority = 10,
73+
.core_id = 0},
74+
int update_period_ms = 16);
7075

7176
/// Get the width of the LCD in pixels
7277
/// \return The width of the LCD in pixels

components/wrover-kit/src/wrover-kit.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ bool WroverKit::initialize_lcd() {
8585
return true;
8686
}
8787

88-
bool WroverKit::initialize_display(size_t pixel_buffer_size, const espp::Task::BaseConfig &task_config, int update_period_ms) {
88+
bool WroverKit::initialize_display(size_t pixel_buffer_size,
89+
const espp::Task::BaseConfig &task_config,
90+
int update_period_ms) {
8991
if (!lcd_handle_) {
9092
logger_.error(
9193
"LCD not initialized, you must call initialize_lcd() before initialize_display()!");

0 commit comments

Comments
 (0)