mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-30 01:38:27 +02:00
a62b6548d2
Apparently play()/stop() etc. are not meant to be called directly by users of the class and if they're called directly that would not give the expected result for the classes that have an empty play(). Make all methods except play_complex, stop_comples and is_running protected. While there also make RemoteTransmitterActionBase::encode protected.
40 lines
1.0 KiB
C++
40 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include "remote_base.h"
|
|
|
|
namespace esphome {
|
|
namespace remote_base {
|
|
|
|
struct PioneerData {
|
|
uint16_t rc_code_1;
|
|
uint16_t rc_code_2;
|
|
|
|
bool operator==(const PioneerData &rhs) const { return rc_code_1 == rhs.rc_code_1 && rc_code_2 == rhs.rc_code_2; }
|
|
};
|
|
|
|
class PioneerProtocol : public RemoteProtocol<PioneerData> {
|
|
public:
|
|
void encode(RemoteTransmitData *dst, const PioneerData &data) override;
|
|
optional<PioneerData> decode(RemoteReceiveData src) override;
|
|
void dump(const PioneerData &data) override;
|
|
};
|
|
|
|
DECLARE_REMOTE_PROTOCOL(Pioneer)
|
|
|
|
template<typename... Ts> class PioneerAction : public RemoteTransmitterActionBase<Ts...> {
|
|
public:
|
|
TEMPLATABLE_VALUE(uint16_t, rc_code_1)
|
|
TEMPLATABLE_VALUE(uint16_t, rc_code_2)
|
|
|
|
protected:
|
|
void encode_(RemoteTransmitData *dst, Ts... x) override {
|
|
PioneerData data{};
|
|
data.rc_code_1 = this->rc_code_1_.value(x...);
|
|
data.rc_code_2 = this->rc_code_2_.value(x...);
|
|
PioneerProtocol().encode(dst, data);
|
|
}
|
|
};
|
|
|
|
} // namespace remote_base
|
|
} // namespace esphome
|