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-18 14:06:35 +00:00
|
|
|
uint8_t *line = gStatusLine;
|
|
|
|
|
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 06:16:15 +00:00
|
|
|
// line += 2;
|
2023-09-09 07:03:56 +00:00
|
|
|
|
2023-09-18 14:06:35 +00:00
|
|
|
// POWER-SAVE indicator
|
2023-09-14 08:56:30 +00:00
|
|
|
if (gCurrentFunction == FUNCTION_POWER_SAVE || test_display)
|
2023-09-18 14:06:35 +00:00
|
|
|
memmove(line, BITMAP_PowerSave, sizeof(BITMAP_PowerSave));
|
|
|
|
line += 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-18 14:06:35 +00:00
|
|
|
memmove(line, BITMAP_NOAA, sizeof(BITMAP_NOAA));
|
|
|
|
line += sizeof(BITMAP_NOAA);
|
|
|
|
#else
|
|
|
|
line += 12;
|
2023-09-14 08:56:30 +00:00
|
|
|
#endif
|
|
|
|
|
2023-09-18 19:37:42 +00:00
|
|
|
if (gSetting_KILLED)
|
|
|
|
memset(line, 0xFF, 10);
|
|
|
|
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-18 14:06:35 +00:00
|
|
|
memmove(line, BITMAP_FM, sizeof(BITMAP_FM));
|
|
|
|
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)
|
|
|
|
memmove(line, BITMAP_SC, sizeof(BITMAP_SC));
|
|
|
|
line += sizeof(BITMAP_SC);
|
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-18 14:06:35 +00:00
|
|
|
memmove(line, BITMAP_VoicePrompt, sizeof(BITMAP_VoicePrompt));
|
2023-09-18 10:29:28 +00:00
|
|
|
#else
|
|
|
|
if (test_display)
|
2023-09-18 14:06:35 +00:00
|
|
|
memset(line, 0xFF, 8);
|
2023-09-14 08:56:30 +00:00
|
|
|
#endif
|
2023-09-18 14:06:35 +00:00
|
|
|
line += 9;
|
|
|
|
|
|
|
|
// 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-18 14:06:35 +00:00
|
|
|
memmove(line, BITMAP_TDR1, sizeof(BITMAP_TDR1));
|
2023-09-18 07:30:24 +00:00
|
|
|
else
|
2023-09-18 14:06:35 +00:00
|
|
|
memmove(line, BITMAP_TDR2, sizeof(BITMAP_TDR2));
|
2023-09-18 07:30:24 +00:00
|
|
|
}
|
2023-09-18 14:06:35 +00:00
|
|
|
line += sizeof(BITMAP_TDR1);
|
|
|
|
|
|
|
|
// CROSS-VFO indicator
|
2023-09-14 08:56:30 +00:00
|
|
|
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF || test_display)
|
2023-09-18 14:06:35 +00:00
|
|
|
memmove(line, BITMAP_XB, sizeof(BITMAP_XB));
|
|
|
|
line += sizeof(BITMAP_XB);
|
2023-09-14 08:56:30 +00:00
|
|
|
|
2023-09-18 14:06:35 +00:00
|
|
|
// VOX indicator
|
2023-09-14 08:56:30 +00:00
|
|
|
if (gEeprom.VOX_SWITCH || test_display)
|
2023-09-18 14:06:35 +00:00
|
|
|
memmove(line, BITMAP_VOX, sizeof(BITMAP_VOX));
|
|
|
|
line += sizeof(BITMAP_VOX);
|
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-18 14:06:35 +00:00
|
|
|
memmove(line, BITMAP_KeyLock, sizeof(BITMAP_KeyLock));
|
2023-09-19 06:59:06 +00:00
|
|
|
line += sizeof(BITMAP_KeyLock);
|
|
|
|
}
|
2023-09-09 07:03:56 +00:00
|
|
|
else
|
|
|
|
if (gWasFKeyPressed)
|
2023-09-19 06:59:06 +00:00
|
|
|
{
|
2023-09-18 14:06:35 +00:00
|
|
|
memmove(line, BITMAP_F_Key, sizeof(BITMAP_F_Key));
|
2023-09-19 06:59:06 +00:00
|
|
|
line += sizeof(BITMAP_F_Key);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (!gChargingWithTypeC)
|
2023-09-19 08:16:57 +00:00
|
|
|
{ // battery voltage or percentage
|
2023-09-09 07:03:56 +00:00
|
|
|
|
2023-09-19 08:16:57 +00:00
|
|
|
#ifdef ENABLE_STATUSBAR_VOLTAGE
|
2023-09-19 06:59:06 +00:00
|
|
|
char s[6];
|
|
|
|
sprintf(s, "%u.%02u", gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100);
|
|
|
|
UI_PrintStringSmallBuffer(s, line);
|
2023-09-19 08:16:57 +00:00
|
|
|
//line += 8 * 4;
|
2023-09-19 06:59:06 +00:00
|
|
|
#elif defined(ENABLE_STATUSBAR_PERCENTAGE)
|
|
|
|
char s[6];
|
2023-09-19 08:16:57 +00:00
|
|
|
const uint16_t volts = (gBatteryVoltageAverage < gMin_bat_v) ? gMin_bat_v : gBatteryVoltageAverage;
|
2023-09-19 06:59:06 +00:00
|
|
|
sprintf(s, "%u%%", (100 * (volts - gMin_bat_v)) / (gMax_bat_v - gMin_bat_v));
|
|
|
|
UI_PrintStringSmallBuffer(s, line);
|
2023-09-19 08:16:57 +00:00
|
|
|
//line += 8 * 4;
|
2023-09-19 06:59:06 +00:00
|
|
|
#endif
|
|
|
|
}
|
2023-09-19 08:16:57 +00:00
|
|
|
// else
|
|
|
|
// line += sizeof(BITMAP_F_Key);
|
|
|
|
|
|
|
|
line = gStatusLine + LCD_WIDTH - sizeof(BITMAP_BatteryLevel5) - sizeof(BITMAP_USB_C); // point to right side of the screen
|
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-18 14:06:35 +00:00
|
|
|
memmove(line, BITMAP_USB_C, sizeof(BITMAP_USB_C));
|
2023-09-19 08:16:57 +00:00
|
|
|
line += 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-14 08:56:30 +00:00
|
|
|
if (gBatteryDisplayLevel >= 5 || test_display)
|
2023-09-18 14:06:35 +00:00
|
|
|
memmove(line, BITMAP_BatteryLevel5, sizeof(BITMAP_BatteryLevel5));
|
2023-09-14 08:56:30 +00:00
|
|
|
else
|
|
|
|
if (gBatteryDisplayLevel >= 4)
|
2023-09-18 14:06:35 +00:00
|
|
|
memmove(line, BITMAP_BatteryLevel4, sizeof(BITMAP_BatteryLevel4));
|
2023-09-14 08:56:30 +00:00
|
|
|
else
|
|
|
|
if (gBatteryDisplayLevel >= 3)
|
2023-09-18 14:06:35 +00:00
|
|
|
memmove(line, BITMAP_BatteryLevel3, sizeof(BITMAP_BatteryLevel3));
|
2023-09-09 07:03:56 +00:00
|
|
|
else
|
2023-09-14 08:56:30 +00:00
|
|
|
if (gBatteryDisplayLevel >= 2)
|
2023-09-18 14:06:35 +00:00
|
|
|
memmove(line, BITMAP_BatteryLevel2, sizeof(BITMAP_BatteryLevel2));
|
2023-09-14 08:56:30 +00:00
|
|
|
else
|
|
|
|
if (gLowBatteryBlink == 1)
|
2023-09-18 14:06:35 +00:00
|
|
|
memmove(line, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
|
2023-09-09 07:03:56 +00:00
|
|
|
|
|
|
|
ST7565_BlitStatusLine();
|
|
|
|
}
|