2023-09-09 07:03:56 +00:00
|
|
|
/* Copyright 2023 Dual Tachyon
|
|
|
|
* https://github.com/DualTachyon
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2023-09-18 10:29:28 +00:00
|
|
|
#include "app/scanner.h"
|
2023-09-14 08:56:30 +00:00
|
|
|
#ifdef ENABLE_FMRADIO
|
|
|
|
#include "app/fm.h"
|
|
|
|
#endif
|
2023-09-09 07:03:56 +00:00
|
|
|
#include "bitmaps.h"
|
|
|
|
#include "driver/keyboard.h"
|
|
|
|
#include "driver/st7565.h"
|
2023-09-19 06:59:06 +00:00
|
|
|
#include "external/printf/printf.h"
|
2023-09-09 07:03:56 +00:00
|
|
|
#include "functions.h"
|
|
|
|
#include "helper/battery.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "settings.h"
|
2023-09-19 06:59:06 +00:00
|
|
|
#include "ui/helper.h"
|
2023-09-18 10:29:28 +00:00
|
|
|
#include "ui/ui.h"
|
2023-09-09 07:03:56 +00:00
|
|
|
#include "ui/status.h"
|
|
|
|
|
2023-09-14 08:56:30 +00:00
|
|
|
void UI_DisplayStatus(const bool test_display)
|
2023-09-09 07:03:56 +00:00
|
|
|
{
|
2023-09-19 19:04:02 +00:00
|
|
|
uint8_t *line = gStatusLine;
|
|
|
|
unsigned int x = 0;
|
|
|
|
unsigned int x1 = 0;
|
2023-09-18 14:06:35 +00:00
|
|
|
|
2023-09-18 10:29:28 +00:00
|
|
|
gUpdateStatus = false;
|
|
|
|
|
2023-09-19 06:16:15 +00:00
|
|
|
memset(gStatusLine, 0, sizeof(gStatusLine));
|
2023-09-18 14:06:35 +00:00
|
|
|
|
2023-09-19 19:04:02 +00:00
|
|
|
// **************
|
2023-09-09 07:03:56 +00:00
|
|
|
|
2023-09-18 14:06:35 +00:00
|
|
|
// POWER-SAVE indicator
|
2023-10-03 15:09:25 +00:00
|
|
|
if (gCurrentFunction == FUNCTION_TRANSMIT)
|
|
|
|
{
|
|
|
|
memmove(line + x, BITMAP_TX, sizeof(BITMAP_TX));
|
|
|
|
x1 = x + sizeof(BITMAP_TX);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (gCurrentFunction == FUNCTION_RECEIVE ||
|
|
|
|
gCurrentFunction == FUNCTION_MONITOR ||
|
|
|
|
gCurrentFunction == FUNCTION_INCOMING)
|
|
|
|
{
|
|
|
|
memmove(line + x, BITMAP_RX, sizeof(BITMAP_RX));
|
|
|
|
x1 = x + sizeof(BITMAP_RX);
|
|
|
|
}
|
|
|
|
else
|
2023-09-14 08:56:30 +00:00
|
|
|
if (gCurrentFunction == FUNCTION_POWER_SAVE || test_display)
|
2023-09-19 19:04:02 +00:00
|
|
|
{
|
2023-10-03 15:09:25 +00:00
|
|
|
memmove(line + x, BITMAP_POWERSAVE, sizeof(BITMAP_POWERSAVE));
|
|
|
|
x1 = x + sizeof(BITMAP_POWERSAVE);
|
2023-09-19 19:04:02 +00:00
|
|
|
}
|
2023-10-03 15:09:25 +00:00
|
|
|
x += sizeof(BITMAP_POWERSAVE);
|
2023-09-09 07:03:56 +00:00
|
|
|
|
2023-09-14 08:56:30 +00:00
|
|
|
#ifdef ENABLE_NOAA
|
2023-09-18 14:06:35 +00:00
|
|
|
// NOASS SCAN indicator
|
2023-09-14 08:56:30 +00:00
|
|
|
if (gIsNoaaMode || test_display)
|
2023-09-19 19:04:02 +00:00
|
|
|
{
|
|
|
|
memmove(line + x, BITMAP_NOAA, sizeof(BITMAP_NOAA));
|
|
|
|
x1 = x + sizeof(BITMAP_NOAA);
|
|
|
|
}
|
|
|
|
x += sizeof(BITMAP_NOAA);
|
2023-09-18 14:06:35 +00:00
|
|
|
#else
|
2023-09-19 19:04:02 +00:00
|
|
|
// hmmm, what to put in it's place
|
2023-09-14 08:56:30 +00:00
|
|
|
#endif
|
|
|
|
|
2023-09-18 19:37:42 +00:00
|
|
|
if (gSetting_KILLED)
|
2023-09-19 19:04:02 +00:00
|
|
|
{
|
|
|
|
memset(line + x, 0xFF, 10);
|
|
|
|
x1 = x + 10;
|
|
|
|
}
|
2023-09-18 19:37:42 +00:00
|
|
|
else
|
2023-09-14 08:56:30 +00:00
|
|
|
#ifdef ENABLE_FMRADIO
|
2023-09-18 14:06:35 +00:00
|
|
|
// FM indicator
|
2023-09-14 08:56:30 +00:00
|
|
|
if (gFmRadioMode || test_display)
|
2023-09-19 19:04:02 +00:00
|
|
|
{
|
|
|
|
memmove(line + x, BITMAP_FM, sizeof(BITMAP_FM));
|
|
|
|
x1 = x + sizeof(BITMAP_FM);
|
|
|
|
}
|
2023-09-18 14:06:35 +00:00
|
|
|
else
|
2023-09-14 08:56:30 +00:00
|
|
|
#endif
|
2023-09-18 14:06:35 +00:00
|
|
|
// SCAN indicator
|
|
|
|
if (gScanState != SCAN_OFF || gScreenToDisplay == DISPLAY_SCANNER || test_display)
|
2023-09-19 19:04:02 +00:00
|
|
|
{
|
2023-10-04 17:54:26 +00:00
|
|
|
if (gEeprom.SCAN_LIST_DEFAULT == 0)
|
2023-10-04 19:05:00 +00:00
|
|
|
// memmove(line + x, BITMAP_SC1, sizeof(BITMAP_SC1));
|
|
|
|
UI_PrintStringSmallBuffer("1", line + x);
|
2023-10-04 17:54:26 +00:00
|
|
|
else
|
2023-10-04 19:05:00 +00:00
|
|
|
// memmove(line + x, BITMAP_SC2, sizeof(BITMAP_SC2));
|
|
|
|
UI_PrintStringSmallBuffer("2", line + x);
|
|
|
|
// x1 = x + sizeof(BITMAP_SC1);
|
|
|
|
x1 = x + 7;
|
2023-09-19 19:04:02 +00:00
|
|
|
}
|
2023-10-04 19:05:00 +00:00
|
|
|
// x += sizeof(BITMAP_SC1);
|
|
|
|
x += 7; // font character width
|
2023-09-09 07:03:56 +00:00
|
|
|
|
2023-09-14 08:56:30 +00:00
|
|
|
#ifdef ENABLE_VOICE
|
2023-09-18 14:06:35 +00:00
|
|
|
// VOICE indicator
|
2023-09-14 08:56:30 +00:00
|
|
|
if (gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF || test_display)
|
2023-09-19 19:04:02 +00:00
|
|
|
{
|
|
|
|
memmove(line + x, BITMAP_VoicePrompt, sizeof(BITMAP_VoicePrompt));
|
|
|
|
x1 = x + sizeof(BITMAP_VoicePrompt);
|
|
|
|
}
|
|
|
|
x += sizeof(BITMAP_VoicePrompt);
|
2023-09-18 10:29:28 +00:00
|
|
|
#else
|
2023-09-19 19:04:02 +00:00
|
|
|
// hmmm, what to put in it's place
|
2023-09-14 08:56:30 +00:00
|
|
|
#endif
|
2023-09-18 14:06:35 +00:00
|
|
|
|
|
|
|
// DUAL-WATCH indicator
|
2023-09-14 08:56:30 +00:00
|
|
|
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF || test_display)
|
2023-09-18 07:30:24 +00:00
|
|
|
{
|
2023-09-18 10:29:28 +00:00
|
|
|
if (gDualWatchActive || test_display)
|
2023-09-19 19:04:02 +00:00
|
|
|
memmove(line + x, BITMAP_TDR1, sizeof(BITMAP_TDR1));
|
2023-09-18 07:30:24 +00:00
|
|
|
else
|
2023-09-19 19:04:02 +00:00
|
|
|
memmove(line + x, BITMAP_TDR2, sizeof(BITMAP_TDR2));
|
2023-09-18 07:30:24 +00:00
|
|
|
}
|
2023-09-19 19:04:02 +00:00
|
|
|
x += sizeof(BITMAP_TDR1);
|
2023-09-18 14:06:35 +00:00
|
|
|
|
|
|
|
// CROSS-VFO indicator
|
2023-09-14 08:56:30 +00:00
|
|
|
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF || test_display)
|
2023-09-19 19:04:02 +00:00
|
|
|
{
|
|
|
|
memmove(line + x, BITMAP_XB, sizeof(BITMAP_XB));
|
|
|
|
x1 = x + sizeof(BITMAP_XB);
|
|
|
|
}
|
|
|
|
x += sizeof(BITMAP_XB);
|
|
|
|
|
2023-10-04 10:57:34 +00:00
|
|
|
#ifdef ENABLE_VOX
|
|
|
|
// VOX indicator
|
|
|
|
if (gEeprom.VOX_SWITCH || test_display)
|
|
|
|
{
|
|
|
|
memmove(line + x, BITMAP_VOX, sizeof(BITMAP_VOX));
|
|
|
|
x1 = x + sizeof(BITMAP_VOX);
|
|
|
|
}
|
|
|
|
x += sizeof(BITMAP_VOX);
|
|
|
|
#endif
|
2023-09-09 07:03:56 +00:00
|
|
|
|
2023-09-18 14:06:35 +00:00
|
|
|
// KEY-LOCK indicator
|
2023-09-14 08:56:30 +00:00
|
|
|
if (gEeprom.KEY_LOCK || test_display)
|
2023-09-19 06:59:06 +00:00
|
|
|
{
|
2023-09-19 19:04:02 +00:00
|
|
|
memmove(line + x, BITMAP_KeyLock, sizeof(BITMAP_KeyLock));
|
|
|
|
x += sizeof(BITMAP_KeyLock);
|
|
|
|
x1 = x;
|
2023-09-19 06:59:06 +00:00
|
|
|
}
|
2023-09-09 07:03:56 +00:00
|
|
|
else
|
|
|
|
if (gWasFKeyPressed)
|
2023-09-19 06:59:06 +00:00
|
|
|
{
|
2023-09-19 19:04:02 +00:00
|
|
|
memmove(line + x, BITMAP_F_Key, sizeof(BITMAP_F_Key));
|
|
|
|
x += sizeof(BITMAP_F_Key);
|
|
|
|
x1 = x;
|
2023-09-19 06:59:06 +00:00
|
|
|
}
|
2023-09-19 17:03:45 +00:00
|
|
|
|
2023-09-19 19:04:02 +00:00
|
|
|
{ // battery voltage or percentage
|
|
|
|
char s[8];
|
|
|
|
unsigned int space_needed;
|
|
|
|
|
|
|
|
unsigned int x2 = LCD_WIDTH - sizeof(BITMAP_BatteryLevel5) - 3;
|
2023-09-19 17:03:45 +00:00
|
|
|
|
2023-09-19 19:04:02 +00:00
|
|
|
if (gChargingWithTypeC)
|
|
|
|
x2 -= sizeof(BITMAP_USB_C); // the radio is on charge
|
2023-09-19 17:03:45 +00:00
|
|
|
|
2023-09-19 19:04:02 +00:00
|
|
|
switch (gSetting_battery_text)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: // voltage
|
|
|
|
{
|
|
|
|
const uint16_t voltage = (gBatteryVoltageAverage <= 999) ? gBatteryVoltageAverage : 999; // limit to 9.99V
|
|
|
|
sprintf(s, "%u.%02uV", voltage / 100, voltage % 100);
|
|
|
|
space_needed = (7 * strlen(s));
|
|
|
|
if (x2 >= (x1 + space_needed))
|
|
|
|
{
|
|
|
|
UI_PrintStringSmallBuffer(s, line + x2 - space_needed);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2: // percentage
|
|
|
|
{
|
2023-10-01 21:14:45 +00:00
|
|
|
sprintf(s, "%u%%", BATTERY_VoltsToPercent(gBatteryVoltageAverage));
|
2023-09-19 19:04:02 +00:00
|
|
|
space_needed = (7 * strlen(s));
|
|
|
|
if (x2 >= (x1 + space_needed))
|
|
|
|
UI_PrintStringSmallBuffer(s, line + x2 - space_needed);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-09-19 06:59:06 +00:00
|
|
|
}
|
2023-09-19 08:16:57 +00:00
|
|
|
|
2023-09-19 13:48:09 +00:00
|
|
|
// move to right side of the screen
|
2023-09-25 06:12:08 +00:00
|
|
|
x = LCD_WIDTH - sizeof(BITMAP_BatteryLevel1) - sizeof(BITMAP_USB_C);
|
2023-09-19 06:59:06 +00:00
|
|
|
|
2023-09-18 14:06:35 +00:00
|
|
|
// USB-C charge indicator
|
2023-09-14 08:56:30 +00:00
|
|
|
if (gChargingWithTypeC || test_display)
|
2023-09-19 19:04:02 +00:00
|
|
|
memmove(line + x, BITMAP_USB_C, sizeof(BITMAP_USB_C));
|
|
|
|
x += sizeof(BITMAP_USB_C);
|
2023-09-09 07:03:56 +00:00
|
|
|
|
2023-09-18 14:06:35 +00:00
|
|
|
// BATTERY LEVEL indicator
|
2023-09-25 06:12:08 +00:00
|
|
|
if (gBatteryDisplayLevel >= 2 && !gLowBattery)
|
|
|
|
{
|
|
|
|
line += x;
|
|
|
|
memmove(line, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
2023-10-02 09:40:27 +00:00
|
|
|
|
2023-09-25 06:12:08 +00:00
|
|
|
#ifndef ENABLE_REVERSE_BAT_SYMBOL
|
|
|
|
line += sizeof(BITMAP_BatteryLevel1);
|
2023-10-04 19:05:00 +00:00
|
|
|
{
|
|
|
|
const int8_t pos[] = {-4, -7, -10, 13};
|
|
|
|
for (unsigned int i = 0; i < ARRAY_SIZE(pos); i++)
|
|
|
|
if (gBatteryDisplayLevel >= (2 + i))
|
|
|
|
memmove(line + pos[i], BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
|
|
|
|
|
|
/* switch (gBatteryDisplayLevel)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 5: memmove(line - 13, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
|
|
case 4: memmove(line - 10, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
|
|
case 3: memmove(line - 7, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
|
|
case 2: memmove(line - 4, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
|
|
}
|
|
|
|
*/ }
|
2023-09-25 06:12:08 +00:00
|
|
|
#else
|
2023-10-04 19:05:00 +00:00
|
|
|
{
|
|
|
|
const int8_t pos[] = {3, 6, 9, 12};
|
|
|
|
for (unsigned int i = 0; i < ARRAY_SIZE(pos); i++)
|
|
|
|
if (gBatteryDisplayLevel >= (2 + i))
|
|
|
|
memmove(line + pos[i], BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
|
|
/*
|
|
|
|
switch (gBatteryDisplayLevel)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 5: memmove(line + 12, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
|
|
case 4: memmove(line + 9, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
|
|
case 3: memmove(line + 6, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
|
|
case 2: memmove(line + 3, BITMAP_BatteryLevel, sizeof(BITMAP_BatteryLevel));
|
|
|
|
}
|
|
|
|
*/ }
|
2023-09-25 06:12:08 +00:00
|
|
|
#endif
|
|
|
|
}
|
2023-09-14 08:56:30 +00:00
|
|
|
else
|
|
|
|
if (gLowBatteryBlink == 1)
|
2023-09-19 19:04:02 +00:00
|
|
|
memmove(line + x, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
|
|
|
|
|
|
|
// **************
|
2023-09-09 07:03:56 +00:00
|
|
|
|
|
|
|
ST7565_BlitStatusLine();
|
|
|
|
}
|