uv-k5-firmware-custom/ui/status.c

133 lines
3.7 KiB
C
Raw Normal View History

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>
#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"
#include "functions.h"
#include "helper/battery.h"
#include "misc.h"
#include "settings.h"
#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
{
uint8_t *line = gStatusLine;
gUpdateStatus = false;
memset(gStatusLine, 0, sizeof(gStatusLine));
// line += 2;
2023-09-09 07:03:56 +00:00
// POWER-SAVE indicator
2023-09-14 08:56:30 +00:00
if (gCurrentFunction == FUNCTION_POWER_SAVE || test_display)
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
// NOASS SCAN indicator
2023-09-14 08:56:30 +00:00
if (gIsNoaaMode || test_display)
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
// FM indicator
2023-09-14 08:56:30 +00:00
if (gFmRadioMode || test_display)
memmove(line, BITMAP_FM, sizeof(BITMAP_FM));
else
2023-09-14 08:56:30 +00:00
#endif
// 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
// VOICE indicator
2023-09-14 08:56:30 +00:00
if (gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF || test_display)
memmove(line, BITMAP_VoicePrompt, sizeof(BITMAP_VoicePrompt));
#else
if (test_display)
memset(line, 0xFF, 8);
2023-09-14 08:56:30 +00:00
#endif
line += 9;
// DUAL-WATCH indicator
2023-09-14 08:56:30 +00:00
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF || test_display)
{
if (gDualWatchActive || test_display)
memmove(line, BITMAP_TDR1, sizeof(BITMAP_TDR1));
else
memmove(line, BITMAP_TDR2, sizeof(BITMAP_TDR2));
}
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)
memmove(line, BITMAP_XB, sizeof(BITMAP_XB));
line += sizeof(BITMAP_XB);
2023-09-14 08:56:30 +00:00
// VOX indicator
2023-09-14 08:56:30 +00:00
if (gEeprom.VOX_SWITCH || test_display)
memmove(line, BITMAP_VOX, sizeof(BITMAP_VOX));
line += sizeof(BITMAP_VOX);
2023-09-09 07:03:56 +00:00
// KEY-LOCK indicator
2023-09-14 08:56:30 +00:00
if (gEeprom.KEY_LOCK || test_display)
memmove(line, BITMAP_KeyLock, sizeof(BITMAP_KeyLock));
2023-09-09 07:03:56 +00:00
else
if (gWasFKeyPressed)
memmove(line, BITMAP_F_Key, sizeof(BITMAP_F_Key));
line += sizeof(BITMAP_F_Key);
2023-09-09 07:03:56 +00:00
// USB-C charge indicator
2023-09-14 08:56:30 +00:00
if (gChargingWithTypeC || test_display)
memmove(line, BITMAP_USB_C, sizeof(BITMAP_USB_C));
// line += sizeof(BITMAP_USB_C);
2023-09-09 07:03:56 +00:00
// BATTERY LEVEL indicator
line = gStatusLine + LCD_WIDTH - sizeof(BITMAP_BatteryLevel5); // point to the far right side of the screen
2023-09-14 08:56:30 +00:00
if (gBatteryDisplayLevel >= 5 || test_display)
memmove(line, BITMAP_BatteryLevel5, sizeof(BITMAP_BatteryLevel5));
2023-09-14 08:56:30 +00:00
else
if (gBatteryDisplayLevel >= 4)
memmove(line, BITMAP_BatteryLevel4, sizeof(BITMAP_BatteryLevel4));
2023-09-14 08:56:30 +00:00
else
if (gBatteryDisplayLevel >= 3)
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)
memmove(line, BITMAP_BatteryLevel2, sizeof(BITMAP_BatteryLevel2));
2023-09-14 08:56:30 +00:00
else
if (gLowBatteryBlink == 1)
memmove(line, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1));
2023-09-09 07:03:56 +00:00
ST7565_BlitStatusLine();
}