Files
esphome-dev/esphome/components/remote_base/lg_protocol.h
T
Andrew Zaborowski a62b6548d2 Make some Action methods protected
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.
2020-05-01 12:44:30 +02:00

41 lines
972 B
C++

#pragma once
#include "esphome/core/component.h"
#include "remote_base.h"
namespace esphome {
namespace remote_base {
struct LGData {
uint32_t data;
uint8_t nbits;
bool operator==(const LGData &rhs) const { return data == rhs.data && nbits == rhs.nbits; }
};
class LGProtocol : public RemoteProtocol<LGData> {
public:
void encode(RemoteTransmitData *dst, const LGData &data) override;
optional<LGData> decode(RemoteReceiveData src) override;
void dump(const LGData &data) override;
};
DECLARE_REMOTE_PROTOCOL(LG)
template<typename... Ts> class LGAction : public RemoteTransmitterActionBase<Ts...> {
public:
TEMPLATABLE_VALUE(uint32_t, data)
TEMPLATABLE_VALUE(uint8_t, nbits)
protected:
void encode_(RemoteTransmitData *dst, Ts... x) override {
LGData data{};
data.data = this->data_.value(x...);
data.nbits = this->nbits_.value(x...);
LGProtocol().encode(dst, data);
}
};
} // namespace remote_base
} // namespace esphome