Skip to content

Commit

Permalink
Move HOY_BOOT_FREQ from define to function
Browse files Browse the repository at this point in the history
  • Loading branch information
tbnobody committed Jan 13, 2024
1 parent 58f0121 commit 16cd1a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/Hoymiles/src/HoymilesRadio_CMT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include "crc.h"
#include <FunctionalInterrupt.h>

#define HOY_BOOT_FREQ 868000000 // Hoymiles boot/init frequency after power up inverter or connection lost for 15 min

uint32_t HoymilesRadio_CMT::getFrequencyFromChannel(const uint8_t channel) const
{
return (_radio->getBaseFrequency() + channel * getChannelWidth());
Expand Down Expand Up @@ -199,6 +197,12 @@ uint32_t HoymilesRadio_CMT::getChannelWidth()
return FH_OFFSET * CMT2300A_ONE_STEP_SIZE;
}

uint32_t HoymilesRadio_CMT::getInvBootFrequency()
{
// Hoymiles boot/init frequency after power up inverter or connection lost for 15 min
return 868000000;
}

void ARDUINO_ISR_ATTR HoymilesRadio_CMT::handleInt1()
{
_packetSent = true;
Expand All @@ -218,7 +222,7 @@ void HoymilesRadio_CMT::sendEsbPacket(CommandAbstract& cmd)
_radio->stopListening();

if (cmd.getDataPayload()[0] == 0x56) { // @todo(tbnobody) Bad hack to identify ChannelChange Command
cmtSwitchDtuFreq(HOY_BOOT_FREQ);
cmtSwitchDtuFreq(getInvBootFrequency());
}

Hoymiles.getMessageOutput()->printf("TX %s %.2f MHz --> ",
Expand Down
2 changes: 2 additions & 0 deletions lib/Hoymiles/src/HoymilesRadio_CMT.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class HoymilesRadio_CMT : public HoymilesRadio {
uint32_t getMaxFrequency() const;
static uint32_t getChannelWidth();

static uint32_t getInvBootFrequency();

uint32_t getFrequencyFromChannel(const uint8_t channel) const;
uint8_t getChannelFromFrequency(const uint32_t frequency) const;

Expand Down

0 comments on commit 16cd1a9

Please sign in to comment.