Skip to content

Commit

Permalink
Merge pull request #17 from kamilsss655/feat4
Browse files Browse the repository at this point in the history
closes #14
  • Loading branch information
kamilsss655 authored Dec 28, 2023
2 parents 5482522 + 3ef5951 commit 0f0dc52
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
case MENU_R_CTCS:
case MENU_T_CTCS:
*pMin = 0;
*pMax = ARRAY_SIZE(CTCSS_Options) - 1;
*pMax = ARRAY_SIZE(CTCSS_Options);
break;

case MENU_W_N:
Expand Down
36 changes: 26 additions & 10 deletions app/spectrum.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct FrequencyBandInfo {
Mode appMode;
//Idea - make this user adjustable to compensate for different antennas, frontends, conditions
#define UHF_NOISE_FLOOR 40
uint8_t scanChannel[MR_CHANNEL_LAST];
uint8_t scanChannel[MR_CHANNEL_LAST+1];
uint8_t scanChannelsCount;
void ToggleScanList();
void AutoAdjustResolution();
Expand Down Expand Up @@ -121,6 +121,8 @@ RegisterSpec registerSpecs[] = {

uint16_t statuslineUpdateTimer = 0;

static void RelaunchScan();

static uint8_t DBm2S(int dbm) {
uint8_t i = 0;
dbm *= -1;
Expand Down Expand Up @@ -285,7 +287,8 @@ uint16_t GetStepsCount()
#ifdef ENABLE_SPECTRUM_CHANNEL_SCAN
if (appMode==CHANNEL_MODE)
{
return scanChannelsCount;
// hack: adds 1 step count if steps > 128 to properly average and display last channel
return scanChannelsCount <= 128 ? scanChannelsCount : scanChannelsCount+1;
}
#endif
#ifdef ENABLE_SCAN_RANGES
Expand Down Expand Up @@ -441,6 +444,13 @@ static void ResetBlacklist() {
memset(blacklistFreqs, 0, sizeof(blacklistFreqs));
blacklistFreqsIdx = 0;
#endif
if(appMode==CHANNEL_MODE){
scanChannelsCount = RADIO_ValidMemoryChannelsCount(true, settings.scanList);
LoadValidMemoryChannels();
AutoAdjustResolution();
}

RelaunchScan();
}

static void RelaunchScan() {
Expand Down Expand Up @@ -553,7 +563,6 @@ static void UpdateScanStep(bool inc) {
return;
}
settings.frequencyChangeStep = GetBW() >> 1;
RelaunchScan();
ResetBlacklist();
redrawScreen = true;
}
Expand All @@ -566,7 +575,6 @@ static void UpdateCurrentFreq(bool inc) {
} else {
return;
}
RelaunchScan();
ResetBlacklist();
redrawScreen = true;
}
Expand Down Expand Up @@ -629,7 +637,6 @@ static void ToggleStepsCount() {
settings.stepsCount--;
}
settings.frequencyChangeStep = GetBW() >> 1;
RelaunchScan();
ResetBlacklist();
redrawScreen = true;
}
Expand Down Expand Up @@ -711,7 +718,15 @@ static void Blacklist() {
#ifdef ENABLE_SCAN_RANGES
static uint8_t ScanRangeidx()
{
return (uint32_t)ARRAY_SIZE(rssiHistory) * 1000 / scanInfo.measurementsCount * scanInfo.i / 1000;
if(scanInfo.measurementsCount > 128) {
uint8_t i = (uint32_t)ARRAY_SIZE(rssiHistory) * 1000 / scanInfo.measurementsCount * scanInfo.i / 1000;
return i;
}
else
{
return 0;
}

}

static bool IsBlacklisted(uint16_t idx)
Expand Down Expand Up @@ -1055,7 +1070,6 @@ static void OnKeyDownFreqInput(uint8_t key) {
currentFreq = tempFreq;
if (currentState == SPECTRUM) {
ResetBlacklist();
RelaunchScan();
} else {
SetF(currentFreq);
}
Expand Down Expand Up @@ -1493,13 +1507,16 @@ void APP_RunSpectrum() {
{
int nextChannel;
nextChannel = RADIO_FindNextChannel((channelIndex)+1, 1, true, settings.scanList);
channelIndex = nextChannel;
scanChannel[i]=channelIndex;

if (nextChannel == 0xFF)
{ // no valid channel found
break;
}
else
{
channelIndex = nextChannel;
scanChannel[i]=channelIndex;
}
}
}

Expand All @@ -1516,7 +1533,6 @@ void APP_RunSpectrum() {

scanChannelsCount = RADIO_ValidMemoryChannelsCount(true, settings.scanList);
LoadValidMemoryChannels();
RelaunchScan();
ResetBlacklist();
AutoAdjustResolution();
}
Expand Down
2 changes: 1 addition & 1 deletion board.c
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ void BOARD_gMR_LoadChannels() {
uint8_t i;
uint32_t freq_buf;

for (i = MR_CHANNEL_FIRST; i < MR_CHANNEL_LAST; i++)
for (i = MR_CHANNEL_FIRST; i <= MR_CHANNEL_LAST; i++)
{
freq_buf = BOARD_fetchChannelFrequency(i);

Expand Down
4 changes: 1 addition & 3 deletions ui/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ const int CHANNEL_ONLY_SETTINGS[] = {
MENU_1_CALL
};

const int VFO_ONLY_SETTINGS[] = {
MENU_MEM_CH
};
const int VFO_ONLY_SETTINGS[] = {};

const uint8_t FIRST_HIDDEN_MENU_ITEM = MENU_F_LOCK;

Expand Down

0 comments on commit 0f0dc52

Please sign in to comment.