2023-09-09 08:03:56 +01: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-10-14 14:07:05 +01:00
|
|
|
#include "app/search.h"
|
2023-09-14 09:56:30 +01:00
|
|
|
#ifdef ENABLE_FMRADIO
|
|
|
|
#include "app/fm.h"
|
|
|
|
#endif
|
2023-09-09 08:03:56 +01:00
|
|
|
#include "bitmaps.h"
|
|
|
|
#include "driver/keyboard.h"
|
|
|
|
#include "driver/st7565.h"
|
2023-09-19 07:59:06 +01:00
|
|
|
#include "external/printf/printf.h"
|
2023-09-09 08:03:56 +01:00
|
|
|
#include "functions.h"
|
|
|
|
#include "helper/battery.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "settings.h"
|
2023-10-09 14:17:14 +02:00
|
|
|
#include "ui/battery.h"
|
2023-09-19 07:59:06 +01:00
|
|
|
#include "ui/helper.h"
|
2023-09-18 11:29:28 +01:00
|
|
|
#include "ui/ui.h"
|
2023-09-09 08:03:56 +01:00
|
|
|
#include "ui/status.h"
|
|
|
|
|
2023-09-14 09:56:30 +01:00
|
|
|
void UI_DisplayStatus(const bool test_display)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-10-08 20:23:37 +01:00
|
|
|
uint8_t *line = g_status_line;
|
2023-09-19 20:04:02 +01:00
|
|
|
unsigned int x = 0;
|
|
|
|
unsigned int x1 = 0;
|
2023-09-18 15:06:35 +01:00
|
|
|
|
2023-10-08 20:23:37 +01:00
|
|
|
g_update_status = false;
|
2023-09-18 11:29:28 +01:00
|
|
|
|
2023-10-08 20:23:37 +01:00
|
|
|
memset(g_status_line, 0, sizeof(g_status_line));
|
2023-09-18 15:06:35 +01:00
|
|
|
|
2023-09-19 20:04:02 +01:00
|
|
|
// **************
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-09-18 15:06:35 +01:00
|
|
|
// POWER-SAVE indicator
|
2023-10-08 20:23:37 +01:00
|
|
|
if (g_current_function == FUNCTION_TRANSMIT)
|
2023-10-03 16:09:25 +01:00
|
|
|
{
|
|
|
|
memmove(line + x, BITMAP_TX, sizeof(BITMAP_TX));
|
|
|
|
x1 = x + sizeof(BITMAP_TX);
|
|
|
|
}
|
|
|
|
else
|
2023-10-08 20:23:37 +01:00
|
|
|
if (g_current_function == FUNCTION_RECEIVE ||
|
|
|
|
g_current_function == FUNCTION_MONITOR ||
|
|
|
|
g_current_function == FUNCTION_INCOMING)
|
2023-10-03 16:09:25 +01:00
|
|
|
{
|
|
|
|
memmove(line + x, BITMAP_RX, sizeof(BITMAP_RX));
|
|
|
|
x1 = x + sizeof(BITMAP_RX);
|
|
|
|
}
|
|
|
|
else
|
2023-10-08 20:23:37 +01:00
|
|
|
if (g_current_function == FUNCTION_POWER_SAVE || test_display)
|
2023-09-19 20:04:02 +01:00
|
|
|
{
|
2023-10-03 16:09:25 +01:00
|
|
|
memmove(line + x, BITMAP_POWERSAVE, sizeof(BITMAP_POWERSAVE));
|
|
|
|
x1 = x + sizeof(BITMAP_POWERSAVE);
|
2023-09-19 20:04:02 +01:00
|
|
|
}
|
2023-10-03 16:09:25 +01:00
|
|
|
x += sizeof(BITMAP_POWERSAVE);
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-09-14 09:56:30 +01:00
|
|
|
#ifdef ENABLE_NOAA
|
2023-09-18 15:06:35 +01:00
|
|
|
// NOASS SCAN indicator
|
2023-10-08 20:23:37 +01:00
|
|
|
if (g_is_noaa_mode || test_display)
|
2023-09-19 20:04:02 +01:00
|
|
|
{
|
|
|
|
memmove(line + x, BITMAP_NOAA, sizeof(BITMAP_NOAA));
|
|
|
|
x1 = x + sizeof(BITMAP_NOAA);
|
|
|
|
}
|
|
|
|
x += sizeof(BITMAP_NOAA);
|
2023-09-18 15:06:35 +01:00
|
|
|
#else
|
2023-09-19 20:04:02 +01:00
|
|
|
// hmmm, what to put in it's place
|
2023-09-14 09:56:30 +01:00
|
|
|
#endif
|
|
|
|
|
2023-10-08 20:23:37 +01:00
|
|
|
if (g_setting_killed)
|
2023-09-19 20:04:02 +01:00
|
|
|
{
|
|
|
|
memset(line + x, 0xFF, 10);
|
|
|
|
x1 = x + 10;
|
|
|
|
}
|
2023-09-18 20:37:42 +01:00
|
|
|
else
|
2023-09-14 09:56:30 +01:00
|
|
|
#ifdef ENABLE_FMRADIO
|
2023-09-18 15:06:35 +01:00
|
|
|
// FM indicator
|
2023-10-08 20:23:37 +01:00
|
|
|
if (g_fm_radio_mode || test_display)
|
2023-09-19 20:04:02 +01:00
|
|
|
{
|
|
|
|
memmove(line + x, BITMAP_FM, sizeof(BITMAP_FM));
|
|
|
|
x1 = x + sizeof(BITMAP_FM);
|
|
|
|
}
|
2023-09-18 15:06:35 +01:00
|
|
|
else
|
2023-09-14 09:56:30 +01:00
|
|
|
#endif
|
2023-09-18 15:06:35 +01:00
|
|
|
// SCAN indicator
|
2023-10-13 15:12:32 +01:00
|
|
|
if (g_scan_state_dir != SCAN_STATE_DIR_OFF || g_screen_to_display == DISPLAY_SEARCH || test_display)
|
2023-09-19 20:04:02 +01:00
|
|
|
{
|
2023-10-13 15:12:32 +01:00
|
|
|
if (g_scan_next_channel <= USER_CHANNEL_LAST)
|
2023-10-05 23:58:55 +01:00
|
|
|
{ // channel mode
|
2023-10-08 17:14:13 +01:00
|
|
|
if (g_eeprom.scan_list_default == 0)
|
2023-10-05 23:58:55 +01:00
|
|
|
UI_PrintStringSmallBuffer("1", line + x);
|
|
|
|
else
|
2023-10-08 17:14:13 +01:00
|
|
|
if (g_eeprom.scan_list_default == 1)
|
2023-10-05 23:58:55 +01:00
|
|
|
UI_PrintStringSmallBuffer("2", line + x);
|
|
|
|
else
|
2023-10-08 17:14:13 +01:00
|
|
|
if (g_eeprom.scan_list_default == 2)
|
2023-10-05 23:58:55 +01:00
|
|
|
UI_PrintStringSmallBuffer("*", line + x);
|
|
|
|
}
|
2023-10-04 18:54:26 +01:00
|
|
|
else
|
2023-10-05 23:58:55 +01:00
|
|
|
{ // frequency mode
|
|
|
|
UI_PrintStringSmallBuffer("S", line + x);
|
|
|
|
}
|
2023-10-04 20:05:00 +01:00
|
|
|
x1 = x + 7;
|
2023-09-19 20:04:02 +01:00
|
|
|
}
|
2023-10-04 20:05:00 +01:00
|
|
|
x += 7; // font character width
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-09-14 09:56:30 +01:00
|
|
|
#ifdef ENABLE_VOICE
|
2023-09-18 15:06:35 +01:00
|
|
|
// VOICE indicator
|
2023-10-08 17:14:13 +01:00
|
|
|
if (g_eeprom.voice_prompt != VOICE_PROMPT_OFF || test_display)
|
2023-09-19 20:04:02 +01:00
|
|
|
{
|
2023-10-08 20:23:37 +01:00
|
|
|
memmove(line + x, BITMAP_VOICE_PROMPT, sizeof(BITMAP_VOICE_PROMPT));
|
|
|
|
x1 = x + sizeof(BITMAP_VOICE_PROMPT);
|
2023-09-19 20:04:02 +01:00
|
|
|
}
|
2023-10-08 20:23:37 +01:00
|
|
|
x += sizeof(BITMAP_VOICE_PROMPT);
|
2023-09-18 11:29:28 +01:00
|
|
|
#else
|
2023-09-19 20:04:02 +01:00
|
|
|
// hmmm, what to put in it's place
|
2023-09-14 09:56:30 +01:00
|
|
|
#endif
|
2023-09-18 15:06:35 +01:00
|
|
|
|
|
|
|
// DUAL-WATCH indicator
|
2023-10-08 17:14:13 +01:00
|
|
|
if (g_eeprom.dual_watch != DUAL_WATCH_OFF || test_display)
|
2023-09-18 08:30:24 +01:00
|
|
|
{
|
2023-10-08 20:23:37 +01:00
|
|
|
if (g_dual_watch_active || test_display)
|
2023-09-19 20:04:02 +01:00
|
|
|
memmove(line + x, BITMAP_TDR1, sizeof(BITMAP_TDR1));
|
2023-09-18 08:30:24 +01:00
|
|
|
else
|
2023-09-19 20:04:02 +01:00
|
|
|
memmove(line + x, BITMAP_TDR2, sizeof(BITMAP_TDR2));
|
2023-09-18 08:30:24 +01:00
|
|
|
}
|
2023-09-19 20:04:02 +01:00
|
|
|
x += sizeof(BITMAP_TDR1);
|
2023-09-18 15:06:35 +01:00
|
|
|
|
|
|
|
// CROSS-VFO indicator
|
2023-10-08 17:14:13 +01:00
|
|
|
if (g_eeprom.cross_vfo_rx_tx != CROSS_BAND_OFF || test_display)
|
2023-09-19 20:04:02 +01:00
|
|
|
{
|
|
|
|
memmove(line + x, BITMAP_XB, sizeof(BITMAP_XB));
|
|
|
|
x1 = x + sizeof(BITMAP_XB);
|
|
|
|
}
|
|
|
|
x += sizeof(BITMAP_XB);
|
|
|
|
|
2023-10-04 11:57:34 +01:00
|
|
|
#ifdef ENABLE_VOX
|
|
|
|
// VOX indicator
|
2023-10-08 17:14:13 +01:00
|
|
|
if (g_eeprom.vox_switch || test_display)
|
2023-10-04 11:57:34 +01:00
|
|
|
{
|
|
|
|
memmove(line + x, BITMAP_VOX, sizeof(BITMAP_VOX));
|
|
|
|
x1 = x + sizeof(BITMAP_VOX);
|
|
|
|
}
|
|
|
|
x += sizeof(BITMAP_VOX);
|
|
|
|
#endif
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-09-18 15:06:35 +01:00
|
|
|
// KEY-LOCK indicator
|
2023-10-08 17:14:13 +01:00
|
|
|
if (g_eeprom.key_lock || test_display)
|
2023-09-19 07:59:06 +01:00
|
|
|
{
|
2023-10-08 20:23:37 +01:00
|
|
|
memmove(line + x, BITMAP_KEYLOCK, sizeof(BITMAP_KEYLOCK));
|
|
|
|
x += sizeof(BITMAP_KEYLOCK);
|
2023-09-19 20:04:02 +01:00
|
|
|
x1 = x;
|
2023-09-19 07:59:06 +01:00
|
|
|
}
|
2023-09-09 08:03:56 +01:00
|
|
|
else
|
2023-10-09 22:49:29 +01:00
|
|
|
if (g_fkey_pressed)
|
2023-09-19 07:59:06 +01:00
|
|
|
{
|
2023-10-08 20:23:37 +01:00
|
|
|
memmove(line + x, BITMAP_F_KEY, sizeof(BITMAP_F_KEY));
|
|
|
|
x += sizeof(BITMAP_F_KEY);
|
2023-09-19 20:04:02 +01:00
|
|
|
x1 = x;
|
2023-09-19 07:59:06 +01:00
|
|
|
}
|
2023-09-19 18:03:45 +01:00
|
|
|
|
2023-10-09 22:49:29 +01:00
|
|
|
{ // battery voltage or percentage text
|
2023-09-19 20:04:02 +01:00
|
|
|
char s[8];
|
|
|
|
unsigned int space_needed;
|
|
|
|
|
2023-10-06 22:16:03 +01:00
|
|
|
unsigned int x2 = LCD_WIDTH - sizeof(BITMAP_BATTERY_LEVEL) - 3;
|
2023-09-19 18:03:45 +01:00
|
|
|
|
2023-10-08 20:23:37 +01:00
|
|
|
if (g_charging_with_type_c)
|
2023-10-09 22:49:29 +01:00
|
|
|
x2 -= sizeof(BITMAP_USB_C); // the radio is on USB charge
|
2023-09-19 18:03:45 +01:00
|
|
|
|
2023-10-08 20:23:37 +01:00
|
|
|
switch (g_setting_battery_text)
|
2023-09-19 20:04:02 +01:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: // voltage
|
|
|
|
{
|
2023-10-08 20:23:37 +01:00
|
|
|
const uint16_t voltage = (g_battery_voltage_average <= 999) ? g_battery_voltage_average : 999; // limit to 9.99V
|
2023-09-19 20:04:02 +01:00
|
|
|
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-08 20:23:37 +01:00
|
|
|
sprintf(s, "%u%%", BATTERY_VoltsToPercent(g_battery_voltage_average));
|
2023-09-19 20:04:02 +01:00
|
|
|
space_needed = (7 * strlen(s));
|
|
|
|
if (x2 >= (x1 + space_needed))
|
|
|
|
UI_PrintStringSmallBuffer(s, line + x2 - space_needed);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-09-19 07:59:06 +01:00
|
|
|
}
|
2023-09-19 09:16:57 +01:00
|
|
|
|
2023-09-19 14:48:09 +01:00
|
|
|
// move to right side of the screen
|
2023-10-06 22:16:03 +01:00
|
|
|
x = LCD_WIDTH - sizeof(BITMAP_BATTERY_LEVEL) - sizeof(BITMAP_USB_C);
|
2023-09-19 07:59:06 +01:00
|
|
|
|
2023-09-18 15:06:35 +01:00
|
|
|
// USB-C charge indicator
|
2023-10-08 20:23:37 +01:00
|
|
|
if (g_charging_with_type_c || test_display)
|
2023-09-19 20:04:02 +01:00
|
|
|
memmove(line + x, BITMAP_USB_C, sizeof(BITMAP_USB_C));
|
|
|
|
x += sizeof(BITMAP_USB_C);
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-09 14:17:14 +02:00
|
|
|
// BATTERY LEVEL indicator
|
2023-10-10 00:18:34 +02:00
|
|
|
UI_DrawBattery(line + x, g_battery_display_level, g_low_battery_blink);
|
2023-10-04 20:05:00 +01:00
|
|
|
|
2023-09-19 20:04:02 +01:00
|
|
|
// **************
|
2023-09-09 08:03:56 +01:00
|
|
|
|
|
|
|
ST7565_BlitStatusLine();
|
|
|
|
}
|