chore: add clang pre-commit (#299)
This commit is contained in:
parent
a90b6fb65f
commit
c603f012e6
|
@ -7,3 +7,12 @@ repos:
|
|||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-added-large-files
|
||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||
rev: v18.1.8
|
||||
hooks:
|
||||
- id: clang-format
|
||||
types_or:
|
||||
- "c++"
|
||||
- "c"
|
||||
- "cuda"
|
||||
args: [-style=Webkit, -i]
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
#include "dry_contact.h"
|
||||
#include "ratgdo.h"
|
||||
|
||||
#include "esphome/components/gpio/binary_sensor/gpio_binary_sensor.h"
|
||||
#include "esphome/core/gpio.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/scheduler.h"
|
||||
#include "esphome/components/gpio/binary_sensor/gpio_binary_sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace ratgdo {
|
||||
|
@ -59,7 +59,8 @@ namespace ratgdo {
|
|||
this->send_door_state();
|
||||
}
|
||||
|
||||
void DryContact::send_door_state(){
|
||||
void DryContact::send_door_state()
|
||||
{
|
||||
if (this->open_limit_reached_) {
|
||||
this->door_state_ = DoorState::OPEN;
|
||||
} else if (this->close_limit_reached_) {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include "SoftwareSerial.h" // Using espsoftwareserial https://github.com/plerup/espsoftwareserial
|
||||
#include "esphome/core/optional.h"
|
||||
#include "esphome/core/gpio.h"
|
||||
#include "esphome/components/gpio/binary_sensor/gpio_binary_sensor.h"
|
||||
#include "esphome/core/gpio.h"
|
||||
#include "esphome/core/optional.h"
|
||||
|
||||
#include "callbacks.h"
|
||||
#include "observable.h"
|
||||
|
@ -36,13 +36,15 @@ namespace ratgdo {
|
|||
void set_close_limit(bool state);
|
||||
void send_door_state();
|
||||
|
||||
void set_discrete_open_pin(InternalGPIOPin* pin) {
|
||||
void set_discrete_open_pin(InternalGPIOPin* pin)
|
||||
{
|
||||
this->discrete_open_pin_ = pin;
|
||||
this->discrete_open_pin_->setup();
|
||||
this->discrete_open_pin_->pin_mode(gpio::FLAG_OUTPUT);
|
||||
}
|
||||
|
||||
void set_discrete_close_pin(InternalGPIOPin* pin) {
|
||||
void set_discrete_close_pin(InternalGPIOPin* pin)
|
||||
{
|
||||
this->discrete_close_pin_ = pin;
|
||||
this->discrete_close_pin_->setup();
|
||||
this->discrete_close_pin_->pin_mode(gpio::FLAG_OUTPUT);
|
||||
|
@ -68,7 +70,6 @@ namespace ratgdo {
|
|||
bool last_open_limit_;
|
||||
bool close_limit_reached_;
|
||||
bool last_close_limit_;
|
||||
|
||||
};
|
||||
|
||||
} // namespace secplus1
|
||||
|
|
|
@ -690,21 +690,17 @@ namespace ratgdo {
|
|||
void RATGDOComponent::set_dry_contact_open_sensor(esphome::gpio::GPIOBinarySensor* dry_contact_open_sensor)
|
||||
{
|
||||
dry_contact_open_sensor_ = dry_contact_open_sensor;
|
||||
dry_contact_open_sensor_->add_on_state_callback([this](bool sensor_value)
|
||||
{
|
||||
dry_contact_open_sensor_->add_on_state_callback([this](bool sensor_value) {
|
||||
this->protocol_->set_open_limit(sensor_value);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
void RATGDOComponent::set_dry_contact_close_sensor(esphome::gpio::GPIOBinarySensor* dry_contact_close_sensor)
|
||||
{
|
||||
dry_contact_close_sensor_ = dry_contact_close_sensor;
|
||||
dry_contact_close_sensor_->add_on_state_callback([this](bool sensor_value)
|
||||
{
|
||||
dry_contact_close_sensor_->add_on_state_callback([this](bool sensor_value) {
|
||||
this->protocol_->set_close_limit(sensor_value);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace ratgdo
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "esphome/components/gpio/binary_sensor/gpio_binary_sensor.h"
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/hal.h"
|
||||
#include "esphome/core/preferences.h"
|
||||
#include "esphome/components/gpio/binary_sensor/gpio_binary_sensor.h"
|
||||
|
||||
#include "callbacks.h"
|
||||
#include "macros.h"
|
||||
|
|
|
@ -102,7 +102,6 @@ namespace ratgdo {
|
|||
void set_discrete_open_pin(InternalGPIOPin* pin) { }
|
||||
void set_discrete_close_pin(InternalGPIOPin* pin) { }
|
||||
|
||||
|
||||
protected:
|
||||
void wall_panel_emulation(size_t index = 0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue