Test out some things
All checks were successful
Build Firmware / build (push) Successful in 22s

This commit is contained in:
2025-03-05 22:35:45 +01:00
parent 72558f93f3
commit 8dd68d74a6
18 changed files with 203 additions and 123 deletions

View File

@@ -9,7 +9,7 @@ ENABLE_UART ?= 1
ENABLE_AIRCOPY ?= 0
ENABLE_NOAA ?= 0
ENABLE_VOICE ?= 0
ENABLE_VOX ?= 1
ENABLE_VOX ?= 0
ENABLE_ALARM ?= 0
ENABLE_TX1750 ?= 1
ENABLE_PWRON_PASSWORD ?= 0

View File

@@ -440,7 +440,7 @@ static void ACTION_Scan_FM(bool bRestart)
static void ACTION_AlarmOr1750(const bool b1750)
{
if(gEeprom.KEY_LOCK && gEeprom.KEY_LOCK_PTT)
if(gEeprom.KEY_LOCK)
return;
#if defined(ENABLE_ALARM)

View File

@@ -970,13 +970,13 @@ void APP_Update(void) {
&& gScanStateDir == SCAN_OFF
&& !gPttIsPressed
&& gCurrentFunction != FUNCTION_POWER_SAVE
#ifdef ENABLE_VOICE
#ifdef ENABLE_VOICE
&& gVoiceWriteIndex == 0
#endif
#ifdef ENABLE_FMRADIO
#endif
#ifdef ENABLE_FMRADIO
&& !gFmRadioMode
#endif
#ifdef ENABLE_DTMF_CALLING
#endif
#ifdef ENABLE_DTMF_CALLING
&& gDTMF_CallState == DTMF_CALL_STATE_NONE
#endif
) {
@@ -1012,10 +1012,10 @@ void APP_Update(void) {
|| gScanStateDir != SCAN_OFF
|| gCssBackgroundScan
|| gScreenToDisplay != DISPLAY_MAIN
#ifdef ENABLE_FMRADIO
#ifdef ENABLE_FMRADIO
|| gFmRadioMode
#endif
#ifdef ENABLE_DTMF_CALLING
#endif
#ifdef ENABLE_DTMF_CALLING
|| gDTMF_CallState != DTMF_CALL_STATE_NONE
#endif
#ifdef ENABLE_NOAA
@@ -1395,6 +1395,10 @@ void APP_TimeSlice10ms(void) {
SCANNER_TimeSlice10ms();
if (gEnteringSMS == SMS_NOT_ENTERING) {
MSG_FSKReceiveData();
}
#ifdef ENABLE_AIRCOPY
if (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState == AIRCOPY_TRANSFER && gAirCopyIsSendMode == 1) {
if (!AIRCOPY_SendMessage()) {
@@ -1818,8 +1822,8 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
bool lowBatPopup = gLowBattery && !gLowBatteryConfirmed && gScreenToDisplay == DISPLAY_MAIN;
if ((gEeprom.KEY_LOCK || lowBatPopup) && gCurrentFunction != FUNCTION_TRANSMIT)
{ // keyboard is locked or low battery popup
if ((gEeprom.KEY_LOCK || lowBatPopup) &&
gCurrentFunction != FUNCTION_TRANSMIT) { // keyboard is locked or low battery popup
// close low battery popup
if (Key == KEY_EXIT && bKeyPressed && lowBatPopup) {

View File

@@ -98,6 +98,88 @@ void MSG_ConfigureFSK(bool rx) {
}
uint16_t calculateCRC(uint8_t *data, size_t length) {
uint16_t crc = 0xFFFF; // Example CRC-16 initialization
for (size_t i = 0; i < length; i++) {
crc ^= data[i];
for (uint8_t j = 0; j < 8; j++) {
if (crc & 1) {
crc = (crc >> 1) ^ 0xA001; // Example polynomial (CRC-16-IBM)
} else {
crc >>= 1;
}
}
}
return crc;
}
void processReceivedPacket(DataPacket *packet) {
char String[31 + DataPacketDataSize];
char numBuf[11]; // Enough for any 64-bit unsigned integer
const unsigned int vfo = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO
: gEeprom.TX_VFO;
if (dataPacket.dest == gEeprom.FSKSRCAddress) {
BK4819_PlaySingleTone(1000, 250, 127, true);
strcpy(String, "SMS by ");
itoa(packet->src, numBuf); // Convert number to string
strcat(String, numBuf);
strcat(String, ": ");
strcat(String, (char *)packet->data);
UI_DisplayPopup(String);
#ifdef ENABLE_FEAT_F4HWN
if (isMainOnly()) {
UI_PrintStringSmallNormal(String, 2, 0, 5);
} else {
UI_PrintStringSmallNormal(String, 2, 0, 3);
}
#else
UI_PrintStringSmallNormal(String, 2, 0, 3);
#endif
} else if (VfoState[vfo] == VFO_STATE_NORMAL && !TX_freq_check(gCurrentVfo->freq_config_TX.Frequency)) {
if (packet->ttl--) {
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, true);
MSG_FSKSendData(packet);
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, false);
}
}
memset(packet, 0, DataPacketDataSize); // Clear data after processing (example action)
}
bool MSG_FSKReceiveData() {
if (!(BK4819_ReadRegister(BK4819_REG_0C) & (1U << 1))) {
return false; // No data available
}
// Read the received data from FIFO
uint16_t *ptr = (uint16_t *) &inBoundPacket;
size_t wordCount = sizeof(inBoundPacket) / sizeof(uint16_t);
for (size_t i = 0; i < wordCount; i++) {
ptr[i] = BK4819_ReadRegister(BK4819_REG_5F);
}
// Clear the RX interrupt flag
BK4819_WriteRegister(BK4819_REG_02, 0);
// Validate checksum (assuming last 2 bytes are CRC-16)
size_t dataLength = sizeof(inBoundPacket.data) - 2;
uint16_t receivedCRC = (inBoundPacket.data[dataLength] << 8) | inBoundPacket.data[dataLength + 1];
uint16_t calculatedCRC = calculateCRC(inBoundPacket.data, dataLength);
if (receivedCRC == calculatedCRC) {
processReceivedPacket(&inBoundPacket);
return true;
}
return false; // CRC check failed
}
void MSG_EnableRX(const bool enable) {
if (enable) {
@@ -111,8 +193,14 @@ void MSG_EnableRX(const bool enable) {
}
}
void MSG_FSKSendData() {
void MSG_FSKSendData(DataPacket *dataPacketIn) {
bool isAudioOn = gEnableSpeaker;
if (gEnableSpeaker) {
AUDIO_AudioPathOff();
BK4819_EnterTxMute();
gEnableSpeaker = false;
}
// turn off CTCSS/CDCSS during FFSK
const uint16_t css_val = BK4819_ReadRegister(BK4819_REG_51);
BK4819_WriteRegister(BK4819_REG_51, 0);
@@ -163,8 +251,8 @@ void MSG_FSKSendData() {
SYSTEM_DelayMs(100);
{ // load the entire packet data into the TX FIFO buffer
uint16_t *ptr = (uint16_t *) &dataPacket;
size_t wordCount = sizeof(dataPacket) / sizeof(uint16_t);
uint16_t *ptr = (uint16_t *) dataPacketIn;
size_t wordCount = sizeof(*dataPacketIn) / sizeof(uint16_t);
for (size_t i = 0; i < wordCount; i++) {
BK4819_WriteRegister(BK4819_REG_5F, ptr[i]);
@@ -211,9 +299,16 @@ void MSG_FSKSendData() {
gUpdateDisplay = true;
gFlagEndTransmission = false;
if (isAudioOn) {
AUDIO_AudioPathOn();
gEnableSpeaker = true;
BK4819_ExitTxMute();
}
}
void prepareDataPacket() {
dataPacket.src = gEeprom.FSKSRCAddress;
dataPacket.seq = seq++;
dataPacket.ttl = 20;
}

View File

@@ -14,6 +14,11 @@
#include "../driver/system.h"
#include "../misc.h"
#include "../app/app.h"
#include <string.h>
#include "../audio.h"
#include <stdio.h>
#include "../ui/helper.h"
#include "../ui/main.h"
// REG_70 bit definitions
#define TONE1_ENABLE_BIT (1U << 15)
@@ -73,22 +78,27 @@
#define FSK_CRC_ON (1U << 6)
#define FSK_CRC_OFF (0U << 6)
#define DataPacketDataSize (36)
#define DataPacketDataSize (35)
typedef struct {
uint32_t dest;
uint32_t src;
uint8_t seq;
uint8_t ttl;
uint8_t flags;
uint8_t data[DataPacketDataSize];
} DataPacket;
void prepareDataPacket();
void MSG_FSKSendData();
void MSG_FSKSendData(DataPacket *dataPacketIn);
void MSG_EnableRX(bool enable);
void processReceivedPacket(DataPacket *packet);
uint16_t calculateCRC(uint8_t *data, size_t length);
bool MSG_FSKReceiveData();
extern DataPacket dataPacket;
extern DataPacket inBoundPacket;

View File

@@ -968,19 +968,15 @@ void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
const unsigned int vfo = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_VFO
: gEeprom.TX_VFO;
if (VfoState[vfo] == VFO_STATE_NORMAL && !TX_freq_check(gCurrentVfo->freq_config_TX.Frequency)) {
AUDIO_AudioPathOff();
gEnableSpeaker = false;
RADIO_PrepareTX();
if (gCurrentVfo->SCRAMBLING_TYPE > 0)
BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1);
else
BK4819_DisableScramble();
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, true);
MSG_FSKSendData();
MSG_FSKSendData(&dataPacket);
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, false);
AUDIO_AudioPathOn();
gEnableSpeaker = true;
BK4819_ExitTxMute();
MSG_EnableRX(true);
gVfoConfigureMode = VFO_CONFIGURE;
dataPTR = dataPacket.data;

View File

@@ -390,12 +390,6 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) {
//*pMin = 0;
*pMax = ARRAY_SIZE(gSubMenu_SET_TOT) - 1;
break;
#ifdef ENABLE_FEAT_F4HWN_CTR
case MENU_SET_CTR:
*pMin = 1;
*pMax = 15;
break;
#endif
#ifdef ENABLE_FEAT_F4HWN_INV
case MENU_SET_INV:
//*pMin = 0;
@@ -855,17 +849,9 @@ void MENU_AcceptSetting(void) {
case MENU_SET_EOT:
gSetting_set_eot = gSubMenuSelection;
break;
#ifdef ENABLE_FEAT_F4HWN_CTR
case MENU_SET_CTR:
gSetting_set_ctr = gSubMenuSelection;
break;
#endif
case MENU_SET_INV:
gSetting_set_inv = gSubMenuSelection;
break;
case MENU_SET_LCK:
gSetting_set_lck = gSubMenuSelection;
break;
#ifdef ENABLE_FEAT_F4HWN_NARROWER
case MENU_SET_NFM:
gSetting_set_nfm = gSubMenuSelection;
@@ -1262,17 +1248,9 @@ void MENU_ShowCurrentSetting(void) {
case MENU_SET_EOT:
gSubMenuSelection = gSetting_set_eot;
break;
#ifdef ENABLE_FEAT_F4HWN_CTR
case MENU_SET_CTR:
gSubMenuSelection = gSetting_set_ctr;
break;
#endif
case MENU_SET_INV:
gSubMenuSelection = gSetting_set_inv;
break;
case MENU_SET_LCK:
gSubMenuSelection = gSetting_set_lck;
break;
#ifdef ENABLE_FEAT_F4HWN_NARROWER
case MENU_SET_NFM:
gSubMenuSelection = gSetting_set_nfm;

View File

@@ -856,7 +856,7 @@ static void ShowChannelName(uint32_t f) {
#endif
static void DrawF(uint32_t f) {
sprintf(String, "%u.%05u", f / 100000, f % 100000);
sprintf(String, "%lu.%05lu", f / 100000, f % 100000);
UI_PrintStringSmallNormal(String, 8, 127, 0);
sprintf(String, "%3s", gModulationStr[settings.modulationType]);
@@ -879,19 +879,19 @@ static void DrawNums() {
}
if (IsCenterMode()) {
sprintf(String, "%u.%05u \x7F%u.%02uk", currentFreq / 100000,
sprintf(String, "%lu.%05lu \x7F%lu.%02luk", currentFreq / 100000,
currentFreq % 100000, settings.frequencyChangeStep / 100,
settings.frequencyChangeStep % 100);
GUI_DisplaySmallest(String, 36, 39, false, true);
} else {
sprintf(String, "%u.%05u", GetFStart() / 100000, GetFStart() % 100000);
sprintf(String, "%lu.%05lu", GetFStart() / 100000, GetFStart() % 100000);
GUI_DisplaySmallest(String, 0, 49, false, true);
sprintf(String, "\x7F%u.%02uk", settings.frequencyChangeStep / 100,
sprintf(String, "\x7F%lu.%02luk", settings.frequencyChangeStep / 100,
settings.frequencyChangeStep % 100);
GUI_DisplaySmallest(String, 48, 10, false, true);
sprintf(String, "%u.%05u", GetFEnd() / 100000, GetFEnd() % 100000);
sprintf(String, "%lu.%05lu", GetFEnd() / 100000, GetFEnd() % 100000);
GUI_DisplaySmallest(String, 93, 49, false, true);
}
}

View File

@@ -202,7 +202,7 @@ uint8_t cmds[] = {
ST7565_WriteByte(ST7565_CMD_INVERSE_DISPLAY | gSetting_set_inv);
break;
case 7:
ST7565_WriteByte(21 + gSetting_set_ctr);
ST7565_WriteByte(21 + ST7565_CTR_SETTING_VAL);
break;
default:
ST7565_WriteByte(cmds[i]);

View File

@@ -27,6 +27,8 @@
extern uint8_t gStatusLine[LCD_WIDTH];
extern uint8_t gFrameBuffer[FRAME_LINES][LCD_WIDTH];
#define ST7565_CTR_SETTING_VAL (15)
void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const uint8_t *pBitmap, const unsigned int Size);
void ST7565_BlitFullScreen(void);
void ST7565_BlitLine(unsigned line);

2
misc.c
View File

@@ -112,10 +112,8 @@ enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
#ifdef ENABLE_FEAT_F4HWN
bool gSetting_set_ptt = 0;
uint8_t gSetting_set_tot = 0;
uint8_t gSetting_set_ctr = 10;
bool gSetting_set_inv = false;
uint8_t gSetting_set_eot = 0;
bool gSetting_set_lck = false;
#ifdef ENABLE_FEAT_F4HWN_NARROWER
bool gSetting_set_nfm = 0;
#endif

2
misc.h
View File

@@ -165,10 +165,8 @@ extern enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
#ifdef ENABLE_FEAT_F4HWN
extern bool gSetting_set_ptt;
extern uint8_t gSetting_set_tot;
extern uint8_t gSetting_set_ctr;
extern bool gSetting_set_inv;
extern uint8_t gSetting_set_eot;
extern bool gSetting_set_lck;
#ifdef ENABLE_FEAT_F4HWN_NARROWER
extern bool gSetting_set_nfm;
#endif

View File

@@ -338,8 +338,6 @@ void SETTINGS_InitEEPROM(void) {
int tmp = ((Data[5] & 0xF0) >> 4);
gSetting_set_inv = (((tmp >> 0) & 0x01) < 2) ? ((tmp >> 0) & 0x01): 0;
gSetting_set_lck = (((tmp >> 1) & 0x01) < 2) ? ((tmp >> 1) & 0x01): 0;
gSetting_set_ctr = (((Data[5] & 0x0F)) > 00 && ((Data[5] & 0x0F)) < 16) ? ((Data[5] & 0x0F)) : 10;
gSetting_set_tmr = ((Data[4] & 1) < 2) ? (Data[4] & 1): 0;
*/
@@ -351,14 +349,6 @@ void SETTINGS_InitEEPROM(void) {
#else
gSetting_set_inv = 0;
#endif
gSetting_set_lck = (tmp >> 1) & 0x01;
#ifdef ENABLE_FEAT_F4HWN_CTR
int ctr_value = Data[5] & 0x0F;
gSetting_set_ctr = (ctr_value > 0 && ctr_value < 16) ? ctr_value : 10;
#else
gSetting_set_ctr = 10;
#endif
gSetting_set_tmr = Data[4] & 0x01;
#ifdef ENABLE_FEAT_F4HWN_SLEEP
@@ -371,7 +361,6 @@ void SETTINGS_InitEEPROM(void) {
// And set special session settings for actions
gSetting_set_ptt_session = gSetting_set_ptt;
gEeprom.KEY_LOCK_PTT = gSetting_set_lck;
#endif
}
@@ -763,8 +752,6 @@ void SETTINGS_SaveSettings(void) {
if(gSetting_set_inv == 1)
tmp = tmp | (1 << 0);
if (gSetting_set_lck == 1)
tmp = tmp | (1 << 1);
*/
#ifdef ENABLE_FEAT_F4HWN_SLEEP
@@ -773,13 +760,11 @@ void SETTINGS_SaveSettings(void) {
State[4] = gSetting_set_tmr ? (1 << 0) : 0;
#endif
tmp = (gSetting_set_inv << 0) |
(gSetting_set_lck << 1);
tmp = (gSetting_set_inv << 0);
State[5] = ((tmp << 4) | (gSetting_set_ctr & 0x0F));
State[5] = (tmp << 4);
State[6] = ((gSetting_set_tot << 4) | (gSetting_set_eot & 0x0F));
State[7] = gSetting_set_ptt & 0x0F;
gEeprom.KEY_LOCK_PTT = gSetting_set_lck;
EEPROM_WriteBuffer(0x1FF0, State);
#endif

View File

@@ -110,6 +110,31 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_
UI_PrintStringBuffer(pString, gFrameBuffer[Line] + Start, char_width, font, inv);
}
void itoa(unsigned long num, char *str) {
char buf[20]; // Enough to store any 32-bit or 64-bit unsigned number
int i = 0;
// Handle 0 explicitly
if (num == 0) {
str[i++] = '0';
str[i] = '\0';
return;
}
// Convert number to string in reverse order
while (num > 0) {
buf[i++] = (num % 10) + '0'; // Get last digit and convert to ASCII
num /= 10;
}
// Reverse the string
int j = 0;
while (i > 0) {
str[j++] = buf[--i];
}
str[j] = '\0'; // Null-terminate the string
}
void UI_PrintStringSmallNormal(const char *pString, uint8_t Start, uint8_t End, uint8_t Line) {
UI_PrintStringSmall(pString, Start, End, Line, ARRAY_SIZE(gFontSmall[0]), (const uint8_t *) gFontSmall, false);

View File

@@ -41,7 +41,7 @@ void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, bool black
#endif
void UI_DrawLineBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black);
void UI_DrawRectangleBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black);
void itoa(unsigned long num, char *str);
void UI_DisplayClear();
#endif

View File

@@ -59,7 +59,7 @@ static uint32_t RxOnVfofrequency;
bool isMainOnlyInputDTMF = false;
static bool isMainOnly() {
bool isMainOnly() {
return (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF) && (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF);
}
@@ -334,7 +334,7 @@ void DisplayRSSIBar(const bool now) {
sprintf(str, "% 4d S%d", -rssi_dBm, s_level);
}
else {
sprintf(str, "% 4d %2d", -rssi_dBm, overS9dBm);
sprintf(str, "% 4d %2ld", -rssi_dBm, overS9dBm);
memcpy(p_line + 2 + 7*5, &plus, ARRAY_SIZE(plus));
}
@@ -401,7 +401,7 @@ void UI_MAIN_PrintAGC(bool now)
int8_t pgaTab[] = {-33, -27, -21, -15, -9, -6, -3, 0};
int16_t agcGain = lnaShortTab[agcGainReg.lnaS] + lnaTab[agcGainReg.lna] + mixerTab[agcGainReg.mixer] + pgaTab[agcGainReg.pga];
sprintf(buf, "%d%2d %2d %2d %3d", reg7e.agcEnab, reg7e.gainIdx, -agcGain, reg7e.agcSigStrength, BK4819_GetRSSI());
sprintf(buf, "%d%2ld %2ld %2ld %3ld", reg7e.agcEnab, reg7e.gainIdx, -agcGain, reg7e.agcSigStrength, BK4819_GetRSSI());
UI_PrintStringSmallNormal(buf, 2, 0, 3);
if(now)
ST7565_BlitLine(3);
@@ -564,9 +564,9 @@ void UI_DisplayMain(void) {
}
UI_PrintString("ScnRng", 5, 0, line + shift /*, 8 */);
sprintf(String, "%3u.%05u", gScanRangeStart / 100000, gScanRangeStart % 100000);
sprintf(String, "%3lu.%05lu", gScanRangeStart / 100000, gScanRangeStart % 100000);
UI_PrintStringSmallNormal(String, 56, 0, line + shift);
sprintf(String, "%3u.%05u", gScanRangeStop / 100000, gScanRangeStop % 100000);
sprintf(String, "%3lu.%05lu", gScanRangeStop / 100000, gScanRangeStop % 100000);
UI_PrintStringSmallNormal(String, 56, 0, line + shift + 1);
if (!isMainOnly())
@@ -576,9 +576,9 @@ void UI_DisplayMain(void) {
}
#else
UI_PrintString("ScnRng", 5, 0, line /*, 8 */);
sprintf(String, "%3u.%05u", gScanRangeStart / 100000, gScanRangeStart % 100000);
sprintf(String, "%3lu.%05lu", gScanRangeStart / 100000, gScanRangeStart % 100000);
UI_PrintStringSmallNormal(String, 56, 0, line);
sprintf(String, "%3u.%05u", gScanRangeStop / 100000, gScanRangeStop % 100000);
sprintf(String, "%3lu.%05lu", gScanRangeStop / 100000, gScanRangeStop % 100000);
UI_PrintStringSmallNormal(String, 56, 0, line + 1);
continue;
#endif
@@ -588,7 +588,7 @@ void UI_DisplayMain(void) {
if (gEnteringSMS == SMS_ENTERING_DEST) {
UI_PrintString("SMS Dst", 0, 0, line - 1 /*, 8 */);
sprintf(String, "%d", dataPacket.dest);
sprintf(String, "%ld", dataPacket.dest);
UI_PrintStringSmallNormal(String, 0, 0, line);
continue;
}
@@ -835,7 +835,7 @@ void UI_DisplayMain(void) {
switch (gEeprom.CHANNEL_DISPLAY_MODE) {
case MDF_FREQUENCY: // show the channel frequency
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
sprintf(String, "%3lu.%05lu", frequency / 100000, frequency % 100000);
#ifdef ENABLE_BIG_FREQ
if (frequency < _1GHz_in_KHz) {
// show the remaining 2 small frequency digits
@@ -884,7 +884,7 @@ void UI_DisplayMain(void) {
#ifdef ENABLE_FEAT_F4HWN
if (isMainOnly()) {
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
sprintf(String, "%3lu.%05lu", frequency / 100000, frequency % 100000);
if (frequency < _1GHz_in_KHz) {
// show the remaining 2 small frequency digits
UI_PrintStringSmallNormal(String + 7, 113, 0, line + 4);
@@ -897,11 +897,11 @@ void UI_DisplayMain(void) {
UI_PrintString(String, 40, 0, line + 3 /*, 8 */);
}
} else {
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
sprintf(String, "%03lu.%05lu", frequency / 100000, frequency % 100000);
UI_PrintStringSmallBold(String, 40 + 4, 0, line + 1);
}
#else // show the channel frequency below the channel number/name
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
sprintf(String, "%03u.%05lu", frequency / 100000, frequency % 100000);
UI_PrintStringSmallNormal(String, 20 + 4, 0, line + 1);
#endif
}
@@ -909,7 +909,7 @@ void UI_DisplayMain(void) {
break;
}
} else { // frequency mode
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
sprintf(String, "%3lu.%05lu", frequency / 100000, frequency % 100000);
#ifdef ENABLE_BIG_FREQ
if (frequency < _1GHz_in_KHz) {

View File

@@ -41,6 +41,7 @@ extern const int8_t dBmCorrTable[7];
void UI_DisplayAudioBar(void);
void UI_MAIN_TimeSlice500ms(void);
void UI_DisplayMain(void);
bool isMainOnly();
#ifdef ENABLE_AGC_SHOW_DATA
void UI_MAIN_PrintAGC(bool force);

View File

@@ -133,9 +133,7 @@ const t_menu_item MenuList[] =
{"SPTT", MENU_SET_PTT},
{"STOT", MENU_SET_TOT},
{"SEOT", MENU_SET_EOT},
{"SCtr", MENU_SET_CTR},
{"SInv", MENU_SET_INV},
{"SLck", MENU_SET_LCK},
{"STmr", MENU_SET_TMR},
#ifdef ENABLE_FEAT_F4HWN_SLEEP
{"SOff", MENU_SET_OFF},
@@ -552,7 +550,7 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
switch (UI_MENU_GetCurrentMenuId()) {
case MENU_SQL:
sprintf(String, "%d", gSubMenuSelection);
sprintf(String, "%ld", gSubMenuSelection);
break;
case MENU_MIC: { // display the mic gain in actual dB rather than just an index number
@@ -605,7 +603,7 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
case MENU_OFFSET:
if (!gIsInSubMenu || gInputBoxIndex == 0) {
sprintf(String, "%3d.%05u", gSubMenuSelection / 100000, abs(gSubMenuSelection) % 100000);
sprintf(String, "%3ld.%05u", gSubMenuSelection / 100000, abs(gSubMenuSelection) % 100000);
UI_PrintString(String, menu_item_x1, menu_item_x2, 1 /*, 8 */);
} else {
const char *ascii = INPUTBOX_GetAscii();
@@ -624,7 +622,7 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
case MENU_SCR:
if (gSubMenuSelection > 0) {
sprintf(String, "%d00", gSubMenuSelection + 25);
sprintf(String, "%ld00", gSubMenuSelection + 25);
BK4819_EnableScramble(gSubMenuSelection - 1);
} else {
strcpy(String, "OFF");
@@ -634,7 +632,7 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
case MENU_VOX:
#ifdef ENABLE_VOX
sprintf(String, gSubMenuSelection == 0 ? gSubMenu_OFF_ON[0] : "%u", gSubMenuSelection);
sprintf(String, gSubMenuSelection == 0 ? gSubMenu_OFF_ON[0] : "%lu", gSubMenuSelection);
#else
strcpy(String, gSubMenu_NA);
#endif
@@ -644,7 +642,7 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
if (gSubMenuSelection == 0) {
strcpy(String, gSubMenu_OFF_ON[0]);
} else if (gSubMenuSelection < 61) {
sprintf(String, "%02dm:%02ds", (((gSubMenuSelection) * 5) / 60), (((gSubMenuSelection) * 5) % 60));
sprintf(String, "%02ldm:%02lds", (((gSubMenuSelection) * 5) / 60), (((gSubMenuSelection) * 5) % 60));
#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO)
//ST7565_Gauge(4, 1, 60, gSubMenuSelection);
gaugeLine = 4;
@@ -662,7 +660,7 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
case MENU_ABR_MIN:
case MENU_ABR_MAX:
sprintf(String, "%d", gSubMenuSelection);
sprintf(String, "%ld", gSubMenuSelection);
if (gIsInSubMenu)
BACKLIGHT_SetBrightness(gSubMenuSelection);
// Obsolete ???
@@ -678,7 +676,7 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
if (gSubMenuSelection == 0)
strcpy(String, gSubMenu_OFF_ON[0]);
else {
sprintf(String, "%02dm:%02ds", ((gSubMenuSelection * 15) / 60), ((gSubMenuSelection * 15) % 60));
sprintf(String, "%02ldm:%02lds", ((gSubMenuSelection * 15) / 60), ((gSubMenuSelection * 15) % 60));
#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO)
//ST7565_Gauge(4, 1, 40, gSubMenuSelection);
gaugeLine = 4;
@@ -689,7 +687,7 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
break;
case MENU_FSKSRC:
sprintf(String, "%d", gSubMenuSelection);
sprintf(String, "%ld", gSubMenuSelection);
break;
case MENU_COMPAND:
@@ -732,7 +730,7 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
if (valid && !gAskForConfirmation) { // show the frequency so that the user knows the channels frequency
const uint32_t frequency = SETTINGS_FetchChannelFrequency(gSubMenuSelection);
sprintf(String, "%u.%05u", frequency / 100000, frequency % 100000);
sprintf(String, "%lu.%05lu", frequency / 100000, frequency % 100000);
UI_PrintString(String, menu_item_x1, menu_item_x2, 4 /*, 8 */);
}
@@ -767,7 +765,7 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
}
if (!gAskForConfirmation) { // show the frequency so that the user knows the channels frequency
sprintf(String, "%u.%05u", frequency / 100000, frequency % 100000);
sprintf(String, "%lu.%05lu", frequency / 100000, frequency % 100000);
UI_PrintString(String, menu_item_x1, menu_item_x2, 4 + (gIsInSubMenu && edit_index >= 0) /*, 8 */);
}
}
@@ -777,7 +775,7 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
}
case MENU_SAVE:
sprintf(String, gSubMenuSelection == 0 ? gSubMenu_OFF_ON[0] : "1:%u", gSubMenuSelection);
sprintf(String, gSubMenuSelection == 0 ? gSubMenu_OFF_ON[0] : "1:%ld", gSubMenuSelection);
break;
case MENU_TDR:
@@ -785,7 +783,7 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
break;
case MENU_TOT:
sprintf(String, "%02dm:%02ds", (((gSubMenuSelection + 1) * 5) / 60), (((gSubMenuSelection + 1) * 5) % 60));
sprintf(String, "%02ldm:%02lds", (((gSubMenuSelection + 1) * 5) / 60), (((gSubMenuSelection + 1) * 5) % 60));
#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO)
//ST7565_Gauge(4, 5, 179, gSubMenuSelection);
gaugeLine = 4;
@@ -804,7 +802,7 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
if (gSubMenuSelection == 0) {
strcpy(String, "STOP");
} else if (gSubMenuSelection < 81) {
sprintf(String, "CARRIER\n%02ds:%03dms", ((gSubMenuSelection * 250) / 1000),
sprintf(String, "CARRIER\n%02lds:%03ldms", ((gSubMenuSelection * 250) / 1000),
((gSubMenuSelection * 250) % 1000));
#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO)
//ST7565_Gauge(5, 1, 80, gSubMenuSelection);
@@ -813,7 +811,7 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
gaugeMax = 80;
#endif
} else {
sprintf(String, "TIMEOUT\n%02dm:%02ds", (((gSubMenuSelection - 80) * 5) / 60),
sprintf(String, "TIMEOUT\n%02ldm:%02lds", (((gSubMenuSelection - 80) * 5) / 60),
(((gSubMenuSelection - 80) * 5) % 60));
#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO)
//ST7565_Gauge(5, 80, 104, gSubMenuSelection);
@@ -829,14 +827,14 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
break;
case MENU_RP_STE:
sprintf(String, gSubMenuSelection == 0 ? gSubMenu_OFF_ON[0] : "%u*100ms", gSubMenuSelection);
sprintf(String, gSubMenuSelection == 0 ? gSubMenu_OFF_ON[0] : "%lu*100ms", gSubMenuSelection);
break;
case MENU_S_LIST:
if (gSubMenuSelection == 0)
strcpy(String, "LIST [0]\nNO LIST");
else if (gSubMenuSelection < 4)
sprintf(String, "LIST [%u]", gSubMenuSelection);
sprintf(String, "LIST [%lu]", gSubMenuSelection);
else if (gSubMenuSelection == 4)
strcpy(String, "LISTS\n[1, 2, 3]");
else if (gSubMenuSelection == 5)
@@ -868,11 +866,11 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
break;
case MENU_D_HOLD:
sprintf(String, "%ds", gSubMenuSelection);
sprintf(String, "%lds", gSubMenuSelection);
break;
#endif
case MENU_D_PRE:
sprintf(String, "%d*10ms", gSubMenuSelection);
sprintf(String, "%ld*10ms", gSubMenuSelection);
break;
case MENU_PTT_ID:
@@ -916,7 +914,7 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
writeXtalFreqCal(gSubMenuSelection, false);
sprintf(String, "%d\n%u.%06u\nMHz",
sprintf(String, "%ld\n%lu.%06lu\nMHz",
gSubMenuSelection,
xtal_Hz / 1000000, xtal_Hz % 1000000);
}
@@ -925,7 +923,7 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
case MENU_BATCAL: {
const uint16_t vol = (uint32_t) gBatteryVoltageAverage * gBatteryCalibration[3] / gSubMenuSelection;
sprintf(String, "%u.%02uV\n%u", vol / 100, vol % 100, gSubMenuSelection);
sprintf(String, "%u.%02dV\n%lu", vol / 100, vol % 100, gSubMenuSelection);
break;
}
@@ -946,7 +944,7 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
if (gSubMenuSelection == 0) {
strcpy(String, gSubMenu_OFF_ON[0]);
} else if (gSubMenuSelection < 121) {
sprintf(String, "%dh:%02dm", (gSubMenuSelection / 60), (gSubMenuSelection % 60));
sprintf(String, "%ldh:%02ldm", (gSubMenuSelection / 60), (gSubMenuSelection % 60));
#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO)
//ST7565_Gauge(4, 1, 120, gSubMenuSelection);
gaugeLine = 4;
@@ -967,16 +965,6 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
strcpy(String, gSubMenu_SET_TOT[gSubMenuSelection]); // Same as SET_TOT
break;
case MENU_SET_CTR:
#ifdef ENABLE_FEAT_F4HWN_CTR
sprintf(String, "%d", gSubMenuSelection);
gSetting_set_ctr = gSubMenuSelection;
ST7565_ContrastAndInv();
#else
strcpy(String, gSubMenu_NA);
#endif
break;
case MENU_SET_INV:
#ifdef ENABLE_FEAT_F4HWN_INV
strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]);
@@ -997,7 +985,7 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
if (gSubMenuSelection == 0) {
strcpy(String, gSubMenu_OFF_ON[0]);
} else if (gSubMenuSelection < 64) {
sprintf(String, "%02u", gSubMenuSelection);
sprintf(String, "%02lu", gSubMenuSelection);
#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO)
//ST7565_Gauge(4, 1, 63, gSubMenuSelection);
gaugeLine = 4;
@@ -1108,12 +1096,12 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
UI_PrintStringSmallNormal(pPrintStr, menu_item_x1, menu_item_x2, 2);
if (IS_MR_CHANNEL(gEeprom.SCANLIST_PRIORITY_CH1[i])) {
sprintf(String, "PRI%d:%u", 1, gEeprom.SCANLIST_PRIORITY_CH1[i] + 1);
sprintf(String, "PRI%ld:%u", 1, gEeprom.SCANLIST_PRIORITY_CH1[i] + 1);
UI_PrintString(String, menu_item_x1, menu_item_x2, 3 , 8);
}
if (IS_MR_CHANNEL(gEeprom.SCANLIST_PRIORITY_CH2[i])) {
sprintf(String, "PRI%d:%u", 2, gEeprom.SCANLIST_PRIORITY_CH2[i] + 1);
sprintf(String, "PRI%ld:%u", 2, gEeprom.SCANLIST_PRIORITY_CH2[i] + 1);
UI_PrintString(String, menu_item_x1, menu_item_x2, 5, 8);
}
*/
@@ -1152,7 +1140,7 @@ UI_PrintStringSmallNormal(String, 2, 0, 6);
|| UI_MENU_GetCurrentMenuId() == MENU_D_LIST
#endif
) {
sprintf(String, "%2d", gSubMenuSelection);
sprintf(String, "%2ld", gSubMenuSelection);
UI_PrintStringSmallNormal(String, 105, 0, 0);
}