Added settings menu.

This commit is contained in:
Dual Tachyon 2023-08-21 23:47:16 +01:00
parent 5a74076439
commit f2766283ab
6 changed files with 525 additions and 8 deletions

453
gui.c
View File

@ -23,6 +23,7 @@
#include "driver/eeprom.h"
#include "driver/keyboard.h"
#include "driver/st7565.h"
#include "dtmf.h"
#include "external/printf/printf.h"
#include "font.h"
#include "fm.h"
@ -32,6 +33,141 @@
#include "misc.h"
#include "settings.h"
static const char MenuList[][7] = {
// 0x00
"SQL", "STEP", "TXP", "R_DCS",
"R_CTCS", "T_DCS", "T_CTCS", "SFT-D",
// 0x08
"OFFSET", "W/N", "SCR", "BCL",
"MEM-CH", "SAVE", "VOX", "ABR",
// 0x10
"TDR", "WX", "BEEP", "TOT",
"VOICE", "SC-REV", "MDF", "AUTOLK",
// 0x18
"S-ADD1", "S-ADD2", "STE", "RP-STE",
"MIC", "1-CALL", "S-LIST", "SLIST1",
// 0x20
"SLIST2", "AL-MOD", "ANI-ID", "UPCODE",
"DWCODE", "D-ST", "D-RSP", "D-HOLD",
// 0x28
"D-PRE", "PTT-ID", "D-DCD", "D-LIST",
"PONMSG", "ROGER", "VOL", "AM",
// 0x30
"NOAA_S", "DEL-CH", "RESET", "350TX",
"F-LOCK", "200TX", "500TX", "350EN",
// 0x38
"SCREN",
};
static const uint16_t gSubMenu_Step[] = {
250,
500,
625,
1000,
1250,
2500,
833,
};
static const char gSubMenu_TXP[3][5] = {
"LOW",
"MID",
"HIGH",
};
static const char gSubMenu_SFT_D[3][4] = {
"OFF",
"+",
"-",
};
static const char gSubMenu_W_N[2][7] = {
"WIDE",
"NARROW",
};
static const char gSubMenu_OFF_ON[2][4] = {
"OFF",
"ON",
};
static const char gSubMenu_SAVE[5][4] = {
"OFF",
"1:1",
"1:2",
"1:3",
"1:4",
};
static const char gSubMenu_CHAN[3][7] = {
"OFF",
"CHAN_A",
"CHAN_B",
};
static const char gSubMenu_VOICE[3][4] = {
"OFF",
"CHI",
"ENG",
};
static const char gSubMenu_SC_REV[3][3] = {
"TO",
"CO",
"SE",
};
static const char gSubMenu_MDF[3][5] = {
"FREQ",
"CHAN",
"NAME",
};
static const char gSubMenu_AL_MOD[2][5] = {
"SITE",
"TONE",
};
static const char gSubMenu_D_RSP[4][6] = {
"NULL",
"RING",
"REPLY",
"BOTH",
};
static const char gSubMenu_PTT_ID[4][5] = {
"OFF",
"BOT",
"EOT",
"BOTH",
};
static const char gSubMenu_PONMSG[3][5] = {
"FULL",
"MSG",
"VOL",
};
static const char gSubMenu_ROGER[3][6] = {
"OFF",
"ROGER",
"MDC",
};
static const char gSubMenu_RESET[2][4] = {
"VFO",
"ALL",
};
static const char gSubMenu_F_LOCK[6][4] = {
"OFF",
"FCC",
"CE",
"GB",
"430",
"438",
};
GUI_DisplayType_t gScreenToDisplay;
uint8_t g_200003C6;
volatile uint8_t gCurrentStep;
@ -450,6 +586,321 @@ static void DisplayFM(void)
ST7565_BlitFullScreen();
}
static void DisplayMenu(void)
{
char String[16];
char Contact[8];
uint8_t i;
for (i = 0; i < 3; i++) {
if (gMenuCursor && i) {
if ((gMenuListCount - 1) != gMenuCursor || (i != 2)) {
GUI_PrintString(MenuList[i], 0, 127, i * 2, 8, false);
}
}
}
for (i = 0; i < 48; i++) {
gFrameBuffer[2][i] ^= 0xFF;
gFrameBuffer[3][i] ^= 0xFF;
}
for (i = 0; i < 7; i++) {
gFrameBuffer[i][48] = 0xFF;
gFrameBuffer[i][49] = 0xFF;
}
NUMBER_ToDigits(gMenuCursor + 1, String);
GUI_DisplaySmallDigits(2, String + 6, 33, 6);
if (g_200003C6) {
memcpy(gFrameBuffer[0] + 50, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator));
}
memset(String, 0, sizeof(String));
switch (gMenuCursor) {
case MENU_SQL:
case MENU_MIC:
sprintf(String, "%d", gSubMenuSelection);
break;
case MENU_STEP:
sprintf(String, "%.2fKHz", gSubMenu_Step[gSubMenuSelection] * 0.01);
break;
case MENU_TXP:
strcpy(String, gSubMenu_TXP[gSubMenuSelection]);
break;
case MENU_R_DCS:
case MENU_T_DCS:
if (gSubMenuSelection == 0) {
strcpy(String, "OFF");
} else if (gSubMenuSelection < 105) {
sprintf(String, "D%03oN", DCS_Options[gSubMenuSelection - 1]);
} else {
sprintf(String, "D%03oI", DCS_Options[gSubMenuSelection - 105]);
}
break;
case MENU_R_CTCS:
case MENU_T_CTCS:
if (gSubMenuSelection == 0) {
strcpy(String, "OFF");
} else {
sprintf(String, "%.1fHz", CTCSS_Options[gSubMenuSelection] * 0.1);
}
break;
case MENU_SFT_D:
strcpy(String, gSubMenu_SFT_D[gSubMenuSelection]);
break;
case MENU_OFFSET:
if (g_200003C6 != 1 || gNumberOffset == 0) {
sprintf(String, "%.5f", gSubMenuSelection * 1e-05);
break;
}
for (i = 0; i < 3; i++) {
if (gNumberForPrintf[i] == 10) {
String[i] = '-';
} else {
String[i] = gNumberForPrintf[i] + '0';
}
}
String[3] = '.';
for (i = 3; i < 6; i++) {
if (gNumberForPrintf[i] == 10) {
String[i + 1] = '-';
} else {
String[i + 1] = gNumberForPrintf[i] + '0';
}
}
String[7] = 0x2d;
String[8] = '-';
String[9] = 0;
String[10] = 0;
String[11] = 0;
break;
case MENU_W_N:
strcpy(String, gSubMenu_W_N[gSubMenuSelection]);
break;
case MENU_SCR:
case MENU_VOX:
case MENU_ABR:
if (gSubMenuSelection == 0) {
strcpy(String, "OFF");
} else {
sprintf(String, "%d", gSubMenuSelection);
}
break;
case MENU_BCL:
case MENU_BEEP:
case MENU_AUTOLK:
case MENU_S_ADD1:
case MENU_S_ADD2:
case MENU_STE:
case MENU_D_ST:
case MENU_D_DCD:
case MENU_AM:
case MENU_NOAA_S:
case MENU_350TX:
case MENU_200TX:
case MENU_500TX:
case MENU_350EN:
case MENU_SCREN:
strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]);
break;
case MENU_MEM_CH:
case MENU_1_CALL:
case MENU_DEL_CH:
GenerateChannelStringEx(
String,
RADIO_CheckValidChannel((uint16_t)gSubMenuSelection, false, 0),
(uint8_t)gSubMenuSelection
);
break;
case MENU_SAVE:
strcpy(String, gSubMenu_SAVE[gSubMenuSelection]);
break;
case MENU_TDR:
case MENU_WX:
strcpy(String, gSubMenu_CHAN[gSubMenuSelection]);
break;
case MENU_TOT:
if (gSubMenuSelection == 0) {
strcpy(String, "OFF");
} else {
sprintf(String, "%dmin", gSubMenuSelection);
}
break;
case MENU_VOICE:
strcpy(String, gSubMenu_VOICE[gSubMenuSelection]);
break;
case MENU_SC_REV:
strcpy(String, gSubMenu_SC_REV[gSubMenuSelection]);
break;
case MENU_MDF:
strcpy(String, gSubMenu_MDF[gSubMenuSelection]);
break;
case MENU_RP_STE:
if (gSubMenuSelection == 0) {
strcpy(String, "OFF");
} else {
sprintf(String, "%d*100ms", gSubMenuSelection);
}
break;
case MENU_S_LIST:
sprintf(String, "LIST%d", gSubMenuSelection);
break;
case MENU_AL_MOD:
sprintf(String, gSubMenu_AL_MOD[gSubMenuSelection]);
break;
case MENU_ANI_ID:
strcpy(String, gEeprom.ANI_DTMF_ID);
break;
case MENU_UPCODE:
strcpy(String, gEeprom.DTMF_UP_CODE);
break;
case MENU_DWCODE:
strcpy(String, gEeprom.DTMF_DOWN_CODE);
break;
case MENU_D_RSP:
strcpy(String, gSubMenu_D_RSP[gSubMenuSelection]);
break;
case MENU_D_HOLD:
sprintf(String, "%ds", gSubMenuSelection);
break;
case MENU_D_PRE:
sprintf(String, "%d*10ms", gSubMenuSelection);
break;
case MENU_PTT_ID:
strcpy(String, gSubMenu_PTT_ID[gSubMenuSelection]);
break;
case MENU_D_LIST:
gIsDtmfContactValid = DTMF_GetContact((uint8_t)gSubMenuSelection - 1, Contact);
if (!gIsDtmfContactValid) {
strcpy(String, "NULL");
} else {
strcpy(String, Contact);
}
break;
case MENU_PONMSG:
strcpy(String, gSubMenu_PONMSG[gSubMenuSelection]);
break;
case MENU_ROGER:
strcpy(String, gSubMenu_ROGER[gSubMenuSelection]);
break;
case MENU_VOL:
sprintf(String, "%.2fV", gBatteryVoltageAverage * 0.01);
break;
case MENU_RESET:
strcpy(String, gSubMenu_RESET[gSubMenuSelection]);
break;
case MENU_F_LOCK:
strcpy(String, gSubMenu_F_LOCK[gSubMenuSelection]);
break;
}
GUI_PrintString(String, 50, 127, 2, 8, true);
if (gMenuCursor == MENU_OFFSET) {
GUI_PrintString("MHz", 50, 127, 4, 8, true);
}
if ((gMenuCursor == MENU_RESET || gMenuCursor == MENU_MEM_CH || gMenuCursor == MENU_DEL_CH) && gAskForConfirmation != false) {
// TODO: Double check gAskForConfirmation
if (gAskForConfirmation == true) {
strcpy(String, "SURE?");
} else {
strcpy(String, "WAIT!");
}
GUI_PrintString(String, 50, 127, 4, 8, true);
}
if ((gMenuCursor == MENU_R_CTCS || gMenuCursor == MENU_R_DCS) && g_20000381 != 0) {
GUI_PrintString("SCAN", 50, 127, 4, 8, true);
}
if (gMenuCursor == MENU_UPCODE) {
if (strlen(gEeprom.DTMF_UP_CODE) > 8) {
GUI_PrintString(gEeprom.DTMF_UP_CODE + 8, 50, 127, 4, 8, true);
}
}
if (gMenuCursor == MENU_DWCODE) {
if (strlen(gEeprom.DTMF_DOWN_CODE) > 8) {
GUI_PrintString(gEeprom.DTMF_DOWN_CODE + 8, 50, 127, 4, 8, true);
}
}
if (gMenuCursor == MENU_D_LIST && gIsDtmfContactValid) {
memcpy(&gDTMF_ID, Contact, 4);
sprintf(String,"ID:%s", Contact);
GUI_PrintString(String, 50, 127, 4, 8, true);
}
if (gMenuCursor == MENU_R_CTCS || gMenuCursor == MENU_T_CTCS ||
gMenuCursor == MENU_R_DCS || gMenuCursor == MENU_T_DCS || gMenuCursor == MENU_D_LIST) {
uint8_t Offset;
NUMBER_ToDigits((uint8_t)gSubMenuSelection, String);
Offset = (gMenuCursor == MENU_D_LIST) ? 2 : 3;
// TODO: Double check r1
GUI_DisplaySmallDigits(Offset, String + (8 - Offset), 105, 0);
}
if (gMenuCursor != MENU_SLIST1 && gMenuCursor != MENU_SLIST2) {
goto Skip;
}
i = gMenuCursor - MENU_SLIST1;
if (gSubMenuSelection == 0xFF) {
sprintf(String,"NULL");
} else {
GenerateChannelStringEx(String, true, (uint8_t)gSubMenuSelection);
}
if (gSubMenuSelection == 0xFF || gEeprom.SCAN_LIST_ENABLED[i] != true) {
GUI_PrintString(String, 50, 127, 2, 8, 1);
} else {
GUI_PrintString(String, 50, 127, 0, 8, 1);
if (gEeprom.SCANLIST_PRIORITY_CH1[i] < 200) {
sprintf(String, "PRI1:%d", gEeprom.SCANLIST_PRIORITY_CH1[i] + 1);
GUI_PrintString(String, 50, 127, 2, 8, 1);
}
if (gEeprom.SCANLIST_PRIORITY_CH2[i] < 200) {
sprintf(String, "PRI2:%d", gEeprom.SCANLIST_PRIORITY_CH2[i] + 1);
GUI_PrintString(String, 50, 127, 4, 8, 1);
}
}
Skip:
ST7565_BlitFullScreen();
}
static void DisplayScanner(void)
{
char String[16];
@ -546,7 +997,7 @@ void GUI_DisplayScreen(void)
DisplayFM();
break;
case DISPLAY_MENU:
// DisplayMenu();
DisplayMenu();
break;
case DISPLAY_SCANNER:
DisplayScanner();

60
gui.h
View File

@ -31,6 +31,66 @@ enum GUI_DisplayType_t {
typedef enum GUI_DisplayType_t GUI_DisplayType_t;
enum {
MENU_SQL = 0,
MENU_STEP = 1,
MENU_TXP = 2,
MENU_R_DCS = 3,
MENU_R_CTCS = 4,
MENU_T_DCS = 5,
MENU_T_CTCS = 6,
MENU_SFT_D = 7,
MENU_OFFSET = 8,
MENU_W_N = 9,
MENU_SCR = 10,
MENU_BCL = 11,
MENU_MEM_CH = 12,
MENU_SAVE = 13,
MENU_VOX = 14,
MENU_ABR = 15,
MENU_TDR = 16,
MENU_WX = 17,
MENU_BEEP = 18,
MENU_TOT = 19,
MENU_VOICE = 20,
MENU_SC_REV = 21,
MENU_MDF = 22,
MENU_AUTOLK = 23,
MENU_S_ADD1 = 24,
MENU_S_ADD2 = 25,
MENU_STE = 26,
MENU_RP_STE = 27,
MENU_MIC = 28,
MENU_1_CALL = 29,
MENU_S_LIST = 30,
MENU_SLIST1 = 31,
MENU_SLIST2 = 32,
MENU_AL_MOD = 33,
MENU_ANI_ID = 34,
MENU_UPCODE = 35,
MENU_DWCODE = 36,
MENU_D_ST = 37,
MENU_D_RSP = 38,
MENU_D_HOLD = 39,
MENU_D_PRE = 40,
MENU_PTT_ID = 41,
MENU_D_DCD = 42,
MENU_D_LIST = 43,
MENU_PONMSG = 44,
MENU_ROGER = 45,
MENU_VOL = 46,
MENU_AM = 47,
MENU_NOAA_S = 48,
MENU_DEL_CH = 49,
MENU_RESET = 50,
MENU_350TX = 51,
MENU_F_LOCK = 52,
MENU_200TX = 53,
MENU_500TX = 54,
MENU_350EN = 55,
MENU_SCREN = 56,
};
extern GUI_DisplayType_t gScreenToDisplay;
extern uint8_t g_200003C6;
extern volatile uint8_t gCurrentStep;

View File

@ -61,12 +61,10 @@ uint8_t HELPER_GetKey(void)
void HELPER_CheckBootKey(uint8_t KeyType)
{
if (KeyType == 1) {
#if 0
gMenuCursor = MENU_350TX;
gSubMenuSelection = (uint)gSetting_350TX;
#endif
gSubMenuSelection = gSetting_350TX;
GUI_SelectNextDisplay(DISPLAY_MENU);
g_2000044C = 0x39;
gMenuListCount = 57;
gF_LOCK = 1;
} else if (KeyType == 2) {
gEeprom.DUAL_WATCH = DUAL_WATCH_OFF;

2
main.c
View File

@ -171,7 +171,7 @@ void Main(void)
GUI_Welcome();
BACKLIGHT_TurnOn();
SYSTEM_DelayMs(1000);
g_2000044C = 0x33;
gMenuListCount = 51;
HELPER_GetKey();
KeyType = HELPER_GetKey();

6
misc.c
View File

@ -96,7 +96,7 @@ uint8_t g_2000042C;
uint8_t g_2000042D;
uint8_t gDTMF_WriteIndex;
uint8_t g_20000438;
uint8_t g_2000044C;
uint8_t gMenuListCount;
uint8_t g_20000458;
uint8_t g_2000045A;
uint8_t g_2000045B;
@ -105,6 +105,10 @@ uint8_t g_20000461;
uint8_t g_20000464;
uint8_t g_20000474;
char gDTMF_Received[16];
bool gIsDtmfContactValid;
char gDTMF_ID[4];
char gDTMF_Contact0[4];
char gDTMF_Contact1[4];
bool gIs_A_Scan;
bool gIsNoaaMode;

6
misc.h
View File

@ -99,7 +99,7 @@ extern uint8_t g_2000042C;
extern uint8_t g_2000042D;
extern uint8_t gDTMF_WriteIndex;
extern uint8_t g_20000438;
extern uint8_t g_2000044C;
extern uint8_t gMenuListCount;
extern uint8_t g_20000458;
extern uint8_t g_2000045A;
extern uint8_t g_2000045B;
@ -109,6 +109,10 @@ extern uint8_t g_20000464;
extern uint8_t gFSKWriteIndex;
extern uint8_t g_20000474;
extern char gDTMF_Received[16];
extern bool gIsDtmfContactValid;
extern char gDTMF_ID[4];
extern char gDTMF_Contact0[4];
extern char gDTMF_Contact1[4];
extern bool gIs_A_Scan;
extern bool gIsNoaaMode;