Skip to content

Commit

Permalink
Scrambler inversion frequencies shown in menu
Browse files Browse the repository at this point in the history
  • Loading branch information
OneOfEleven committed Sep 26, 2023
1 parent cb92f2e commit ee05c4f
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 75 deletions.
114 changes: 57 additions & 57 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,80 +861,79 @@ void APP_EndTransmission(void)
}

RADIO_SetupRegisters(false);

if (gMonitor)
ACTION_Monitor(); // 1of11
}

static void APP_HandleVox(void)
{
if (!gSetting_KILLED)
if (gSetting_KILLED)
return;

if (gVoxResumeCountdown == 0)
{
if (gVoxResumeCountdown == 0)
{
if (gVoxPauseCountdown)
return;
}
else
{
g_VOX_Lost = false;
gVoxPauseCountdown = 0;
}
if (gVoxPauseCountdown)
return;
}
else
{
g_VOX_Lost = false;
gVoxPauseCountdown = 0;
}

if (gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_MONITOR &&
gScanState == SCAN_OFF &&
gCssScanMode == CSS_SCAN_MODE_OFF
#ifdef ENABLE_FMRADIO
&& !gFmRadioMode
#endif
)
{
if (gVOX_NoiseDetected)
{
if (g_VOX_Lost)
gVoxStopCountdown_10ms = 100; // 1 sec
else
if (gVoxStopCountdown_10ms == 0)
gVOX_NoiseDetected = false;
#ifdef ENABLE_FMRADIO
if (gFmRadioMode)
return;
#endif

if (gCurrentFunction == FUNCTION_TRANSMIT && !gPttIsPressed && !gVOX_NoiseDetected)
{
if (gFlagEndTransmission)
{
FUNCTION_Select(FUNCTION_FOREGROUND);
}
else
{
APP_EndTransmission();
if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR)
return;

if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
FUNCTION_Select(FUNCTION_FOREGROUND);
else
gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
}
if (gScanState != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF)
return;

gUpdateDisplay = true;
gFlagEndTransmission = false;
if (gVOX_NoiseDetected)
{
if (g_VOX_Lost)
gVoxStopCountdown_10ms = vox_stop_count_down_10ms;
else
if (gVoxStopCountdown_10ms == 0)
gVOX_NoiseDetected = false;

return;
}
if (gCurrentFunction == FUNCTION_TRANSMIT && !gPttIsPressed && !gVOX_NoiseDetected)
{
if (gFlagEndTransmission)
{
FUNCTION_Select(FUNCTION_FOREGROUND);
}
else
if (g_VOX_Lost)
{
gVOX_NoiseDetected = true;

if (gCurrentFunction == FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_FOREGROUND);
APP_EndTransmission();

if (gCurrentFunction != FUNCTION_TRANSMIT)
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
{
gDTMF_ReplyState = DTMF_REPLY_NONE;
RADIO_PrepareTX();
gUpdateDisplay = true;
FUNCTION_Select(FUNCTION_FOREGROUND);
}
else
gRTTECountdown = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10;
}

gUpdateDisplay = true;
gFlagEndTransmission = false;
}
return;
}

if (g_VOX_Lost)
{
gVOX_NoiseDetected = true;

if (gCurrentFunction == FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_FOREGROUND);

if (gCurrentFunction != FUNCTION_TRANSMIT)
{
gDTMF_ReplyState = DTMF_REPLY_NONE;
RADIO_PrepareTX();
gUpdateDisplay = true;
}
}
}
Expand Down Expand Up @@ -1452,6 +1451,7 @@ void APP_TimeSlice10ms(void)
if (--gRTTECountdown == 0)
{
FUNCTION_Select(FUNCTION_FOREGROUND);

gUpdateDisplay = true;
}
}
Expand Down
3 changes: 3 additions & 0 deletions app/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ void GENERIC_Key_PTT(bool bKeyPressed)

RADIO_SetVfoState(VFO_STATE_NORMAL);

// beep when you release the PTT
//gBeepToPlay = BEEP_880HZ_40MS_OPTIONAL; // 1of11

gRequestDisplayScreen = DISPLAY_MAIN;
return;
}
Expand Down
4 changes: 4 additions & 0 deletions app/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
break;

case MENU_SCR:
*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_SCRAMBLER) - 1;
break;

case MENU_VOX:
case MENU_TOT:
case MENU_RP_STE:
Expand Down
4 changes: 1 addition & 3 deletions audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
uint16_t ToneFrequency;
uint16_t Duration;

if (Beep != BEEP_500HZ_60MS_DOUBLE_BEEP &&
Beep != BEEP_440HZ_500MS &&
!gEeprom.BEEP_CONTROL)
if (Beep != BEEP_500HZ_60MS_DOUBLE_BEEP && Beep != BEEP_440HZ_500MS && !gEeprom.BEEP_CONTROL)
return;

#ifdef ENABLE_AIRCOPY
Expand Down
2 changes: 1 addition & 1 deletion driver/bk4819.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ void BK4819_EnableScramble(uint8_t Type)
const uint16_t Value = BK4819_ReadRegister(BK4819_REG_31);
BK4819_WriteRegister(BK4819_REG_31, Value | (1u << 1));

BK4819_WriteRegister(BK4819_REG_71, 0x68DC + (Type * 1032));
BK4819_WriteRegister(BK4819_REG_71, 0x68DC + (Type * 1032)); // 0110 1000 1101 1100
}

bool BK4819_CompanderEnabled(void)
Expand Down
Binary file modified firmware.bin
Binary file not shown.
Binary file modified firmware.packed.bin
Binary file not shown.
35 changes: 21 additions & 14 deletions functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,16 @@ void FUNCTION_Init(void)

void FUNCTION_Select(FUNCTION_Type_t Function)
{
FUNCTION_Type_t PreviousFunction = gCurrentFunction;
bool bWasPowerSave = (PreviousFunction == FUNCTION_POWER_SAVE);
const FUNCTION_Type_t PreviousFunction = gCurrentFunction;
const bool bWasPowerSave = (PreviousFunction == FUNCTION_POWER_SAVE);

gCurrentFunction = Function;

if (bWasPowerSave)
if (bWasPowerSave && Function != FUNCTION_POWER_SAVE)
{
if (Function != FUNCTION_POWER_SAVE)
{
BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable();
gRxIdleMode = false;
UI_DisplayStatus(false);
}
BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable();
gRxIdleMode = false;
UI_DisplayStatus(false);
}

switch (Function)
Expand Down Expand Up @@ -130,7 +127,6 @@ void FUNCTION_Select(FUNCTION_Type_t Function)

case FUNCTION_INCOMING:
case FUNCTION_RECEIVE:
// gMonitor = false;
break;

case FUNCTION_POWER_SAVE:
Expand All @@ -151,6 +147,10 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
return;

case FUNCTION_TRANSMIT:

// if DTMF is enabled when TX'ing, it changes the TX audio filtering !! .. 1of11
BK4819_DisableDTMF();

#if defined(ENABLE_FMRADIO)
if (gFmRadioMode)
BK1080_Init(0, false);
Expand All @@ -160,22 +160,32 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
if (gAlarmState == ALARM_STATE_TXALARM && gEeprom.ALARM_MODE != ALARM_MODE_TONE)
{
gAlarmState = ALARM_STATE_ALARM;

GUI_DisplayScreen();

GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);

SYSTEM_DelayMs(20);
BK4819_PlayTone(500, 0);
SYSTEM_DelayMs(2);

GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);

gEnableSpeaker = true;

SYSTEM_DelayMs(60);
BK4819_ExitTxMute();

gAlarmToneCounter = 0;
break;
}
#endif

GUI_DisplayScreen();

RADIO_SetTxParameters();

// turn the LED on RED
BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_RED, true);

DTMF_Reply();
Expand All @@ -191,10 +201,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
break;
}
#endif

// if the DTMF decoder is enabled, it destroys the TX audio !! .. 1of11
BK4819_DisableDTMF();


if (gCurrentVfo->SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable)
BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1);
else
Expand Down
2 changes: 2 additions & 0 deletions misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ const uint16_t battery_save_count_10ms = 10000 / 10; // 10 seconds
const uint16_t power_save1_10ms = 100 / 10; // 100ms
const uint16_t power_save2_10ms = 200 / 10; // 200ms

const uint16_t vox_stop_count_down_10ms = 1000 / 10; // 1 second

const uint16_t NOAA_countdown_10ms = 5000 / 10; // 5 seconds
const uint16_t NOAA_countdown_2_10ms = 500 / 10; // 500ms
const uint16_t NOAA_countdown_3_10ms = 200 / 10; // 200ms
Expand Down
2 changes: 2 additions & 0 deletions misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ extern const uint16_t battery_save_count_10ms;
extern const uint16_t power_save1_10ms;
extern const uint16_t power_save2_10ms;

extern const uint16_t vox_stop_count_down_10ms;

extern const uint16_t NOAA_countdown_10ms;
extern const uint16_t NOAA_countdown_2_10ms;
extern const uint16_t NOAA_countdown_3_10ms;
Expand Down
18 changes: 18 additions & 0 deletions ui/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,21 @@ const char gSubMenu_BAT_TXT[3][8] =
"PERCENT"
};

const char gSubMenu_SCRAMBLER[11][7] =
{
"OFF",
"2600Hz",
"2700Hz",
"2800Hz",
"2900Hz",
"3000Hz",
"3100Hz",
"3200Hz",
"3300Hz",
"3400Hz",
"3500Hz"
};

bool gIsInSubMenu;
uint8_t gMenuCursor;
int8_t gMenuScrollDirection;
Expand Down Expand Up @@ -421,6 +436,9 @@ void UI_DisplayMenu(void)
break;

case MENU_SCR:
strcpy(String, gSubMenu_SCRAMBLER[gSubMenuSelection]);
break;

case MENU_VOX:
if (gSubMenuSelection == 0)
strcpy(String, "OFF");
Expand Down
2 changes: 2 additions & 0 deletions ui/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ extern const char gSubMenu_BACKLIGHT[8][7];
extern const char gSubMenu_AM_fix_test1[4][8];
#endif
extern const char gSubMenu_BAT_TXT[3][8];

extern const char gSubMenu_SCRAMBLER[11][7];

extern bool gIsInSubMenu;

Expand Down

0 comments on commit ee05c4f

Please sign in to comment.