mirror of
https://github.com/meshtastic/meshtastic.git
synced 2024-12-31 16:37:32 -08:00
simplify
This commit is contained in:
parent
3856459fce
commit
045c5f7dd5
|
@ -263,22 +263,21 @@ export const FrequencyCalculator = (): JSX.Element => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const selectedRegion = RegionData.get(region);
|
const selectedRegion = RegionData.get(region);
|
||||||
const selectedModemPreset = modemPresets.get(modemPreset);
|
const selectedModemPreset = modemPresets.get(modemPreset);
|
||||||
const calculatedNumChannels = Math.floor(
|
setNumChannels(
|
||||||
|
Math.floor(
|
||||||
(selectedRegion.freq_end - selectedRegion.freq_start) /
|
(selectedRegion.freq_end - selectedRegion.freq_start) /
|
||||||
(selectedRegion.spacing + selectedModemPreset.bw / 1000),
|
(selectedRegion.spacing + selectedModemPreset.bw / 1000),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
setNumChannels(calculatedNumChannels);
|
|
||||||
|
|
||||||
let updatedChannel = channel;
|
if (channel >= numChannels) {
|
||||||
if (updatedChannel >= calculatedNumChannels) {
|
setChannel(numChannels - 1);
|
||||||
updatedChannel = calculatedNumChannels - 1;
|
|
||||||
}
|
}
|
||||||
setChannel(updatedChannel);
|
|
||||||
|
|
||||||
setChannelFrequency(
|
setChannelFrequency(
|
||||||
selectedRegion.freq_start +
|
selectedRegion.freq_start +
|
||||||
selectedModemPreset.bw / 2000 +
|
selectedModemPreset.bw / 2000 +
|
||||||
updatedChannel * (selectedModemPreset.bw / 1000),
|
channel * (selectedModemPreset.bw / 1000),
|
||||||
);
|
);
|
||||||
}, [modemPreset, region, channel]);
|
}, [modemPreset, region, channel]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue