moved components into a single file

This commit is contained in:
Gábor Poczkodi 2024-10-19 17:45:02 +02:00
parent c25bc13708
commit d14cbdeaa1
91 changed files with 420 additions and 1303 deletions

View file

@ -1,12 +0,0 @@
#include "acomp_gain_number.h"
namespace esphome {
namespace si4713 {
void AcompGainNumber::control(float value) {
this->publish_state(value);
this->parent_->set_acomp_gain(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/number/number.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class AcompGainNumber : public number::Number, public Parented<Si4713Component> {
public:
AcompGainNumber() = default;
protected:
void control(float value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "acomp_threshold_number.h"
namespace esphome {
namespace si4713 {
void AcompThresholdNumber::control(float value) {
this->publish_state(value);
this->parent_->set_acomp_threshold(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/number/number.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class AcompThresholdNumber : public number::Number, public Parented<Si4713Component> {
public:
AcompThresholdNumber() = default;
protected:
void control(float value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "analog_level_number.h"
namespace esphome {
namespace si4713 {
void AnalogLevelNumber::control(float value) {
this->publish_state(value);
this->parent_->set_analog_level(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/number/number.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class AnalogLevelNumber : public number::Number, public Parented<Si4713Component> {
public:
AnalogLevelNumber() = default;
protected:
void control(float value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "asq_duration_high_number.h"
namespace esphome {
namespace si4713 {
void AsqDurationHighNumber::control(float value) {
this->publish_state(value);
this->parent_->set_asq_duration_high(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/number/number.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class AsqDurationHighNumber : public number::Number, public Parented<Si4713Component> {
public:
AsqDurationHighNumber() = default;
protected:
void control(float value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "asq_duration_low_number.h"
namespace esphome {
namespace si4713 {
void AsqDurationLowNumber::control(float value) {
this->publish_state(value);
this->parent_->set_asq_duration_low(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/number/number.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class AsqDurationLowNumber : public number::Number, public Parented<Si4713Component> {
public:
AsqDurationLowNumber() = default;
protected:
void control(float value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "asq_level_high_number.h"
namespace esphome {
namespace si4713 {
void AsqLevelHighNumber::control(float value) {
this->publish_state(value);
this->parent_->set_asq_level_high(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/number/number.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class AsqLevelHighNumber : public number::Number, public Parented<Si4713Component> {
public:
AsqLevelHighNumber() = default;
protected:
void control(float value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "asq_level_low_number.h"
namespace esphome {
namespace si4713 {
void AsqLevelLowNumber::control(float value) {
this->publish_state(value);
this->parent_->set_asq_level_low(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/number/number.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class AsqLevelLowNumber : public number::Number, public Parented<Si4713Component> {
public:
AsqLevelLowNumber() = default;
protected:
void control(float value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "digital_sample_rate_number.h"
namespace esphome {
namespace si4713 {
void DigitalSampleRateNumber::control(float value) {
this->publish_state(value);
this->parent_->set_digital_sample_rate(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/number/number.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class DigitalSampleRateNumber : public number::Number, public Parented<Si4713Component> {
public:
DigitalSampleRateNumber() = default;
protected:
void control(float value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "limiter_release_time_number.h"
namespace esphome {
namespace si4713 {
void LimiterReleaseTimeNumber::control(float value) {
this->publish_state(value);
this->parent_->set_limiter_release_time(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/number/number.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class LimiterReleaseTimeNumber : public number::Number, public Parented<Si4713Component> {
public:
LimiterReleaseTimeNumber() = default;
protected:
void control(float value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -0,0 +1,154 @@
#pragma once
#include "esphome/components/number/number.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class AcompGainNumber : public number::Number, public Parented<Si4713Component> {
protected:
void control(float value) override {
this->publish_state(value);
this->parent_->set_acomp_gain(value);
}
};
class AcompThresholdNumber : public number::Number, public Parented<Si4713Component> {
protected:
void control(float value) override {
this->publish_state(value);
this->parent_->set_acomp_threshold(value);
}
};
class AnalogLevelNumber : public number::Number, public Parented<Si4713Component> {
protected:
void control(float value) override {
this->publish_state(value);
this->parent_->set_analog_level(value);
}
};
class AsqDurationHighNumber : public number::Number, public Parented<Si4713Component> {
protected:
void control(float value) override {
this->publish_state(value);
this->parent_->set_asq_duration_high(value);
}
};
class AsqDurationLowNumber : public number::Number, public Parented<Si4713Component> {
protected:
void control(float value) override {
this->publish_state(value);
this->parent_->set_asq_duration_low(value);
}
};
class AsqLevelHighNumber : public number::Number, public Parented<Si4713Component> {
protected:
void control(float value) override {
this->publish_state(value);
this->parent_->set_asq_level_high(value);
}
};
class AsqLevelLowNumber : public number::Number, public Parented<Si4713Component> {
protected:
void control(float value) override {
this->publish_state(value);
this->parent_->set_asq_level_low(value);
}
};
class DigitalSampleRateNumber : public number::Number, public Parented<Si4713Component> {
protected:
void control(float value) override {
this->publish_state(value);
this->parent_->set_digital_sample_rate(value);
}
};
class LimiterReleaseTimeNumber : public number::Number, public Parented<Si4713Component> {
protected:
void control(float value) override {
this->publish_state(value);
this->parent_->set_limiter_release_time(value);
}
};
class PilotDeviationNumber : public number::Number, public Parented<Si4713Component> {
protected:
void control(float value) override {
this->publish_state(value);
this->parent_->set_pilot_deviation(value);
}
};
class PilotFrequencyNumber : public number::Number, public Parented<Si4713Component> {
protected:
void control(float value) override {
this->publish_state(value);
this->parent_->set_pilot_frequency(value);
}
};
class RdsDeviationNumber : public number::Number, public Parented<Si4713Component> {
protected:
void control(float value) override {
this->publish_state(value);
this->parent_->set_rds_deviation(value);
}
};
class RefClkFrequencyNumber : public number::Number, public Parented<Si4713Component> {
protected:
void control(float value) override {
this->publish_state(value);
this->parent_->set_refclk_frequency(value);
}
};
class RefClkPrescalerNumber : public number::Number, public Parented<Si4713Component> {
protected:
void control(float value) override {
this->publish_state(value);
this->parent_->set_refclk_prescaler(value);
}
};
class TunerAntcapNumber : public number::Number, public Parented<Si4713Component> {
protected:
void control(float value) override {
this->publish_state(value);
this->parent_->set_tuner_antcap(value);
}
};
class TunerDeviationNumber : public number::Number, public Parented<Si4713Component> {
protected:
void control(float value) override {
this->publish_state(value);
this->parent_->set_tuner_deviation(value);
}
};
class TunerFrequencyNumber : public number::Number, public Parented<Si4713Component> {
protected:
void control(float value) override {
this->publish_state(value);
this->parent_->set_tuner_frequency(value);
}
};
class TunerPowerNumber : public number::Number, public Parented<Si4713Component> {
protected:
void control(float value) override {
this->publish_state(value);
this->parent_->set_tuner_power(value);
}
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "pilot_deviation_number.h"
namespace esphome {
namespace si4713 {
void PilotDeviationNumber::control(float value) {
this->publish_state(value);
this->parent_->set_pilot_deviation(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/number/number.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class PilotDeviationNumber : public number::Number, public Parented<Si4713Component> {
public:
PilotDeviationNumber() = default;
protected:
void control(float value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "pilot_frequency_number.h"
namespace esphome {
namespace si4713 {
void PilotFrequencyNumber::control(float value) {
this->publish_state(value);
this->parent_->set_pilot_frequency(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/number/number.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class PilotFrequencyNumber : public number::Number, public Parented<Si4713Component> {
public:
PilotFrequencyNumber() = default;
protected:
void control(float value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "rds_deviation_number.h"
namespace esphome {
namespace si4713 {
void RdsDeviationNumber::control(float value) {
this->publish_state(value);
this->parent_->set_rds_deviation(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/number/number.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class RdsDeviationNumber : public number::Number, public Parented<Si4713Component> {
public:
RdsDeviationNumber() = default;
protected:
void control(float value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "refclk_frequency_number.h"
namespace esphome {
namespace si4713 {
void RefClkFrequencyNumber::control(float value) {
this->publish_state(value);
this->parent_->set_refclk_frequency(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/number/number.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class RefClkFrequencyNumber : public number::Number, public Parented<Si4713Component> {
public:
RefClkFrequencyNumber() = default;
protected:
void control(float value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "refclk_prescaler_number.h"
namespace esphome {
namespace si4713 {
void RefClkPrescalerNumber::control(float value) {
this->publish_state(value);
this->parent_->set_refclk_prescaler(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/number/number.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class RefClkPrescalerNumber : public number::Number, public Parented<Si4713Component> {
public:
RefClkPrescalerNumber() = default;
protected:
void control(float value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "tuner_antcap_number.h"
namespace esphome {
namespace si4713 {
void TunerAntcapNumber::control(float value) {
this->publish_state(value);
this->parent_->set_tuner_antcap(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/number/number.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class TunerAntcapNumber : public number::Number, public Parented<Si4713Component> {
public:
TunerAntcapNumber() = default;
protected:
void control(float value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "tuner_deviation_number.h"
namespace esphome {
namespace si4713 {
void TunerDeviationNumber::control(float value) {
this->publish_state(value);
this->parent_->set_tuner_deviation(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/number/number.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class TunerDeviationNumber : public number::Number, public Parented<Si4713Component> {
public:
TunerDeviationNumber() = default;
protected:
void control(float value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "tuner_frequency_number.h"
namespace esphome {
namespace si4713 {
void TunerFrequencyNumber::control(float value) {
this->publish_state(value);
this->parent_->set_tuner_frequency(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/number/number.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class TunerFrequencyNumber : public number::Number, public Parented<Si4713Component> {
public:
TunerFrequencyNumber() = default;
protected:
void control(float value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "tuner_power_number.h"
namespace esphome {
namespace si4713 {
void TunerPowerNumber::control(float value) {
this->publish_state(value);
this->parent_->set_tuner_power(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/number/number.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class TunerPowerNumber : public number::Number, public Parented<Si4713Component> {
public:
TunerPowerNumber() = default;
protected:
void control(float value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,25 +0,0 @@
#include "binary_output.h"
#include "esphome/core/log.h"
namespace esphome {
namespace si4713 {
static const char *const TAG = "si4713";
void BinaryOutput::dump_config() {
ESP_LOGCONFIG(TAG, "Si4713 Output:");
LOG_BINARY_OUTPUT(this);
ESP_LOGCONFIG(TAG, " Pin: %d", this->pin_);
}
void BinaryOutput::write_state(bool state) {
this->parent_->set_output_gpio(this->pin_, state);
}
} // namespace si4713
} // namespace esphome

View file

@ -9,12 +9,12 @@ namespace si4713 {
class BinaryOutput : public output::BinaryOutput, public Component, public Parented<Si4713Component> {
public:
void dump_config() override;
void set_pin(uint8_t pin) { this->pin_ = pin - 1; }
protected:
void write_state(bool state) override;
void write_state(bool state) override {
this->parent_->set_output_gpio(this->pin_, state);
}
uint8_t pin_{0};
};

View file

@ -1,14 +0,0 @@
#include "acomp_attack_select.h"
namespace esphome {
namespace si4713 {
void AcompAttackSelect::control(const std::string &value) {
this->publish_state(value);
if (auto index = this->active_index()) {
this->parent_->set_acomp_attack((AcompAttack) *index);
}
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/select/select.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class AcompAttackSelect : public select::Select, public Parented<Si4713Component> {
public:
AcompAttackSelect() = default;
protected:
void control(const std::string &value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,14 +0,0 @@
#include "acomp_preset_select.h"
namespace esphome {
namespace si4713 {
void AcompPresetSelect::control(const std::string &value) {
this->publish_state(value);
if (auto index = this->active_index()) {
this->parent_->set_acomp_preset((AcompPreset) *index);
}
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/select/select.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class AcompPresetSelect : public select::Select, public Parented<Si4713Component> {
public:
AcompPresetSelect() = default;
protected:
void control(const std::string &value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,14 +0,0 @@
#include "acomp_release_select.h"
namespace esphome {
namespace si4713 {
void AcompReleaseSelect::control(const std::string &value) {
this->publish_state(value);
if (auto index = this->active_index()) {
this->parent_->set_acomp_release((AcompRelease) *index);
}
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/select/select.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class AcompReleaseSelect : public select::Select, public Parented<Si4713Component> {
public:
AcompReleaseSelect() = default;
protected:
void control(const std::string &value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,14 +0,0 @@
#include "analog_attenuation_select.h"
namespace esphome {
namespace si4713 {
void AnalogAttenuationSelect::control(const std::string &value) {
this->publish_state(value);
if (auto index = this->active_index()) {
this->parent_->set_analog_attenuation((LineAttenuation) *index);
}
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/select/select.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class AnalogAttenuationSelect : public select::Select, public Parented<Si4713Component> {
public:
AnalogAttenuationSelect() = default;
protected:
void control(const std::string &value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,14 +0,0 @@
#include "digital_channels_select.h"
namespace esphome {
namespace si4713 {
void DigitalChannelsSelect::control(const std::string &value) {
this->publish_state(value);
if (auto index = this->active_index()) {
this->parent_->set_digital_channels((SampleChannels) *index);
}
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/select/select.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class DigitalChannelsSelect : public select::Select, public Parented<Si4713Component> {
public:
DigitalChannelsSelect() = default;
protected:
void control(const std::string &value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,14 +0,0 @@
#include "digital_clock_edge_select.h"
namespace esphome {
namespace si4713 {
void DigitalClockEdgeSelect::control(const std::string &value) {
this->publish_state(value);
if (auto index = this->active_index()) {
this->parent_->set_digital_clock_edge((DigitalClockEdge) *index);
}
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/select/select.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class DigitalClockEdgeSelect : public select::Select, public Parented<Si4713Component> {
public:
DigitalClockEdgeSelect() = default;
protected:
void control(const std::string &value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,14 +0,0 @@
#include "digital_mode_select.h"
namespace esphome {
namespace si4713 {
void DigitalModeSelect::control(const std::string &value) {
this->publish_state(value);
if (auto index = this->active_index()) {
this->parent_->set_digital_mode((DigitalMode) *index);
}
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/select/select.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class DigitalModeSelect : public select::Select, public Parented<Si4713Component> {
public:
DigitalModeSelect() = default;
protected:
void control(const std::string &value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,14 +0,0 @@
#include "digital_sample_bits_select.h"
namespace esphome {
namespace si4713 {
void DigitalSampleBitsSelect::control(const std::string &value) {
this->publish_state(value);
if (auto index = this->active_index()) {
this->parent_->set_digital_sample_bits((SampleBits) *index);
}
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/select/select.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class DigitalSampleBitsSelect : public select::Select, public Parented<Si4713Component> {
public:
DigitalSampleBitsSelect() = default;
protected:
void control(const std::string &value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,14 +0,0 @@
#include "pre_emphasis_select.h"
namespace esphome {
namespace si4713 {
void PreEmphasisSelect::control(const std::string &value) {
this->publish_state(value);
if (auto index = this->active_index()) {
this->parent_->set_pre_emphasis((PreEmphasis) *index);
}
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/select/select.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class PreEmphasisSelect : public select::Select, public Parented<Si4713Component> {
public:
PreEmphasisSelect() = default;
protected:
void control(const std::string &value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,14 +0,0 @@
#include "refclk_source_select.h"
namespace esphome {
namespace si4713 {
void RefClkSourceSelect::control(const std::string &value) {
this->publish_state(value);
if (auto index = this->active_index()) {
this->parent_->set_refclk_source((RefClkSource) *index);
}
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/select/select.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class RefClkSourceSelect : public select::Select, public Parented<Si4713Component> {
public:
RefClkSourceSelect() = default;
protected:
void control(const std::string &value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -0,0 +1,111 @@
#pragma once
#include "esphome/components/select/select.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class AcompAttackSelect : public select::Select, public Parented<Si4713Component> {
protected:
void control(const std::string &value) override {
this->publish_state(value);
if (auto index = this->active_index()) {
this->parent_->set_acomp_attack((AcompAttack) *index);
}
}
};
class AcompPresetSelect : public select::Select, public Parented<Si4713Component> {
protected:
void control(const std::string &value) override {
this->publish_state(value);
if (auto index = this->active_index()) {
this->parent_->set_acomp_preset((AcompPreset) *index);
}
}
};
class AcompReleaseSelect : public select::Select, public Parented<Si4713Component> {
protected:
void control(const std::string &value) override {
this->publish_state(value);
if (auto index = this->active_index()) {
this->parent_->set_acomp_release((AcompRelease) *index);
}
}
};
class AnalogAttenuationSelect : public select::Select, public Parented<Si4713Component> {
protected:
void control(const std::string &value) override {
this->publish_state(value);
if (auto index = this->active_index()) {
this->parent_->set_analog_attenuation((LineAttenuation) *index);
}
}
};
class DigitalChannelsSelect : public select::Select, public Parented<Si4713Component> {
protected:
void control(const std::string &value) override {
this->publish_state(value);
if (auto index = this->active_index()) {
this->parent_->set_digital_channels((SampleChannels) *index);
}
}
};
class DigitalClockEdgeSelect : public select::Select, public Parented<Si4713Component> {
protected:
void control(const std::string &value) override {
this->publish_state(value);
if (auto index = this->active_index()) {
this->parent_->set_digital_clock_edge((DigitalClockEdge) *index);
}
}
};
class DigitalModeSelect : public select::Select, public Parented<Si4713Component> {
protected:
void control(const std::string &value) override {
this->publish_state(value);
if (auto index = this->active_index()) {
this->parent_->set_digital_mode((DigitalMode) *index);
}
}
};
class DigitalSampleBitsSelect : public select::Select, public Parented<Si4713Component> {
protected:
void control(const std::string &value) override {
this->publish_state(value);
if (auto index = this->active_index()) {
this->parent_->set_digital_sample_bits((SampleBits) *index);
}
}
};
class PreEmphasisSelect : public select::Select, public Parented<Si4713Component> {
protected:
void control(const std::string &value) override {
this->publish_state(value);
if (auto index = this->active_index()) {
this->parent_->set_pre_emphasis((PreEmphasis) *index);
}
}
};
class RefClkSourceSelect : public select::Select, public Parented<Si4713Component> {
protected:
void control(const std::string &value) override {
this->publish_state(value);
if (auto index = this->active_index()) {
this->parent_->set_refclk_source((RefClkSource) *index);
}
}
};
} // namespace si4713
} // namespace esphome

View file

@ -45,9 +45,9 @@ bool Si4713Component::send_cmd(const void *cmd, size_t cmd_size, void *res, size
return false;
}
uint8_t status = 0;
while (!(status & SI4710_STATUS_CTS)) {
err = this->read(&status, 1); // TODO: read res_size into res here?
ResBase status;
while(status.CTS == 0) {
err = this->read((uint8_t*) &status, 1); // TODO: read res_size into res here?
if (err != i2c::ERROR_OK) {
ESP_LOGE(TAG, "send_cmd(0x%02X, %d) read status error", buff[0], cmd_size);
// this->mark_failed();

View file

@ -3,8 +3,6 @@
namespace esphome {
namespace si4713 {
static const uint8_t SI4710_STATUS_CTS = 0x80;
static const float FREQ_MIN = 76;
static const float FREQ_MAX = 108;
static const int FREQ_RAW_MIN = 7600;

View file

@ -174,33 +174,33 @@ CONFIG_SCHEMA = cv.Schema(
VARIABLES = {
None: [
[CONF_MUTE, None],
[CONF_MONO, None],
[CONF_MUTE],
[CONF_MONO],
],
CONF_TUNER: [
[CONF_ENABLE, None],
[CONF_ENABLE],
],
CONF_PILOT: [
[CONF_ENABLE, None],
[CONF_ENABLE],
],
CONF_ACOMP: [
[CONF_ENABLE, None],
[CONF_ENABLE],
],
CONF_LIMITER: [
[CONF_ENABLE, None],
[CONF_ENABLE],
],
CONF_ASQ: [
[CONF_IALL, None],
[CONF_IALH, None],
[CONF_OVERMOD, None],
[CONF_IALL],
[CONF_IALH],
[CONF_OVERMOD],
],
CONF_RDS: [
[CONF_ENABLE, None],
[CONF_ENABLE],
],
CONF_OUTPUT: [
[CONF_GPIO1, lambda sw: sw.set_pin(1)],
[CONF_GPIO2, lambda sw: sw.set_pin(2)],
[CONF_GPIO3, lambda sw: sw.set_pin(3)],
[CONF_GPIO1],
[CONF_GPIO2],
[CONF_GPIO3],
],
}
@ -211,8 +211,12 @@ async def to_code(config):
async def new_switch(c, args, setter):
s = await switch.new_switch(c)
await cg.register_parented(s, parent)
sw = cg.add(getattr(parent, setter + "_switch")(s))
if cb := s[1]:
cb(sw)
cg.add(getattr(parent, setter + "_switch")(s))
if args[0] == CONF_GPIO1:
cg.add(s.set_pin(1))
elif args[0] == CONF_GPIO2:
cg.add(s.set_pin(2))
elif args[0] == CONF_GPIO3:
cg.add(s.set_pin(3))
await for_each_conf(config, VARIABLES, new_switch)

View file

@ -1,12 +0,0 @@
#include "acomp_enable_switch.h"
namespace esphome {
namespace si4713 {
void AcompEnableSwitch::write_state(bool value) {
this->publish_state(value);
this->parent_->set_acomp_enable(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/switch/switch.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class AcompEnableSwitch : public switch_::Switch, public Parented<Si4713Component> {
public:
AcompEnableSwitch() = default;
protected:
void write_state(bool value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "asq_ialh_switch.h"
namespace esphome {
namespace si4713 {
void AsqIalhSwitch::write_state(bool value) {
this->publish_state(value);
this->parent_->set_asq_ialh(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/switch/switch.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class AsqIalhSwitch : public switch_::Switch, public Parented<Si4713Component> {
public:
AsqIalhSwitch() = default;
protected:
void write_state(bool value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "asq_iall_switch.h"
namespace esphome {
namespace si4713 {
void AsqIallSwitch::write_state(bool value) {
this->publish_state(value);
this->parent_->set_asq_iall(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/switch/switch.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class AsqIallSwitch : public switch_::Switch, public Parented<Si4713Component> {
public:
AsqIallSwitch() = default;
protected:
void write_state(bool value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "asq_overmod_switch.h"
namespace esphome {
namespace si4713 {
void AsqOvermodSwitch::write_state(bool value) {
this->publish_state(value);
this->parent_->set_asq_overmod(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/switch/switch.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class AsqOvermodSwitch : public switch_::Switch, public Parented<Si4713Component> {
public:
AsqOvermodSwitch() = default;
protected:
void write_state(bool value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "limiter_enable_switch.h"
namespace esphome {
namespace si4713 {
void LimiterEnableSwitch::write_state(bool value) {
this->publish_state(value);
this->parent_->set_limiter_enable(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/switch/switch.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class LimiterEnableSwitch : public switch_::Switch, public Parented<Si4713Component> {
public:
LimiterEnableSwitch() = default;
protected:
void write_state(bool value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "mono_switch.h"
namespace esphome {
namespace si4713 {
void MonoSwitch::write_state(bool value) {
this->publish_state(value);
this->parent_->set_mono(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/switch/switch.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class MonoSwitch : public switch_::Switch, public Parented<Si4713Component> {
public:
MonoSwitch() = default;
protected:
void write_state(bool value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "mute_switch.h"
namespace esphome {
namespace si4713 {
void MuteSwitch::write_state(bool value) {
this->publish_state(value);
this->parent_->set_mute(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/switch/switch.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class MuteSwitch : public switch_::Switch, public Parented<Si4713Component> {
public:
MuteSwitch() = default;
protected:
void write_state(bool value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "output_gpio_switch.h"
namespace esphome {
namespace si4713 {
void OutputGpioSwitch::write_state(bool value) {
this->publish_state(value);
this->parent_->set_output_gpio(this->pin_, value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,22 +0,0 @@
#pragma once
#include "esphome/components/switch/switch.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class OutputGpioSwitch : public switch_::Switch, public Parented<Si4713Component> {
public:
OutputGpioSwitch() = default;
void set_pin(uint8_t pin) { this->pin_ = pin - 1; }
protected:
void write_state(bool value) override;
uint8_t pin_{0};
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "pilot_enable_switch.h"
namespace esphome {
namespace si4713 {
void PilotEnableSwitch::write_state(bool value) {
this->publish_state(value);
this->parent_->set_pilot_enable(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/switch/switch.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class PilotEnableSwitch : public switch_::Switch, public Parented<Si4713Component> {
public:
PilotEnableSwitch() = default;
protected:
void write_state(bool value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "rds_enable_switch.h"
namespace esphome {
namespace si4713 {
void RDSEnableSwitch::write_state(bool value) {
this->publish_state(value);
this->parent_->set_rds_enable(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/switch/switch.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class RDSEnableSwitch : public switch_::Switch, public Parented<Si4713Component> {
public:
RDSEnableSwitch() = default;
protected:
void write_state(bool value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -0,0 +1,103 @@
#pragma once
#include "esphome/components/switch/switch.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class AcompEnableSwitch : public switch_::Switch, public Parented<Si4713Component> {
protected:
void write_state(bool value) override {
this->publish_state(value);
this->parent_->set_acomp_enable(value);
}
};
class AsqIalhSwitch : public switch_::Switch, public Parented<Si4713Component> {
protected:
void write_state(bool value) override {
this->publish_state(value);
this->parent_->set_asq_ialh(value);
}
};
class AsqIallSwitch : public switch_::Switch, public Parented<Si4713Component> {
protected:
void write_state(bool value) override {
this->publish_state(value);
this->parent_->set_asq_iall(value);
}
};
class AsqOvermodSwitch : public switch_::Switch, public Parented<Si4713Component> {
protected:
void write_state(bool value) override {
this->publish_state(value);
this->parent_->set_asq_overmod(value);
}
};
class LimiterEnableSwitch : public switch_::Switch, public Parented<Si4713Component> {
protected:
void write_state(bool value) override {
this->publish_state(value);
this->parent_->set_limiter_enable(value);
}
};
class MonoSwitch : public switch_::Switch, public Parented<Si4713Component> {
protected:
void write_state(bool value) override {
this->publish_state(value);
this->parent_->set_mono(value);
}
};
class MuteSwitch : public switch_::Switch, public Parented<Si4713Component> {
protected:
void write_state(bool value) override {
this->publish_state(value);
this->parent_->set_mute(value);
}
};
class OutputGpioSwitch : public switch_::Switch, public Parented<Si4713Component> {
public:
void set_pin(uint8_t pin) { this->pin_ = pin - 1; }
protected:
void write_state(bool value) override {
this->publish_state(value);
this->parent_->set_output_gpio(this->pin_, value);
}
uint8_t pin_{0};
};
class PilotEnableSwitch : public switch_::Switch, public Parented<Si4713Component> {
protected:
void write_state(bool value) override {
this->publish_state(value);
this->parent_->set_pilot_enable(value);
}
};
class RDSEnableSwitch : public switch_::Switch, public Parented<Si4713Component> {
protected:
void write_state(bool value) override {
this->publish_state(value);
this->parent_->set_rds_enable(value);
}
};
class TunerEnableSwitch : public switch_::Switch, public Parented<Si4713Component> {
protected:
void write_state(bool value) override {
this->publish_state(value);
this->parent_->set_tuner_enable(value);
}
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "tuner_enable_switch.h"
namespace esphome {
namespace si4713 {
void TunerEnableSwitch::write_state(bool value) {
this->publish_state(value);
this->parent_->set_tuner_enable(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/switch/switch.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class TunerEnableSwitch : public switch_::Switch, public Parented<Si4713Component> {
public:
TunerEnableSwitch() = default;
protected:
void write_state(bool value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "rds_station_text.h"
namespace esphome {
namespace si4713 {
void RDSStationText::control(const std::string &value) {
this->publish_state(value);
this->parent_->set_rds_station(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/text/text.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class RDSStationText : public text::Text, public Parented<Si4713Component> {
public:
RDSStationText() = default;
protected:
void control(const std::string &value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -1,12 +0,0 @@
#include "rds_text_text.h"
namespace esphome {
namespace si4713 {
void RDSTextText::control(const std::string &value) {
this->publish_state(value);
this->parent_->set_rds_text(value);
}
} // namespace si4713
} // namespace esphome

View file

@ -1,18 +0,0 @@
#pragma once
#include "esphome/components/text/text.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class RDSTextText : public text::Text, public Parented<Si4713Component> {
public:
RDSTextText() = default;
protected:
void control(const std::string &value) override;
};
} // namespace si4713
} // namespace esphome

View file

@ -0,0 +1,26 @@
#pragma once
#include "esphome/components/text/text.h"
#include "../si4713.h"
namespace esphome {
namespace si4713 {
class RDSStationText : public text::Text, public Parented<Si4713Component> {
protected:
void control(const std::string &value) override {
this->publish_state(value);
this->parent_->set_rds_station(value);
}
};
class RDSTextText : public text::Text, public Parented<Si4713Component> {
protected:
void control(const std::string &value) override {
this->publish_state(value);
this->parent_->set_rds_text(value);
}
};
} // namespace si4713
} // namespace esphome