0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 22:31:25 +03:00

Fix big freq digits moving 1 pixel to the right + added chan name edit menu

This commit is contained in:
OneOfEleven 2023-09-20 08:29:11 +01:00
parent 0b676d29e3
commit af9b0d6cb7
23 changed files with 619 additions and 399 deletions

View File

@ -86,7 +86,7 @@ bool DTMF_ValidateCodes(char *pCode, uint8_t Size)
bool DTMF_GetContact(const int Index, char *pContact) bool DTMF_GetContact(const int Index, char *pContact)
{ {
int i = -1; int i = -1;
if (Index >= 0 && Index < 16 && pContact != NULL) // max 16 DTMF contacts if (Index >= 0 && Index < MAX_DTMF_CONTACTS && pContact != NULL)
{ {
EEPROM_ReadBuffer(0x1C00 + (Index * 16), pContact, 16); EEPROM_ReadBuffer(0x1C00 + (Index * 16), pContact, 16);
i = (int)pContact[0] - ' '; i = (int)pContact[0] - ' ';
@ -99,7 +99,7 @@ bool DTMF_FindContact(const char *pContact, char *pResult)
char Contact[16]; char Contact[16];
unsigned int i; unsigned int i;
for (i = 0; i < 16; i++) for (i = 0; i < MAX_DTMF_CONTACTS; i++)
{ {
unsigned int j; unsigned int j;
@ -130,7 +130,6 @@ char DTMF_GetCharacter(const uint8_t code)
bool DTMF_CompareMessage(const char *pMsg, const char *pTemplate, uint8_t Size, bool bCheckGroup) bool DTMF_CompareMessage(const char *pMsg, const char *pTemplate, uint8_t Size, bool bCheckGroup)
{ {
unsigned int i; unsigned int i;
for (i = 0; i < Size; i++) for (i = 0; i < Size; i++)
{ {
if (pMsg[i] != pTemplate[i]) if (pMsg[i] != pTemplate[i])
@ -147,7 +146,6 @@ bool DTMF_CompareMessage(const char *pMsg, const char *pTemplate, uint8_t Size,
bool DTMF_CheckGroupCall(const char *pMsg, uint32_t Size) bool DTMF_CheckGroupCall(const char *pMsg, uint32_t Size)
{ {
uint32_t i; uint32_t i;
for (i = 0; i < Size; i++) for (i = 0; i < Size; i++)
if (pMsg[i] == gEeprom.DTMF_GROUP_CALL_CODE) if (pMsg[i] == gEeprom.DTMF_GROUP_CALL_CODE)
break; break;
@ -189,12 +187,15 @@ void DTMF_HandleRequest(void)
{ {
Offset = gDTMF_WriteIndex - 9; Offset = gDTMF_WriteIndex - 9;
sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, gEeprom.KILL_CODE); sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, gEeprom.KILL_CODE);
if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 9, true)) if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 9, true))
{ {
if (gEeprom.PERMIT_REMOTE_KILL) if (gEeprom.PERMIT_REMOTE_KILL)
{ {
gSetting_KILLED = true; gSetting_KILLED = true;
SETTINGS_SaveSettings(); SETTINGS_SaveSettings();
gDTMF_ReplyState = DTMF_REPLY_AB; gDTMF_ReplyState = DTMF_REPLY_AB;
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
@ -243,7 +244,9 @@ void DTMF_HandleRequest(void)
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT && gDTMF_CallMode == DTMF_CALL_MODE_NOT_GROUP && gDTMF_WriteIndex >= 9) if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT && gDTMF_CallMode == DTMF_CALL_MODE_NOT_GROUP && gDTMF_WriteIndex >= 9)
{ {
Offset = gDTMF_WriteIndex - 9; Offset = gDTMF_WriteIndex - 9;
sprintf(String, "%s%c%s", gDTMF_String, gEeprom.DTMF_SEPARATE_CODE, "AAAAA"); sprintf(String, "%s%c%s", gDTMF_String, gEeprom.DTMF_SEPARATE_CODE, "AAAAA");
if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 9, false)) if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 9, false))
{ {
gDTMF_State = DTMF_STATE_CALL_OUT_RSP; gDTMF_State = DTMF_STATE_CALL_OUT_RSP;
@ -257,12 +260,16 @@ void DTMF_HandleRequest(void)
if (gDTMF_WriteIndex >= 7) if (gDTMF_WriteIndex >= 7)
{ {
Offset = gDTMF_WriteIndex - 7; Offset = gDTMF_WriteIndex - 7;
sprintf(String, "%s%c", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE); sprintf(String, "%s%c", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE);
gDTMF_IsGroupCall = false; gDTMF_IsGroupCall = false;
if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 4, true)) if (DTMF_CompareMessage(gDTMF_Received + Offset, String, 4, true))
{ {
gDTMF_CallState = DTMF_CALL_STATE_RECEIVED; gDTMF_CallState = DTMF_CALL_STATE_RECEIVED;
memmove(gDTMF_Callee, gDTMF_Received + Offset, 3);
memmove(gDTMF_Callee, gDTMF_Received + Offset + 0, 3);
memmove(gDTMF_Caller, gDTMF_Received + Offset + 4, 3); memmove(gDTMF_Caller, gDTMF_Received + Offset + 4, 3);
gUpdateDisplay = true; gUpdateDisplay = true;
@ -364,4 +371,3 @@ void DTMF_Reply(void)
BK4819_ExitDTMF_TX(false); BK4819_ExitDTMF_TX(false);
} }

View File

@ -20,6 +20,8 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#define MAX_DTMF_CONTACTS 16
enum DTMF_State_t { enum DTMF_State_t {
DTMF_STATE_0 = 0, DTMF_STATE_0 = 0,
DTMF_STATE_TX_SUCC, DTMF_STATE_TX_SUCC,

View File

@ -59,7 +59,11 @@ uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction)
for (i = 0; i < ARRAY_SIZE(gFM_Channels); i++) for (i = 0; i < ARRAY_SIZE(gFM_Channels); i++)
{ {
Channel %= ARRAY_SIZE(gFM_Channels); if (Channel == 0xFF)
Channel = ARRAY_SIZE(gFM_Channels) - 1;
else
if (Channel >= ARRAY_SIZE(gFM_Channels))
Channel = 0;
if (FM_CheckValidChannel(Channel)) if (FM_CheckValidChannel(Channel))
return Channel; return Channel;
Channel += Direction; Channel += Direction;

View File

@ -314,6 +314,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gInputBoxIndex = 0; gInputBoxIndex = 0;
Channel = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1; Channel = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1;
if (!RADIO_CheckValidChannel(Channel, false, 0)) if (!RADIO_CheckValidChannel(Channel, false, 0))
{ {
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
@ -398,7 +399,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gInputBoxIndex = 0; gInputBoxIndex = 0;
Channel = (gInputBox[0] * 10) + gInputBox[1]; Channel = (gInputBox[0] * 10) + gInputBox[1];
if (Channel >= 1 && Channel <= 10) if (Channel >= 1 && Channel <= ARRAY_SIZE(NoaaFrequencyTable))
{ {
Channel += NOAA_CHANNEL_FIRST; Channel += NOAA_CHANNEL_FIRST;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE

View File

@ -39,6 +39,7 @@
#endif #endif
#include "ui/inputbox.h" #include "ui/inputbox.h"
#include "ui/menu.h" #include "ui/menu.h"
#include "ui/menu.h"
#include "ui/ui.h" #include "ui/ui.h"
#ifndef ARRAY_SIZE #ifndef ARRAY_SIZE
@ -64,6 +65,7 @@
VOICE_ID_BUSY_LOCKOUT, // BUSYCL VOICE_ID_BUSY_LOCKOUT, // BUSYCL
VOICE_ID_MEMORY_CHANNEL, // CH-SAV VOICE_ID_MEMORY_CHANNEL, // CH-SAV
VOICE_ID_DELETE_CHANNEL, // CH-DEL VOICE_ID_DELETE_CHANNEL, // CH-DEL
VOICE_ID_INVALID, // CH-EDIT
VOICE_ID_INVALID, // CH-DIS VOICE_ID_INVALID, // CH-DIS
VOICE_ID_SAVE_MODE, // BATSAV VOICE_ID_SAVE_MODE, // BATSAV
VOICE_ID_VOX, // VOX VOICE_ID_VOX, // VOX
@ -285,17 +287,16 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
case MENU_MEM_CH: case MENU_MEM_CH:
case MENU_1_CALL: case MENU_1_CALL:
// case MENU_SLIST1:
// case MENU_SLIST2:
case MENU_DEL_CH: case MENU_DEL_CH:
case MENU_MEM_NAME:
*pMin = 0; *pMin = 0;
*pMax = 199; *pMax = MR_CHANNEL_LAST;
break; break;
case MENU_SLIST1: case MENU_SLIST1:
case MENU_SLIST2: case MENU_SLIST2:
*pMin = -1; *pMin = -1;
*pMax = 199; *pMax = MR_CHANNEL_LAST;
break; break;
case MENU_SAVE: case MENU_SAVE:
@ -344,8 +345,8 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
break; break;
case MENU_F_CALI: case MENU_F_CALI:
*pMin = -1000; *pMin = -50;
*pMax = +1000; *pMax = +50;
break; break;
default: default:
@ -479,7 +480,28 @@ void MENU_AcceptSetting(void)
case MENU_MEM_CH: case MENU_MEM_CH:
gTxVfo->CHANNEL_SAVE = gSubMenuSelection; gTxVfo->CHANNEL_SAVE = gSubMenuSelection;
gRequestSaveChannel = 2; gRequestSaveChannel = 2;
#if 0
gEeprom.MrChannel[0] = gSubMenuSelection; gEeprom.MrChannel[0] = gSubMenuSelection;
#else
gEeprom.MrChannel[gEeprom.TX_CHANNEL] = gSubMenuSelection;
#endif
return;
case MENU_MEM_NAME:
{ // trailing trim
for (int i = 9; i >= 0; i--)
{
if (edit[i] != ' ' && edit[i] != '_' && edit[i] != 0 && edit[i] != 0xff)
break;
edit[i] = ' ';
}
}
// save the channel name
memset(gTxVfo->Name, 0xff, sizeof(gTxVfo->Name));
memmove(gTxVfo->Name, edit, 10);
SETTINGS_SaveChannel(gSubMenuSelection, gEeprom.TX_CHANNEL, gTxVfo, 2);
gFlagReconfigureVfos = true;
return; return;
case MENU_SAVE: case MENU_SAVE:
@ -630,6 +652,8 @@ void MENU_AcceptSetting(void)
return; return;
case MENU_D_LIVE_DEC: case MENU_D_LIVE_DEC:
gDTMF_RecvTimeoutSaved = 0;
gDTMF_ReceivedSaved[0] = '\0';
gSetting_live_DTMF_decoder = gSubMenuSelection; gSetting_live_DTMF_decoder = gSubMenuSelection;
break; break;
@ -873,6 +897,10 @@ void MENU_ShowCurrentSetting(void)
#endif #endif
break; break;
case MENU_MEM_NAME:
gSubMenuSelection = gEeprom.MrChannel[gEeprom.TX_CHANNEL];
break;
case MENU_SAVE: case MENU_SAVE:
gSubMenuSelection = gEeprom.BATTERY_SAVE; gSubMenuSelection = gEeprom.BATTERY_SAVE;
break; break;
@ -1065,12 +1093,12 @@ void MENU_ShowCurrentSetting(void)
static void MENU_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) static void MENU_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
uint8_t Offset;
int32_t Min;
int32_t Max;
uint16_t Value = 0; uint16_t Value = 0;
if (bKeyHeld) if (bKeyHeld || !bKeyPressed)
return;
if (!bKeyPressed)
return; return;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
@ -1106,33 +1134,37 @@ static void MENU_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
} }
gInputBoxIndex = 0; gInputBoxIndex = 0;
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
} }
else
{
if (gMenuCursor == MENU_OFFSET) if (gMenuCursor == MENU_OFFSET)
{ {
uint32_t Frequency; uint32_t Frequency;
if (gInputBoxIndex < 6) if (gInputBoxIndex < 6)
{ { // invalid frequency
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; gAnotherVoiceID = (VOICE_ID_t)Key;
#endif #endif
return; return;
} }
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
NUMBER_Get(gInputBox, &Frequency);
gSubMenuSelection = FREQUENCY_FloorToStep(Frequency + 62, gTxVfo->StepFrequency, 0);
gInputBoxIndex = 0; gInputBoxIndex = 0;
NUMBER_Get(gInputBox, &Frequency);
Frequency += 75;
#ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key;
#endif
gSubMenuSelection = FREQUENCY_FloorToStep(Frequency, gTxVfo->StepFrequency, 0);
return; return;
} }
if (gMenuCursor == MENU_MEM_CH || gMenuCursor == MENU_DEL_CH || gMenuCursor == MENU_1_CALL) if (gMenuCursor == MENU_MEM_CH || gMenuCursor == MENU_DEL_CH || gMenuCursor == MENU_1_CALL || gMenuCursor == MENU_MEM_NAME)
{ { // enter 3-digit channel number
if (gInputBoxIndex < 3) if (gInputBoxIndex < 3)
{ {
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
@ -1154,15 +1186,19 @@ static void MENU_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gSubMenuSelection = Value; gSubMenuSelection = Value;
return; return;
} }
}
else
{
int32_t Min;
int32_t Max;
if (!MENU_GetLimits(gMenuCursor, &Min, &Max)) gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
if (MENU_GetLimits(gMenuCursor, &Min, &Max))
{ {
const uint8_t Offset = (Max >= 100) ? 3 : (Max >= 10) ? 2 : 1; gInputBoxIndex = 0;
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
Offset = (Max >= 100) ? 3 : (Max >= 10) ? 2 : 1;
switch (gInputBoxIndex) switch (gInputBoxIndex)
{ {
@ -1185,19 +1221,15 @@ static void MENU_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gSubMenuSelection = Value; gSubMenuSelection = Value;
return; return;
} }
}
else
gInputBoxIndex = 0;
}
}
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
} }
static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld) static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
{ {
if (!bKeyHeld && bKeyPressed) if (bKeyHeld || !bKeyPressed)
{ return;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (gCssScanMode == CSS_SCAN_MODE_OFF) if (gCssScanMode == CSS_SCAN_MODE_OFF)
@ -1206,10 +1238,11 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
{ {
if (gInputBoxIndex == 0 || gMenuCursor != MENU_OFFSET) if (gInputBoxIndex == 0 || gMenuCursor != MENU_OFFSET)
{ {
gAskForConfirmation = 0; // fix bug gAskForConfirmation = 0;
gIsInSubMenu = false; gIsInSubMenu = false;
gInputBoxIndex = 0; gInputBoxIndex = 0;
gFlagRefreshSetting = true; gFlagRefreshSetting = true;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL; gAnotherVoiceID = VOICE_ID_CANCEL;
#endif #endif
@ -1224,25 +1257,28 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_CANCEL; gAnotherVoiceID = VOICE_ID_CANCEL;
#endif #endif
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
} }
else else
{ {
MENU_StopCssScan(); MENU_StopCssScan();
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP; gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif #endif
gRequestDisplayScreen = DISPLAY_MENU; gRequestDisplayScreen = DISPLAY_MENU;
} }
gPttWasReleased = true; gPttWasReleased = true;
} }
}
static void MENU_Key_MENU(bool bKeyPressed, bool bKeyHeld) static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
{
if (!bKeyHeld && bKeyPressed)
{ {
if (bKeyHeld || !bKeyPressed)
return;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gRequestDisplayScreen = DISPLAY_MENU; gRequestDisplayScreen = DISPLAY_MENU;
@ -1253,18 +1289,64 @@ static void MENU_Key_MENU(bool bKeyPressed, bool bKeyHeld)
gAnotherVoiceID = MenuVoices[gMenuCursor]; gAnotherVoiceID = MenuVoices[gMenuCursor];
#endif #endif
#if 1
if (gMenuCursor == MENU_DEL_CH || gMenuCursor == MENU_MEM_NAME)
if (!RADIO_CheckValidChannel(gSubMenuSelection, false, 0))
return; // invalid channel
#endif
gAskForConfirmation = 0; gAskForConfirmation = 0;
gIsInSubMenu = true; gIsInSubMenu = true;
gInputBoxIndex = 0;
edit_index = -1;
return;
}
if (gMenuCursor == MENU_MEM_NAME)
{
if (edit_index < 0)
{ // enter channel name edit mode
if (!RADIO_CheckValidChannel(gSubMenuSelection, false, 0))
{
return;
}
BOARD_fetchChannelName(edit, gSubMenuSelection);
// pad the channel name out with '_'
edit_index = strlen(edit);
while (edit_index < 10)
edit[edit_index++] = '_';
edit[edit_index] = 0;
edit_index = 0; // 'edit_index' is going to be used as the cursor position
return;
} }
else else
{ if (edit_index >= 0 && edit_index < 10)
if (gMenuCursor == MENU_RESET || gMenuCursor == MENU_MEM_CH || gMenuCursor == MENU_DEL_CH) { // editing the channel name characters
if (++edit_index < 10)
return; // next char
// exit
gFlagAcceptSetting = false;
gAskForConfirmation = 0;
}
}
if (gMenuCursor == MENU_RESET ||
gMenuCursor == MENU_MEM_CH ||
gMenuCursor == MENU_DEL_CH ||
gMenuCursor == MENU_MEM_NAME)
{ {
switch (gAskForConfirmation) switch (gAskForConfirmation)
{ {
case 0: case 0:
gAskForConfirmation = 1; gAskForConfirmation = 1;
break; break;
case 1: case 1:
gAskForConfirmation = 2; gAskForConfirmation = 2;
@ -1276,6 +1358,7 @@ static void MENU_Key_MENU(bool bKeyPressed, bool bKeyHeld)
AUDIO_SetVoiceID(0, VOICE_ID_CONFIRM); AUDIO_SetVoiceID(0, VOICE_ID_CONFIRM);
AUDIO_PlaySingleVoice(true); AUDIO_PlaySingleVoice(true);
#endif #endif
MENU_AcceptSetting(); MENU_AcceptSetting();
#if defined(ENABLE_OVERLAY) #if defined(ENABLE_OVERLAY)
@ -1305,16 +1388,15 @@ static void MENU_Key_MENU(bool bKeyPressed, bool bKeyHeld)
else else
gAnotherVoiceID = VOICE_ID_CONFIRM; gAnotherVoiceID = VOICE_ID_CONFIRM;
#endif #endif
}
gInputBoxIndex = 0; gInputBoxIndex = 0;
} }
}
static void MENU_Key_STAR(bool bKeyPressed, bool bKeyHeld) static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld)
{
if (!bKeyHeld && bKeyPressed)
{ {
if (bKeyHeld || !bKeyPressed)
return;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
RADIO_SelectVfos(); RADIO_SelectVfos();
@ -1326,7 +1408,8 @@ static void MENU_Key_STAR(bool bKeyPressed, bool bKeyHeld)
#endif #endif
{ {
if (gMenuCursor == MENU_R_CTCS || gMenuCursor == MENU_R_DCS) if (gMenuCursor == MENU_R_CTCS || gMenuCursor == MENU_R_DCS)
{ { // scan CTCSS or DCS to find the tone/code of the incoming signal
if (gCssScanMode == CSS_SCAN_MODE_OFF) if (gCssScanMode == CSS_SCAN_MODE_OFF)
{ {
MENU_StartCssScan(1); MENU_StartCssScan(1);
@ -1352,7 +1435,6 @@ static void MENU_Key_STAR(bool bKeyPressed, bool bKeyHeld)
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
} }
}
static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
{ {
@ -1360,12 +1442,76 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
uint8_t Channel; uint8_t Channel;
bool bCheckScanList; bool bCheckScanList;
if (gMenuCursor == MENU_MEM_NAME && gIsInSubMenu && edit_index >= 0)
{ // change the character
if (bKeyPressed && edit_index < 10)
{
#if 0
char c1 = edit[edit_index];
char c2 = 0;
if (Direction == 0)
return;
if (Direction < 0)
{
switch (c1)
{
case 'a': c2 = 'Z'; break;
case 'A': c2 = '9'; break;
case '0': c2 = '.'; break;
case '.': c2 = '-'; break;
case '-': c2 = '_'; break;
case '_': c2 = ' '; break;
case ' ': c2 = 'z'; break;
}
}
else
{
switch (c1)
{
case ' ': c2 = '_'; break;
case '_': c2 = '-'; break;
case '-': c2 = '.'; break;
case '.': c2 = '0'; break;
case '9': c2 = 'A'; break;
case 'Z': c2 = 'a'; break;
case 'z': c2 = ' '; break;
}
}
if (c2 == 0)
{
if ((c1 >= '0' && c1 <= '9') ||
(c1 >= 'A' && c1 <= 'Z') ||
(c1 >= 'a' && c1 <= 'z'))
{
c2 = c1 + Direction;
}
else
{
c2 = 'A';
}
}
edit[edit_index] = c2;
#else
const char c = edit[edit_index] + Direction;
edit[edit_index] = (c < 32) ? 126 : (c > 126) ? 32 : c;
#endif
gRequestDisplayScreen = DISPLAY_MENU;
}
return;
}
if (!bKeyHeld) if (!bKeyHeld)
{ {
if (!bKeyPressed) if (!bKeyPressed)
return; return;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gInputBoxIndex = 0; gInputBoxIndex = 0;
} }
else else
@ -1375,6 +1521,7 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
if (gCssScanMode != CSS_SCAN_MODE_OFF) if (gCssScanMode != CSS_SCAN_MODE_OFF)
{ {
MENU_StartCssScan(Direction); MENU_StartCssScan(Direction);
gPttWasReleased = true; gPttWasReleased = true;
gRequestDisplayScreen = DISPLAY_MENU; gRequestDisplayScreen = DISPLAY_MENU;
return; return;
@ -1410,14 +1557,12 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
{ {
case MENU_DEL_CH: case MENU_DEL_CH:
case MENU_1_CALL: case MENU_1_CALL:
case MENU_MEM_NAME:
bCheckScanList = false; bCheckScanList = false;
break; break;
case MENU_SLIST2: case MENU_SLIST2:
VFO = 1; VFO = 1;
// Fallthrough
case MENU_SLIST1: case MENU_SLIST1:
bCheckScanList = true; bCheckScanList = true;
break; break;

View File

@ -300,7 +300,7 @@ static void SCANNER_Key_UP_DOWN(bool bKeyPressed, bool pKeyHeld, int8_t Directio
if (gScannerEditState == 1) if (gScannerEditState == 1)
{ {
gScanChannel = NUMBER_AddWithWraparound(gScanChannel, Direction, 0, 199); gScanChannel = NUMBER_AddWithWraparound(gScanChannel, Direction, 0, MR_CHANNEL_LAST);
gShowChPrefix = RADIO_CheckValidChannel(gScanChannel, false, 0); gShowChPrefix = RADIO_CheckValidChannel(gScanChannel, false, 0);
gRequestDisplayScreen = DISPLAY_SCANNER; gRequestDisplayScreen = DISPLAY_SCANNER;
} }

32
board.c
View File

@ -595,11 +595,8 @@ void BOARD_EEPROM_Init(void)
gEeprom.KEY_1_SHORT_PRESS_ACTION = (Data[1] < ACTION_OPT_LEN) ? Data[1] : ACTION_OPT_MONITOR; gEeprom.KEY_1_SHORT_PRESS_ACTION = (Data[1] < ACTION_OPT_LEN) ? Data[1] : ACTION_OPT_MONITOR;
gEeprom.KEY_1_LONG_PRESS_ACTION = (Data[2] < ACTION_OPT_LEN) ? Data[2] : ACTION_OPT_FLASHLIGHT; gEeprom.KEY_1_LONG_PRESS_ACTION = (Data[2] < ACTION_OPT_LEN) ? Data[2] : ACTION_OPT_FLASHLIGHT;
gEeprom.KEY_2_SHORT_PRESS_ACTION = (Data[3] < ACTION_OPT_LEN) ? Data[3] : ACTION_OPT_SCAN; gEeprom.KEY_2_SHORT_PRESS_ACTION = (Data[3] < ACTION_OPT_LEN) ? Data[3] : ACTION_OPT_SCAN;
#ifdef ENABLE_FMRADIO
gEeprom.KEY_2_LONG_PRESS_ACTION = (Data[4] < ACTION_OPT_LEN) ? Data[4] : ACTION_OPT_NONE; gEeprom.KEY_2_LONG_PRESS_ACTION = (Data[4] < ACTION_OPT_LEN) ? Data[4] : ACTION_OPT_NONE;
#else
gEeprom.SCAN_RESUME_MODE = (Data[5] < 3) ? Data[5] : SCAN_RESUME_CO; gEeprom.SCAN_RESUME_MODE = (Data[5] < 3) ? Data[5] : SCAN_RESUME_CO;
#endif
gEeprom.AUTO_KEYPAD_LOCK = (Data[6] < 2) ? Data[6] : false; gEeprom.AUTO_KEYPAD_LOCK = (Data[6] < 2) ? Data[6] : false;
gEeprom.POWER_ON_DISPLAY_MODE = (Data[7] < 4) ? Data[7] : POWER_ON_DISPLAY_MODE_VOLTAGE; gEeprom.POWER_ON_DISPLAY_MODE = (Data[7] < 4) ? Data[7] : POWER_ON_DISPLAY_MODE_VOLTAGE;
@ -791,6 +788,35 @@ void BOARD_EEPROM_LoadMoreSettings(void)
} }
} }
void BOARD_fetchChannelName(char *s, const int channel)
{
int i;
if (s == NULL)
return;
memset(s, 0, 11); // 's' had better be large enough !
if (channel < 0)
return;
if (!RADIO_CheckValidChannel(channel, false, 0))
return;
EEPROM_ReadBuffer(0x0F50 + (channel * 16), s + 0, 8);
EEPROM_ReadBuffer(0x0F58 + (channel * 16), s + 8, 2);
for (i = 0; i < 10; i++)
if (s[i] < 32 || s[i] > 127)
break; // invalid char
s[i--] = 0; // null term
while (i >= 0 && s[i] == 32) // trim trailing spaces
s[i--] = 0; // null term
}
void BOARD_FactoryReset(bool bIsAll) void BOARD_FactoryReset(bool bIsAll)
{ {
uint16_t i; uint16_t i;

View File

@ -27,6 +27,7 @@ void BOARD_ADC_GetBatteryInfo(uint16_t *pVoltage, uint16_t *pCurrent);
void BOARD_Init(void); void BOARD_Init(void);
void BOARD_EEPROM_Init(void); void BOARD_EEPROM_Init(void);
void BOARD_EEPROM_LoadMoreSettings(void); void BOARD_EEPROM_LoadMoreSettings(void);
void BOARD_fetchChannelName(char *s, const int channel);
void BOARD_FactoryReset(bool bIsAll); void BOARD_FactoryReset(bool bIsAll);
#endif #endif

View File

@ -22,6 +22,7 @@
#include "driver/spi.h" #include "driver/spi.h"
#include "driver/st7565.h" #include "driver/st7565.h"
#include "driver/system.h" #include "driver/system.h"
#include "misc.h"
uint8_t gStatusLine[128]; uint8_t gStatusLine[128];
uint8_t gFrameBuffer[7][128]; uint8_t gFrameBuffer[7][128];
@ -66,12 +67,12 @@ void ST7565_BlitFullScreen(void)
ST7565_WriteByte(0x40); ST7565_WriteByte(0x40);
for (Line = 0; Line < 7; Line++) for (Line = 0; Line < ARRAY_SIZE(gFrameBuffer); Line++)
{ {
unsigned int Column; unsigned int Column;
ST7565_SelectColumnAndLine(4, Line + 1); ST7565_SelectColumnAndLine(4, Line + 1);
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0); GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
for (Column = 0; Column < 128; Column++) for (Column = 0; Column < ARRAY_SIZE(gFrameBuffer[0]); Column++)
{ {
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {} while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
SPI0->WDR = gFrameBuffer[Line][Column]; SPI0->WDR = gFrameBuffer[Line][Column];
@ -102,7 +103,7 @@ void ST7565_BlitStatusLine(void)
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0); GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_ST7565_A0);
for (i = 0; i < sizeof(gStatusLine); i++) for (i = 0; i < ARRAY_SIZE(gStatusLine); i++)
{ {
while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {} while ((SPI0->FIFOST & SPI_FIFOST_TFF_MASK) != SPI_FIFOST_TFF_BITS_NOT_FULL) {}
SPI0->WDR = gStatusLine[i]; SPI0->WDR = gStatusLine[i];

BIN
firmware

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -174,7 +174,7 @@ int FREQUENCY_Check(VFO_Info_t *pInfo)
const uint32_t Frequency = pInfo->pTX->Frequency; const uint32_t Frequency = pInfo->pTX->Frequency;
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (pInfo->CHANNEL_SAVE >= NOAA_CHANNEL_FIRST) if (pInfo->CHANNEL_SAVE > FREQ_CHANNEL_LAST)
return -1; return -1;
#endif #endif

View File

@ -90,7 +90,7 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode)
gEeprom.KEY_2_SHORT_PRESS_ACTION = 0; gEeprom.KEY_2_SHORT_PRESS_ACTION = 0;
gEeprom.KEY_2_LONG_PRESS_ACTION = 0; gEeprom.KEY_2_LONG_PRESS_ACTION = 0;
RADIO_InitInfo(gRxVfo, 205, 5, 41002500); RADIO_InitInfo(gRxVfo, FREQ_CHANNEL_LAST - 1, 5, 41002500);
gRxVfo->CHANNEL_BANDWIDTH = BANDWIDTH_NARROW; gRxVfo->CHANNEL_BANDWIDTH = BANDWIDTH_NARROW;
gRxVfo->OUTPUT_POWER = 0; gRxVfo->OUTPUT_POWER = 0;

2
misc.c
View File

@ -83,7 +83,7 @@ uint16_t gEEPROM_RSSI_CALIB[3][4];
uint16_t gEEPROM_1F8A; uint16_t gEEPROM_1F8A;
uint16_t gEEPROM_1F8C; uint16_t gEEPROM_1F8C;
uint8_t gMR_ChannelAttributes[207]; uint8_t gMR_ChannelAttributes[FREQ_CHANNEL_LAST + 1];
volatile uint16_t gBatterySaveCountdown_10ms = battery_save_count_10ms; volatile uint16_t gBatterySaveCountdown_10ms = battery_save_count_10ms;
volatile bool gBatterySaveCountdownExpired; volatile bool gBatterySaveCountdownExpired;

7
misc.h
View File

@ -22,10 +22,12 @@
#define IS_MR_CHANNEL(x) ((x) >= MR_CHANNEL_FIRST && (x) <= MR_CHANNEL_LAST) #define IS_MR_CHANNEL(x) ((x) >= MR_CHANNEL_FIRST && (x) <= MR_CHANNEL_LAST)
#define IS_FREQ_CHANNEL(x) ((x) >= FREQ_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST) #define IS_FREQ_CHANNEL(x) ((x) >= FREQ_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST)
#define IS_VALID_CHANNEL(x) ((x) <= NOAA_CHANNEL_LAST) #define IS_VALID_CHANNEL(x) ((x) < LAST_CHANNEL)
#ifdef ENABLE_NOAA
#define IS_NOAA_CHANNEL(x) ((x) >= NOAA_CHANNEL_FIRST && (x) <= NOAA_CHANNEL_LAST) #define IS_NOAA_CHANNEL(x) ((x) >= NOAA_CHANNEL_FIRST && (x) <= NOAA_CHANNEL_LAST)
#define IS_NOT_NOAA_CHANNEL(x) ((x) >= MR_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST) #define IS_NOT_NOAA_CHANNEL(x) ((x) >= MR_CHANNEL_FIRST && (x) <= FREQ_CHANNEL_LAST)
#endif
#ifndef ARRAY_SIZE #ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
@ -36,8 +38,11 @@ enum {
MR_CHANNEL_LAST = 199u, MR_CHANNEL_LAST = 199u,
FREQ_CHANNEL_FIRST = 200u, FREQ_CHANNEL_FIRST = 200u,
FREQ_CHANNEL_LAST = 206u, FREQ_CHANNEL_LAST = 206u,
#ifdef ENABLE_NOAA
NOAA_CHANNEL_FIRST = 207u, NOAA_CHANNEL_FIRST = 207u,
NOAA_CHANNEL_LAST = 216u NOAA_CHANNEL_LAST = 216u
#endif
LAST_CHANNEL
}; };
enum { enum {

12
radio.c
View File

@ -100,7 +100,7 @@ uint8_t RADIO_FindNextChannel(uint8_t Channel, int8_t Direction, bool bCheckScan
{ {
unsigned int i; unsigned int i;
for (i = 0; i < 200; i++) for (i = 0; i <= MR_CHANNEL_LAST; i++)
{ {
if (Channel == 0xFF) if (Channel == 0xFF)
Channel = MR_CHANNEL_LAST; Channel = MR_CHANNEL_LAST;
@ -159,11 +159,11 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg)
if (!gSetting_350EN) if (!gSetting_350EN)
{ {
if (gEeprom.FreqChannel[VFO] == 204) if (gEeprom.FreqChannel[VFO] == (FREQ_CHANNEL_LAST - 2))
gEeprom.FreqChannel[VFO]++; gEeprom.FreqChannel[VFO] = FREQ_CHANNEL_LAST - 1;
if (gEeprom.ScreenChannel[VFO] == 204) if (gEeprom.ScreenChannel[VFO] == (FREQ_CHANNEL_LAST - 2))
gEeprom.ScreenChannel[VFO]++; gEeprom.ScreenChannel[VFO] = FREQ_CHANNEL_LAST - 1;
} }
Channel = gEeprom.ScreenChannel[VFO]; Channel = gEeprom.ScreenChannel[VFO];
@ -201,7 +201,7 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg)
} }
} }
else else
Channel = 205; Channel = FREQ_CHANNEL_LAST - 1;
Attributes = gMR_ChannelAttributes[Channel]; Attributes = gMR_ChannelAttributes[Channel];
if (Attributes == 0xFF) if (Attributes == 0xFF)

View File

@ -39,8 +39,6 @@ EEPROM_Config_t gEeprom;
uint8_t Padding[4]; uint8_t Padding[4];
} State; } State;
UART_LogSend("sFm\r\n", 5);
memset(&State, 0xFF, sizeof(State)); memset(&State, 0xFF, sizeof(State));
State.Channel = gEeprom.FM_SelectedChannel; State.Channel = gEeprom.FM_SelectedChannel;
State.Frequency = gEeprom.FM_SelectedFrequency; State.Frequency = gEeprom.FM_SelectedFrequency;
@ -56,7 +54,9 @@ void SETTINGS_SaveVfoIndices(void)
{ {
uint8_t State[8]; uint8_t State[8];
UART_LogSend("sidx\r\n", 6); #ifndef ENABLE_NOAA
EEPROM_ReadBuffer(0x0E80, State, sizeof(State));
#endif
State[0] = gEeprom.ScreenChannel[0]; State[0] = gEeprom.ScreenChannel[0];
State[1] = gEeprom.MrChannel[0]; State[1] = gEeprom.MrChannel[0];
@ -67,9 +67,6 @@ void SETTINGS_SaveVfoIndices(void)
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
State[6] = gEeprom.NoaaChannel[0]; State[6] = gEeprom.NoaaChannel[0];
State[7] = gEeprom.NoaaChannel[1]; State[7] = gEeprom.NoaaChannel[1];
#else
State[6] = NOAA_CHANNEL_FIRST;
State[7] = NOAA_CHANNEL_FIRST;
#endif #endif
EEPROM_WriteBuffer(0x0E80, State); EEPROM_WriteBuffer(0x0E80, State);
@ -80,8 +77,6 @@ void SETTINGS_SaveSettings(void)
uint8_t State[8]; uint8_t State[8];
uint32_t Password[2]; uint32_t Password[2];
UART_LogSend("spub\r\n", 6);
State[0] = gEeprom.CHAN_1_CALL; State[0] = gEeprom.CHAN_1_CALL;
State[1] = gEeprom.SQUELCH_LEVEL; State[1] = gEeprom.SQUELCH_LEVEL;
State[2] = gEeprom.TX_TIMEOUT_TIMER; State[2] = gEeprom.TX_TIMEOUT_TIMER;
@ -178,8 +173,6 @@ void SETTINGS_SaveSettings(void)
void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode) void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode)
{ {
UART_LogSend("schn\r\n", 6);
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(Channel)) if (IS_NOT_NOAA_CHANNEL(Channel))
#endif #endif
@ -218,22 +211,28 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,
SETTINGS_UpdateChannel(Channel, pVFO, true); SETTINGS_UpdateChannel(Channel, pVFO, true);
#ifndef KEEP_MEM_NAME
if (IS_MR_CHANNEL(Channel)) if (IS_MR_CHANNEL(Channel))
{ // clear/reset the channel name {
#ifndef KEEP_MEM_NAME
// clear/reset the channel name
memset(&State8, 0xFF, sizeof(State8)); memset(&State8, 0xFF, sizeof(State8));
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State8); EEPROM_WriteBuffer(0x0F50 + OffsetMR, State8);
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State8); EEPROM_WriteBuffer(0x0F58 + OffsetMR, State8);
} #else
// save the channel name
memmove(State8, pVFO->Name + 0, 8);
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State8);
memset(State8, 0xFF, sizeof(State8));
memmove(State8, pVFO->Name + 8, 2);
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State8);
#endif #endif
} }
} }
} }
}
void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep) void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep)
{ {
UART_LogSend("svalid\r\n", 8);
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(Channel)) if (IS_NOT_NOAA_CHANNEL(Channel))
#endif #endif
@ -265,13 +264,24 @@ void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep)
gMR_ChannelAttributes[Channel] = Attributes; gMR_ChannelAttributes[Channel] = Attributes;
// #ifndef KEEP_MEM_NAME // #ifndef KEEP_MEM_NAME
if (IS_MR_CHANNEL(Channel) && !keep) if (IS_MR_CHANNEL(Channel))
{ // clear/reset the channel name {
const uint16_t OffsetMR = Channel * 16; const uint16_t OffsetMR = Channel * 16;
if (!keep)
{ // clear/reset the channel name
memset(&State, 0xFF, sizeof(State)); memset(&State, 0xFF, sizeof(State));
EEPROM_WriteBuffer(0x0F50 + OffsetMR, State); EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
EEPROM_WriteBuffer(0x0F58 + OffsetMR, State); EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
} }
// else
// { // update the channel name
// memmove(State, pVFO->Name + 0, 8);
// EEPROM_WriteBuffer(0x0F50 + OffsetMR, State);
// memset(State, 0xFF, sizeof(State));
// memmove(State, pVFO->Name + 8, 2);
// EEPROM_WriteBuffer(0x0F58 + OffsetMR, State);
// }
}
// #endif // #endif
} }
} }

View File

@ -18,6 +18,7 @@
#include "app/dtmf.h" #include "app/dtmf.h"
#include "bitmaps.h" #include "bitmaps.h"
#include "board.h"
#include "driver/st7565.h" #include "driver/st7565.h"
#include "external/printf/printf.h" #include "external/printf/printf.h"
#include "functions.h" #include "functions.h"
@ -150,9 +151,7 @@ void UI_DisplayMain(void)
#ifdef ENABLE_ALARM #ifdef ENABLE_ALARM
if (gAlarmState == ALARM_STATE_ALARM) if (gAlarmState == ALARM_STATE_ALARM)
{
duff_beer = 2; duff_beer = 2;
}
else else
#endif #endif
{ {
@ -227,7 +226,7 @@ void UI_DisplayMain(void)
else else
if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_CHANNEL == vfo_num) if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_CHANNEL == vfo_num)
{ // user entering a frequency { // user entering a frequency
UI_DisplayFrequency(gInputBox, 31, Line, true, false); UI_DisplayFrequency(gInputBox, 32, Line, true, false);
center_line_is_free = false; center_line_is_free = false;
} }
@ -263,9 +262,9 @@ void UI_DisplayMain(void)
#ifdef ENABLE_BIG_FREQ #ifdef ENABLE_BIG_FREQ
NUMBER_ToDigits(frequency, String); NUMBER_ToDigits(frequency, String);
// show the main large frequency digits // show the main large frequency digits
UI_DisplayFrequency(String, 31, Line, false, false); UI_DisplayFrequency(String, 32, Line, false, false);
// show the remaining 2 small frequency digits // show the remaining 2 small frequency digits
UI_DisplaySmallDigits(2, String + 7, 112, Line + 1, true); UI_DisplaySmallDigits(2, String + 7, 113, Line + 1, true);
#else #else
// show the frequency in the main font // show the frequency in the main font
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000); sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
@ -276,38 +275,26 @@ void UI_DisplayMain(void)
case MDF_CHANNEL: // show the channel number case MDF_CHANNEL: // show the channel number
sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1); sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1);
UI_PrintString(String, 32, 0, Line, 8); UI_PrintString(String, 32, 0, Line, 8);
frequency = 0;
break; break;
case MDF_NAME: // show the channel name case MDF_NAME: // show the channel name
if (gEeprom.VfoInfo[vfo_num].Name[0] <= 32 || gEeprom.VfoInfo[vfo_num].Name[0] >= 127) case MDF_NAME_FREQ: // show the channel name and frequency
BOARD_fetchChannelName(String, gEeprom.ScreenChannel[vfo_num]);
if (String[0] == 0)
{ // no channel name, show the channel number instead { // no channel name, show the channel number instead
sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1); sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1);
} }
else if (gEeprom.CHANNEL_DISPLAY_MODE == MDF_NAME)
{ // channel name {
memset(String, 0, sizeof(String));
memmove(String, gEeprom.VfoInfo[vfo_num].Name, 10);
}
// UI_PrintString(String, 32, 112, Line, 8);
UI_PrintString(String, 32, 0, Line, 8); UI_PrintString(String, 32, 0, Line, 8);
break;
case MDF_NAME_FREQ: // show the channel name and frequency
if (gEeprom.VfoInfo[vfo_num].Name[0] <= 32 || gEeprom.VfoInfo[vfo_num].Name[0] >= 127)
{ // no channel name, show channel number instead
sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1);
} }
else else
{ // channel name {
memset(String, 0, sizeof(String));
memmove(String, gEeprom.VfoInfo[vfo_num].Name, 10);
}
UI_PrintStringSmall(String, 32 + 4, 0, Line); UI_PrintStringSmall(String, 32 + 4, 0, Line);
// show the channel frequency below the channel number/name // show the channel frequency below the channel number/name
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000); sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
UI_PrintStringSmall(String, 32 + 4, 0, Line + 1); UI_PrintStringSmall(String, 32 + 4, 0, Line + 1);
}
break; break;
} }
} }
@ -318,24 +305,20 @@ void UI_DisplayMain(void)
// show the main large frequency digits // show the main large frequency digits
UI_DisplayFrequency(String, 32, Line, false, false); UI_DisplayFrequency(String, 32, Line, false, false);
// show the remaining 2 small frequency digits // show the remaining 2 small frequency digits
UI_DisplaySmallDigits(2, String + 7, 112, Line + 1, true); UI_DisplaySmallDigits(2, String + 7, 113, Line + 1, true);
#else #else
// show the frequency in the main font // show the frequency in the main font
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000); sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
UI_PrintString(String, 32, 0, Line, 8); UI_PrintString(String, 32, 0, Line, 8);
#endif #endif
#ifdef ENABLE_COMPANDER
// show the channel symbols // show the channel symbols
const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]];
(void)attributes; // stop compiler warning/error if ((attributes & MR_CH_COMPAND) > 0)
#ifdef ENABLE_BIG_FREQ #ifdef ENABLE_BIG_FREQ
#ifdef ENABLE_COMPANDER
if ((attributes & MR_CH_COMPAND) > 0)
memmove(pLine0 + 120, BITMAP_compand, sizeof(BITMAP_compand)); memmove(pLine0 + 120, BITMAP_compand, sizeof(BITMAP_compand));
#endif
#else #else
#ifdef ENABLE_COMPANDER
if ((attributes & MR_CH_COMPAND) > 0)
memmove(pLine0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); memmove(pLine0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand));
#endif #endif
#endif #endif
@ -423,12 +406,9 @@ void UI_DisplayMain(void)
if (gEeprom.VfoInfo[vfo_num].ConfigRX.Frequency != gEeprom.VfoInfo[vfo_num].ConfigTX.Frequency) if (gEeprom.VfoInfo[vfo_num].ConfigRX.Frequency != gEeprom.VfoInfo[vfo_num].ConfigTX.Frequency)
{ // show the TX offset symbol { // show the TX offset symbol
String[0] = '\0'; const char dir_list[] = "\0+-";
switch (gEeprom.VfoInfo[vfo_num].TX_OFFSET_FREQUENCY_DIRECTION) const unsigned int i = gEeprom.VfoInfo[vfo_num].TX_OFFSET_FREQUENCY_DIRECTION;
{ String[0] = (i < sizeof(dir_list)) ? dir_list[i] : '?';
case TX_OFFSET_FREQUENCY_DIRECTION_ADD: String[0] = '+'; break;
case TX_OFFSET_FREQUENCY_DIRECTION_SUB: String[0] = '-'; break;
}
String[1] = '\0'; String[1] = '\0';
UI_PrintStringSmall(String, LCD_WIDTH + 54, 0, Line + 1); UI_PrintStringSmall(String, LCD_WIDTH + 54, 0, Line + 1);
} }

125
ui/menu.c
View File

@ -19,6 +19,7 @@
#include "app/dtmf.h" #include "app/dtmf.h"
#include "bitmaps.h" #include "bitmaps.h"
#include "board.h"
#include "dcs.h" #include "dcs.h"
#include "driver/bk4819.h" #include "driver/bk4819.h"
#include "driver/eeprom.h" // EEPROM_ReadBuffer() #include "driver/eeprom.h" // EEPROM_ReadBuffer()
@ -55,6 +56,7 @@ const char MenuList[][7] =
"BUSYCL", // was "BCL" "BUSYCL", // was "BCL"
"CH-SAV", // was "MEM-CH" "CH-SAV", // was "MEM-CH"
"CH-DEL", // was "DEL-CH" "CH-DEL", // was "DEL-CH"
"CH-NAM",
"CH-DIS", // was "MDF" "CH-DIS", // was "MDF"
"BATSAV", // was "SAVE" "BATSAV", // was "SAVE"
"VOX", "VOX",
@ -261,6 +263,10 @@ uint8_t gMenuCursor;
int8_t gMenuScrollDirection; int8_t gMenuScrollDirection;
int32_t gSubMenuSelection; int32_t gSubMenuSelection;
// edit box
char edit[17];
int edit_index;
void UI_DisplayMenu(void) void UI_DisplayMenu(void)
{ {
unsigned int i; unsigned int i;
@ -281,26 +287,11 @@ void UI_DisplayMenu(void)
} }
// draw vertical separating line // draw vertical separating line
#if 0
// original thick line
for (i = 0; i < 7; i++)
{
gFrameBuffer[i][48] = 0xFF;
gFrameBuffer[i][49] = 0xFF;
}
#else
// a less intense thinner dotted line
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
gFrameBuffer[i][49] = 0xAA; gFrameBuffer[i][49] = 0xAA;
#endif
#if 0
NUMBER_ToDigits(1 + gMenuCursor, String);
UI_DisplaySmallDigits(2, String + 6, 33, 6, false);
#else
sprintf(String, "%2u.%u", 1 + gMenuCursor, gMenuListCount); sprintf(String, "%2u.%u", 1 + gMenuCursor, gMenuListCount);
UI_PrintStringSmall(String, 8, 0, 6); UI_PrintStringSmall(String, 8, 0, 6);
#endif
if (gIsInSubMenu) if (gIsInSubMenu)
memmove(gFrameBuffer[0] + 50, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator)); memmove(gFrameBuffer[0] + 50, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator));
@ -451,10 +442,75 @@ void UI_DisplayMenu(void)
case MENU_MEM_CH: case MENU_MEM_CH:
case MENU_1_CALL: case MENU_1_CALL:
case MENU_DEL_CH: case MENU_DEL_CH:
UI_GenerateChannelStringEx(String, RADIO_CheckValidChannel(gSubMenuSelection, false, 0), gSubMenuSelection); {
const bool valid = RADIO_CheckValidChannel(gSubMenuSelection, false, 0);
UI_GenerateChannelStringEx(String, valid, gSubMenuSelection);
UI_PrintString(String, 50, 127, 0, 8); UI_PrintString(String, 50, 127, 0, 8);
if (valid && !gAskForConfirmation)
{ // show the frequency so that the user knows the channels frequency
struct
{
uint32_t Frequency;
uint32_t Offset;
} __attribute__((packed)) Info;
EEPROM_ReadBuffer(gSubMenuSelection * 16, &Info, sizeof(Info));
sprintf(String, "%03u.%05u", Info.Frequency / 100000, Info.Frequency % 100000);
// UI_PrintStringSmall(String, 50, 127, 5);
UI_PrintString(String, 50, 127, 4, 8);
}
already_printed = true; already_printed = true;
break; break;
}
case MENU_MEM_NAME:
{
const bool valid = RADIO_CheckValidChannel(gSubMenuSelection, false, 0);
UI_GenerateChannelStringEx(String, valid, gSubMenuSelection);
UI_PrintString(String, 50, 127, 0, 8);
if (valid)
{
struct
{
uint32_t Frequency;
uint32_t Offset;
} __attribute__((packed)) Info;
EEPROM_ReadBuffer(gSubMenuSelection * 16, &Info, sizeof(Info));
if (!gIsInSubMenu || edit_index < 0)
{ // show the channel name
BOARD_fetchChannelName(String, gSubMenuSelection);
if (String[0] == 0)
strcpy(String, "--");
UI_PrintString(String, 50, 127, 2, 8);
}
else
{ // show the channel name being edited
UI_PrintString(edit, 50, 0, 2, 8);
if (edit_index < 10)
// UI_PrintString("^", 50 + (8 * edit_index), 0, 4, 8); // show the cursor
UI_PrintStringSmall("^", 50 + (8 * edit_index), 0, 4);
}
if (!gAskForConfirmation)
{ // show the frequency so that the user knows the channels frequency
sprintf(String, "%03u.%05u", Info.Frequency / 100000, Info.Frequency % 100000);
if (!gIsInSubMenu || edit_index < 0)
UI_PrintString(String, 50, 127, 4, 8);
else
UI_PrintString(String, 50, 127, 5, 8);
// UI_PrintStringSmall(String, 50, 127, 5);
}
}
already_printed = true;
break;
}
case MENU_SAVE: case MENU_SAVE:
strcpy(String, gSubMenu_SAVE[gSubMenuSelection]); strcpy(String, gSubMenu_SAVE[gSubMenuSelection]);
@ -641,36 +697,12 @@ void UI_DisplayMenu(void)
gMenuCursor == MENU_SLIST1 || gMenuCursor == MENU_SLIST1 ||
gMenuCursor == MENU_SLIST2) gMenuCursor == MENU_SLIST2)
{ // display the channel name { // display the channel name
if (gSubMenuSelection >= 0) char s[11];
{ BOARD_fetchChannelName(s, gSubMenuSelection);
const uint16_t channel = (uint16_t)gSubMenuSelection; if (s[0] == 0)
const bool valid = RADIO_CheckValidChannel(channel, false, 0); strcpy(s, "--");
if (valid)
{ // 16 bytes allocated to the channel name but only 12 used
char s[17] = {0};
EEPROM_ReadBuffer(0x0F50 + (channel * 16), s + 0, 8);
EEPROM_ReadBuffer(0x0F58 + (channel * 16), s + 8, 2);
{ // make invalid chars '0'
i = 0;
while (i < sizeof(s))
{
if (s[i] < 32 || s[i] >= 128)
break;
i++;
}
while (i < sizeof(s))
s[i++] = 0;
while (--i > 0)
{
if (s[i] != 0 && s[i] != 32)
break;
s[i] = 0;
}
}
UI_PrintString(s, 50, 127, 2, 8); UI_PrintString(s, 50, 127, 2, 8);
} }
}
}
if ((gMenuCursor == MENU_R_CTCS || gMenuCursor == MENU_R_DCS) && gCssScanMode != CSS_SCAN_MODE_OFF) if ((gMenuCursor == MENU_R_CTCS || gMenuCursor == MENU_R_DCS) && gCssScanMode != CSS_SCAN_MODE_OFF)
UI_PrintString("SCAN", 50, 127, 4, 8); UI_PrintString("SCAN", 50, 127, 4, 8);
@ -703,7 +735,10 @@ void UI_DisplayMenu(void)
UI_DisplaySmallDigits(Offset, String + (8 - Offset), 105, 0, false); UI_DisplaySmallDigits(Offset, String + (8 - Offset), 105, 0, false);
} }
if ((gMenuCursor == MENU_RESET || gMenuCursor == MENU_MEM_CH || gMenuCursor == MENU_DEL_CH) && gAskForConfirmation) if ((gMenuCursor == MENU_RESET ||
gMenuCursor == MENU_MEM_CH ||
gMenuCursor == MENU_MEM_NAME ||
gMenuCursor == MENU_DEL_CH) && gAskForConfirmation)
{ // display confirmation { // display confirmation
strcpy(String, (gAskForConfirmation == 1) ? "SURE?" : "WAIT!"); strcpy(String, (gAskForConfirmation == 1) ? "SURE?" : "WAIT!");
UI_PrintString(String, 50, 127, 5, 8); UI_PrintString(String, 50, 127, 5, 8);

View File

@ -38,6 +38,7 @@ enum
MENU_BCL, MENU_BCL,
MENU_MEM_CH, MENU_MEM_CH,
MENU_DEL_CH, MENU_DEL_CH,
MENU_MEM_NAME,
MENU_MDF, MENU_MDF,
MENU_SAVE, MENU_SAVE,
MENU_VOX, MENU_VOX,
@ -131,6 +132,9 @@ extern uint8_t gMenuCursor;
extern int8_t gMenuScrollDirection; extern int8_t gMenuScrollDirection;
extern int32_t gSubMenuSelection; extern int32_t gSubMenuSelection;
extern char edit[17];
extern int edit_index;
void UI_DisplayMenu(void); void UI_DisplayMenu(void);
#endif #endif

View File

@ -2,7 +2,7 @@
#ifdef GIT_HASH #ifdef GIT_HASH
#define VER GIT_HASH #define VER GIT_HASH
#else #else
#define VER "230919" #define VER "230920"
#endif #endif
const char Version[] = "OEFW-"VER; const char Version[] = "OEFW-"VER;

View File

@ -21,7 +21,7 @@ del /S /Q *.d >nul 2>nul
:: https://github.com/OneOfEleven/k5prog-win :: https://github.com/OneOfEleven/k5prog-win
:: ::
::python -m pip install --upgrade pip crcmod ::python -m pip install --upgrade pip crcmod
fw-pack.py firmware.bin 230919 firmware.packed.bin fw-pack.py firmware.bin 230920 firmware.packed.bin
::arm-none-eabi-size firmware ::arm-none-eabi-size firmware