Skip to content

Commit

Permalink
webapp: Remove hard coded min/max frequencies for CMT module
Browse files Browse the repository at this point in the history
  • Loading branch information
tbnobody committed Jan 13, 2024
1 parent ee78698 commit 2c92750
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/Hoymiles/src/HoymilesRadio_CMT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ uint32_t HoymilesRadio_CMT::getMaxFrequency()
return MAX_FREQ;
}

uint32_t HoymilesRadio_CMT::getChannelWidth()
{
return FH_OFFSET * CMT2300A_ONE_STEP_SIZE;
}

void ARDUINO_ISR_ATTR HoymilesRadio_CMT::handleInt1()
{
_packetSent = true;
Expand Down
1 change: 1 addition & 0 deletions lib/Hoymiles/src/HoymilesRadio_CMT.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class HoymilesRadio_CMT : public HoymilesRadio {

static uint32_t getMinFrequency();
static uint32_t getMaxFrequency();
static uint32_t getChannelWidth();

static uint32_t getFrequencyFromChannel(const uint8_t channel);
static uint8_t getChannelFromFrequency(const uint32_t frequency);
Expand Down
5 changes: 4 additions & 1 deletion src/WebApi_dtu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ void WebApiDtuClass::onDtuAdminGet(AsyncWebServerRequest* request)
root["cmt_enabled"] = Hoymiles.getRadioCmt()->isInitialized();
root["cmt_palevel"] = config.Dtu.Cmt.PaLevel;
root["cmt_frequency"] = config.Dtu.Cmt.Frequency;
root["cmt_min_freq"] = Hoymiles.getRadioCmt()->getMinFrequency();
root["cmt_max_freq"] = Hoymiles.getRadioCmt()->getMaxFrequency();
root["cmt_chan_width"] = Hoymiles.getRadioCmt()->getChannelWidth();

response->setLength();
request->send(response);
Expand Down Expand Up @@ -166,4 +169,4 @@ void WebApiDtuClass::onDtuAdminPost(AsyncWebServerRequest* request)
Hoymiles.getRadioCmt()->setDtuSerial(config.Dtu.Serial);
Hoymiles.getRadioCmt()->setInverterTargetFrequency(config.Dtu.Cmt.Frequency);
Hoymiles.setPollInterval(config.Dtu.PollInterval);
}
}
5 changes: 4 additions & 1 deletion webapp/src/types/DtuConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ export interface DtuConfig {
cmt_enabled: boolean;
cmt_palevel: number;
cmt_frequency: number;
}
cmt_min_freq: number;
cmt_max_freq: number;
cmt_chan_width: number;
}
2 changes: 1 addition & 1 deletion webapp/src/views/DtuAdminView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<div class="input-group mb-3">
<input type="range" class="form-control form-range"
v-model="dtuConfigList.cmt_frequency"
min="860250000" max="923500000" step="250000"
:min="dtuConfigList.cmt_min_freq" :max="dtuConfigList.cmt_max_freq" :step="dtuConfigList.cmt_chan_width"
id="cmtFrequency" aria-describedby="basic-addon2"
style="height: unset;" />
<span class="input-group-text" id="basic-addon2">{{ cmtFrequencyText }}</span>
Expand Down

0 comments on commit 2c92750

Please sign in to comment.