2
2
3
3
using namespace espp ;
4
4
5
- EspTimerCam::EspTimerCam () : BaseComponent( " EspTimerCam " ) {
6
- }
5
+ EspTimerCam::EspTimerCam ()
6
+ : BaseComponent( " EspTimerCam " ) { }
7
7
8
8
// //////////////////////
9
9
// LED //
@@ -20,7 +20,10 @@ bool EspTimerCam::initialize_led(float breathing_period) {
20
20
.channels = led_channels_,
21
21
.duty_resolution = LEDC_TIMER_10_BIT,
22
22
});
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)});
24
27
set_led_breathing_period (breathing_period);
25
28
return true ;
26
29
}
@@ -30,9 +33,7 @@ void EspTimerCam::start_led_breathing() {
30
33
led_task_->start ();
31
34
}
32
35
33
- void EspTimerCam::stop_led_breathing () {
34
- led_task_->stop ();
35
- }
36
+ void EspTimerCam::stop_led_breathing () { led_task_->stop (); }
36
37
37
38
bool EspTimerCam::set_led_brightness (float brightness) {
38
39
if (led_ == nullptr ) {
@@ -70,23 +71,17 @@ bool EspTimerCam::set_led_breathing_period(float breathing_period) {
70
71
return true ;
71
72
}
72
73
73
- float EspTimerCam::get_led_breathing_period () {
74
- return breathing_period_;
75
- }
74
+ float EspTimerCam::get_led_breathing_period () { return breathing_period_; }
76
75
77
- std::shared_ptr<espp::Led> EspTimerCam::led () {
78
- return led_;
79
- }
76
+ std::shared_ptr<espp::Led> EspTimerCam::led () { return led_; }
80
77
81
- espp::Gaussian &EspTimerCam::gaussian () {
82
- return gaussian_;
83
- }
78
+ espp::Gaussian &EspTimerCam::gaussian () { return gaussian_; }
84
79
85
80
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);
90
85
}
91
86
92
87
bool EspTimerCam::led_task_callback (std::mutex &m, std::condition_variable &cv) {
@@ -121,15 +116,13 @@ bool EspTimerCam::initialize_rtc() {
121
116
return false ;
122
117
}
123
118
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),
129
124
.log_level = espp::Logger::Verbosity::WARN});
130
125
return true ;
131
126
}
132
127
133
- std::shared_ptr<EspTimerCam::Rtc> EspTimerCam::rtc () {
134
- return rtc_;
135
- }
128
+ std::shared_ptr<EspTimerCam::Rtc> EspTimerCam::rtc () { return rtc_; }
0 commit comments