Skip to content

Commit

Permalink
Removed floating point stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
OneOfEleven committed Sep 13, 2023
1 parent 21d5d1e commit 2f907f8
Show file tree
Hide file tree
Showing 24 changed files with 146 additions and 117 deletions.
14 changes: 1 addition & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,7 @@ To enable the custom option just uncomment the line by removing the starting '#'
* AM RX now allowed everywhere, although the radio really doesn't do AM, the adverts are a con !
* Finer RSSI bar steps
* Nicer/cleaner big numeric font than original QS big numeric font
*
* "MEM-CH" and "DEL-CH" menus now include channel name
* "STEP" menu, added 1.25kHz option, removed 5kHz option
* "TXP" menu, renamed to "TX-PWR"
* "SAVE" menu, renamed to "B-SAVE"
* "WX" menu, renamed to "CROS-B" ('WX' means weather here in the UK)
* "ABR" menu, renamed to "BAK-LT", extended times, includes always ON option
* "SCR" menu, renamed to "SCRAM"
* "MIC" menu, shows mic gain in dB's, includes max mic gain possible (+15.5dB)
* "VOL" menu, renamed to "BATVOL", added percentage level
* "AM" menu, renamed to "MODE", shows RX modulation mode

Menu renames are to try and reduce 'WTF does that mean ?'
* Various menu re-wordings - to try and reduce 'WTH does that mean ?'

# Compiler

Expand Down
2 changes: 1 addition & 1 deletion app/aircopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)

for (i = 0; i < 7; i++)
{
if (Frequency >= gLowerLimitFrequencyBandTable[i] && Frequency <= gUpperLimitFrequencyBandTable[i])
if (Frequency >= LowerLimitFrequencyBandTable[i] && Frequency <= UpperLimitFrequencyBandTable[i])
{
#ifndef DISABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
Expand Down
8 changes: 4 additions & 4 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,11 @@ void APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step)
{
uint32_t Frequency = pInfo->ConfigRX.Frequency + (Step * pInfo->StepFrequency);

if (Frequency < gLowerLimitFrequencyBandTable[pInfo->Band])
Frequency = FREQUENCY_FloorToStep(gUpperLimitFrequencyBandTable[pInfo->Band], pInfo->StepFrequency, gLowerLimitFrequencyBandTable[pInfo->Band]);
if (Frequency < LowerLimitFrequencyBandTable[pInfo->Band])
Frequency = FREQUENCY_FloorToStep(UpperLimitFrequencyBandTable[pInfo->Band], pInfo->StepFrequency, LowerLimitFrequencyBandTable[pInfo->Band]);
else
if (Frequency > gUpperLimitFrequencyBandTable[pInfo->Band])
Frequency = gLowerLimitFrequencyBandTable[pInfo->Band];
if (Frequency > UpperLimitFrequencyBandTable[pInfo->Band])
Frequency = LowerLimitFrequencyBandTable[pInfo->Band];

pInfo->ConfigRX.Frequency = Frequency;
}
Expand Down
4 changes: 3 additions & 1 deletion app/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

#include <string.h>

#include "app/app.h"
#include "app/fm.h"
#include "app/generic.h"
Expand Down Expand Up @@ -174,7 +176,7 @@ void GENERIC_Key_PTT(bool bKeyPressed)
else
gDTMF_CallMode = DTMF_CALL_MODE_DTMF;

sprintf(gDTMF_String, "%s", gDTMF_InputBox);
strcpy(gDTMF_String, gDTMF_InputBox);

gDTMF_PreviousIndex = gDTMF_InputIndex;
gDTMF_ReplyState = DTMF_REPLY_ANI;
Expand Down
4 changes: 2 additions & 2 deletions app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
unsigned int i;
for (i = 0; i < 7; i++)
{
if (Frequency >= gLowerLimitFrequencyBandTable[i] && Frequency <= gUpperLimitFrequencyBandTable[i])
if (Frequency >= LowerLimitFrequencyBandTable[i] && Frequency <= UpperLimitFrequencyBandTable[i])
{
#ifndef DISABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
Expand All @@ -123,7 +123,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)

Frequency += 75;

gTxVfo->ConfigRX.Frequency = FREQUENCY_FloorToStep(Frequency, gTxVfo->StepFrequency, gLowerLimitFrequencyBandTable[gTxVfo->Band]);
gTxVfo->ConfigRX.Frequency = FREQUENCY_FloorToStep(Frequency, gTxVfo->StepFrequency, LowerLimitFrequencyBandTable[gTxVfo->Band]);

gRequestSaveChannel = 1;
return;
Expand Down
5 changes: 3 additions & 2 deletions audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
unsigned int 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++)
Expand All @@ -179,11 +179,12 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
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);
}
}

Expand Down
27 changes: 23 additions & 4 deletions board.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@
#include "settings.h"
#include "sram-overlay.h"

static const uint32_t gDefaultFrequencyTable[] =
{
14502500,
14552500,
43477500,
43502500,
43697500
};

void BOARD_FLASH_Init(void)
{
FLASH_Init(FLASH_READ_MODE_1_CYCLE);
Expand Down Expand Up @@ -389,7 +398,7 @@ void BOARD_EEPROM_Init(void)
gEeprom.KEY_2_LONG_PRESS_ACTION = (Data[4] < ACTION_OPT_LEN) ? Data[4] : ACTION_OPT_FM;
gEeprom.SCAN_RESUME_MODE = (Data[5] < 3) ? Data[5] : SCAN_RESUME_CO;
gEeprom.AUTO_KEYPAD_LOCK = (Data[6] < 2) ? Data[6] : false;
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);
Expand Down Expand Up @@ -478,9 +487,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] : false; // was true
gSetting_KILLED = (Data[2] < 2) ? Data[2] : false;
gSetting_200TX = (Data[3] < 2) ? Data[3] : false;
Expand Down Expand Up @@ -587,4 +593,17 @@ void BOARD_FactoryReset(bool bIsAll)
EEPROM_WriteBuffer(i, Template);
}
}

if (bIsAll)
{
RADIO_InitInfo(gRxVfo, FREQ_CHANNEL_FIRST + 5, 5, 43300000);
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);
}
}
}
Binary file modified firmware
Binary file not shown.
Binary file modified firmware.bin
Binary file not shown.
Binary file modified firmware.packed.bin
Binary file not shown.
3 changes: 0 additions & 3 deletions misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ const uint32_t gDefaultAesKey[4] = {0x4AA5CC60, 0x0312CC5F, 0xFFD2DABB, 0x6BB

const uint8_t gMicGain_dB2[5] = {3, 8, 16, 24, 31};

const uint32_t *gUpperLimitFrequencyBandTable;
const uint32_t *gLowerLimitFrequencyBandTable;

bool gSetting_350TX;
bool gSetting_KILLED;
bool gSetting_200TX;
Expand Down
3 changes: 0 additions & 3 deletions misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ extern const uint16_t gMin_bat_v;

extern const uint8_t gMicGain_dB2[5];

extern const uint32_t *gUpperLimitFrequencyBandTable;
extern const uint32_t *gLowerLimitFrequencyBandTable;

extern bool gSetting_350TX;
extern bool gSetting_KILLED;
extern bool gSetting_200TX;
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
18 changes: 12 additions & 6 deletions radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ void RADIO_InitInfo(VFO_Info_t *pInfo, uint8_t ChannelSave, uint8_t Band, uint32
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);
}

Expand Down Expand Up @@ -199,7 +205,7 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg)

Index = Channel - FREQ_CHANNEL_FIRST;

RADIO_InitInfo(pRadio, Channel, Index, gLowerLimitFrequencyBandTable[Index]);
RADIO_InitInfo(pRadio, Channel, Index, LowerLimitFrequencyBandTable[Index]);
return;
}

Expand Down Expand Up @@ -342,14 +348,14 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg)

Frequency = pRadio->ConfigRX.Frequency;

if (Frequency < gLowerLimitFrequencyBandTable[Band])
Frequency = gLowerLimitFrequencyBandTable[Band];
if (Frequency < LowerLimitFrequencyBandTable[Band])
Frequency = LowerLimitFrequencyBandTable[Band];
else
if (Frequency > gUpperLimitFrequencyBandTable[Band])
Frequency = gUpperLimitFrequencyBandTable[Band];
if (Frequency > UpperLimitFrequencyBandTable[Band])
Frequency = UpperLimitFrequencyBandTable[Band];
else
if (Channel >= FREQ_CHANNEL_FIRST)
Frequency = FREQUENCY_FloorToStep(Frequency, gEeprom.VfoInfo[VFO].StepFrequency, gLowerLimitFrequencyBandTable[Band]);
Frequency = FREQUENCY_FloorToStep(Frequency, gEeprom.VfoInfo[VFO].StepFrequency, LowerLimitFrequencyBandTable[Band]);

pRadio->ConfigRX.Frequency = Frequency;

Expand Down
4 changes: 2 additions & 2 deletions ui/aircopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ void UI_DisplayAircopy(void)

memset(String, 0, sizeof(String));
if (gAirCopyIsSendMode == 0)
sprintf(String, "RCV:%d E:%d", gAirCopyBlockNumber, gErrorsDuringAirCopy);
sprintf(String, "RCV:%u E:%u", gAirCopyBlockNumber, gErrorsDuringAirCopy);
else
if (gAirCopyIsSendMode == 1)
sprintf(String, "SND:%d", gAirCopyBlockNumber);
sprintf(String, "SND:%u", gAirCopyBlockNumber);
UI_PrintString(String, 2, 127, 4, 8);

ST7565_BlitFullScreen();
Expand Down
80 changes: 48 additions & 32 deletions ui/fmradio.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,64 +27,80 @@

void UI_DisplayFM(void)
{
uint8_t i;
char String[16];
unsigned int i;
char String[16];

memset(gFrameBuffer, 0, sizeof(gFrameBuffer));

memset(String, 0, sizeof(String));
strcpy(String, "FM");

UI_PrintString(String, 0, 127, 0, 12);
memset(String, 0, sizeof(String));

if (gAskToSave) {
memset(String, 0, sizeof(String));
if (gAskToSave)
{
strcpy(String, "SAVE?");
} else if (gAskToDelete) {
}
else
if (gAskToDelete)
{
strcpy(String, "DEL?");
} else {
if (gFM_ScanState == FM_SCAN_OFF) {
if (!gEeprom.FM_IsMrMode) {
for (i = 0; i < 20; i++) {
if (gEeprom.FM_FrequencyPlaying == gFM_Channels[i]) {
sprintf(String, "VFO(CH%02d)", i + 1);
}
else
{
if (gFM_ScanState == FM_SCAN_OFF)
{
if (!gEeprom.FM_IsMrMode)
{
for (i = 0; i < 20; i++)
{
if (gEeprom.FM_FrequencyPlaying == gFM_Channels[i])
{
sprintf(String, "VFO(CH%02u)", i + 1);
break;
}
}
if (i == 20) {

if (i == 20)
strcpy(String, "VFO");
}
} else {
sprintf(String, "MR(CH%02d)", gEeprom.FM_SelectedChannel + 1);
}
} else {
if (!gFM_AutoScan) {
else
sprintf(String, "MR(CH%02u)", gEeprom.FM_SelectedChannel + 1);
}
else
{
if (!gFM_AutoScan)
strcpy(String, "M-SCAN");
} else {
sprintf(String, "A-SCAN(%d)", gFM_ChannelPosition + 1);
}
else
sprintf(String, "A-SCAN(%u)", gFM_ChannelPosition + 1);
}
}

UI_PrintString(String, 0, 127, 2, 10);
memset(String, 0, sizeof(String));

if (gAskToSave || (gEeprom.FM_IsMrMode && gInputBoxIndex)) {
memset(String, 0, sizeof(String));
if (gAskToSave || (gEeprom.FM_IsMrMode && gInputBoxIndex))
{
UI_GenerateChannelString(String, gFM_ChannelPosition);
} else if (!gAskToDelete) {
if (gInputBoxIndex == 0) {
}
else
if (!gAskToDelete)
{
if (gInputBoxIndex == 0)
{
NUMBER_ToDigits(gEeprom.FM_FrequencyPlaying * 10000, String);
UI_DisplayFrequency(String, 23, 4, false, true);
} else {
UI_DisplayFrequency(gInputBox, 23, 4, true, false);
}
else
UI_DisplayFrequency(gInputBox, 23, 4, true, false);

ST7565_BlitFullScreen();
return;
} else {
sprintf(String, "CH-%02d", gEeprom.FM_SelectedChannel + 1);
}

else
{
sprintf(String, "CH-%02u", gEeprom.FM_SelectedChannel + 1);
}
UI_PrintString(String, 0, 127, 4, 10);

ST7565_BlitFullScreen();
}

6 changes: 3 additions & 3 deletions ui/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void UI_GenerateChannelString(char *pString, const uint8_t Channel)

if (gInputBoxIndex == 0)
{
sprintf(pString, "CH-%02d", Channel + 1);
sprintf(pString, "CH-%02u", Channel + 1);
return;
}

Expand All @@ -54,12 +54,12 @@ void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uin
}

if (bShowPrefix)
sprintf(pString, "CH-%03d", ChannelNumber + 1);
sprintf(pString, "CH-%03u", ChannelNumber + 1);
else
if (ChannelNumber == 0xFF)
strcpy(pString, "NULL");
else
sprintf(pString, "%03d", ChannelNumber + 1);
sprintf(pString, "%03u", ChannelNumber + 1);
}

void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width)
Expand Down
Loading

0 comments on commit 2f907f8

Please sign in to comment.