Implement get and set channel in cmt2300 wrapper class

This commit is contained in:
Thomas Basler 2023-04-10 00:29:21 +02:00
parent fffd872b20
commit 2a92f67a9a
3 changed files with 23 additions and 3 deletions

View File

@ -60,6 +60,16 @@ bool CMT2300A::write(const uint8_t* buf, uint8_t len)
return true; return true;
} }
void CMT2300A::setChannel(uint8_t channel)
{
CMT2300A_SetFrequencyChannel(channel);
}
uint8_t CMT2300A::getChannel(void)
{
return CMT2300A_ReadReg(CMT2300A_CUS_FREQ_CHNL);
}
bool CMT2300A::setPALevel(int8_t level) bool CMT2300A::setPALevel(int8_t level)
{ {
uint16_t Tx_dBm_word; uint16_t Tx_dBm_word;

View File

@ -21,6 +21,18 @@ public:
bool write(const uint8_t* buf, uint8_t len); bool write(const uint8_t* buf, uint8_t len);
/**
* Set RF communication channel. The frequency used by a channel is
* @param channel Which RF channel to communicate on, 0-254
*/
void setChannel(uint8_t channel);
/**
* Get RF communication channel
* @return The currently configured RF Channel
*/
uint8_t getChannel(void);
bool setPALevel(int8_t level); bool setPALevel(int8_t level);
private: private:

View File

@ -26,9 +26,7 @@ String HoymilesRadio_CMT::cmtChToFreq(const uint8_t channel)
void HoymilesRadio_CMT::cmtSwitchChannel(const uint8_t channel) void HoymilesRadio_CMT::cmtSwitchChannel(const uint8_t channel)
{ {
yield(); _radio->setChannel(channel);
CMT2300A_SetFrequencyChannel(channel);
yield();
cmtCurrentCh = channel; cmtCurrentCh = channel;
} }