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

@@ -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);
}