mirror of
https://github.com/esphome/esphome.git
synced 2025-03-14 06:38:17 +00:00
C Code cleanup
This commit is contained in:
parent
51b7777e91
commit
dcf05efc3e
@ -3,6 +3,8 @@
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/components/binary_sensor/binary_sensor.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace esphome {
|
||||
namespace obd {
|
||||
|
||||
@ -51,7 +53,11 @@ class PIDRequest : public Component {
|
||||
public:
|
||||
explicit PIDRequest(OBDComponent *parent, const std::uint32_t can_id, const std::uint32_t pid,
|
||||
const std::uint32_t can_response_id, const bool use_extended_id)
|
||||
: parent_(parent), can_id_(can_id), pid_(pid), can_response_id_(can_response_id), use_extended_id_(use_extended_id){
|
||||
: parent_(parent),
|
||||
can_id_(can_id),
|
||||
pid_(pid),
|
||||
can_response_id_(can_response_id),
|
||||
use_extended_id_(use_extended_id) {
|
||||
this->state_ = WAITING;
|
||||
};
|
||||
|
||||
@ -136,19 +142,18 @@ class OBDBinarySensor : public OBDSensorBase, public binary_sensor::BinarySensor
|
||||
|
||||
class OBDCanbusTrigger : public canbus::CanbusTrigger, public Action<std::vector<uint8_t>, uint32_t, bool> {
|
||||
public:
|
||||
explicit OBDCanbusTrigger(PIDRequest *parent) : CanbusTrigger(parent->parent_->canbus_, parent->can_response_id_, 0x1FFFFFFF, parent->use_extended_id_), parent_(parent){
|
||||
explicit OBDCanbusTrigger(PIDRequest *parent)
|
||||
: CanbusTrigger(parent->parent_->canbus_, parent->can_response_id_, 0x1FFFFFFF, parent->use_extended_id_),
|
||||
parent_(parent) {
|
||||
auto automation = new Automation<std::vector<uint8_t>, uint32_t, bool>(this);
|
||||
automation->add_action(this);
|
||||
};
|
||||
|
||||
void play(std::vector<uint8_t> data, uint32_t can_id, bool rx) override {
|
||||
this->parent_->handle_incoming(data);
|
||||
}
|
||||
void play(std::vector<uint8_t> data, uint32_t can_id, bool rx) override { this->parent_->handle_incoming(data); }
|
||||
|
||||
protected:
|
||||
PIDRequest *parent_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace obd
|
||||
} // namespace esphome
|
||||
|
Loading…
x
Reference in New Issue
Block a user