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) if (gScanState != SCAN_OFF)
{ {
ScanPauseDelayIn10msec = 500; ScanPauseDelayIn10msec = 500; // 5 seconds
gScheduleScanListen = false; gScheduleScanListen = false;
gScanPauseMode = true; gScanPauseMode = true;
} }

108
app/app.c
View File

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

View File

@ -195,7 +195,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
VoiceID = gVoiceID[0]; 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) if (gEeprom.VOICE_PROMPT == VOICE_PROMPT_CHINESE)
{ // 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 "settings.h"
#include "ui/lock.h" #include "ui/lock.h"
#include "ui/welcome.h" #include "ui/welcome.h"
#include "version.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
void _putchar(char c) void _putchar(char c)
{ {
@ -66,15 +59,7 @@ void Main(void)
BOARD_Init(); BOARD_Init();
UART_Init(); UART_Init();
#ifdef GIT_HASH UART_Send(UART_Version, strlen(UART_Version));
UART_Send(Version, sizeof(Version));
#else
{
UART_Send(Version1, sizeof(Version1));
UART_Send(Version, strlen(Version));
UART_Send(Version2, sizeof(Version2));
}
#endif
// Not implementing authentic device checks // Not implementing authentic device checks

3
misc.c
View File

@ -18,7 +18,8 @@
#include "misc.h" #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 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_FREQ_CHANNEL(x) ((x) >= FREQ_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST)
#define IS_VALID_CHANNEL(x) ((x) <= NOAA_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_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)
#define IS_NOT_NOAA_CHANNEL(x) ((x) >= MR_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST)
#endif
enum { enum {
MR_CHANNEL_FIRST = 0, MR_CHANNEL_FIRST = 0,
@ -67,7 +65,8 @@ enum ReceptionMode_t {
typedef enum ReceptionMode_t ReceptionMode_t; typedef enum ReceptionMode_t ReceptionMode_t;
enum CssScanMode_t { enum CssScanMode_t
{
CSS_SCAN_MODE_OFF = 0, CSS_SCAN_MODE_OFF = 0,
CSS_SCAN_MODE_SCANNING, CSS_SCAN_MODE_SCANNING,
CSS_SCAN_MODE_FOUND, CSS_SCAN_MODE_FOUND,
@ -91,7 +90,6 @@ extern bool gSetting_500TX;
extern bool gSetting_350EN; extern bool gSetting_350EN;
extern uint8_t gSetting_F_LOCK; extern uint8_t gSetting_F_LOCK;
extern bool gSetting_ScrambleEnable; extern bool gSetting_ScrambleEnable;
extern uint8_t gSetting_F_LOCK;
extern const uint32_t gDefaultAesKey[4]; extern const uint32_t gDefaultAesKey[4];
extern uint32_t gCustomAesKey[4]; extern uint32_t gCustomAesKey[4];
@ -186,7 +184,6 @@ extern uint8_t gScanDelay;
#endif #endif
extern uint8_t gFSKWriteIndex; extern uint8_t gFSKWriteIndex;
extern uint8_t gNeverUsed; extern uint8_t gNeverUsed;
#ifndef DISABLE_NOAA #ifndef DISABLE_NOAA
extern bool gIsNoaaMode; extern bool gIsNoaaMode;
extern uint8_t gNoaaChannel; extern uint8_t gNoaaChannel;
@ -210,13 +207,9 @@ extern volatile bool gScheduleDualWatch;
#endif #endif
extern volatile bool gFlagTteComplete; extern volatile bool gFlagTteComplete;
extern volatile bool gScheduleFM; extern volatile bool gScheduleFM;
extern uint16_t gCurrentRSSI; extern uint16_t gCurrentRSSI;
extern uint8_t gIsLocked; extern uint8_t gIsLocked;
// --------
void NUMBER_Get(char *pDigits, uint32_t *pInteger); void NUMBER_Get(char *pDigits, uint32_t *pInteger);
void NUMBER_ToDigits(uint32_t Value, char *pDigits); void NUMBER_ToDigits(uint32_t Value, char *pDigits);
uint8_t NUMBER_AddWithWraparound(uint8_t Base, int8_t Add, uint8_t LowerLimit, uint8_t UpperLimit); 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 #ifdef GIT_HASH
const char Version[] = "OEFW-" GIT_HASH; #define VER GIT_HASH
const char UART_Version[45] = "UV-K5 Firmware, Open Edition, OEFW-"GIT_HASH"\r\n";
#else #else
const char Version[] = "OEFW-230913"; #define VER "230913"
const char UART_Version[45] = "UV-K5 Firmware, Open Edition, OEFW-230913\r\n";
#endif #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 #define VERSION_H
extern const char Version[]; extern const char Version[];
extern const char UART_Version[45]; extern const char UART_Version[];
#endif #endif