mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 06:11:24 +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] = '-';
|
||||
if (gDTMF_InputIndex)
|
||||
{
|
||||
gPttWasReleased = true;
|
||||
gPttWasReleased = true;
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
return;
|
||||
}
|
||||
|
35
app/app.c
35
app/app.c
@ -907,6 +907,8 @@ void APP_Update(void)
|
||||
|
||||
void APP_CheckKeys(void)
|
||||
{
|
||||
const uint16_t key_repeat_delay = 70; // 700ms
|
||||
|
||||
KEY_Code_t Key;
|
||||
|
||||
#ifndef DISABLE_AIRCOPY
|
||||
@ -920,15 +922,25 @@ void APP_CheckKeys(void)
|
||||
if (gPttIsPressed)
|
||||
{
|
||||
if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
|
||||
{
|
||||
SYSTEM_DelayMs(20);
|
||||
{ // PTT released
|
||||
|
||||
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);
|
||||
|
||||
gPttIsPressed = false;
|
||||
|
||||
if (gKeyReading1 != KEY_INVALID)
|
||||
gPttWasReleased = true;
|
||||
}
|
||||
@ -938,7 +950,7 @@ void APP_CheckKeys(void)
|
||||
{
|
||||
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
|
||||
{
|
||||
if (++gPttDebounceCounter > 4)
|
||||
if (++gPttDebounceCounter >= 4) // 40ms
|
||||
{
|
||||
gPttIsPressed = true;
|
||||
APP_ProcessKey(KEY_PTT, true, false);
|
||||
@ -982,7 +994,7 @@ void APP_CheckKeys(void)
|
||||
gKeyBeingHeld = false;
|
||||
}
|
||||
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)
|
||||
{
|
||||
@ -991,7 +1003,7 @@ void APP_CheckKeys(void)
|
||||
}
|
||||
}
|
||||
else
|
||||
if (gDebounceCounter > 128)
|
||||
if (gDebounceCounter > key_repeat_delay)
|
||||
{
|
||||
if (Key == KEY_UP || Key == KEY_DOWN)
|
||||
{
|
||||
@ -1003,14 +1015,14 @@ void APP_CheckKeys(void)
|
||||
if (gDebounceCounter < 0xFFFF)
|
||||
return;
|
||||
|
||||
gDebounceCounter = 128;
|
||||
gDebounceCounter = key_repeat_delay;
|
||||
}
|
||||
}
|
||||
|
||||
void APP_TimeSlice10ms(void)
|
||||
{
|
||||
gFlashLightBlinkCounter++;
|
||||
|
||||
|
||||
if (UART_IsCommandAvailable())
|
||||
{
|
||||
__disable_irq();
|
||||
@ -1102,6 +1114,7 @@ void APP_TimeSlice10ms(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
// repeater tail tone elimination
|
||||
if (gRTTECountdown)
|
||||
{
|
||||
if (--gRTTECountdown == 0)
|
||||
@ -1560,9 +1573,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
if (gDTMF_DecodeRing)
|
||||
{
|
||||
gDTMF_DecodeRing = false;
|
||||
|
||||
AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL);
|
||||
|
||||
if (Key != KEY_PTT)
|
||||
{
|
||||
gPttWasReleased = true;
|
||||
|
11
dcs.h
11
dcs.h
@ -19,11 +19,12 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum DCS_CodeType_t {
|
||||
CODE_TYPE_OFF = 0x00U,
|
||||
CODE_TYPE_CONTINUOUS_TONE = 0x01U,
|
||||
CODE_TYPE_DIGITAL = 0x02U,
|
||||
CODE_TYPE_REVERSE_DIGITAL = 0x03U,
|
||||
enum DCS_CodeType_t
|
||||
{
|
||||
CODE_TYPE_OFF = 0,
|
||||
CODE_TYPE_CONTINUOUS_TONE,
|
||||
CODE_TYPE_DIGITAL,
|
||||
CODE_TYPE_REVERSE_DIGITAL
|
||||
};
|
||||
|
||||
typedef enum DCS_CodeType_t DCS_CodeType_t;
|
||||
|
@ -19,19 +19,14 @@
|
||||
#include "driver/gpio.h"
|
||||
#include "settings.h"
|
||||
|
||||
uint8_t gBacklightCountdown;
|
||||
uint8_t gBacklightCountdown = 0;
|
||||
|
||||
void BACKLIGHT_TurnOn(void)
|
||||
{
|
||||
if (gEeprom.BACKLIGHT > 0)
|
||||
{
|
||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
|
||||
#if 0
|
||||
gBacklightCountdown = 1 + (gEeprom.BACKLIGHT * 2);
|
||||
#else
|
||||
// much longer backlight times
|
||||
gBacklightCountdown = (gEeprom.BACKLIGHT * 20) - 19;
|
||||
#endif
|
||||
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight ON
|
||||
gBacklightCountdown = (gEeprom.BACKLIGHT < 5) ? (gEeprom.BACKLIGHT * 20) - 19 : 0; // much longer backlight times
|
||||
}
|
||||
}
|
||||
|
||||
|
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>
|
||||
|
||||
enum FUNCTION_Type_t {
|
||||
FUNCTION_FOREGROUND = 0U,
|
||||
FUNCTION_TRANSMIT = 1U,
|
||||
FUNCTION_MONITOR = 2U,
|
||||
FUNCTION_INCOMING = 3U,
|
||||
FUNCTION_RECEIVE = 4U,
|
||||
FUNCTION_POWER_SAVE = 5U,
|
||||
enum FUNCTION_Type_t
|
||||
{
|
||||
FUNCTION_FOREGROUND = 0,
|
||||
FUNCTION_TRANSMIT,
|
||||
FUNCTION_MONITOR,
|
||||
FUNCTION_INCOMING,
|
||||
FUNCTION_RECEIVE,
|
||||
FUNCTION_POWER_SAVE
|
||||
};
|
||||
|
||||
typedef enum FUNCTION_Type_t FUNCTION_Type_t;
|
||||
|
||||
extern FUNCTION_Type_t gCurrentFunction;
|
||||
extern FUNCTION_Type_t gCurrentFunction;
|
||||
|
||||
void FUNCTION_Init(void);
|
||||
void FUNCTION_Select(FUNCTION_Type_t Function);
|
||||
|
9
main.c
9
main.c
@ -64,7 +64,6 @@ void Main(void)
|
||||
|
||||
SYSTICK_Init();
|
||||
BOARD_Init();
|
||||
|
||||
UART_Init();
|
||||
|
||||
#ifdef GIT_HASH
|
||||
@ -110,8 +109,12 @@ void Main(void)
|
||||
if (!gChargingWithTypeC && !gBatteryDisplayLevel)
|
||||
{
|
||||
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;
|
||||
}
|
||||
else
|
||||
|
15
radio.c
15
radio.c
@ -874,17 +874,20 @@ void RADIO_EnableCxCSS(void)
|
||||
{
|
||||
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_REVERSE_DIGITAL:
|
||||
BK4819_EnableCDCSS();
|
||||
break;
|
||||
|
||||
default:
|
||||
BK4819_EnableCTCSS();
|
||||
SYSTEM_DelayMs(200);
|
||||
break;
|
||||
}
|
||||
|
||||
SYSTEM_DelayMs(200);
|
||||
}
|
||||
|
||||
void RADIO_PrepareCssTX(void)
|
||||
|
92
scheduler.c
92
scheduler.c
@ -22,6 +22,10 @@
|
||||
#include "misc.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include "driver/backlight.h"
|
||||
#include "bsp/dp32g030/gpio.h"
|
||||
#include "driver/gpio.h"
|
||||
|
||||
#define DECREMENT_AND_TRIGGER(cnt, flag) \
|
||||
do { \
|
||||
if (cnt) { \
|
||||
@ -35,40 +39,41 @@ static volatile uint32_t gGlobalSysTickCounter;
|
||||
|
||||
void SystickHandler(void);
|
||||
|
||||
// we come here every 10ms
|
||||
void SystickHandler(void)
|
||||
{
|
||||
gGlobalSysTickCounter++;
|
||||
|
||||
gNextTimeslice = true;
|
||||
if ((gGlobalSysTickCounter % 50) == 0) {
|
||||
|
||||
if ((gGlobalSysTickCounter % 50) == 0)
|
||||
{
|
||||
gNextTimeslice500ms = true;
|
||||
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 (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT) {
|
||||
if (gCurrentFunction != FUNCTION_RECEIVE) {
|
||||
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 (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
|
||||
if (gCurrentFunction != FUNCTION_RECEIVE)
|
||||
DECREMENT_AND_TRIGGER(gDualWatchCountdown, gScheduleDualWatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef DISABLE_NOAA
|
||||
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);
|
||||
#endif
|
||||
|
||||
if (gScanState != SCAN_OFF || gCssScanMode == CSS_SCAN_MODE_SCANNING) {
|
||||
if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT) {
|
||||
if (gScanState != SCAN_OFF || gCssScanMode == CSS_SCAN_MODE_SCANNING)
|
||||
if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
|
||||
DECREMENT_AND_TRIGGER(ScanPauseDelayIn10msec, gScheduleScanListen);
|
||||
}
|
||||
}
|
||||
|
||||
DECREMENT_AND_TRIGGER(gTailNoteEliminationCountdown, gFlagTteComplete);
|
||||
|
||||
@ -89,13 +92,28 @@ void SystickHandler(void)
|
||||
DECREMENT_AND_TRIGGER(gCountdownToPlayNextVoice, gFlagPlayQueuedVoice);
|
||||
#endif
|
||||
|
||||
if (gFM_ScanState != FM_SCAN_OFF && gCurrentFunction != FUNCTION_MONITOR) {
|
||||
if (gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_RECEIVE) {
|
||||
if (gFM_ScanState != FM_SCAN_OFF && gCurrentFunction != FUNCTION_MONITOR)
|
||||
if (gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_RECEIVE)
|
||||
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