Apply changes to v0.22

This commit is contained in:
Armel FAUVEAU
2024-01-29 22:43:47 +01:00
parent ad9cc0c8b7
commit 74421ed6d7
23 changed files with 1181 additions and 22 deletions

View File

@@ -198,6 +198,28 @@ static void sort(int16_t *a, int16_t *b)
}
}
#ifdef ENABLE_FEAT_F4HWN
void UI_DrawLineDottedBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black)
{
if(x2==x1) {
sort(&y1, &y2);
for(int16_t i = y1; i <= y2; i+=2) {
UI_DrawPixelBuffer(buffer, x1, i, black);
}
} else {
const int multipl = 1000;
int a = (y2-y1)*multipl / (x2-x1);
int b = y1 - a * x1 / multipl;
sort(&x1, &x2);
for(int i = x1; i<= x2; i+=2)
{
UI_DrawPixelBuffer(buffer, i, i*a/multipl +b, black);
}
}
}
#endif
void UI_DrawLineBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black)
{
if(x2==x1) {

View File

@@ -32,6 +32,9 @@ void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center);
void UI_DisplayPopup(const char *string);
void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, bool black);
#ifdef ENABLE_FEAT_F4HWN
void UI_DrawLineDottedBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black);
#endif
void UI_DrawLineBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black);
void UI_DrawRectangleBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black);

242
ui/main.c
View File

@@ -39,6 +39,11 @@
center_line_t center_line = CENTER_LINE_NONE;
#ifdef ENABLE_FEAT_F4HWN
static bool RXCounter;
static int8_t RXLine;
#endif
const int8_t dBmCorrTable[7] = {
-15, // band 1
-25, // band 2
@@ -77,17 +82,42 @@ static void DrawSmallAntennaAndBars(uint8_t *p, unsigned int level)
static void DrawLevelBar(uint8_t xpos, uint8_t line, uint8_t level)
{
#ifdef ENABLE_FEAT_F4HWN
const char hollowBar[] = {
0b00111110,
0b00100010,
0b00100010,
0b00111110
};
const char simpleBar[] = {
0b00111110,
0b00111110,
0b00111110,
0b00111110
};
#else
const char hollowBar[] = {
0b01111111,
0b01000001,
0b01000001,
0b01111111
};
#endif
uint8_t *p_line = gFrameBuffer[line];
level = MIN(level, 13);
for(uint8_t i = 0; i < level; i++) {
#ifdef ENABLE_FEAT_F4HWN
if(i < 9) {
memcpy(p_line + (xpos + i * 5), &simpleBar, ARRAY_SIZE(simpleBar));
}
else {
memcpy(p_line + (xpos + i * 5), &hollowBar, ARRAY_SIZE(hollowBar));
}
#else
if(i < 9) {
for(uint8_t j = 0; j < 4; j++)
p_line[xpos + i * 5 + j] = (~(0x7F >> (i+1))) & 0x7F;
@@ -95,6 +125,7 @@ static void DrawLevelBar(uint8_t xpos, uint8_t line, uint8_t level)
else {
memcpy(p_line + (xpos + i * 5), &hollowBar, ARRAY_SIZE(hollowBar));
}
#endif
}
}
#endif
@@ -125,7 +156,19 @@ void UI_DisplayAudioBar(void)
if(gLowBattery && !gLowBatteryConfirmed)
return;
const unsigned int line = 3;
#ifdef ENABLE_FEAT_F4HWN
unsigned int line;
if ((gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2 == 0)
{
line = 5;
}
else
{
line = 3;
}
#else
const unsigned int line = 3;
#endif
if (gCurrentFunction != FUNCTION_TRANSMIT ||
gScreenToDisplay != DISPLAY_MAIN
@@ -159,6 +202,11 @@ void UI_DisplayAudioBar(void)
}
#endif
#ifdef ENABLE_FEAT_F4HWN
static int16_t map(int16_t x, int16_t in_min, int16_t in_max, int16_t out_min, int16_t out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
#endif
void DisplayRSSIBar(const bool now)
{
@@ -167,10 +215,58 @@ void DisplayRSSIBar(const bool now)
const unsigned int txt_width = 7 * 8; // 8 text chars
const unsigned int bar_x = 2 + txt_width + 4; // X coord of bar graph
const unsigned int line = 3;
#ifdef ENABLE_FEAT_F4HWN
const char empty[] = {
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
};
unsigned int line;
if ((gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2 == 0)
{
line = 5;
}
else
{
line = 3;
}
char rx[4];
//sprintf(String, "%d", RXCounter);
//UI_PrintStringSmallBold(String, 80, 0, RXLine);
if(RXLine >= 0 && center_line != CENTER_LINE_IN_USE)
{
if(RXCounter == true)
{
sprintf(rx, "%s", "RX");
//UI_PrintStringSmallBold("RX", 14, 0, RXLine);
RXCounter = false;
}
else
{
sprintf(rx, "%s", " ");
memcpy(gFrameBuffer[RXLine] + 14, &empty, ARRAY_SIZE(empty));
memcpy(gFrameBuffer[RXLine] + 21, &empty, ARRAY_SIZE(empty));
//UI_PrintStringSmallBold(" ", 14, 0, RXLine);
RXCounter = true;
}
UI_PrintStringSmallBold(rx, 14, 0, RXLine);
ST7565_BlitLine(RXLine);
}
#else
const unsigned int line = 3;
#endif
uint8_t *p_line = gFrameBuffer[line];
char str[16];
#ifndef ENABLE_FEAT_F4HWN
const char plus[] = {
0b00011000,
0b00011000,
@@ -180,6 +276,7 @@ void DisplayRSSIBar(const bool now)
0b00011000,
0b00011000,
};
#endif
if ((gEeprom.KEY_LOCK && gKeypadLocked > 0) || center_line != CENTER_LINE_RSSI)
return; // display is in use
@@ -195,7 +292,32 @@ void DisplayRSSIBar(const bool now)
if (now)
memset(p_line, 0, LCD_WIDTH);
#ifdef ENABLE_FEAT_F4HWN
int16_t rssi_dBm =
BK4819_GetRSSI_dBm()
#ifdef ENABLE_AM_FIX
+ ((gSetting_AM_fix && gRxVfo->Modulation == MODULATION_AM) ? AM_fix_get_gain_diff() : 0)
#endif
+ dBmCorrTable[gRxVfo->Band];
rssi_dBm = -rssi_dBm;
if(rssi_dBm > 141) rssi_dBm = 141;
if(rssi_dBm < 53) rssi_dBm = 53;
uint8_t s_level = 0;
uint8_t overS9dBm = 0;
uint8_t overS9Bars = 0;
if(rssi_dBm >= 93) {
s_level = map(rssi_dBm, 141, 93, 1, 9);
}
else {
s_level = 9;
overS9dBm = map(rssi_dBm, 93, 53, 0, 40);
overS9Bars = map(overS9dBm, 0, 40, 0, 4);
}
#else
const int16_t s0_dBm = -gEeprom.S0_LEVEL; // S0 .. base level
const int16_t rssi_dBm =
BK4819_GetRSSI_dBm()
@@ -208,16 +330,32 @@ void DisplayRSSIBar(const bool now)
const uint8_t s_level = MIN(MAX((int32_t)(rssi_dBm - s0_dBm)*100 / (s0_9*100/9), 0), 9); // S0 - S9
uint8_t overS9dBm = MIN(MAX(rssi_dBm + gEeprom.S9_LEVEL, 0), 99);
uint8_t overS9Bars = MIN(overS9dBm/10, 4);
#endif
#ifdef ENABLE_FEAT_F4HWN
if(overS9Bars == 0) {
sprintf(str, "% 4d S%d", rssi_dBm, s_level);
sprintf(str, "% 4d", -rssi_dBm);
UI_PrintStringSmallNormal(str, LCD_WIDTH + 8, 0, line - 1);
sprintf(str, "S%d", s_level);
UI_PrintStringSmallBold(str, LCD_WIDTH + 38, 0, line - 1);
}
else {
sprintf(str, "% 4d %2d", rssi_dBm, overS9dBm);
sprintf(str, "% 4d", -rssi_dBm);
UI_PrintStringSmallNormal(str, LCD_WIDTH + 8, 0, line - 1);
sprintf(str, "+%02d", overS9dBm);
UI_PrintStringSmallBold(str, LCD_WIDTH + 38, 0, line - 1);
}
#else
if(overS9Bars == 0) {
sprintf(str, "% 4d S%d", -rssi_dBm, s_level);
}
else {
sprintf(str, "% 4d %2d", -rssi_dBm, overS9dBm);
memcpy(p_line + 2 + 7*5, &plus, ARRAY_SIZE(plus));
}
UI_PrintStringSmallNormal(str, 2, 0, line);
#endif
DrawLevelBar(bar_x, line, s_level + overS9Bars);
if (now)
ST7565_BlitLine(line);
@@ -329,6 +467,23 @@ void UI_DisplayMain(void)
for (unsigned int vfo_num = 0; vfo_num < 2; vfo_num++)
{
#ifdef ENABLE_FEAT_F4HWN
const unsigned int line0 = 0; // text screen line
const unsigned int line1 = 4;
unsigned int line;
if ((gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2 == 0)
{
line = 0;
}
else
{
line = (vfo_num == 0) ? line0 : line1;
}
const bool isMainVFO = (vfo_num == gEeprom.TX_VFO);
uint8_t *p_line0 = gFrameBuffer[line + 0];
uint8_t *p_line1 = gFrameBuffer[line + 1];
enum Vfo_txtr_mode mode = VFO_MODE_NONE;
#else
const unsigned int line0 = 0; // text screen line
const unsigned int line1 = 4;
const unsigned int line = (vfo_num == 0) ? line0 : line1;
@@ -336,7 +491,17 @@ void UI_DisplayMain(void)
uint8_t *p_line0 = gFrameBuffer[line + 0];
uint8_t *p_line1 = gFrameBuffer[line + 1];
enum Vfo_txtr_mode mode = VFO_MODE_NONE;
#endif
#ifdef ENABLE_FEAT_F4HWN
if ((gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2 == 0)
{
if (activeTxVFO != vfo_num)
{
continue;
}
}
#endif
if (activeTxVFO != vfo_num) // this is not active TX VFO
{
#ifdef ENABLE_SCAN_RANGES
@@ -428,7 +593,19 @@ void UI_DisplayMain(void)
{ // receiving .. show the RX symbol
mode = VFO_MODE_RX;
if (FUNCTION_IsRx() && gEeprom.RX_VFO == vfo_num) {
#ifdef ENABLE_FEAT_F4HWN
if(!isMainVFO)
{
RXLine = line;
}
else
{
RXLine = -1;
UI_PrintStringSmallBold("RX", 14, 0, line);
}
#else
UI_PrintStringSmallBold("RX", 14, 0, line);
#endif
}
}
@@ -570,10 +747,51 @@ void UI_DisplayMain(void)
UI_PrintString(String, 32, 0, line, 8);
}
else {
#ifdef ENABLE_FEAT_F4HWN
if ((gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2 == 0)
{
UI_PrintString(String, 32, 0, line, 8);
}
else
{
if(activeTxVFO == vfo_num) {
UI_PrintStringSmallBold(String, 32 + 4, 0, line);
}
else
{
UI_PrintStringSmallNormal(String, 32 + 4, 0, line);
}
}
#else
UI_PrintStringSmallBold(String, 32 + 4, 0, line);
// show the channel frequency below the channel number/name
#endif
#ifdef ENABLE_FEAT_F4HWN
if ((gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2 == 0)
{
sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000);
if(frequency < _1GHz_in_KHz) {
// show the remaining 2 small frequency digits
UI_PrintStringSmallNormal(String + 7, 113, 0, line + 4);
String[7] = 0;
// show the main large frequency digits
UI_DisplayFrequency(String, 32, line + 3, false);
}
else
{
// show the frequency in the main font
UI_PrintString(String, 32, 0, line + 3, 8);
}
}
else
{
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
UI_PrintStringSmallNormal(String, 32 + 4, 0, line + 1);
}
#else // show the channel frequency below the channel number/name
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000);
UI_PrintStringSmallNormal(String, 32 + 4, 0, line + 1);
#endif
}
break;
@@ -751,7 +969,19 @@ void UI_DisplayMain(void)
center_line = CENTER_LINE_DTMF_DEC;
sprintf(String, "DTMF %s", gDTMF_RX_live + idx);
#ifdef ENABLE_FEAT_F4HWN
if ((gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2 == 0)
{
UI_PrintStringSmallNormal(String, 2, 0, 5);
}
else
{
UI_PrintStringSmallNormal(String, 2, 0, 3);
}
#else
UI_PrintStringSmallNormal(String, 2, 0, 3);
#endif
}
#else
if (gSetting_live_DTMF_decoder && gDTMF_RX_index > 0)

View File

@@ -123,7 +123,10 @@ const t_menu_item MenuList[] =
{"BatVol", VOICE_ID_INVALID, MENU_VOL }, // was "VOL"
{"RxMode", VOICE_ID_DUAL_STANDBY, MENU_TDR },
{"Sql", VOICE_ID_SQUELCH, MENU_SQL },
#ifdef ENABLE_FEAT_F4HWN
{"SetLow", VOICE_ID_INVALID, MENU_SET_LOW },
{"SetPtt", VOICE_ID_INVALID, MENU_SET_PTT },
#endif
// hidden menu items from here on
// enabled if pressing both the PTT and upper side button at power-on
{"F Lock", VOICE_ID_INVALID, MENU_F_LOCK },
@@ -334,6 +337,23 @@ const char gSubMenu_SCRAMBLER[][7] =
"3500Hz"
};
#ifdef ENABLE_FEAT_F4HWN
const char gSubMenu_SET_LOW[][7] =
{
"125mW",
"250mW",
"500mW",
"1W",
"< 20mW"
};
const char gSubMenu_SET_PTT[][8] =
{
"Classic",
"OnePush"
};
#endif
const t_sidefunction gSubMenu_SIDEFUNCTIONS[] =
{
{"NONE", ACTION_OPT_NONE},
@@ -362,6 +382,10 @@ const t_sidefunction gSubMenu_SIDEFUNCTIONS[] =
#ifdef ENABLE_BLMIN_TMP_OFF
{"BLMIN\nTMP OFF", ACTION_OPT_BLMIN_TMP_OFF}, //BackLight Minimum Temporay OFF
#endif
#ifdef ENABLE_FEAT_F4HWN
{"SWITCH\nMAIN ONLY", ACTION_OPT_MAIN},
{"SWITCH\nPTT", ACTION_OPT_PTT},
#endif
};
const uint8_t gSubMenu_SIDEFUNCTIONS_size = ARRAY_SIZE(gSubMenu_SIDEFUNCTIONS);
@@ -404,6 +428,11 @@ void UI_DisplayMenu(void)
UI_DisplayClear();
#ifdef ENABLE_FEAT_F4HWN
UI_DrawLineBuffer(gFrameBuffer, 50, 0, 50, 63, 1); // Be ware, limit is 63 pixels (not 64)
UI_DrawLineDottedBuffer(gFrameBuffer, 0, 46, 50, 46, 1);
#endif
#ifndef ENABLE_CUSTOM_MENU_LAYOUT
// original menu layout
for (i = 0; i < 3; i++)
@@ -427,8 +456,11 @@ void UI_DisplayMenu(void)
memcpy(gFrameBuffer[0] + (8 * menu_list_width) + 1, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator));
// draw the menu index number/count
#ifdef ENABLE_FEAT_F4HWN
sprintf(String, "%02u/%u", 1 + gMenuCursor, gMenuListCount);
#else
sprintf(String, "%2u.%u", 1 + gMenuCursor, gMenuListCount);
#endif
UI_PrintStringSmallNormal(String, 2, 0, 6);
#else
@@ -839,6 +871,15 @@ void UI_DisplayMenu(void)
strcpy(String, gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].name);
break;
#ifdef ENABLE_FEAT_F4HWN
case MENU_SET_LOW:
strcpy(String, gSubMenu_SET_LOW[gSubMenuSelection]);
break;
case MENU_SET_PTT:
strcpy(String, gSubMenu_SET_PTT[gSubMenuSelection]);
break;
#endif
}
if (!already_printed)

View File

@@ -116,6 +116,10 @@ enum
MENU_SCREN,
#ifdef ENABLE_F_CAL_MENU
MENU_F_CALI, // reference xtal calibration
#endif
#ifdef ENABLE_FEAT_F4HWN
MENU_SET_LOW,
MENU_SET_PTT,
#endif
MENU_BATCAL, // battery voltage calibration
MENU_F1SHRT,
@@ -148,6 +152,12 @@ extern const char* const gSubMenu_MDF[4];
#ifdef ENABLE_DTMF_CALLING
extern const char gSubMenu_D_RSP[4][11];
#endif
#ifdef ENABLE_FEAT_F4HWN
extern const char gSubMenu_SET_LOW[5][7];
extern const char gSubMenu_SET_PTT[2][8];
#endif
extern const char* const gSubMenu_PTT_ID[5];
extern const char gSubMenu_PONMSG[4][8];
extern const char gSubMenu_ROGER[3][6];

View File

@@ -69,7 +69,13 @@ void UI_DisplayWelcome(void)
UI_PrintString(WelcomeString0, 0, 127, 0, 10);
UI_PrintString(WelcomeString1, 0, 127, 2, 10);
#ifdef ENABLE_FEAT_F4HWN
UI_PrintStringSmallNormal(Version, 0, 128, 5);
UI_PrintStringSmallNormal(Feat, 0, 128, 6);
#else
UI_PrintStringSmallNormal(Version, 0, 128, 6);
#endif
ST7565_BlitStatusLine(); // blank status line
ST7565_BlitFullScreen();