Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/OneOfEleven/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
egzumer committed Oct 4, 2023
2 parents 292181a + fe949d2 commit bee4a8c
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 62 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ENABLE_NOAA := 0
ENABLE_VOICE := 0
ENABLE_VOX := 1
ENABLE_ALARM := 0
ENABLE_TX1750 := 0
ENABLE_TX1750 := 1
ENABLE_BIG_FREQ := 1
ENABLE_SMALL_BOLD := 1
ENABLE_KEEP_MEM_NAME := 1
Expand Down Expand Up @@ -176,7 +176,7 @@ ifeq ($(ENABLE_LTO), 1)
CFLAGS += -flto=2
endif

CFLAGS += -Wpadded
#CFLAGS += -Wpadded
CFLAGS += -DPRINTF_INCLUDE_CONFIG_H
CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\"

Expand Down
22 changes: 14 additions & 8 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -1711,16 +1711,22 @@ void APP_TimeSlice500ms(void)

if (gDTMF_RX_live_timeout > 0)
{
if (--gDTMF_RX_live_timeout == 0)
#ifdef ENABLE_RSSI_BAR
if (center_line == CENTER_LINE_DTMF_DEC ||
center_line == CENTER_LINE_NONE) // wait till the center line is free for us to use before timing out
#endif
{
if (gDTMF_RX_live[0] != 0)
if (--gDTMF_RX_live_timeout == 0)
{
memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live));
gUpdateDisplay = true;
if (gDTMF_RX_live[0] != 0)
{
memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live));
gUpdateDisplay = true;
}
}
}
}

if (gDTMF_RX_timeout > 0)
if (--gDTMF_RX_timeout == 0)
DTMF_clear_RX();
Expand Down Expand Up @@ -1973,9 +1979,9 @@ void APP_TimeSlice500ms(void)
gCurrentFunction != FUNCTION_TRANSMIT &&
gCurrentFunction != FUNCTION_RECEIVE)
{
if (gDTMF_AUTO_RESET_TIME > 0)
if (gDTMF_auto_reset_time_500ms > 0)
{
if (--gDTMF_AUTO_RESET_TIME == 0)
if (--gDTMF_auto_reset_time_500ms == 0)
{
gDTMF_CallState = DTMF_CALL_STATE_NONE;
gUpdateDisplay = true;
Expand Down Expand Up @@ -2463,7 +2469,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)

RADIO_SetupRegisters(true);

gDTMF_AUTO_RESET_TIME = 0;
gDTMF_auto_reset_time_500ms = 0;
gDTMF_CallState = DTMF_CALL_STATE_NONE;
gDTMF_TxStopCountdown_500ms = 0;
gDTMF_IsTx = false;
Expand Down
9 changes: 4 additions & 5 deletions app/dtmf.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ char gDTMF_Caller[4];
char gDTMF_Callee[4];
DTMF_State_t gDTMF_State;
uint8_t gDTMF_DecodeRingCountdown_500ms;
uint8_t gDTMFChosenContact;
uint8_t gDTMF_AUTO_RESET_TIME;
uint8_t gDTMF_chosen_contact;
uint8_t gDTMF_auto_reset_time_500ms;
DTMF_CallState_t gDTMF_CallState;
DTMF_ReplyState_t gDTMF_ReplyState;
DTMF_CallMode_t gDTMF_CallMode;
Expand Down Expand Up @@ -403,13 +403,12 @@ void DTMF_Reply(void)
if (pString == NULL)
return;

Delay = gEeprom.DTMF_PRELOAD_TIME;
Delay = (gEeprom.DTMF_PRELOAD_TIME < 200) ? 200 : gEeprom.DTMF_PRELOAD_TIME;

if (gEeprom.DTMF_SIDE_TONE)
{ // the will also hear the transmitted tones
{ // the user will also hear the transmitted tones
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gEnableSpeaker = true;
Delay = (gEeprom.DTMF_PRELOAD_TIME < 60) ? 60 : gEeprom.DTMF_PRELOAD_TIME;
}

SYSTEM_DelayMs(Delay);
Expand Down
4 changes: 2 additions & 2 deletions app/dtmf.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ extern char gDTMF_Caller[4];
extern char gDTMF_Callee[4];
extern DTMF_State_t gDTMF_State;
extern uint8_t gDTMF_DecodeRingCountdown_500ms;
extern uint8_t gDTMFChosenContact;
extern uint8_t gDTMF_AUTO_RESET_TIME;
extern uint8_t gDTMF_chosen_contact;
extern uint8_t gDTMF_auto_reset_time_500ms;
extern DTMF_CallState_t gDTMF_CallState;
extern DTMF_ReplyState_t gDTMF_ReplyState;
extern DTMF_CallMode_t gDTMF_CallMode;
Expand Down
39 changes: 22 additions & 17 deletions app/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
void writeXtalFreqCal(const int32_t value, const bool update_eeprom)
{
BK4819_WriteRegister(BK4819_REG_3B, 22656 + value);

if (update_eeprom)
{
struct
Expand All @@ -62,9 +62,9 @@
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
//
Expand Down Expand Up @@ -431,7 +431,7 @@ void MENU_AcceptSetting(void)

BK4819_SetCTCSSFrequency(CTCSS_Options[Code]);
}

gRequestSaveChannel = 1;
return;

Expand Down Expand Up @@ -630,7 +630,7 @@ void MENU_AcceptSetting(void)
break;

case MENU_D_HOLD:
gEeprom.DTMF_AUTO_RESET_TIME = gSubMenuSelection;
gEeprom.DTMF_auto_reset_time = gSubMenuSelection;
break;

case MENU_D_PRE:
Expand Down Expand Up @@ -663,7 +663,7 @@ void MENU_AcceptSetting(void)
break;

case MENU_D_LIST:
gDTMFChosenContact = gSubMenuSelection - 1;
gDTMF_chosen_contact = gSubMenuSelection - 1;
if (gIsDtmfContactValid)
{
GUI_SelectNextDisplay(DISPLAY_MAIN);
Expand Down Expand Up @@ -758,19 +758,24 @@ void MENU_AcceptSetting(void)
#endif

case MENU_BATCAL:
gBatteryCalibration[0] = 520*gSubMenuSelection/760; //5.2V empty, blinking above this value, reduced functionality below
gBatteryCalibration[1] = 700*gSubMenuSelection/760; // 7V, ~5%, 1 bars above this value
gBatteryCalibration[2] = 745*gSubMenuSelection/760; // 7.45V, ~17%, 2 bars above this value
gBatteryCalibration[3] = gSubMenuSelection; // 7.6V, ~29%, 3 bars above this value
gBatteryCalibration[4] = 788*gSubMenuSelection/760; // 7.88V, ~65% 4 bars above this value
{
uint16_t buf[4];

gBatteryCalibration[0] = (520ul * gSubMenuSelection) / 760; // 5.20V empty, blinking above this value, reduced functionality below
gBatteryCalibration[1] = (700ul * gSubMenuSelection) / 760; // 7.00V, ~5%, 1 bars above this value
gBatteryCalibration[2] = (745ul * gSubMenuSelection) / 760; // 7.45V, ~17%, 2 bars above this value
gBatteryCalibration[3] = gSubMenuSelection; // 7.6V, ~29%, 3 bars above this value
gBatteryCalibration[4] = (788ul * gSubMenuSelection) / 760; // 7.88V, ~65%, 4 bars above this value
gBatteryCalibration[5] = 2300;
EEPROM_WriteBuffer(0x1F40, gBatteryCalibration);
uint16_t buf[4];
EEPROM_ReadBuffer(0x1F48, buf, sizeof(buf));

EEPROM_ReadBuffer( 0x1F48, buf, sizeof(buf));
buf[0] = gBatteryCalibration[4];
buf[1] = gBatteryCalibration[5];
EEPROM_WriteBuffer(0x1F48, buf);
EEPROM_WriteBuffer(0x1F48, buf);

break;
}
}

gRequestSaveSettings = true;
Expand Down Expand Up @@ -932,7 +937,7 @@ void MENU_ShowCurrentSetting(void)
gSubMenuSelection = gEeprom.VOX_SWITCH ? gEeprom.VOX_LEVEL + 1 : 0;
break;
#endif

case MENU_ABR:
gSubMenuSelection = gEeprom.BACKLIGHT;

Expand Down Expand Up @@ -1039,7 +1044,7 @@ void MENU_ShowCurrentSetting(void)
break;

case MENU_D_HOLD:
gSubMenuSelection = gEeprom.DTMF_AUTO_RESET_TIME;
gSubMenuSelection = gEeprom.DTMF_auto_reset_time;
break;

case MENU_D_PRE:
Expand All @@ -1059,7 +1064,7 @@ void MENU_ShowCurrentSetting(void)
break;

case MENU_D_LIST:
gSubMenuSelection = gDTMFChosenContact + 1;
gSubMenuSelection = gDTMF_chosen_contact + 1;
break;

case MENU_D_LIVE_DEC:
Expand Down
7 changes: 0 additions & 7 deletions app/spectrum.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,14 @@ typedef struct SpectrumSettings {
uint32_t frequencyChangeStep;
StepsCount stepsCount;
ScanStep scanStepIndex;

uint16_t scanDelay;
uint16_t rssiTriggerLevel;


BK4819_FilterBandwidth_t bw;
BK4819_FilterBandwidth_t listenBw;
int dbMin;
int dbMax;
ModulationType modulationType;
bool backlightState;
uint8_t _pad[2];
} SpectrumSettings;

typedef struct KeyboardState {
Expand All @@ -151,7 +147,6 @@ typedef struct ScanInfo {
uint32_t f, fPeak;
uint16_t scanStep;
uint8_t measurementsCount;
uint8_t _pad[1];
} ScanInfo;

typedef struct RegisterSpec {
Expand All @@ -160,15 +155,13 @@ typedef struct RegisterSpec {
uint8_t offset;
uint16_t maxValue;
uint16_t inc;
uint8_t _pad[2];
} RegisterSpec;

typedef struct PeakInfo {
uint16_t t;
uint16_t rssi;
uint32_t f;
uint8_t i;
uint8_t _pad[3];
} PeakInfo;

void APP_RunSpectrum(void);
Expand Down
2 changes: 1 addition & 1 deletion board.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ void BOARD_EEPROM_Init(void)
gEeprom.DTMF_SEPARATE_CODE = DTMF_ValidateCodes((char *)(Data + 1), 1) ? Data[1] : '*';
gEeprom.DTMF_GROUP_CALL_CODE = DTMF_ValidateCodes((char *)(Data + 2), 1) ? Data[2] : '#';
gEeprom.DTMF_DECODE_RESPONSE = (Data[3] < 4) ? Data[3] : 0;
gEeprom.DTMF_AUTO_RESET_TIME = (Data[4] < 61) ? Data[4] : 5;
gEeprom.DTMF_auto_reset_time = (Data[4] < 61) ? Data[4] : (Data[4] >= 10) ? Data[4] : 10;
gEeprom.DTMF_PRELOAD_TIME = (Data[5] < 101) ? Data[5] * 10 : 300;
gEeprom.DTMF_FIRST_CODE_PERSIST_TIME = (Data[6] < 101) ? Data[6] * 10 : 100;
gEeprom.DTMF_HASH_CODE_PERSIST_TIME = (Data[7] < 101) ? Data[7] * 10 : 100;
Expand Down
22 changes: 20 additions & 2 deletions driver/bk4819.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ void BK4819_EnableDTMF(void)
// REG_24 <3:0> 14 Max symbol number for SelCall detection

// const uint16_t threshold = 24; // doesn't decode non-QS radios
const uint16_t threshold = 140; // but 128 ~ 247 does
const uint16_t threshold = 200; // but 128 ~ 247 does
BK4819_WriteRegister(BK4819_REG_24, // 1 00011000 1 1 1 1110
(1u << BK4819_REG_24_SHIFT_UNKNOWN_15)
| (threshold << BK4819_REG_24_SHIFT_THRESHOLD) // 0 ~ 255
Expand Down Expand Up @@ -1183,7 +1183,25 @@ void BK4819_TransmitTone(bool bLocalLoopback, uint32_t Frequency)
{
BK4819_EnterTxMute();

BK4819_WriteRegister(BK4819_REG_70, 0 | BK4819_REG_70_MASK_ENABLE_TONE1 | (96U << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN));
// REG_70 <15> 0 Enable TONE1
// 1 = Enable
// 0 = Disable
//
// REG_70 <14:8> 0 TONE1 tuning gain
// 0 ~ 127
//
// REG_70 <7> 0 Enable TONE2
// 1 = Enable
// 0 = Disable
//
// REG_70 <6:0> 0 TONE2/FSK tuning gain
// 0 ~ 127
//
// set the tone amplitude
//
// BK4819_WriteRegister(BK4819_REG_70, BK4819_REG_70_MASK_ENABLE_TONE1 | (96u << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN));
BK4819_WriteRegister(BK4819_REG_70, BK4819_REG_70_MASK_ENABLE_TONE1 | (50u << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN));

BK4819_WriteRegister(BK4819_REG_71, scale_freq(Frequency));

BK4819_SetAF(bLocalLoopback ? BK4819_AF_BEEP : BK4819_AF_MUTE);
Expand Down
2 changes: 1 addition & 1 deletion functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
#endif

if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED)
gDTMF_AUTO_RESET_TIME = 1 + (gEeprom.DTMF_AUTO_RESET_TIME * 2);
gDTMF_auto_reset_time_500ms = 1 + (gEeprom.DTMF_auto_reset_time * 2);

gUpdateStatus = true;
return;
Expand Down
9 changes: 5 additions & 4 deletions radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,8 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
case BK4819_FILTER_BW_WIDE:
case BK4819_FILTER_BW_NARROW:
#ifdef ENABLE_AM_FIX
BK4819_SetFilterBandwidth(Bandwidth, gRxVfo->AM_mode && gSetting_AM_fix);
// BK4819_SetFilterBandwidth(Bandwidth, false);
// BK4819_SetFilterBandwidth(Bandwidth, gRxVfo->AM_mode && gSetting_AM_fix);
BK4819_SetFilterBandwidth(Bandwidth, true);
#else
BK4819_SetFilterBandwidth(Bandwidth, false);
#endif
Expand Down Expand Up @@ -732,6 +732,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
#else
if (gCurrentFunction != FUNCTION_TRANSMIT)
{
BK4819_DisableDTMF();
BK4819_EnableDTMF();
InterruptMask |= BK4819_REG_3F_DTMF_5TONE_FOUND;
}
Expand Down Expand Up @@ -812,8 +813,8 @@ void RADIO_SetTxParameters(void)
case BK4819_FILTER_BW_WIDE:
case BK4819_FILTER_BW_NARROW:
#ifdef ENABLE_AM_FIX
BK4819_SetFilterBandwidth(Bandwidth, gCurrentVfo->AM_mode && gSetting_AM_fix);
// BK4819_SetFilterBandwidth(Bandwidth, false);
// BK4819_SetFilterBandwidth(Bandwidth, gCurrentVfo->AM_mode && gSetting_AM_fix);
BK4819_SetFilterBandwidth(Bandwidth, true);
#else
BK4819_SetFilterBandwidth(Bandwidth, false);
#endif
Expand Down
2 changes: 1 addition & 1 deletion settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void SETTINGS_SaveSettings(void)
State[1] = gEeprom.DTMF_SEPARATE_CODE;
State[2] = gEeprom.DTMF_GROUP_CALL_CODE;
State[3] = gEeprom.DTMF_DECODE_RESPONSE;
State[4] = gEeprom.DTMF_AUTO_RESET_TIME;
State[4] = gEeprom.DTMF_auto_reset_time;
State[5] = gEeprom.DTMF_PRELOAD_TIME / 10U;
State[6] = gEeprom.DTMF_FIRST_CODE_PERSIST_TIME / 10U;
State[7] = gEeprom.DTMF_HASH_CODE_PERSIST_TIME / 10U;
Expand Down
2 changes: 1 addition & 1 deletion settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ typedef struct {
char DTMF_SEPARATE_CODE;
char DTMF_GROUP_CALL_CODE;
uint8_t DTMF_DECODE_RESPONSE;
uint8_t DTMF_AUTO_RESET_TIME;
uint8_t DTMF_auto_reset_time;
uint16_t DTMF_PRELOAD_TIME;
uint16_t DTMF_FIRST_CODE_PERSIST_TIME;
uint16_t DTMF_HASH_CODE_PERSIST_TIME;
Expand Down
11 changes: 0 additions & 11 deletions ui/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,6 @@
#include "ui/main.h"
#include "ui/ui.h"

enum center_line_t {
CENTER_LINE_NONE = 0,
CENTER_LINE_IN_USE,
CENTER_LINE_AUDIO_BAR,
CENTER_LINE_RSSI,
CENTER_LINE_AM_FIX_DATA,
CENTER_LINE_DTMF_DEC,
CENTER_LINE_CHARGE_DATA
};
typedef enum center_line_t center_line_t;

center_line_t center_line = CENTER_LINE_NONE;

// ***************************************************************************
Expand Down
13 changes: 13 additions & 0 deletions ui/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@
#ifndef UI_MAIN_H
#define UI_MAIN_H

enum center_line_t {
CENTER_LINE_NONE = 0,
CENTER_LINE_IN_USE,
CENTER_LINE_AUDIO_BAR,
CENTER_LINE_RSSI,
CENTER_LINE_AM_FIX_DATA,
CENTER_LINE_DTMF_DEC,
CENTER_LINE_CHARGE_DATA
};
typedef enum center_line_t center_line_t;

extern center_line_t center_line;

void UI_DisplayAudioBar(void);
void UI_UpdateRSSI(const int16_t rssi, const int vfo);
void UI_DisplayMain(void);
Expand Down

0 comments on commit bee4a8c

Please sign in to comment.