Set RC Switch protocol TX carrier frequen to 38kHz

The RC Switch protocol can be used for both RF and IR remotes. RF
Remotes don't require generating a carrier signal, so, as pointed out in
the [remote transmitter configuration variables docs](https://esphome.io/components/remote_transmitter#configuration-variables),
that carrier frequency can be nullified by setting the duty cycle to
100%.

Since this protocol is also used with IR devices, a 50% duty cycle
should still result in a carrier frequency being generated. Therefore,
this sets the frequency to 38kHz in the protocol implementaion, allowing
the user to cancel it out in YAML config.

When this carrier frequency is left to 0, then even with the duty cycle
set to 50%, infrarer transmitters don't include the carrier, and thus
demodulators don't pick up the signal at all.

So to summarise, this one liner enables the use of the RC Switch
protocol for IR as well as RF.
This commit is contained in:
Michael Duerinckx 2023-09-20 16:30:08 +01:00
parent 11f6e555f9
commit adbe06543e
1 changed files with 1 additions and 1 deletions

View File

@ -54,7 +54,7 @@ void RCSwitchBase::sync(RemoteTransmitData *dst) const {
}
}
void RCSwitchBase::transmit(RemoteTransmitData *dst, uint64_t code, uint8_t len) const {
dst->set_carrier_frequency(0);
dst->set_carrier_frequency(38000);
this->sync(dst);
for (int16_t i = len - 1; i >= 0; i--) {
if (code & ((uint64_t) 1 << i)) {