Compare commits

...

11 Commits
main ... fixes

Author SHA1 Message Date
Dual Tachyon
33084aef98 Use 0 for channel name to fix CPS display. 2023-10-30 12:09:29 +00:00
Dual Tachyon
d012a25bb2 Fixed QS bug with step selection. 2023-10-30 12:09:29 +00:00
Dual Tachyon
df4e7d1622 Fixed step 2/3 of 8.33kHz. 2023-10-30 12:09:29 +00:00
Dual Tachyon
ac5ff212ec Fixed Quansheng's bug with 8.33khz stepping. 2023-10-30 12:09:29 +00:00
Dual Tachyon
86b737ca4d Removed use of floats for nice savings. 2023-10-30 12:09:28 +00:00
Dual Tachyon
bf430c9d98 Unified version strings to a single file. 2023-10-30 12:09:28 +00:00
Dual Tachyon
61280302b5 Fix for bug from issue 35. 2023-10-30 12:09:28 +00:00
Dual Tachyon
caae4c63f7 Fix for bug from issue 38. 2023-10-30 12:09:28 +00:00
Dual Tachyon
1e2a86755e Reapplied fix that was lost during a conflict. 2023-10-30 12:09:11 +00:00
Dual Tachyon
b75d59a283 Identified some more differences. 2023-10-30 12:09:11 +00:00
Dual Tachyon
9b7ee2ffff Added differences from v2.01.31. 2023-10-30 12:09:11 +00:00
18 changed files with 96 additions and 46 deletions

View File

@ -115,7 +115,7 @@ static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gInputBoxIndex = 0;
NUMBER_Get(gInputBox, &Frequency);
for (i = 0; i < 7; i++) {
if (Frequency >= gLowerLimitFrequencyBandTable[i] && Frequency <= gUpperLimitFrequencyBandTable[i]) {
if (Frequency >= LowerLimitFrequencyBandTable[i] && Frequency <= UpperLimitFrequencyBandTable[i]) {
gAnotherVoiceID = (VOICE_ID_t)Key;
gRxVfo->Band = i;
Frequency += 75;

View File

@ -381,10 +381,24 @@ void APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step)
uint32_t Frequency;
Frequency = pInfo->ConfigRX.Frequency + (Step * pInfo->StepFrequency);
if (Frequency > gUpperLimitFrequencyBandTable[pInfo->Band]) {
pInfo->ConfigRX.Frequency = gLowerLimitFrequencyBandTable[pInfo->Band];
} else if (Frequency < gLowerLimitFrequencyBandTable[pInfo->Band]) {
pInfo->ConfigRX.Frequency = FREQUENCY_FloorToStep(gUpperLimitFrequencyBandTable[pInfo->Band], pInfo->StepFrequency, gLowerLimitFrequencyBandTable[pInfo->Band]);
if (pInfo->StepFrequency == 833) {
const uint32_t Lower = LowerLimitFrequencyBandTable[pInfo->Band];
const uint32_t Delta = Frequency - Lower;
uint32_t Base = (Delta / 2500) * 2500;
const uint32_t Index = ((Delta - Base) % 2500) / 833;
if (Index == 2) {
Base++;
}
Frequency = Lower + Base + (Index * 833);
}
if (Frequency > UpperLimitFrequencyBandTable[pInfo->Band]) {
pInfo->ConfigRX.Frequency = LowerLimitFrequencyBandTable[pInfo->Band];
} else if (Frequency < LowerLimitFrequencyBandTable[pInfo->Band]) {
pInfo->ConfigRX.Frequency = FREQUENCY_FloorToStep(UpperLimitFrequencyBandTable[pInfo->Band], pInfo->StepFrequency, LowerLimitFrequencyBandTable[pInfo->Band]);
} else {
pInfo->ConfigRX.Frequency = Frequency;
}
@ -1126,18 +1140,18 @@ void APP_TimeSlice500ms(void)
#if defined(ENABLE_FMRADIO)
(gFM_ScanState == FM_SCAN_OFF || gAskToSave) &&
#endif
gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF) {
gCssScanMode == CSS_SCAN_MODE_OFF) {
if (gBacklightCountdown) {
gBacklightCountdown--;
if (gBacklightCountdown == 0) {
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
}
}
if (
if (gScanState == SCAN_OFF
#if defined(ENABLE_AIRCOPY)
gScreenToDisplay != DISPLAY_AIRCOPY &&
&& gScreenToDisplay != DISPLAY_AIRCOPY
#endif
(gScreenToDisplay != DISPLAY_SCANNER || (gScanCssState >= SCAN_CSS_STATE_FOUND))) {
&& (gScreenToDisplay != DISPLAY_SCANNER || (gScanCssState >= SCAN_CSS_STATE_FOUND))) {
if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown && !gDTMF_InputMode) {
gKeyLockCountdown--;
if (gKeyLockCountdown == 0) {

View File

@ -85,7 +85,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
uint8_t i;
for (i = 0; i < 7; i++) {
if (Frequency <= gUpperLimitFrequencyBandTable[i] && (gLowerLimitFrequencyBandTable[i] <= Frequency)) {
if (Frequency <= UpperLimitFrequencyBandTable[i] && (LowerLimitFrequencyBandTable[i] <= Frequency)) {
gAnotherVoiceID = (VOICE_ID_t)Key;
if (gTxVfo->Band != i) {
gTxVfo->Band = i;
@ -98,7 +98,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gTxVfo->ConfigRX.Frequency = FREQUENCY_FloorToStep(
Frequency,
gTxVfo->StepFrequency,
gLowerLimitFrequencyBandTable[gTxVfo->Band]
LowerLimitFrequencyBandTable[gTxVfo->Band]
);
gRequestSaveChannel = 1;
return;

View File

@ -235,7 +235,7 @@ void MENU_AcceptSetting(void)
gRequestSaveChannel = 1;
return;
}
gSubMenuSelection = gTxVfo->STEP_SETTING;
gTxVfo->STEP_SETTING = gTxVfo->STEP_SETTING;
return;
case MENU_TXP:
@ -959,6 +959,7 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
gInputBoxIndex = 0;
gFlagRefreshSetting = true;
gAnotherVoiceID = VOICE_ID_CANCEL;
gAskForConfirmation = 0;
} else {
gInputBoxIndex--;
gInputBox[gInputBoxIndex] = 10;

View File

@ -164,7 +164,7 @@ void AUDIO_PlayVoice(uint8_t VoiceID)
uint8_t i;
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
SYSTEM_DelayMs(7);
SYSTEM_DelayMs(20);
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
for (i = 0; i < 8; i++) {
if ((VoiceID & 0x80U) == 0) {
@ -172,11 +172,12 @@ void AUDIO_PlayVoice(uint8_t VoiceID)
} else {
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_VOICE_1);
}
SYSTICK_DelayUs(1200);
SYSTICK_DelayUs(1000);
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
SYSTICK_DelayUs(1200);
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
VoiceID <<= 1;
SYSTICK_DelayUs(200);
}
}

24
board.c
View File

@ -44,6 +44,14 @@
#include "sram-overlay.h"
#endif
static const uint32_t gDefaultFrequencyTable[5] = {
14502500,
14552500,
43477500,
43502500,
43697500,
};
#if defined(ENABLE_OVERLAY)
void BOARD_FLASH_Init(void)
{
@ -582,7 +590,7 @@ void BOARD_EEPROM_Init(void)
gEeprom.KEY_2_LONG_PRESS_ACTION = (Data[4] < 9) ? Data[4] : 6;
gEeprom.SCAN_RESUME_MODE = (Data[5] < 3) ? Data[5] : SCAN_RESUME_CO;
gEeprom.AUTO_KEYPAD_LOCK = (Data[6] < 2) ? Data[6] : true;
gEeprom.POWER_ON_DISPLAY_MODE = (Data[7] < 3) ? Data[7] : POWER_ON_DISPLAY_MODE_MESSAGE;
gEeprom.POWER_ON_DISPLAY_MODE = (Data[7] < 3) ? Data[7] : POWER_ON_DISPLAY_MODE_VOLTAGE;
// 0E98..0E9F
EEPROM_ReadBuffer(0x0E98, Data, 8);
@ -675,9 +683,6 @@ void BOARD_EEPROM_Init(void)
EEPROM_ReadBuffer(0x0F40, Data, 8);
gSetting_F_LOCK = (Data[0] < 6) ? Data[0] : F_LOCK_OFF;
gUpperLimitFrequencyBandTable = UpperLimitFrequencyBandTable;
gLowerLimitFrequencyBandTable = LowerLimitFrequencyBandTable;
gSetting_350TX = (Data[1] < 2) ? Data[1] : true;
gSetting_KILLED = (Data[2] < 2) ? Data[2] : false;
gSetting_200TX = (Data[3] < 2) ? Data[3] : false;
@ -775,5 +780,16 @@ void BOARD_FactoryReset(bool bIsAll)
EEPROM_WriteBuffer(i, Template);
}
}
if (bIsAll) {
RADIO_InitInfo(gRxVfo, FREQ_CHANNEL_FIRST + 5, 5, 41002500);
for (i = 0; i < 5; i++) {
const uint32_t Frequency = gDefaultFrequencyTable[i];
gRxVfo->ConfigRX.Frequency = Frequency;
gRxVfo->ConfigTX.Frequency = Frequency;
gRxVfo->Band = FREQUENCY_GetBand(Frequency);
SETTINGS_SaveChannel(MR_CHANNEL_FIRST + i, 0, gRxVfo, 2);
}
}
}

View File

@ -456,7 +456,7 @@ void BK4819_PlayTone(uint16_t Frequency, bool bTuningGainSwitch)
| BK4819_REG_30_ENABLE_TX_DSP);
;
BK4819_WriteRegister(BK4819_REG_71, (uint16_t)(Frequency * 10.32444));
BK4819_WriteRegister(BK4819_REG_71, (uint16_t)((Frequency * 1032444) / 100000));
}
void BK4819_EnterTxMute(void)
@ -694,7 +694,7 @@ void BK4819_TransmitTone(bool bLocalLoopback, uint32_t Frequency)
BK4819_WriteRegister(BK4819_REG_70, 0
| BK4819_REG_70_MASK_ENABLE_TONE1
| (96U << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN));
BK4819_WriteRegister(BK4819_REG_71, (uint16_t)(Frequency * 10.32444));
BK4819_WriteRegister(BK4819_REG_71, (uint16_t)((Frequency * 1032444) / 100000));
if (bLocalLoopback) {
BK4819_SetAF(BK4819_AF_BEEP);
} else {
@ -946,7 +946,7 @@ void BK4819_GetVoxAmp(uint16_t *pResult)
void BK4819_SetScrambleFrequencyControlWord(uint32_t Frequency)
{
BK4819_WriteRegister(BK4819_REG_71, (uint16_t)(Frequency * 10.32444));
BK4819_WriteRegister(BK4819_REG_71, (uint16_t)((Frequency * 1032444) / 100000));
}
void BK4819_PlayDTMFEx(bool bLocalLoopback, char Code)

View File

@ -121,7 +121,20 @@ uint32_t FREQUENCY_FloorToStep(uint32_t Upper, uint32_t Step, uint32_t Lower)
{
uint32_t Index;
if (Step == 833) {
const uint32_t Delta = Upper - Lower;
uint32_t Base = (Delta / 2500) * 2500;
const uint32_t Index = ((Delta - Base) % 2500) / 833;
if (Index == 2) {
Base++;
}
return Lower + Base + (Index * 833);
}
Index = (Upper - Lower) / Step;
return Lower + (Step * Index);
}

7
main.c
View File

@ -36,10 +36,7 @@
#include "settings.h"
#include "ui/lock.h"
#include "ui/welcome.h"
#if defined(ENABLE_UART)
static const char Version[] = "UV-K5 Firmware, Open Edition, OEFW-"GIT_HASH"\r\n";
#endif
#include "version.h"
void _putchar(char c)
{
@ -69,7 +66,7 @@ void Main(void)
#if defined(ENABLE_UART)
UART_Init();
UART_Send(Version, sizeof(Version));
UART_Send(UART_Version, sizeof(UART_Version));
#endif
// Not implementing authentic device checks

3
misc.h
View File

@ -79,9 +79,6 @@ enum CssScanMode_t {
typedef enum CssScanMode_t CssScanMode_t;
extern const uint32_t *gUpperLimitFrequencyBandTable;
extern const uint32_t *gLowerLimitFrequencyBandTable;
extern bool gSetting_350TX;
extern bool gSetting_KILLED;
extern bool gSetting_200TX;

View File

@ -1,3 +1,4 @@
#define PRINTF_DISABLE_SUPPORT_LONG_LONG
#define PRINTF_DISABLE_SUPPORT_EXPONENTIAL
#define PRINTF_DISABLE_SUPPORT_PTRDIFF_T
#define PRINTF_DISABLE_SUPPORT_FLOAT

26
radio.c
View File

@ -126,6 +126,12 @@ void RADIO_InitInfo(VFO_Info_t *pInfo, uint8_t ChannelSave, uint8_t Band, uint32
pInfo->pRX = &pInfo->ConfigRX;
pInfo->pTX = &pInfo->ConfigTX;
pInfo->FREQUENCY_OF_DEVIATION = 1000000;
if (ChannelSave == (FREQ_CHANNEL_FIRST + BAND2_108MHz)) {
pInfo->AM_CHANNEL_MODE = true;
pInfo->IsAM = true;
}
RADIO_ConfigureSquelchAndOutputPower(pInfo);
}
@ -188,7 +194,7 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Configure)
gEeprom.ScreenChannel[VFO] = gEeprom.FreqChannel[VFO];
}
Index = Channel - FREQ_CHANNEL_FIRST;
RADIO_InitInfo(pRadio, Channel, Index, gLowerLimitFrequencyBandTable[Index]);
RADIO_InitInfo(pRadio, Channel, Index, LowerLimitFrequencyBandTable[Index]);
return;
}
@ -315,12 +321,12 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Configure)
}
Frequency = pRadio->ConfigRX.Frequency;
if (Frequency < gLowerLimitFrequencyBandTable[Band]) {
pRadio->ConfigRX.Frequency = gLowerLimitFrequencyBandTable[Band];
} else if (Frequency > gUpperLimitFrequencyBandTable[Band]) {
pRadio->ConfigRX.Frequency = gUpperLimitFrequencyBandTable[Band];
if (Frequency < LowerLimitFrequencyBandTable[Band]) {
pRadio->ConfigRX.Frequency = LowerLimitFrequencyBandTable[Band];
} else if (Frequency > UpperLimitFrequencyBandTable[Band]) {
pRadio->ConfigRX.Frequency = UpperLimitFrequencyBandTable[Band];
} else if (Channel >= FREQ_CHANNEL_FIRST) {
pRadio->ConfigRX.Frequency = FREQUENCY_FloorToStep(pRadio->ConfigRX.Frequency, gEeprom.VfoInfo[VFO].StepFrequency, gLowerLimitFrequencyBandTable[Band]);
pRadio->ConfigRX.Frequency = FREQUENCY_FloorToStep(pRadio->ConfigRX.Frequency, gEeprom.VfoInfo[VFO].StepFrequency, LowerLimitFrequencyBandTable[Band]);
}
if (Frequency >= 10800000 && Frequency <= 13599990) {
@ -809,13 +815,15 @@ void RADIO_EnableCxCSS(void)
case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL:
BK4819_EnableCDCSS();
SYSTEM_DelayMs(200);
break;
case CODE_TYPE_CONTINUOUS_TONE:
BK4819_EnableCTCSS();
SYSTEM_DelayMs(200);
break;
default:
BK4819_EnableCTCSS();
break;
}
SYSTEM_DelayMs(200);
}
void RADIO_PrepareCssTX(void)

View File

@ -230,7 +230,7 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,
SETTINGS_UpdateChannel(Channel, pVFO, true);
if (IS_MR_CHANNEL(Channel)) {
memset(&State32, 0xFF, sizeof(State32));
memset(&State32, 0x00, sizeof(State32));
EEPROM_WriteBuffer(OffsetMR + 0x0F50, State32);
EEPROM_WriteBuffer(OffsetMR + 0x0F58, State32);
}

View File

@ -216,7 +216,7 @@ void UI_DisplayMenu(void)
break;
case MENU_STEP:
sprintf(String, "%.2fKHz", gSubMenu_Step[gSubMenuSelection] * 0.01);
sprintf(String, "%d.%02dKHz", gSubMenu_Step[gSubMenuSelection] / 100, gSubMenu_Step[gSubMenuSelection] % 100);
break;
case MENU_TXP:
@ -239,7 +239,7 @@ void UI_DisplayMenu(void)
if (gSubMenuSelection == 0) {
strcpy(String, "OFF");
} else {
sprintf(String, "%.1fHz", CTCSS_Options[gSubMenuSelection - 1] * 0.1);
sprintf(String, "%d.%dHz", CTCSS_Options[gSubMenuSelection - 1] / 10, CTCSS_Options[gSubMenuSelection - 1] % 10);
}
break;
@ -249,7 +249,7 @@ void UI_DisplayMenu(void)
case MENU_OFFSET:
if (!gIsInSubMenu || gInputBoxIndex == 0) {
sprintf(String, "%.5f", gSubMenuSelection * 1e-05);
sprintf(String, "%d.%05d", gSubMenuSelection / 100000, gSubMenuSelection % 100000);
break;
}
for (i = 0; i < 3; i++) {
@ -412,7 +412,7 @@ void UI_DisplayMenu(void)
break;
case MENU_VOL:
sprintf(String, "%.2fV", gBatteryVoltageAverage * 0.01);
sprintf(String, "%d.%02dV", gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100);
break;
case MENU_RESET:

View File

@ -34,7 +34,7 @@ void UI_DisplayScanner(void)
memset(String, 0, sizeof(String));
if (gScanSingleFrequency || (gScanCssState != SCAN_CSS_STATE_OFF && gScanCssState != SCAN_CSS_STATE_FAILED)) {
sprintf(String, "FREQ:%.5f", gScanFrequency * 1e-05);
sprintf(String, "FREQ:%d.%05d", gScanFrequency / 100000, gScanFrequency % 100000);
} else {
sprintf(String, "FREQ:**.*****");
}
@ -44,7 +44,7 @@ void UI_DisplayScanner(void)
if (gScanCssState < SCAN_CSS_STATE_FOUND || !gScanUseCssResult) {
sprintf(String, "CTC:******");
} else if (gScanCssResultType == CODE_TYPE_CONTINUOUS_TONE) {
sprintf(String, "CTC:%.1fHz", CTCSS_Options[gScanCssResultCode] * 0.1);
sprintf(String, "CTC:%d.%dHz", CTCSS_Options[gScanCssResultCode] / 10, CTCSS_Options[gScanCssResultCode] % 10);
} else {
sprintf(String, "DCS:D%03oN", DCS_Options[gScanCssResultCode]);
}

View File

@ -39,7 +39,7 @@ void UI_DisplayWelcome(void)
memset(WelcomeString1, 0, sizeof(WelcomeString1));
if (gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_VOLTAGE) {
sprintf(WelcomeString0, "VOLTAGE");
sprintf(WelcomeString1, "%.2fV", gBatteryVoltageAverage * 0.01);
sprintf(WelcomeString1, "%d.%02dV", gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100);
} else {
EEPROM_ReadBuffer(0x0EB0, WelcomeString0, 16);
EEPROM_ReadBuffer(0x0EC0, WelcomeString1, 16);

View File

@ -1,2 +1,3 @@
const char Version[] = "OEFW-" GIT_HASH;
const char UART_Version[45] = "UV-K5 Firmware, Open Edition, OEFW-"GIT_HASH"\r\n";

View File

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