mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 14:21:25 +03:00
Fixed 200ms TX tail bug.
This commit is contained in:
parent
37afeb0414
commit
50a55e34ab
@ -230,7 +230,7 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
gDTMF_InputBox[--gDTMF_InputIndex] = '-';
|
gDTMF_InputBox[--gDTMF_InputIndex] = '-';
|
||||||
if (gDTMF_InputIndex)
|
if (gDTMF_InputIndex)
|
||||||
{
|
{
|
||||||
gPttWasReleased = true;
|
gPttWasReleased = true;
|
||||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
35
app/app.c
35
app/app.c
@ -907,6 +907,8 @@ void APP_Update(void)
|
|||||||
|
|
||||||
void APP_CheckKeys(void)
|
void APP_CheckKeys(void)
|
||||||
{
|
{
|
||||||
|
const uint16_t key_repeat_delay = 70; // 700ms
|
||||||
|
|
||||||
KEY_Code_t Key;
|
KEY_Code_t Key;
|
||||||
|
|
||||||
#ifndef DISABLE_AIRCOPY
|
#ifndef DISABLE_AIRCOPY
|
||||||
@ -920,15 +922,25 @@ void APP_CheckKeys(void)
|
|||||||
if (gPttIsPressed)
|
if (gPttIsPressed)
|
||||||
{
|
{
|
||||||
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
|
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
|
||||||
{
|
{ // PTT released
|
||||||
SYSTEM_DelayMs(20);
|
|
||||||
|
|
||||||
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
|
// denoise the PTT
|
||||||
|
unsigned int i = 4; // loop for 4ms
|
||||||
|
unsigned int count = 0;
|
||||||
|
while (i-- > 0)
|
||||||
|
{
|
||||||
|
SYSTEM_DelayMs(1);
|
||||||
|
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
|
||||||
|
count++;
|
||||||
|
else
|
||||||
|
if (count > 0)
|
||||||
|
count--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count >= 2)
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -938,7 +950,7 @@ void APP_CheckKeys(void)
|
|||||||
{
|
{
|
||||||
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
|
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
|
||||||
{
|
{
|
||||||
if (++gPttDebounceCounter > 4)
|
if (++gPttDebounceCounter >= 4) // 40ms
|
||||||
{
|
{
|
||||||
gPttIsPressed = true;
|
gPttIsPressed = true;
|
||||||
APP_ProcessKey(KEY_PTT, true, false);
|
APP_ProcessKey(KEY_PTT, true, false);
|
||||||
@ -982,7 +994,7 @@ void APP_CheckKeys(void)
|
|||||||
gKeyBeingHeld = false;
|
gKeyBeingHeld = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (gDebounceCounter == 128)
|
if (gDebounceCounter == key_repeat_delay)
|
||||||
{
|
{
|
||||||
if (Key == KEY_STAR || Key == KEY_F || Key == KEY_SIDE2 || Key == KEY_SIDE1 || Key == KEY_UP || Key == KEY_DOWN)
|
if (Key == KEY_STAR || Key == KEY_F || Key == KEY_SIDE2 || Key == KEY_SIDE1 || Key == KEY_UP || Key == KEY_DOWN)
|
||||||
{
|
{
|
||||||
@ -991,7 +1003,7 @@ void APP_CheckKeys(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (gDebounceCounter > 128)
|
if (gDebounceCounter > key_repeat_delay)
|
||||||
{
|
{
|
||||||
if (Key == KEY_UP || Key == KEY_DOWN)
|
if (Key == KEY_UP || Key == KEY_DOWN)
|
||||||
{
|
{
|
||||||
@ -1003,14 +1015,14 @@ void APP_CheckKeys(void)
|
|||||||
if (gDebounceCounter < 0xFFFF)
|
if (gDebounceCounter < 0xFFFF)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gDebounceCounter = 128;
|
gDebounceCounter = key_repeat_delay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void APP_TimeSlice10ms(void)
|
void APP_TimeSlice10ms(void)
|
||||||
{
|
{
|
||||||
gFlashLightBlinkCounter++;
|
gFlashLightBlinkCounter++;
|
||||||
|
|
||||||
if (UART_IsCommandAvailable())
|
if (UART_IsCommandAvailable())
|
||||||
{
|
{
|
||||||
__disable_irq();
|
__disable_irq();
|
||||||
@ -1102,6 +1114,7 @@ void APP_TimeSlice10ms(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// repeater tail tone elimination
|
||||||
if (gRTTECountdown)
|
if (gRTTECountdown)
|
||||||
{
|
{
|
||||||
if (--gRTTECountdown == 0)
|
if (--gRTTECountdown == 0)
|
||||||
@ -1560,9 +1573,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
if (gDTMF_DecodeRing)
|
if (gDTMF_DecodeRing)
|
||||||
{
|
{
|
||||||
gDTMF_DecodeRing = false;
|
gDTMF_DecodeRing = false;
|
||||||
|
|
||||||
AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL);
|
AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL);
|
||||||
|
|
||||||
if (Key != KEY_PTT)
|
if (Key != KEY_PTT)
|
||||||
{
|
{
|
||||||
gPttWasReleased = true;
|
gPttWasReleased = true;
|
||||||
|
11
dcs.h
11
dcs.h
@ -19,11 +19,12 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
enum DCS_CodeType_t {
|
enum DCS_CodeType_t
|
||||||
CODE_TYPE_OFF = 0x00U,
|
{
|
||||||
CODE_TYPE_CONTINUOUS_TONE = 0x01U,
|
CODE_TYPE_OFF = 0,
|
||||||
CODE_TYPE_DIGITAL = 0x02U,
|
CODE_TYPE_CONTINUOUS_TONE,
|
||||||
CODE_TYPE_REVERSE_DIGITAL = 0x03U,
|
CODE_TYPE_DIGITAL,
|
||||||
|
CODE_TYPE_REVERSE_DIGITAL
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum DCS_CodeType_t DCS_CodeType_t;
|
typedef enum DCS_CodeType_t DCS_CodeType_t;
|
||||||
|
@ -19,19 +19,14 @@
|
|||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
uint8_t gBacklightCountdown;
|
uint8_t gBacklightCountdown = 0;
|
||||||
|
|
||||||
void BACKLIGHT_TurnOn(void)
|
void BACKLIGHT_TurnOn(void)
|
||||||
{
|
{
|
||||||
if (gEeprom.BACKLIGHT > 0)
|
if (gEeprom.BACKLIGHT > 0)
|
||||||
{
|
{
|
||||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
|
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight ON
|
||||||
#if 0
|
gBacklightCountdown = (gEeprom.BACKLIGHT < 5) ? (gEeprom.BACKLIGHT * 20) - 19 : 0; // much longer backlight times
|
||||||
gBacklightCountdown = 1 + (gEeprom.BACKLIGHT * 2);
|
|
||||||
#else
|
|
||||||
// much longer backlight times
|
|
||||||
gBacklightCountdown = (gEeprom.BACKLIGHT * 20) - 19;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
17
functions.h
17
functions.h
@ -19,18 +19,19 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
enum FUNCTION_Type_t {
|
enum FUNCTION_Type_t
|
||||||
FUNCTION_FOREGROUND = 0U,
|
{
|
||||||
FUNCTION_TRANSMIT = 1U,
|
FUNCTION_FOREGROUND = 0,
|
||||||
FUNCTION_MONITOR = 2U,
|
FUNCTION_TRANSMIT,
|
||||||
FUNCTION_INCOMING = 3U,
|
FUNCTION_MONITOR,
|
||||||
FUNCTION_RECEIVE = 4U,
|
FUNCTION_INCOMING,
|
||||||
FUNCTION_POWER_SAVE = 5U,
|
FUNCTION_RECEIVE,
|
||||||
|
FUNCTION_POWER_SAVE
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum FUNCTION_Type_t FUNCTION_Type_t;
|
typedef enum FUNCTION_Type_t FUNCTION_Type_t;
|
||||||
|
|
||||||
extern FUNCTION_Type_t gCurrentFunction;
|
extern FUNCTION_Type_t gCurrentFunction;
|
||||||
|
|
||||||
void FUNCTION_Init(void);
|
void FUNCTION_Init(void);
|
||||||
void FUNCTION_Select(FUNCTION_Type_t Function);
|
void FUNCTION_Select(FUNCTION_Type_t Function);
|
||||||
|
9
main.c
9
main.c
@ -64,7 +64,6 @@ void Main(void)
|
|||||||
|
|
||||||
SYSTICK_Init();
|
SYSTICK_Init();
|
||||||
BOARD_Init();
|
BOARD_Init();
|
||||||
|
|
||||||
UART_Init();
|
UART_Init();
|
||||||
|
|
||||||
#ifdef GIT_HASH
|
#ifdef GIT_HASH
|
||||||
@ -110,8 +109,12 @@ void Main(void)
|
|||||||
if (!gChargingWithTypeC && !gBatteryDisplayLevel)
|
if (!gChargingWithTypeC && !gBatteryDisplayLevel)
|
||||||
{
|
{
|
||||||
FUNCTION_Select(FUNCTION_POWER_SAVE);
|
FUNCTION_Select(FUNCTION_POWER_SAVE);
|
||||||
//if (gEeprom.BACKLIGHT < 5)
|
|
||||||
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
|
if (gEeprom.BACKLIGHT < 5)
|
||||||
|
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
|
||||||
|
else
|
||||||
|
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight ON
|
||||||
|
|
||||||
gReducedService = true;
|
gReducedService = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
15
radio.c
15
radio.c
@ -874,17 +874,20 @@ void RADIO_EnableCxCSS(void)
|
|||||||
{
|
{
|
||||||
switch (gCurrentVfo->pTX->CodeType)
|
switch (gCurrentVfo->pTX->CodeType)
|
||||||
{
|
{
|
||||||
|
case CODE_TYPE_OFF:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CODE_TYPE_CONTINUOUS_TONE:
|
||||||
|
BK4819_EnableCTCSS();
|
||||||
|
SYSTEM_DelayMs(200);
|
||||||
|
break;
|
||||||
|
|
||||||
case CODE_TYPE_DIGITAL:
|
case CODE_TYPE_DIGITAL:
|
||||||
case CODE_TYPE_REVERSE_DIGITAL:
|
case CODE_TYPE_REVERSE_DIGITAL:
|
||||||
BK4819_EnableCDCSS();
|
BK4819_EnableCDCSS();
|
||||||
break;
|
SYSTEM_DelayMs(200);
|
||||||
|
|
||||||
default:
|
|
||||||
BK4819_EnableCTCSS();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SYSTEM_DelayMs(200);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RADIO_PrepareCssTX(void)
|
void RADIO_PrepareCssTX(void)
|
||||||
|
92
scheduler.c
92
scheduler.c
@ -22,6 +22,10 @@
|
|||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
|
#include "driver/backlight.h"
|
||||||
|
#include "bsp/dp32g030/gpio.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
|
||||||
#define DECREMENT_AND_TRIGGER(cnt, flag) \
|
#define DECREMENT_AND_TRIGGER(cnt, flag) \
|
||||||
do { \
|
do { \
|
||||||
if (cnt) { \
|
if (cnt) { \
|
||||||
@ -35,40 +39,41 @@ static volatile uint32_t gGlobalSysTickCounter;
|
|||||||
|
|
||||||
void SystickHandler(void);
|
void SystickHandler(void);
|
||||||
|
|
||||||
|
// we come here every 10ms
|
||||||
void SystickHandler(void)
|
void SystickHandler(void)
|
||||||
{
|
{
|
||||||
gGlobalSysTickCounter++;
|
gGlobalSysTickCounter++;
|
||||||
|
|
||||||
gNextTimeslice = true;
|
gNextTimeslice = true;
|
||||||
if ((gGlobalSysTickCounter % 50) == 0) {
|
|
||||||
|
if ((gGlobalSysTickCounter % 50) == 0)
|
||||||
|
{
|
||||||
gNextTimeslice500ms = true;
|
gNextTimeslice500ms = true;
|
||||||
DECREMENT_AND_TRIGGER(gTxTimerCountdown, gTxTimeoutReached);
|
DECREMENT_AND_TRIGGER(gTxTimerCountdown, gTxTimeoutReached);
|
||||||
}
|
}
|
||||||
if ((gGlobalSysTickCounter & 3) == 0) {
|
|
||||||
gNextTimeslice40ms = true;
|
|
||||||
}
|
|
||||||
if (gSystickCountdown2) {
|
|
||||||
gSystickCountdown2--;
|
|
||||||
}
|
|
||||||
if (gFoundCDCSSCountdown) {
|
|
||||||
gFoundCDCSSCountdown--;
|
|
||||||
}
|
|
||||||
if (gFoundCTCSSCountdown) {
|
|
||||||
gFoundCTCSSCountdown--;
|
|
||||||
}
|
|
||||||
if (gCurrentFunction == FUNCTION_FOREGROUND) {
|
|
||||||
DECREMENT_AND_TRIGGER(gBatterySaveCountdown, gSchedulePowerSave);
|
|
||||||
}
|
|
||||||
if (gCurrentFunction == FUNCTION_POWER_SAVE) {
|
|
||||||
DECREMENT_AND_TRIGGER(gBatterySave, gBatterySaveCountdownExpired);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) {
|
if ((gGlobalSysTickCounter & 3) == 0)
|
||||||
if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT) {
|
gNextTimeslice40ms = true;
|
||||||
if (gCurrentFunction != FUNCTION_RECEIVE) {
|
|
||||||
|
if (gSystickCountdown2)
|
||||||
|
gSystickCountdown2--;
|
||||||
|
|
||||||
|
if (gFoundCDCSSCountdown)
|
||||||
|
gFoundCDCSSCountdown--;
|
||||||
|
|
||||||
|
if (gFoundCTCSSCountdown)
|
||||||
|
gFoundCTCSSCountdown--;
|
||||||
|
|
||||||
|
if (gCurrentFunction == FUNCTION_FOREGROUND)
|
||||||
|
DECREMENT_AND_TRIGGER(gBatterySaveCountdown, gSchedulePowerSave);
|
||||||
|
|
||||||
|
if (gCurrentFunction == FUNCTION_POWER_SAVE)
|
||||||
|
DECREMENT_AND_TRIGGER(gBatterySave, gBatterySaveCountdownExpired);
|
||||||
|
|
||||||
|
if (gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
|
||||||
|
if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
|
||||||
|
if (gCurrentFunction != FUNCTION_RECEIVE)
|
||||||
DECREMENT_AND_TRIGGER(gDualWatchCountdown, gScheduleDualWatch);
|
DECREMENT_AND_TRIGGER(gDualWatchCountdown, gScheduleDualWatch);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef DISABLE_NOAA
|
#ifndef DISABLE_NOAA
|
||||||
if (gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && gEeprom.DUAL_WATCH == DUAL_WATCH_OFF)
|
if (gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && gEeprom.DUAL_WATCH == DUAL_WATCH_OFF)
|
||||||
@ -77,11 +82,9 @@ void SystickHandler(void)
|
|||||||
DECREMENT_AND_TRIGGER(gNOAA_Countdown, gScheduleNOAA);
|
DECREMENT_AND_TRIGGER(gNOAA_Countdown, gScheduleNOAA);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (gScanState != SCAN_OFF || gCssScanMode == CSS_SCAN_MODE_SCANNING) {
|
if (gScanState != SCAN_OFF || gCssScanMode == CSS_SCAN_MODE_SCANNING)
|
||||||
if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT) {
|
if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
|
||||||
DECREMENT_AND_TRIGGER(ScanPauseDelayIn10msec, gScheduleScanListen);
|
DECREMENT_AND_TRIGGER(ScanPauseDelayIn10msec, gScheduleScanListen);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DECREMENT_AND_TRIGGER(gTailNoteEliminationCountdown, gFlagTteComplete);
|
DECREMENT_AND_TRIGGER(gTailNoteEliminationCountdown, gFlagTteComplete);
|
||||||
|
|
||||||
@ -89,13 +92,28 @@ void SystickHandler(void)
|
|||||||
DECREMENT_AND_TRIGGER(gCountdownToPlayNextVoice, gFlagPlayQueuedVoice);
|
DECREMENT_AND_TRIGGER(gCountdownToPlayNextVoice, gFlagPlayQueuedVoice);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (gFM_ScanState != FM_SCAN_OFF && gCurrentFunction != FUNCTION_MONITOR) {
|
if (gFM_ScanState != FM_SCAN_OFF && gCurrentFunction != FUNCTION_MONITOR)
|
||||||
if (gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_RECEIVE) {
|
if (gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_RECEIVE)
|
||||||
DECREMENT_AND_TRIGGER(gFmPlayCountdown, gScheduleFM);
|
DECREMENT_AND_TRIGGER(gFmPlayCountdown, gScheduleFM);
|
||||||
}
|
|
||||||
}
|
|
||||||
if (gVoxStopCountdown) {
|
|
||||||
gVoxStopCountdown--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (gVoxStopCountdown)
|
||||||
|
gVoxStopCountdown--;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (gCurrentFunction == FUNCTION_TRANSMIT || gBacklightCountdown > 0)
|
||||||
|
{
|
||||||
|
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight ON
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (gEeprom.BACKLIGHT >= 5)
|
||||||
|
{ // backlight ON - half brightness
|
||||||
|
// was hoping to use this but don't like the odd flicker
|
||||||
|
if (gGlobalSysTickCounter & 1)
|
||||||
|
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight ON
|
||||||
|
else
|
||||||
|
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
|
||||||
|
}
|
||||||
|
else
|
||||||
|
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight OFF
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user