Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Removed use of floats for nice savings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dual Tachyon authored and Dual Tachyon committed Sep 19, 2023
1 parent 2b5a29b commit 65af9e0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions driver/bk4819.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions printf_config.h
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions ui/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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;

Expand All @@ -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++) {
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions ui/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:**.*****");
}
Expand All @@ -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]);
}
Expand Down
2 changes: 1 addition & 1 deletion ui/welcome.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 65af9e0

Please sign in to comment.