0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-05-07 18:51:26 +03:00

Rename AF constant

This commit is contained in:
OneOfEleven 2023-10-04 10:01:07 +01:00
parent 9d990f7e67
commit 5f2e069437
11 changed files with 109 additions and 107 deletions

View File

@ -12,17 +12,17 @@ ENABLE_FMRADIO := 0
ENABLE_NOAA := 0
ENABLE_VOICE := 0
ENABLE_ALARM := 0
ENABLE_TX1750 := 1
ENABLE_TX1750 := 0
ENABLE_BIG_FREQ := 0
ENABLE_SMALL_BOLD := 1
ENABLE_KEEP_MEM_NAME := 1
ENABLE_WIDE_RX := 1
ENABLE_TX_WHEN_AM := 0
ENABLE_F_CAL_MENU := 0
ENABLE_F_CAL_MENU := 1
ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1
ENABLE_MAIN_KEY_HOLD := 1
ENABLE_BOOT_BEEPS := 0
ENABLE_COMPANDER := 0
ENABLE_COMPANDER := 1
ENABLE_SHOW_CHARGE_LEVEL := 1
ENABLE_REVERSE_BAT_SYMBOL := 1
ENABLE_CODE_SCAN_TIMEOUT := 0

View File

@ -544,7 +544,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
}
{ // RF RX front end gain
// original setting
uint16_t lna_short = orig_lna_short;
uint16_t lna = orig_lna;
@ -577,7 +577,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
#ifdef ENABLE_VOICE
if (gVoiceWriteIndex == 0) // AM/FM RX mode will be set when the voice has finished
#endif
BK4819_SetAF(gRxVfo->AM_mode ? BK4819_AF_AM : BK4819_AF_OPEN); // no need, set it now
BK4819_SetAF(gRxVfo->AM_mode ? BK4819_AF_AM : BK4819_AF_FM); // no need, set it now
FUNCTION_Select(Function);
@ -2057,17 +2057,6 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
if (gEeprom.AUTO_KEYPAD_LOCK)
gKeyLockCountdown = 30; // 15 seconds
if (Key == KEY_EXIT && bKeyPressed && bKeyHeld && gDTMF_RX_live[0] != 0)
{ // clear the live DTMF decoder if the EXIT key is held
if (gDTMF_RX_live[0] != 0)
{
gDTMF_RX_live_timeout = 0;
memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live));
gUpdateDisplay = true;
}
}
if (!bKeyPressed)
{
if (gFlagSaveVfo)
@ -2103,11 +2092,23 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
}
else
{
BACKLIGHT_TurnOn();
if (Key == KEY_EXIT && bKeyHeld)
{ // exit key held pressed
// clear the live DTMF decoder
if (gDTMF_RX_live[0] != 0)
{
memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live));
gDTMF_RX_live_timeout = 0;
gUpdateDisplay = true;
}
}
if (gScreenToDisplay == DISPLAY_MENU) // 1of11
gMenuCountdown = menu_timeout_500ms;
BACKLIGHT_TurnOn();
if (gDTMF_DecodeRingCountdown_500ms > 0)
{ // cancel the ringing
gDTMF_DecodeRingCountdown_500ms = 0;
@ -2164,24 +2165,27 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
Key != KEY_MENU)
{
if (gScanState != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF)
{ // frequency or CTCSS/DCS scanning
{ // FREQ/CTCSS/DCS scanning
if (bKeyPressed && !bKeyHeld)
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
return;
}
}
if (gPttWasPressed && Key == KEY_PTT)
if (Key == KEY_PTT)
{
bFlag = bKeyHeld;
if (!bKeyPressed)
if (gPttWasPressed)
{
bFlag = true;
gPttWasPressed = false;
bFlag = bKeyHeld;
if (!bKeyPressed)
{
bFlag = true;
gPttWasPressed = false;
}
}
}
if (gPttWasReleased && Key != KEY_PTT)
else
if (gPttWasReleased)
{
if (bKeyHeld)
bFlag = true;
@ -2268,7 +2272,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
ALARM_Off();
// TODO: fix side key 1750, you have to press it twice to restart the tone :(
if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0)
{
//if (gCurrentFunction != FUNCTION_FOREGROUND)

View File

@ -47,26 +47,33 @@
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
void writeXtalFreqCal(const int32_t value)
{
struct
#ifdef ENABLE_F_CAL_MENU
void writeXtalFreqCal(const int32_t value, const bool update_eeprom)
{
int16_t BK4819_XtalFreqLow;
uint16_t EEPROM_1F8A;
uint16_t EEPROM_1F8C;
uint8_t VOLUME_GAIN;
uint8_t DAC_GAIN;
} __attribute__((packed)) Misc;
gEeprom.BK4819_XTAL_FREQ_LOW = value;
BK4819_WriteRegister(BK4819_REG_3B, 22656 + gEeprom.BK4819_XTAL_FREQ_LOW);
// radio 1 .. 04 00 46 00 50 00 2C 0E
// radio 2 .. 05 00 46 00 50 00 2C 0E
EEPROM_ReadBuffer(0x1F88, &Misc, 8);
Misc.BK4819_XtalFreqLow = gEeprom.BK4819_XTAL_FREQ_LOW;
EEPROM_WriteBuffer(0x1F88, &Misc);
}
BK4819_WriteRegister(BK4819_REG_3B, 22656 + value);
if (update_eeprom)
{
struct
{
int16_t BK4819_XtalFreqLow;
uint16_t EEPROM_1F8A;
uint16_t EEPROM_1F8C;
uint8_t VOLUME_GAIN;
uint8_t DAC_GAIN;
} __attribute__((packed)) misc;
gEeprom.BK4819_XTAL_FREQ_LOW = value;
// radio 1 .. 04 00 46 00 50 00 2C 0E
// radio 2 .. 05 00 46 00 50 00 2C 0E
//
EEPROM_ReadBuffer(0x1F88, &misc, 8);
misc.BK4819_XtalFreqLow = value;
EEPROM_WriteBuffer(0x1F88, &misc);
}
}
#endif
void MENU_StartCssScan(int8_t Direction)
{
@ -746,7 +753,7 @@ void MENU_AcceptSetting(void)
#ifdef ENABLE_F_CAL_MENU
case MENU_F_CALI:
writeXtalFreqCal(gSubMenuSelection);
writeXtalFreqCal(gSubMenuSelection, true);
return;
#endif

View File

@ -19,6 +19,10 @@
#include "driver/keyboard.h"
#ifdef ENABLE_F_CAL_MENU
void writeXtalFreqCal(const int32_t value, const bool update_eeprom);
#endif
int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax);
void MENU_AcceptSetting(void);
void MENU_SelectNextCode(void);

View File

@ -283,7 +283,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
if (gCurrentFunction == FUNCTION_RECEIVE ||
gCurrentFunction == FUNCTION_MONITOR ||
gCurrentFunction == FUNCTION_INCOMING) // 1of11
BK4819_SetAF(gRxVfo->AM_mode ? BK4819_AF_AM : BK4819_AF_OPEN);
BK4819_SetAF(gRxVfo->AM_mode ? BK4819_AF_AM : BK4819_AF_FM);
#ifdef ENABLE_FMRADIO
if (gFmRadioMode)
@ -417,7 +417,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
if (gCurrentFunction == FUNCTION_RECEIVE ||
gCurrentFunction == FUNCTION_MONITOR ||
gCurrentFunction == FUNCTION_INCOMING) // 1of11
BK4819_SetAF(gRxVfo->AM_mode ? BK4819_AF_AM : BK4819_AF_OPEN);
BK4819_SetAF(gRxVfo->AM_mode ? BK4819_AF_AM : BK4819_AF_FM);
#ifdef ENABLE_FMRADIO
if (gFmRadioMode)

View File

@ -839,9 +839,6 @@ void BK4819_SetCompander(const unsigned int mode)
return;
}
// enable
BK4819_WriteRegister(BK4819_REG_31, r31 | (1u < 3));
// set the compressor ratio
//
// REG_29 <15:14> 10 Compress (AF Tx) Ratio
@ -883,6 +880,9 @@ void BK4819_SetCompander(const unsigned int mode)
(expand_ratio < 14)
| (expand_0dB < 7)
| (expand_noise_dB < 0));
// enable
BK4819_WriteRegister(BK4819_REG_31, r31 | (1u < 3));
}
void BK4819_DisableVox(void)

View File

@ -24,22 +24,22 @@
enum BK4819_AF_Type_t
{
BK4819_AF_MUTE = 0u,
BK4819_AF_OPEN = 1u,
BK4819_AF_ALAM = 2u,
BK4819_AF_BEEP = 3u,
BK4819_AF_UNKNOWN1 = 4u,
BK4819_AF_UNKNOWN2 = 5u,
BK4819_AF_CTCO = 6u,
BK4819_AF_AM = 7u,
BK4819_AF_FSKO = 8u,
BK4819_AF_UNKNOWN3 = 9u,
BK4819_AF_UNKNOWN4 = 10u,
BK4819_AF_UNKNOWN5 = 11u,
BK4819_AF_UNKNOWN6 = 12u,
BK4819_AF_UNKNOWN7 = 13u,
BK4819_AF_UNKNOWN8 = 14u,
BK4819_AF_UNKNOWN9 = 15u
BK4819_AF_MUTE = 0u, //
BK4819_AF_FM = 1u, // FM
BK4819_AF_ALAM = 2u, //
BK4819_AF_BEEP = 3u, //
BK4819_AF_UNKNOWN1 = 4u, // SSB I think
BK4819_AF_UNKNOWN2 = 5u, // SSB again
BK4819_AF_CTCO = 6u, // strange LF audio .. maybe the CTCSS LF line ?
BK4819_AF_AM = 7u, // AM
BK4819_AF_FSKO = 8u, // nothing
BK4819_AF_UNKNOWN3 = 9u, // distorted
BK4819_AF_UNKNOWN4 = 10u, // nothing at all
BK4819_AF_UNKNOWN5 = 11u, // distorted
BK4819_AF_UNKNOWN6 = 12u, // distorted
BK4819_AF_UNKNOWN7 = 13u, // interesting
BK4819_AF_UNKNOWN8 = 14u, // interesting
BK4819_AF_UNKNOWN9 = 15u // not a lot
};
typedef enum BK4819_AF_Type_t BK4819_AF_Type_t;

Binary file not shown.

Binary file not shown.

View File

@ -51,6 +51,22 @@ center_line_t center_line = CENTER_LINE_NONE;
// ***************************************************************************
void UI_drawBars(uint8_t *p, const unsigned int level)
{
switch (level)
{
default:
case 7: memmove(p + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6));
case 6: memmove(p + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5));
case 5: memmove(p + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4));
case 4: memmove(p + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3));
case 3: memmove(p + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2));
case 2: memmove(p + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1));
case 1: memmove(p + 0, BITMAP_Antenna, sizeof(BITMAP_Antenna));
case 0: break;
}
}
#ifdef ENABLE_AUDIO_BAR
unsigned int sqrt16(unsigned int value)
@ -82,7 +98,7 @@ center_line_t center_line = CENTER_LINE_NONE;
if (gScreenToDisplay != DISPLAY_MAIN)
return;
#if 1
// TX audio level
@ -93,7 +109,7 @@ center_line_t center_line = CENTER_LINE_NONE;
if (gAlarmState != ALARM_STATE_OFF)
return;
#endif
const unsigned int voice_amp = BK4819_GetVoiceAmplitudeOut(); // 15:0
// const unsigned int max = 65535;
@ -280,25 +296,12 @@ void UI_UpdateRSSI(const int16_t rssi, const int vfo)
memset(p_line, 0, 23);
if (rssi_level > 0)
{
//if (rssi_level >= 1)
memmove(p_line, BITMAP_Antenna, 5);
if (rssi_level >= 2)
memmove(p_line + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1));
if (rssi_level >= 3)
memmove(p_line + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2));
if (rssi_level >= 4)
memmove(p_line + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3));
if (rssi_level >= 5)
memmove(p_line + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4));
if (rssi_level >= 6)
memmove(p_line + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5));
if (rssi_level >= 7)
memmove(p_line + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6));
}
else
// untested !!!
if (rssi_level == 0)
p_line = NULL;
else
UI_drawBars(p_line, rssi_level);
ST7565_DrawLine(0, Line, 23, p_line);
#endif
@ -647,23 +650,7 @@ void UI_DisplayMain(void)
#endif
}
if (Level >= 1)
{
uint8_t *p_line = p_line1 + LCD_WIDTH;
memmove(p_line + 0, BITMAP_Antenna, sizeof(BITMAP_Antenna));
if (Level >= 2)
memmove(p_line + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1));
if (Level >= 3)
memmove(p_line + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2));
if (Level >= 4)
memmove(p_line + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3));
if (Level >= 5)
memmove(p_line + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4));
if (Level >= 6)
memmove(p_line + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5));
if (Level >= 7)
memmove(p_line + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6));
}
UI_drawBars(p_line1 + LCD_WIDTH, Level);
}
// ************

View File

@ -18,6 +18,7 @@
#include <stdlib.h> // abs()
#include "app/dtmf.h"
#include "app/menu.h"
#include "bitmaps.h"
#include "board.h"
#include "dcs.h"
@ -787,8 +788,7 @@ void UI_DisplayMenu(void)
const uint32_t value = 22656 + gSubMenuSelection;
const uint32_t xtal_Hz = (0x4f0000u + value) * 5;
//gEeprom.BK4819_XTAL_FREQ_LOW = gSubMenuSelection; // already set when the user was adjusting the value
BK4819_WriteRegister(BK4819_REG_3B, value);
writeXtalFreqCal(gSubMenuSelection, false);
sprintf(String, "%d\n%u.%06u\nMHz",
gSubMenuSelection,