Skip to content

Commit

Permalink
feat: disable sound completely when "squelch" closed
Browse files Browse the repository at this point in the history
  • Loading branch information
fagci committed Aug 13, 2023
1 parent 28817c7 commit d050bdc
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/spectrum_fagci/spectrum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ template <Radio::CBK4819 &RadioDriver> class CSpectrum {
static constexpr auto BarPos = 5 * 128;

static constexpr auto ModesCount = 7;
static constexpr auto LastLowBWModeIndex = 3;

static constexpr u32 modeHalfSpectrumBW[ModesCount] = {
16_KHz, 50_KHz, 100_KHz, 200_KHz, 400_KHz, 800_KHz, 1600_KHz};
Expand All @@ -28,8 +29,6 @@ template <Radio::CBK4819 &RadioDriver> class CSpectrum {
u8 rssiMin = 255;
u8 btnCounter = 0;

bool resetBlacklist = false;

CSpectrum()
: DisplayBuff(gDisplayBuffer), Display(DisplayBuff),
FontSmallNr(gSmallDigs), scanDelay(800), mode(5), rssiTriggerLevel(50) {
Expand All @@ -44,7 +43,7 @@ template <Radio::CBK4819 &RadioDriver> class CSpectrum {

fMeasure = GetFStart();

RadioDriver.ToggleAFDAC(false);
// RadioDriver.ToggleAFDAC(false);
MuteAF();

u16 scanStep = GetScanStep();
Expand Down Expand Up @@ -217,10 +216,12 @@ template <Radio::CBK4819 &RadioDriver> class CSpectrum {
void Update() {
if (peakRssi >= rssiTriggerLevel) {
ToggleGreen(true);
GPIOC->DATA |= GPIO_PIN_4;
Listen();
}
if (peakRssi < rssiTriggerLevel) {
ToggleGreen(false);
GPIOC->DATA &= ~GPIO_PIN_4;
Scan();
}
}
Expand Down Expand Up @@ -290,7 +291,7 @@ template <Radio::CBK4819 &RadioDriver> class CSpectrum {

void ResetPeak() { peakRssi = 0; }

void SetBW() { BK4819SetChannelBandwidth(mode < 4); }
void SetBW() { BK4819SetChannelBandwidth(mode <= LastLowBWModeIndex); }
void MuteAF() { BK4819Write(0x47, 0); }
void RestoreOldAFSettings() { BK4819Write(0x47, oldAFSettings); }

Expand All @@ -299,7 +300,7 @@ template <Radio::CBK4819 &RadioDriver> class CSpectrum {
fMeasure = peakF;
RadioDriver.SetFrequency(fMeasure);
RestoreOldAFSettings();
RadioDriver.ToggleAFDAC(true);
// RadioDriver.ToggleAFDAC(true);
}
for (u8 i = 0; i < 16 && PollKeyboard() == 255; ++i) {
DelayMs(64);
Expand All @@ -322,7 +323,7 @@ template <Radio::CBK4819 &RadioDriver> class CSpectrum {
u8 GetRssi() {
ResetRSSI();

DelayUs(scanDelay << (mode < 4));
DelayUs(scanDelay << (mode <= LastLowBWModeIndex));
auto v = BK4819Read(0x67) & 0x1FF;
return v < 255 ? v : 255;
}
Expand Down Expand Up @@ -362,4 +363,5 @@ template <Radio::CBK4819 &RadioDriver> class CSpectrum {
u32 frequencyChangeStep;

bool isInitialized;
bool resetBlacklist;
};

0 comments on commit d050bdc

Please sign in to comment.