PTT release denoise update

This commit is contained in:
OneOfEleven 2023-09-13 09:20:09 +01:00
parent 2f907f82f8
commit e3e2409854
11 changed files with 229 additions and 211 deletions

View File

@ -80,7 +80,7 @@ static void ACTION_Monitor(void)
if (gScanState != SCAN_OFF)
{
ScanPauseDelayIn10msec = 500;
ScanPauseDelayIn10msec = 500; // 5 seconds
gScheduleScanListen = false;
gScanPauseMode = true;
}

108
app/app.c
View File

@ -102,7 +102,7 @@ static void APP_CheckForIncoming(void)
return;
}
ScanPauseDelayIn10msec = 20;
ScanPauseDelayIn10msec = 20; // 200ms
gScheduleScanListen = false;
}
@ -139,7 +139,9 @@ static void APP_HandleIncoming(void)
}
if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_POSITIVE_CODE && (gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL))
{
gFoundCDCSS = false;
}
else
if (!bFlag)
return;
@ -168,13 +170,11 @@ static void APP_HandleIncoming(void)
static void APP_HandleReceive(void)
{
uint8_t Mode;
#define END_OF_RX_MODE_SKIP 0
#define END_OF_RX_MODE_END 1
#define END_OF_RX_MODE_TTE 2
Mode = END_OF_RX_MODE_SKIP;
uint8_t Mode = END_OF_RX_MODE_SKIP;
if (gFlagTteComplete)
{
@ -193,6 +193,10 @@ static void APP_HandleReceive(void)
switch (gCurrentCodeType)
{
default:
case CODE_TYPE_OFF:
break;
case CODE_TYPE_CONTINUOUS_TONE:
if (gFoundCTCSS && gFoundCTCSSCountdown == 0)
{
@ -202,6 +206,7 @@ static void APP_HandleReceive(void)
goto Skip;
}
break;
case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL:
if (gFoundCDCSS && gFoundCDCSSCountdown == 0)
@ -212,8 +217,6 @@ static void APP_HandleReceive(void)
goto Skip;
}
break;
default:
break;
}
if (g_SquelchLost)
@ -259,7 +262,9 @@ static void APP_HandleReceive(void)
case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL:
if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_POSITIVE_CODE)
{
gFoundCDCSS = false;
}
else
if (!gFoundCDCSS)
{
@ -276,16 +281,18 @@ static void APP_HandleReceive(void)
}
break;
default:
break;
}
}
}
else
Mode = END_OF_RX_MODE_END;
if (!gEndOfRxDetectedMaybe && Mode == END_OF_RX_MODE_SKIP && gNextTimeslice40ms && gEeprom.TAIL_NOTE_ELIMINATION && (gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL) && BK4819_GetCTCType() == 1)
if (!gEndOfRxDetectedMaybe &&
Mode == END_OF_RX_MODE_SKIP &&
gNextTimeslice40ms &&
gEeprom.TAIL_NOTE_ELIMINATION &&
(gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL) &&
BK4819_GetCTCType() == 1)
Mode = END_OF_RX_MODE_TTE;
else
gNextTimeslice40ms = false;
@ -293,6 +300,9 @@ static void APP_HandleReceive(void)
Skip:
switch (Mode)
{
case END_OF_RX_MODE_SKIP:
break;
case END_OF_RX_MODE_END:
RADIO_SetupRegisters(true);
@ -307,21 +317,27 @@ Skip:
{
switch (gEeprom.SCAN_RESUME_MODE)
{
case SCAN_RESUME_TO:
break;
case SCAN_RESUME_CO:
ScanPauseDelayIn10msec = 360;
gScheduleScanListen = false;
break;
case SCAN_RESUME_SE:
SCANNER_Stop();
break;
}
}
break;
case END_OF_RX_MODE_TTE:
if (gEeprom.TAIL_NOTE_ELIMINATION)
{
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gTailNoteEliminationCountdown = 20;
gFlagTteComplete = false;
gEnableSpeaker = false;
@ -338,17 +354,24 @@ static void APP_HandleFunction(void)
case FUNCTION_FOREGROUND:
APP_CheckForIncoming();
break;
case FUNCTION_POWER_SAVE:
if (!gRxIdleMode)
APP_CheckForIncoming();
case FUNCTION_TRANSMIT:
break;
case FUNCTION_MONITOR:
break;
case FUNCTION_INCOMING:
APP_HandleIncoming();
break;
case FUNCTION_RECEIVE:
APP_HandleReceive();
break;
default:
case FUNCTION_POWER_SAVE:
if (!gRxIdleMode)
APP_CheckForIncoming();
break;
}
}
@ -363,6 +386,7 @@ void APP_StartListening(FUNCTION_Type_t Function)
gVFO_RSSI_Level[gEeprom.RX_CHANNEL == 0] = 0;
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gEnableSpeaker = true;
BACKLIGHT_TurnOn();
@ -379,6 +403,7 @@ void APP_StartListening(FUNCTION_Type_t Function)
gScanPauseMode = true;
}
break;
case SCAN_RESUME_CO:
case SCAN_RESUME_SE:
ScanPauseDelayIn10msec = 0;
@ -851,8 +876,8 @@ void APP_Update(void)
}
}
if (gFM_ScanState != FM_SCAN_OFF &&
gScheduleFM &&
if (gScheduleFM &&
gFM_ScanState != FM_SCAN_OFF &&
gCurrentFunction != FUNCTION_MONITOR &&
gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_TRANSMIT)
@ -867,13 +892,13 @@ void APP_Update(void)
if (gSchedulePowerSave)
{
#ifndef DISABLE_NOAA
if (gEeprom.BATTERY_SAVE == 0 ||
if (gFmRadioMode ||
gPttIsPressed ||
gKeyBeingHeld ||
gEeprom.BATTERY_SAVE == 0 ||
gScanState != SCAN_OFF ||
gCssScanMode != CSS_SCAN_MODE_OFF ||
gFmRadioMode ||
gPttIsPressed ||
gScreenToDisplay != DISPLAY_MAIN ||
gKeyBeingHeld ||
gDTMF_CallState != DTMF_CALL_STATE_NONE)
gBatterySaveCountdown = 1000;
else
@ -882,13 +907,13 @@ void APP_Update(void)
else
gBatterySaveCountdown = 1000;
#else
if (gEeprom.BATTERY_SAVE == 0 ||
if (gFmRadioMode ||
gPttIsPressed ||
gKeyBeingHeld ||
gEeprom.BATTERY_SAVE == 0 ||
gScanState != SCAN_OFF ||
gCssScanMode != CSS_SCAN_MODE_OFF ||
gFmRadioMode ||
gPttIsPressed ||
gScreenToDisplay != DISPLAY_MAIN ||
gKeyBeingHeld ||
gDTMF_CallState != DTMF_CALL_STATE_NONE)
gBatterySaveCountdown = 1000;
else
@ -968,34 +993,47 @@ void APP_CheckKeys(void)
{
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
{ // PTT released
#if 0
// denoise the PTT
unsigned int i = 6; // test the PTT button for 6ms
unsigned int count = 0;
while (i-- > 0)
{
SYSTEM_DelayMs(1);
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
count++; // PTT still released
else
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
{ // PTT pressed
if (count > 0)
count--; // no it's not
count--;
continue;
}
if (count >= 3)
{ // good enough to end transmission
if (++count < 3)
continue;
// stop transmitting
APP_ProcessKey(KEY_PTT, false, false);
gPttIsPressed = false;
if (gKeyReading1 != KEY_INVALID)
gPttWasReleased = true;
break;
}
#else
if (++gPttDebounceCounter >= 3) // 30ms
{ // stop transmitting
APP_ProcessKey(KEY_PTT, false, false);
gPttIsPressed = false;
if (gKeyReading1 != KEY_INVALID)
gPttWasReleased = true;
}
#endif
}
else
gPttDebounceCounter = 0;
}
else
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
{ // PTT pressed
if (++gPttDebounceCounter >= 4) // 40ms
{ // lets start transmitting
if (++gPttDebounceCounter >= 3) // 30ms
{ // start transmitting
gPttDebounceCounter = 0;
gPttIsPressed = true;
APP_ProcessKey(KEY_PTT, true, false);
}
@ -1184,7 +1222,7 @@ void APP_TimeSlice10ms(void)
BK4819_CssScanResult_t ScanResult;
uint16_t CtcssFreq;
if (gScanDelay)
if (gScanDelay > 0)
{
gScanDelay--;
APP_CheckKeys();

View File

@ -195,7 +195,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
VoiceID = gVoiceID[0];
if (gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF && gVoiceWriteIndex)
if (gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF && gVoiceWriteIndex > 0)
{
if (gEeprom.VOICE_PROMPT == VOICE_PROMPT_CHINESE)
{ // Chinese

BIN
firmware

Binary file not shown.

Binary file not shown.

Binary file not shown.

19
main.c
View File

@ -35,14 +35,7 @@
#include "settings.h"
#include "ui/lock.h"
#include "ui/welcome.h"
#ifdef GIT_HASH
static const char Version[] = "UV-K5 Firmware, Open Edition, OEFW-"GIT_HASH"\r\n";
#else
#include "version.h"
static const char Version1[] = "UV-K5 Firmware, Open Edition, ";
static const char Version2[] = "\r\n";
#endif
#include "version.h"
void _putchar(char c)
{
@ -66,15 +59,7 @@ void Main(void)
BOARD_Init();
UART_Init();
#ifdef GIT_HASH
UART_Send(Version, sizeof(Version));
#else
{
UART_Send(Version1, sizeof(Version1));
UART_Send(Version, strlen(Version));
UART_Send(Version2, sizeof(Version2));
}
#endif
UART_Send(UART_Version, strlen(UART_Version));
// Not implementing authentic device checks

3
misc.c
View File

@ -18,7 +18,8 @@
#include "misc.h"
const uint8_t g_scan_delay = 21; // 21
const uint8_t g_scan_delay = 21; // 210ms
//const uint8_t g_scan_delay = 2; // 20ms
const uint8_t g_menu_timeout = 2 * 30; // 30 seconds

15
misc.h
View File

@ -24,10 +24,8 @@
#define IS_FREQ_CHANNEL(x) ((x) >= FREQ_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST)
#define IS_VALID_CHANNEL(x) ((x) <= NOAA_CHANNEL_LAST)
#ifndef DISABLE_NOAA
#define IS_NOAA_CHANNEL(x) ((x) >= NOAA_CHANNEL_FIRST && (x) <= NOAA_CHANNEL_LAST)
#define IS_NOT_NOAA_CHANNEL(x) ((x) >= MR_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST)
#endif
#define IS_NOAA_CHANNEL(x) ((x) >= NOAA_CHANNEL_FIRST && (x) <= NOAA_CHANNEL_LAST)
#define IS_NOT_NOAA_CHANNEL(x) ((x) >= MR_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST)
enum {
MR_CHANNEL_FIRST = 0,
@ -67,7 +65,8 @@ enum ReceptionMode_t {
typedef enum ReceptionMode_t ReceptionMode_t;
enum CssScanMode_t {
enum CssScanMode_t
{
CSS_SCAN_MODE_OFF = 0,
CSS_SCAN_MODE_SCANNING,
CSS_SCAN_MODE_FOUND,
@ -91,7 +90,6 @@ extern bool gSetting_500TX;
extern bool gSetting_350EN;
extern uint8_t gSetting_F_LOCK;
extern bool gSetting_ScrambleEnable;
extern uint8_t gSetting_F_LOCK;
extern const uint32_t gDefaultAesKey[4];
extern uint32_t gCustomAesKey[4];
@ -186,7 +184,6 @@ extern uint8_t gScanDelay;
#endif
extern uint8_t gFSKWriteIndex;
extern uint8_t gNeverUsed;
#ifndef DISABLE_NOAA
extern bool gIsNoaaMode;
extern uint8_t gNoaaChannel;
@ -210,13 +207,9 @@ extern volatile bool gScheduleDualWatch;
#endif
extern volatile bool gFlagTteComplete;
extern volatile bool gScheduleFM;
extern uint16_t gCurrentRSSI;
extern uint8_t gIsLocked;
// --------
void NUMBER_Get(char *pDigits, uint32_t *pInteger);
void NUMBER_ToDigits(uint32_t Value, char *pDigits);
uint8_t NUMBER_AddWithWraparound(uint8_t Base, int8_t Add, uint8_t LowerLimit, uint8_t UpperLimit);

View File

@ -1,8 +1,9 @@
#ifdef GIT_HASH
const char Version[] = "OEFW-" GIT_HASH;
const char UART_Version[45] = "UV-K5 Firmware, Open Edition, OEFW-"GIT_HASH"\r\n";
#define VER GIT_HASH
#else
const char Version[] = "OEFW-230913";
const char UART_Version[45] = "UV-K5 Firmware, Open Edition, OEFW-230913\r\n";
#define VER "230913"
#endif
const char Version[] = "OEFW-"VER;
const char UART_Version[] = "UV-K5 Firmware, Open Edition, OEFW-"VER"\r\n";

View File

@ -18,7 +18,7 @@
#define VERSION_H
extern const char Version[];
extern const char UART_Version[45];
extern const char UART_Version[];
#endif