mirror of
https://github.com/esphome/esphome.git
synced 2024-11-21 11:37:27 +01:00
Fix line endings normalization (#2407)
* Strip CRLF line endings from modbus controller files * Normalize all line endings to LF
This commit is contained in:
parent
5b0fbbaada
commit
1031ea4313
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -1 +1,2 @@
|
|||||||
* text=auto eol=lf
|
# Normalize line endings to LF in the repository
|
||||||
|
* text eol=lf
|
||||||
|
@ -1,48 +1,48 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "esphome/components/number/number.h"
|
#include "esphome/components/number/number.h"
|
||||||
#include "esphome/components/modbus_controller/modbus_controller.h"
|
#include "esphome/components/modbus_controller/modbus_controller.h"
|
||||||
#include "esphome/core/component.h"
|
#include "esphome/core/component.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace modbus_controller {
|
namespace modbus_controller {
|
||||||
|
|
||||||
using value_to_data_t = std::function<float>(float);
|
using value_to_data_t = std::function<float>(float);
|
||||||
|
|
||||||
class ModbusNumber : public number::Number, public Component, public SensorItem {
|
class ModbusNumber : public number::Number, public Component, public SensorItem {
|
||||||
public:
|
public:
|
||||||
ModbusNumber(uint16_t start_address, uint8_t offset, uint32_t bitmask, SensorValueType value_type, int register_count,
|
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)
|
uint8_t skip_updates, bool force_new_range)
|
||||||
: number::Number(), Component(), SensorItem() {
|
: number::Number(), Component(), SensorItem() {
|
||||||
this->register_type = ModbusRegisterType::HOLDING;
|
this->register_type = ModbusRegisterType::HOLDING;
|
||||||
this->start_address = start_address;
|
this->start_address = start_address;
|
||||||
this->offset = offset;
|
this->offset = offset;
|
||||||
this->bitmask = bitmask;
|
this->bitmask = bitmask;
|
||||||
this->sensor_value_type = value_type;
|
this->sensor_value_type = value_type;
|
||||||
this->register_count = register_count;
|
this->register_count = register_count;
|
||||||
this->skip_updates = skip_updates;
|
this->skip_updates = skip_updates;
|
||||||
this->force_new_range = force_new_range;
|
this->force_new_range = force_new_range;
|
||||||
};
|
};
|
||||||
|
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
void parse_and_publish(const std::vector<uint8_t> &data) override;
|
void parse_and_publish(const std::vector<uint8_t> &data) override;
|
||||||
float get_setup_priority() const override { return setup_priority::HARDWARE; }
|
float get_setup_priority() const override { return setup_priority::HARDWARE; }
|
||||||
void set_update_interval(int) {}
|
void set_update_interval(int) {}
|
||||||
void set_parent(ModbusController *parent) { this->parent_ = parent; }
|
void set_parent(ModbusController *parent) { this->parent_ = parent; }
|
||||||
void set_write_multiply(float factor) { multiply_by_ = factor; }
|
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 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> &)>;
|
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_template(transform_func_t &&f) { this->transform_func_ = f; }
|
||||||
void set_write_template(write_transform_func_t &&f) { this->write_transform_func_ = f; }
|
void set_write_template(write_transform_func_t &&f) { this->write_transform_func_ = f; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void control(float value) override;
|
void control(float value) override;
|
||||||
optional<transform_func_t> transform_func_;
|
optional<transform_func_t> transform_func_;
|
||||||
optional<write_transform_func_t> write_transform_func_;
|
optional<write_transform_func_t> write_transform_func_;
|
||||||
ModbusController *parent_;
|
ModbusController *parent_;
|
||||||
float multiply_by_{1.0};
|
float multiply_by_{1.0};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace modbus_controller
|
} // namespace modbus_controller
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
@ -1,45 +1,45 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "esphome/components/output/float_output.h"
|
#include "esphome/components/output/float_output.h"
|
||||||
#include "esphome/components/modbus_controller/modbus_controller.h"
|
#include "esphome/components/modbus_controller/modbus_controller.h"
|
||||||
#include "esphome/core/component.h"
|
#include "esphome/core/component.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace modbus_controller {
|
namespace modbus_controller {
|
||||||
|
|
||||||
using value_to_data_t = std::function<float>(float);
|
using value_to_data_t = std::function<float>(float);
|
||||||
|
|
||||||
class ModbusOutput : public output::FloatOutput, public Component, public SensorItem {
|
class ModbusOutput : public output::FloatOutput, public Component, public SensorItem {
|
||||||
public:
|
public:
|
||||||
ModbusOutput(uint16_t start_address, uint8_t offset, SensorValueType value_type)
|
ModbusOutput(uint16_t start_address, uint8_t offset, SensorValueType value_type)
|
||||||
: output::FloatOutput(), Component() {
|
: output::FloatOutput(), Component() {
|
||||||
this->register_type = ModbusRegisterType::HOLDING;
|
this->register_type = ModbusRegisterType::HOLDING;
|
||||||
this->start_address = start_address;
|
this->start_address = start_address;
|
||||||
this->offset = offset;
|
this->offset = offset;
|
||||||
this->bitmask = bitmask;
|
this->bitmask = bitmask;
|
||||||
this->sensor_value_type = value_type;
|
this->sensor_value_type = value_type;
|
||||||
this->skip_updates = 0;
|
this->skip_updates = 0;
|
||||||
this->start_address += offset;
|
this->start_address += offset;
|
||||||
this->offset = 0;
|
this->offset = 0;
|
||||||
}
|
}
|
||||||
void setup() override;
|
void setup() override;
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
|
|
||||||
void set_parent(ModbusController *parent) { this->parent_ = parent; }
|
void set_parent(ModbusController *parent) { this->parent_ = parent; }
|
||||||
void set_write_multiply(float factor) { multiply_by_ = factor; }
|
void set_write_multiply(float factor) { multiply_by_ = factor; }
|
||||||
// Do nothing
|
// Do nothing
|
||||||
void parse_and_publish(const std::vector<uint8_t> &data) override{};
|
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> &)>;
|
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; }
|
void set_write_template(write_transform_func_t &&f) { this->write_transform_func_ = f; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void write_state(float value) override;
|
void write_state(float value) override;
|
||||||
optional<write_transform_func_t> write_transform_func_{nullopt};
|
optional<write_transform_func_t> write_transform_func_{nullopt};
|
||||||
|
|
||||||
ModbusController *parent_;
|
ModbusController *parent_;
|
||||||
float multiply_by_{1.0};
|
float multiply_by_{1.0};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace modbus_controller
|
} // namespace modbus_controller
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
Loading…
Reference in New Issue
Block a user