Fix line endings normalization (#2407)

* Strip CRLF line endings from modbus controller files

* Normalize all line endings to LF
This commit is contained in:
Oxan van Leeuwen 2021-09-30 18:07:28 +02:00 committed by GitHub
parent 5b0fbbaada
commit 1031ea4313
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 95 additions and 94 deletions

3
.gitattributes vendored
View file

@ -1 +1,2 @@
* text=auto eol=lf
# Normalize line endings to LF in the repository
* text eol=lf

View file

@ -1,48 +1,48 @@
#pragma once
#include "esphome/components/number/number.h"
#include "esphome/components/modbus_controller/modbus_controller.h"
#include "esphome/core/component.h"
namespace esphome {
namespace modbus_controller {
using value_to_data_t = std::function<float>(float);
class ModbusNumber : public number::Number, public Component, public SensorItem {
public:
ModbusNumber(uint16_t start_address, uint8_t offset, uint32_t bitmask, SensorValueType value_type, int register_count,
uint8_t skip_updates, bool force_new_range)
: number::Number(), Component(), SensorItem() {
this->register_type = ModbusRegisterType::HOLDING;
this->start_address = start_address;
this->offset = offset;
this->bitmask = bitmask;
this->sensor_value_type = value_type;
this->register_count = register_count;
this->skip_updates = skip_updates;
this->force_new_range = force_new_range;
};
void dump_config() override;
void parse_and_publish(const std::vector<uint8_t> &data) override;
float get_setup_priority() const override { return setup_priority::HARDWARE; }
void set_update_interval(int) {}
void set_parent(ModbusController *parent) { this->parent_ = parent; }
void set_write_multiply(float factor) { multiply_by_ = factor; }
using transform_func_t = std::function<optional<float>(ModbusNumber *, float, const std::vector<uint8_t> &)>;
using write_transform_func_t = std::function<optional<float>(ModbusNumber *, float, std::vector<uint16_t> &)>;
void set_template(transform_func_t &&f) { this->transform_func_ = f; }
void set_write_template(write_transform_func_t &&f) { this->write_transform_func_ = f; }
protected:
void control(float value) override;
optional<transform_func_t> transform_func_;
optional<write_transform_func_t> write_transform_func_;
ModbusController *parent_;
float multiply_by_{1.0};
};
} // namespace modbus_controller
} // namespace esphome
#pragma once
#include "esphome/components/number/number.h"
#include "esphome/components/modbus_controller/modbus_controller.h"
#include "esphome/core/component.h"
namespace esphome {
namespace modbus_controller {
using value_to_data_t = std::function<float>(float);
class ModbusNumber : public number::Number, public Component, public SensorItem {
public:
ModbusNumber(uint16_t start_address, uint8_t offset, uint32_t bitmask, SensorValueType value_type, int register_count,
uint8_t skip_updates, bool force_new_range)
: number::Number(), Component(), SensorItem() {
this->register_type = ModbusRegisterType::HOLDING;
this->start_address = start_address;
this->offset = offset;
this->bitmask = bitmask;
this->sensor_value_type = value_type;
this->register_count = register_count;
this->skip_updates = skip_updates;
this->force_new_range = force_new_range;
};
void dump_config() override;
void parse_and_publish(const std::vector<uint8_t> &data) override;
float get_setup_priority() const override { return setup_priority::HARDWARE; }
void set_update_interval(int) {}
void set_parent(ModbusController *parent) { this->parent_ = parent; }
void set_write_multiply(float factor) { multiply_by_ = factor; }
using transform_func_t = std::function<optional<float>(ModbusNumber *, float, const std::vector<uint8_t> &)>;
using write_transform_func_t = std::function<optional<float>(ModbusNumber *, float, std::vector<uint16_t> &)>;
void set_template(transform_func_t &&f) { this->transform_func_ = f; }
void set_write_template(write_transform_func_t &&f) { this->write_transform_func_ = f; }
protected:
void control(float value) override;
optional<transform_func_t> transform_func_;
optional<write_transform_func_t> write_transform_func_;
ModbusController *parent_;
float multiply_by_{1.0};
};
} // namespace modbus_controller
} // namespace esphome

View file

@ -1,45 +1,45 @@
#pragma once
#include "esphome/components/output/float_output.h"
#include "esphome/components/modbus_controller/modbus_controller.h"
#include "esphome/core/component.h"
namespace esphome {
namespace modbus_controller {
using value_to_data_t = std::function<float>(float);
class ModbusOutput : public output::FloatOutput, public Component, public SensorItem {
public:
ModbusOutput(uint16_t start_address, uint8_t offset, SensorValueType value_type)
: output::FloatOutput(), Component() {
this->register_type = ModbusRegisterType::HOLDING;
this->start_address = start_address;
this->offset = offset;
this->bitmask = bitmask;
this->sensor_value_type = value_type;
this->skip_updates = 0;
this->start_address += offset;
this->offset = 0;
}
void setup() override;
void dump_config() override;
void set_parent(ModbusController *parent) { this->parent_ = parent; }
void set_write_multiply(float factor) { multiply_by_ = factor; }
// Do nothing
void parse_and_publish(const std::vector<uint8_t> &data) override{};
using write_transform_func_t = std::function<optional<float>(ModbusOutput *, float, std::vector<uint16_t> &)>;
void set_write_template(write_transform_func_t &&f) { this->write_transform_func_ = f; }
protected:
void write_state(float value) override;
optional<write_transform_func_t> write_transform_func_{nullopt};
ModbusController *parent_;
float multiply_by_{1.0};
};
} // namespace modbus_controller
} // namespace esphome
#pragma once
#include "esphome/components/output/float_output.h"
#include "esphome/components/modbus_controller/modbus_controller.h"
#include "esphome/core/component.h"
namespace esphome {
namespace modbus_controller {
using value_to_data_t = std::function<float>(float);
class ModbusOutput : public output::FloatOutput, public Component, public SensorItem {
public:
ModbusOutput(uint16_t start_address, uint8_t offset, SensorValueType value_type)
: output::FloatOutput(), Component() {
this->register_type = ModbusRegisterType::HOLDING;
this->start_address = start_address;
this->offset = offset;
this->bitmask = bitmask;
this->sensor_value_type = value_type;
this->skip_updates = 0;
this->start_address += offset;
this->offset = 0;
}
void setup() override;
void dump_config() override;
void set_parent(ModbusController *parent) { this->parent_ = parent; }
void set_write_multiply(float factor) { multiply_by_ = factor; }
// Do nothing
void parse_and_publish(const std::vector<uint8_t> &data) override{};
using write_transform_func_t = std::function<optional<float>(ModbusOutput *, float, std::vector<uint16_t> &)>;
void set_write_template(write_transform_func_t &&f) { this->write_transform_func_ = f; }
protected:
void write_state(float value) override;
optional<write_transform_func_t> write_transform_func_{nullopt};
ModbusController *parent_;
float multiply_by_{1.0};
};
} // namespace modbus_controller
} // namespace esphome