mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-08-03 17:46:31 +03:00
Tidy ups, speedier channel scanning, RSSI meter updating fix
This commit is contained in:
56
ui/main.c
56
ui/main.c
@@ -36,7 +36,18 @@
|
||||
#include "ui/main.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
bool center_line_is_free = true;
|
||||
enum center_line_t {
|
||||
CENTER_LINE_NONE = 0,
|
||||
CENTER_LINE_IN_USE,
|
||||
CENTER_LINE_AUDIO_BAR,
|
||||
CENTER_LINE_RSSI,
|
||||
CENTER_LINE_AM_FIX_DATA,
|
||||
CENTER_LINE_DTMF_DEC,
|
||||
CENTER_LINE_CHARGE_DATA
|
||||
};
|
||||
typedef enum center_line_t center_line_t;
|
||||
|
||||
center_line_t center_line = CENTER_LINE_NONE;
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
@@ -154,14 +165,14 @@ bool center_line_is_free = true;
|
||||
|
||||
if (rssi_dBm >= (s9_dBm + 6))
|
||||
{ // S9+XXdB, 1dB increment
|
||||
const char *fmt[] = {"%-4d +%u ", "%-4d +%2u "};
|
||||
const unsigned int dB = ((rssi_dBm - s9_dBm) <= 99) ? rssi_dBm - s9_dBm : 99;
|
||||
sprintf(s, (dB < 10) ? fmt[0] : fmt[1], rssi_dBm, dB);
|
||||
const char *fmt[] = {"%3d 9+%u ", "%3d 9+%2u "};
|
||||
const unsigned int s9_dB = ((rssi_dBm - s9_dBm) <= 99) ? rssi_dBm - s9_dBm : 99;
|
||||
sprintf(s, (s9_dB < 10) ? fmt[0] : fmt[1], rssi_dBm, s9_dB);
|
||||
}
|
||||
else
|
||||
{ // S0 ~ S9, 6dB per S-point
|
||||
const unsigned int s_level = (rssi_dBm >= s0_dBm) ? (rssi_dBm - s0_dBm) / 6 : 0;
|
||||
sprintf(s, "%-4d S%u ", rssi_dBm, s_level);
|
||||
sprintf(s, "%4d S%u ", rssi_dBm, s_level);
|
||||
}
|
||||
UI_PrintStringSmall(s, 2, 0, line);
|
||||
|
||||
@@ -184,7 +195,9 @@ void UI_UpdateRSSI(const int16_t rssi, const int vfo)
|
||||
{
|
||||
#ifdef ENABLE_RSSI_BAR
|
||||
|
||||
if (!center_line_is_free)
|
||||
// optional larger RSSI dBm, S-point and bar level
|
||||
|
||||
if (center_line != CENTER_LINE_RSSI)
|
||||
return;
|
||||
|
||||
if (gCurrentFunction == FUNCTION_RECEIVE ||
|
||||
@@ -193,9 +206,11 @@ void UI_UpdateRSSI(const int16_t rssi, const int vfo)
|
||||
{
|
||||
UI_DisplayRSSIBar(rssi, true);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
// original little RS bars
|
||||
|
||||
// const int16_t dBm = (rssi / 2) - 160;
|
||||
const uint8_t Line = (vfo == 0) ? 3 : 7;
|
||||
uint8_t *p_line = gFrameBuffer[Line - 1];
|
||||
@@ -290,8 +305,7 @@ void UI_DisplayMain(void)
|
||||
char String[16];
|
||||
unsigned int vfo_num;
|
||||
|
||||
// true if the center screen line is available to use
|
||||
center_line_is_free = true;
|
||||
center_line = CENTER_LINE_NONE;
|
||||
|
||||
// #ifdef SINGLE_VFO_CHAN
|
||||
// const bool single_vfo = (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? true : false;
|
||||
@@ -356,7 +370,7 @@ void UI_DisplayMain(void)
|
||||
{
|
||||
sprintf(String, ">%s", gDTMF_InputBox);
|
||||
|
||||
center_line_is_free = false;
|
||||
center_line = CENTER_LINE_IN_USE;
|
||||
}
|
||||
UI_PrintString(String, 2, 0, vfo_num * 3, 8);
|
||||
|
||||
@@ -375,11 +389,11 @@ void UI_DisplayMain(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
center_line_is_free = false;
|
||||
center_line = CENTER_LINE_IN_USE;
|
||||
}
|
||||
UI_PrintString(String, 2, 0, 2 + (vfo_num * 3), 8);
|
||||
|
||||
center_line_is_free = false;
|
||||
center_line = CENTER_LINE_IN_USE;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -483,7 +497,7 @@ void UI_DisplayMain(void)
|
||||
{ // user entering a frequency
|
||||
UI_DisplayFrequency(gInputBox, 32, line, true, false);
|
||||
|
||||
center_line_is_free = false;
|
||||
// center_line = CENTER_LINE_IN_USE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -689,7 +703,7 @@ void UI_DisplayMain(void)
|
||||
UI_PrintStringSmall("SCR", LCD_WIDTH + 106, 0, line + 1);
|
||||
}
|
||||
|
||||
if (center_line_is_free)
|
||||
if (center_line == CENTER_LINE_NONE)
|
||||
{ // we're free to use the middle line
|
||||
|
||||
const bool rx = (gCurrentFunction == FUNCTION_RECEIVE ||
|
||||
@@ -700,7 +714,7 @@ void UI_DisplayMain(void)
|
||||
if (gSetting_mic_bar && gCurrentFunction == FUNCTION_TRANSMIT)
|
||||
{
|
||||
UI_DisplayAudioBar();
|
||||
center_line_is_free = false;
|
||||
center_line = CENTER_LINE_AUDIO_BAR;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@@ -710,7 +724,7 @@ void UI_DisplayMain(void)
|
||||
{
|
||||
AM_fix_print_data(gEeprom.RX_CHANNEL, String);
|
||||
UI_PrintStringSmall(String, 2, 0, 3);
|
||||
center_line_is_free = false;
|
||||
center_line = CENTER_LINE_AM_FIX_DATA;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@@ -719,11 +733,11 @@ void UI_DisplayMain(void)
|
||||
if (rx)
|
||||
{
|
||||
UI_DisplayRSSIBar(gCurrentRSSI[gEeprom.RX_CHANNEL], false);
|
||||
center_line_is_free = false;
|
||||
center_line = CENTER_LINE_RSSI;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
|
||||
if (rx || gCurrentFunction == FUNCTION_FOREGROUND || gCurrentFunction == FUNCTION_POWER_SAVE)
|
||||
{
|
||||
#if 1
|
||||
@@ -734,7 +748,7 @@ void UI_DisplayMain(void)
|
||||
strcpy(String, "DTMF ");
|
||||
strcat(String, gDTMF_RX_live + idx);
|
||||
UI_PrintStringSmall(String, 2, 0, 3);
|
||||
center_line_is_free = false;
|
||||
center_line = CENTER_LINE_DTMF_DEC;
|
||||
}
|
||||
#else
|
||||
if (gSetting_live_DTMF_decoder && gDTMF_RX_index > 0)
|
||||
@@ -744,7 +758,7 @@ void UI_DisplayMain(void)
|
||||
strcpy(String, "DTMF ");
|
||||
strcat(String, gDTMF_RX + idx);
|
||||
UI_PrintStringSmall(String, 2, 0, 3);
|
||||
center_line_is_free = false;
|
||||
center_line = CENTER_LINE_DTMF_DEC;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -756,7 +770,7 @@ void UI_DisplayMain(void)
|
||||
gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100,
|
||||
BATTERY_VoltsToPercent(gBatteryVoltageAverage));
|
||||
UI_PrintStringSmall(String, 2, 0, 3);
|
||||
center_line_is_free = false;
|
||||
center_line = CENTER_LINE_CHARGE_DATA;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
62
ui/menu.c
62
ui/menu.c
@@ -207,9 +207,6 @@ const char gSubMenu_XB[3][10] =
|
||||
|
||||
const char gSubMenu_SC_REV[3][13] =
|
||||
{
|
||||
// "TIME\nOPER",
|
||||
// "CARRIER\nOPER",
|
||||
// "SEARCH\nOPER"
|
||||
"TIME",
|
||||
"CARRIER",
|
||||
"SEARCH"
|
||||
@@ -231,9 +228,9 @@ const char gSubMenu_MDF[4][15] =
|
||||
};
|
||||
#endif
|
||||
|
||||
const char gSubMenu_D_RSP[4][6] =
|
||||
const char gSubMenu_D_RSP[4][11] =
|
||||
{
|
||||
"NULL",
|
||||
"DO\nNOTHING",
|
||||
"RING",
|
||||
"REPLY",
|
||||
"BOTH"
|
||||
@@ -255,11 +252,11 @@ const char gSubMenu_PONMSG[4][8] =
|
||||
"NONE"
|
||||
};
|
||||
|
||||
const char gSubMenu_ROGER[3][6] =
|
||||
const char gSubMenu_ROGER[3][9] =
|
||||
{
|
||||
"OFF",
|
||||
"ROGER",
|
||||
"MDC"
|
||||
"MDC\n1200"
|
||||
};
|
||||
|
||||
const char gSubMenu_RESET[2][4] =
|
||||
@@ -339,7 +336,7 @@ int32_t gSubMenuSelection;
|
||||
int32_t gSubMenuSelection_original = 0; // copy of the original value
|
||||
|
||||
// edit box
|
||||
char edit_original[17] = {0}; // a copy of the text before editing so that we can easily test for changes/difference
|
||||
char edit_original[17]; // a copy of the text before editing so that we can easily test for changes/difference
|
||||
char edit[17];
|
||||
int edit_index;
|
||||
|
||||
@@ -349,21 +346,21 @@ void UI_DisplayMenu(void)
|
||||
const unsigned int menu_item_x1 = (8 * menu_list_width) + 2;
|
||||
const unsigned int menu_item_x2 = LCD_WIDTH - 1;
|
||||
unsigned int i;
|
||||
char String[64];
|
||||
char String[64]; // bigger cuz we can now do multi-line in one string (use '\n' char)
|
||||
char Contact[16];
|
||||
|
||||
// clear the screen
|
||||
// clear the screen buffer
|
||||
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));
|
||||
|
||||
// draw the left menu list
|
||||
#if 0
|
||||
|
||||
// original menu layout
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
if (gMenuCursor > 0 || i > 0)
|
||||
if ((gMenuListCount - 1) != gMenuCursor || i != 2)
|
||||
UI_PrintString(MenuList[gMenuCursor + i - 1].name, 0, 0, i * 2, 8);
|
||||
|
||||
// invert the current menu list item text pixels
|
||||
// invert the current menu list item pixels
|
||||
for (i = 0; i < (8 * menu_list_width); i++)
|
||||
{
|
||||
gFrameBuffer[2][i] ^= 0xFF;
|
||||
@@ -374,7 +371,7 @@ void UI_DisplayMenu(void)
|
||||
for (i = 0; i < 7; i++)
|
||||
gFrameBuffer[i][(8 * menu_list_width) + 1] = 0xAA;
|
||||
|
||||
// draw the little triangle marker if we're in the sub-menu
|
||||
// draw the little sub-menu triangle marker
|
||||
if (gIsInSubMenu)
|
||||
memmove(gFrameBuffer[0] + (8 * menu_list_width) + 1, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator));
|
||||
|
||||
@@ -383,14 +380,15 @@ void UI_DisplayMenu(void)
|
||||
UI_PrintStringSmall(String, 2, 0, 6);
|
||||
|
||||
#else
|
||||
{
|
||||
{ // new menu layout .. experimental & unfinished
|
||||
|
||||
const int menu_index = gMenuCursor; // current selected menu item
|
||||
i = 1;
|
||||
|
||||
if (!gIsInSubMenu)
|
||||
{
|
||||
while (i < 2)
|
||||
{ // leading menu items
|
||||
{ // leading menu items - small text
|
||||
const int k = menu_index + i - 2;
|
||||
if (k < 0)
|
||||
UI_PrintStringSmall(MenuList[gMenuListCount + k].name, 0, 0, i); // wrap-a-round
|
||||
@@ -400,13 +398,13 @@ void UI_DisplayMenu(void)
|
||||
i++;
|
||||
}
|
||||
|
||||
// current menu item
|
||||
// current menu item - keep big n fat
|
||||
if (menu_index >= 0 && menu_index < (int)gMenuListCount)
|
||||
UI_PrintString(MenuList[menu_index].name, 0, 0, 2, 8);
|
||||
i++;
|
||||
|
||||
while (i < 4)
|
||||
{ // trailing menu item
|
||||
{ // trailing menu item - small text
|
||||
const int k = menu_index + i - 2;
|
||||
if (k >= 0 && k < (int)gMenuListCount)
|
||||
UI_PrintStringSmall(MenuList[k].name, 0, 0, 1 + i);
|
||||
@@ -589,7 +587,6 @@ void UI_DisplayMenu(void)
|
||||
const uint32_t frequency = BOARD_fetchChannelFrequency(gSubMenuSelection);
|
||||
sprintf(String, "%u.%05u", frequency / 100000, frequency % 100000);
|
||||
UI_PrintString(String, menu_item_x1, menu_item_x2, 4, 8);
|
||||
// UI_PrintStringSmall(String, menu_item_x1, menu_item_x2, 5);
|
||||
}
|
||||
|
||||
already_printed = true;
|
||||
@@ -619,7 +616,6 @@ void UI_DisplayMenu(void)
|
||||
UI_PrintString(edit, menu_item_x1, 0, 2, 8);
|
||||
if (edit_index < 10)
|
||||
UI_PrintString( "^", menu_item_x1 + (8 * edit_index), 0, 4, 8); // show the cursor
|
||||
// UI_PrintStringSmall("^", menu_item_x1 + (8 * edit_index), 0, 4);
|
||||
}
|
||||
|
||||
if (!gAskForConfirmation)
|
||||
@@ -629,7 +625,6 @@ void UI_DisplayMenu(void)
|
||||
UI_PrintString(String, menu_item_x1, menu_item_x2, 4, 8);
|
||||
else
|
||||
UI_PrintString(String, menu_item_x1, menu_item_x2, 5, 8);
|
||||
// UI_PrintStringSmall(String, menu_item_x1, menu_item_x2, 5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -769,9 +764,9 @@ void UI_DisplayMenu(void)
|
||||
}
|
||||
|
||||
if (!already_printed)
|
||||
{
|
||||
{ // we now do multi-line text in a single string
|
||||
|
||||
unsigned int y;
|
||||
unsigned int k = 0;
|
||||
unsigned int lines = 1;
|
||||
unsigned int len = strlen(String);
|
||||
bool small = false;
|
||||
@@ -782,9 +777,9 @@ void UI_DisplayMenu(void)
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (String[i] == '\n' && i < (len - 1))
|
||||
{
|
||||
{ // found new line char
|
||||
lines++;
|
||||
String[i] = 0;
|
||||
String[i] = 0; // null terminate the line
|
||||
}
|
||||
}
|
||||
|
||||
@@ -795,21 +790,28 @@ void UI_DisplayMenu(void)
|
||||
lines = 7;
|
||||
}
|
||||
|
||||
// move the 1st line up
|
||||
// center vertically'ish
|
||||
if (small)
|
||||
y = 3 - ((lines + 0) / 2);
|
||||
y = 3 - ((lines + 0) / 2); // untested
|
||||
else
|
||||
y = 2 - ((lines + 0) / 2);
|
||||
|
||||
// draw the text lines
|
||||
for (i = 0; i < len && lines > 0; lines--)
|
||||
{
|
||||
if (small)
|
||||
UI_PrintStringSmall(String + k, menu_item_x1, menu_item_x2, y);
|
||||
UI_PrintStringSmall(String + i, menu_item_x1, menu_item_x2, y);
|
||||
else
|
||||
UI_PrintString(String + k, menu_item_x1, menu_item_x2, y, 8);
|
||||
UI_PrintString(String + i, menu_item_x1, menu_item_x2, y, 8);
|
||||
|
||||
// look for start of next line
|
||||
while (i < len && String[i] >= 32)
|
||||
i++;
|
||||
k = ++i;
|
||||
|
||||
// hop over the null term char(s)
|
||||
while (i < len && String[i] < 32)
|
||||
i++;
|
||||
|
||||
y += small ? 1 : 2;
|
||||
}
|
||||
}
|
||||
|
@@ -135,10 +135,10 @@ extern const char gSubMenu_MDF[4][15];
|
||||
#ifdef ENABLE_ALARM
|
||||
extern const char gSubMenu_AL_MOD[2][5];
|
||||
#endif
|
||||
extern const char gSubMenu_D_RSP[4][6];
|
||||
extern const char gSubMenu_D_RSP[4][11];
|
||||
extern const char gSubMenu_PTT_ID[4][7];
|
||||
extern const char gSubMenu_PONMSG[4][8];
|
||||
extern const char gSubMenu_ROGER[3][6];
|
||||
extern const char gSubMenu_ROGER[3][9];
|
||||
extern const char gSubMenu_RESET[2][4];
|
||||
extern const char gSubMenu_F_LOCK[6][4];
|
||||
extern const char gSubMenu_BACKLIGHT[8][7];
|
||||
|
Reference in New Issue
Block a user