[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2024-11-10 18:05:29 +00:00
parent fd43050842
commit eee6f5e4d5
20 changed files with 107 additions and 99 deletions

View File

@ -7,7 +7,8 @@ namespace ratgdo {
static const char* TAG = "ratgdo.output"; static const char* TAG = "ratgdo.output";
void RATGDOOutput::setup(){ void RATGDOOutput::setup()
{
ESP_LOGD(TAG, "Output was setup"); ESP_LOGD(TAG, "Output was setup");
if (this->output_type_ == OutputType::RATGDO_BEEPER) { if (this->output_type_ == OutputType::RATGDO_BEEPER) {
@ -27,25 +28,29 @@ void RATGDOOutput::setup(){
this->repeat_ = false; this->repeat_ = false;
} }
}); });
} }
} }
void RATGDOOutput::play(){ void RATGDOOutput::play()
{
this->beeper_->play(this->rtttlSong_); this->beeper_->play(this->rtttlSong_);
} }
void RATGDOOutput::finished_playback(){ void RATGDOOutput::finished_playback()
if(this->repeat_) this->play(); {
if (this->repeat_)
this->play();
} }
void RATGDOOutput::dump_config() { void RATGDOOutput::dump_config()
{
if (this->output_type_ == OutputType::RATGDO_BEEPER) { if (this->output_type_ == OutputType::RATGDO_BEEPER) {
ESP_LOGCONFIG(TAG, " Type: Beeper"); ESP_LOGCONFIG(TAG, " Type: Beeper");
} }
} }
void RATGDOOutput::set_output_type(OutputType output_type_) { void RATGDOOutput::set_output_type(OutputType output_type_)
{
this->output_type_ = output_type_; this->output_type_ = output_type_;
} }

View File

@ -1,8 +1,8 @@
#pragma once #pragma once
#include "../ratgdo.h" #include "../ratgdo.h"
#include "esphome/core/component.h"
#include "esphome/components/rtttl/rtttl.h" #include "esphome/components/rtttl/rtttl.h"
#include "esphome/core/component.h"
namespace esphome { namespace esphome {
namespace ratgdo { namespace ratgdo {

View File

@ -361,13 +361,15 @@ namespace ratgdo {
this->closing_duration = duration; this->closing_duration = duration;
} }
void RATGDOComponent::set_target_distance_measurement(int16_t distance){ void RATGDOComponent::set_target_distance_measurement(int16_t distance)
{
this->target_distance_measurement = distance; this->target_distance_measurement = distance;
} }
void RATGDOComponent::set_distance_measurement(int16_t distance) void RATGDOComponent::set_distance_measurement(int16_t distance)
{ {
if(distance > 0 && distance < MIN_DISTANCE) return; if (distance > 0 && distance < MIN_DISTANCE)
return;
this->last_distance_measurement = distance; this->last_distance_measurement = distance;
@ -395,8 +397,10 @@ namespace ratgdo {
} }
} }
if(all_in_range) this->vehicle_detected_state = VehicleDetectedState::YES; if (all_in_range)
if(all_out_of_range) this->vehicle_detected_state = VehicleDetectedState::NO; this->vehicle_detected_state = VehicleDetectedState::YES;
if (all_out_of_range)
this->vehicle_detected_state = VehicleDetectedState::NO;
// auto k = this->distance_measurement; // auto k = this->distance_measurement;
// ESP_LOGD(TAG,"measure: %i,%i,%i,%i,%i,%i,%i,%i,%i,%i; target: %i; all_in: %s; all_out: %s;", k[0],k[1],k[2],k[3],k[4],k[5],k[6],k[7],k[8],k[9], *this->target_distance_measurement, all_in_range ? "y" : "n", all_out_of_range ? "y" : "n"); // ESP_LOGD(TAG,"measure: %i,%i,%i,%i,%i,%i,%i,%i,%i,%i; target: %i; all_in: %s; all_out: %s;", k[0],k[1],k[2],k[3],k[4],k[5],k[6],k[7],k[8],k[9], *this->target_distance_measurement, all_in_range ? "y" : "n", all_out_of_range ? "y" : "n");

View File

@ -39,4 +39,3 @@ async def to_code(config):
if CONF_PIN in config: if CONF_PIN in config:
pin = await cg.gpio_pin_expression(config[CONF_PIN]) pin = await cg.gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin)) cg.add(var.set_pin(pin))