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-11-03 18:28:34 +00:00
|
|
|
#include "app/chFrScanner.h"
|
2023-09-14 08:56:30 +00:00
|
|
|
#ifdef ENABLE_FMRADIO
|
|
|
|
#include "app/fm.h"
|
|
|
|
#endif
|
2023-11-06 00:25:44 +00:00
|
|
|
#include "app/scanner.h"
|
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-10-09 14:30:20 +00:00
|
|
|
#include "ui/battery.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-10-27 18:11:22 +00:00
|
|
|
void UI_DisplayStatus()
|
2023-09-09 07:03:56 +00:00
|
|
|
{
|
2023-12-25 00:35:06 +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-12-11 23:45:09 +00:00
|
|
|
uint8_t *line = gStatusLine;
|
|
|
|
unsigned int x = 0;
|
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-12-11 23:45:09 +00:00
|
|
|
if (gCurrentFunction == FUNCTION_TRANSMIT) {
|
|
|
|
memcpy(line + x, BITMAP_TX, sizeof(BITMAP_TX));
|
2023-10-03 15:09:25 +00:00
|
|
|
}
|
2023-12-11 23:45:09 +00:00
|
|
|
else if (FUNCTION_IsRx()) {
|
|
|
|
memcpy(line + x, BITMAP_RX, sizeof(BITMAP_RX));
|
2023-10-03 15:09:25 +00:00
|
|
|
}
|
2023-12-11 23:45:09 +00:00
|
|
|
else if (gCurrentFunction == FUNCTION_POWER_SAVE) {
|
|
|
|
memcpy(line + x, BITMAP_POWERSAVE, sizeof(BITMAP_POWERSAVE));
|
2023-09-19 19:04:02 +00:00
|
|
|
}
|
2023-12-11 23:45:09 +00:00
|
|
|
x += 8;
|
|
|
|
unsigned int x1 = x;
|
|
|
|
|
|
|
|
#ifdef ENABLE_NOAA
|
|
|
|
if (gIsNoaaMode) { // NOASS SCAN indicator
|
|
|
|
memcpy(line + x, BITMAP_NOAA, sizeof(BITMAP_NOAA));
|
|
|
|
x1 = x + sizeof(BITMAP_NOAA);
|
|
|
|
}
|
|
|
|
x += sizeof(BITMAP_NOAA);
|
|
|
|
#endif
|
2023-11-28 19:11:03 +00:00
|
|
|
|
|
|
|
#ifdef ENABLE_DTMF_CALLING
|
2023-12-11 23:45:09 +00:00
|
|
|
if (gSetting_KILLED) {
|
2023-09-19 19:04:02 +00:00
|
|
|
memset(line + x, 0xFF, 10);
|
|
|
|
x1 = x + 10;
|
|
|
|
}
|
2023-12-25 00:35:06 +00:00
|
|
|
else
|
2023-12-11 23:52:26 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FMRADIO
|
|
|
|
if (gFmRadioMode) { // FM indicator
|
|
|
|
memcpy(line + x, BITMAP_FM, sizeof(BITMAP_FM));
|
|
|
|
x1 = x + sizeof(BITMAP_FM);
|
|
|
|
}
|
|
|
|
else
|
2023-11-28 19:11:03 +00:00
|
|
|
#endif
|
2023-12-11 23:45:09 +00:00
|
|
|
{ // SCAN indicator
|
|
|
|
if (gScanStateDir != SCAN_OFF || SCANNER_IsScanning()) {
|
2023-10-27 18:11:22 +00:00
|
|
|
char * s = "";
|
2023-12-11 23:45:09 +00:00
|
|
|
if (IS_MR_CHANNEL(gNextMrChannel) && !SCANNER_IsScanning()) { // channel mode
|
2023-10-27 18:11:22 +00:00
|
|
|
switch(gEeprom.SCAN_LIST_DEFAULT) {
|
|
|
|
case 0: s = "1"; break;
|
|
|
|
case 1: s = "2"; break;
|
|
|
|
case 2: s = "*"; break;
|
|
|
|
}
|
2023-10-05 22:58:55 +00:00
|
|
|
}
|
2023-12-11 23:45:09 +00:00
|
|
|
else { // frequency mode
|
2023-10-27 18:11:22 +00:00
|
|
|
s = "S";
|
2023-10-05 22:58:55 +00:00
|
|
|
}
|
2023-12-25 00:35:06 +00:00
|
|
|
UI_PrintStringSmallBufferNormal(s, line + x + 1);
|
2023-12-11 23:52:26 +00:00
|
|
|
x1 = x + 10;
|
2023-09-19 19:04:02 +00:00
|
|
|
}
|
2023-11-28 19:11:03 +00:00
|
|
|
}
|
2023-12-11 23:52:26 +00:00
|
|
|
x += 10; // font character width
|
2023-09-09 07:03:56 +00:00
|
|
|
|
2023-12-11 23:45:09 +00:00
|
|
|
#ifdef ENABLE_VOICE
|
|
|
|
// VOICE indicator
|
|
|
|
if (gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF){
|
|
|
|
memcpy(line + x, BITMAP_VoicePrompt, sizeof(BITMAP_VoicePrompt));
|
|
|
|
x1 = x + sizeof(BITMAP_VoicePrompt);
|
|
|
|
}
|
2023-12-11 23:52:26 +00:00
|
|
|
x += sizeof(BITMAP_VoicePrompt);
|
2023-12-11 23:45:09 +00:00
|
|
|
#endif
|
2023-09-18 14:06:35 +00:00
|
|
|
|
2023-11-06 00:25:44 +00:00
|
|
|
if(!SCANNER_IsScanning()) {
|
2023-10-17 00:57:55 +00:00
|
|
|
uint8_t dw = (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2;
|
2023-10-27 18:11:22 +00:00
|
|
|
if(dw == 1 || dw == 3) { // DWR - dual watch + respond
|
2023-12-25 00:35:06 +00:00
|
|
|
if(gDualWatchActive)
|
2023-12-11 23:52:26 +00:00
|
|
|
memcpy(line + x + (dw==1?0:2), BITMAP_TDR1, sizeof(BITMAP_TDR1) - (dw==1?0:5));
|
2023-12-25 00:35:06 +00:00
|
|
|
else
|
2023-12-11 23:45:09 +00:00
|
|
|
memcpy(line + x + 3, BITMAP_TDR2, sizeof(BITMAP_TDR2));
|
2023-10-17 00:57:55 +00:00
|
|
|
}
|
|
|
|
else if(dw == 2) { // XB - crossband
|
2023-12-11 23:52:26 +00:00
|
|
|
memcpy(line + x + 2, BITMAP_XB, sizeof(BITMAP_XB));
|
2023-10-17 00:57:55 +00:00
|
|
|
}
|
2023-09-19 19:04:02 +00:00
|
|
|
}
|
2023-12-11 23:52:26 +00:00
|
|
|
x += sizeof(BITMAP_TDR1) + 1;
|
2023-12-25 00:35:06 +00:00
|
|
|
|
2023-12-11 23:45:09 +00:00
|
|
|
#ifdef ENABLE_VOX
|
|
|
|
// VOX indicator
|
|
|
|
if (gEeprom.VOX_SWITCH) {
|
|
|
|
memcpy(line + x, BITMAP_VOX, sizeof(BITMAP_VOX));
|
2023-12-11 23:52:26 +00:00
|
|
|
x1 = x + sizeof(BITMAP_VOX) + 1;
|
2023-12-11 23:45:09 +00:00
|
|
|
}
|
2023-12-11 23:52:26 +00:00
|
|
|
x += sizeof(BITMAP_VOX) + 1;
|
2023-12-11 23:45:09 +00:00
|
|
|
#endif
|
2023-09-09 07:03:56 +00:00
|
|
|
|
2023-12-11 23:52:26 +00:00
|
|
|
x = MAX(x1, 61u);
|
2023-10-15 19:42:17 +00:00
|
|
|
|
2023-09-18 14:06:35 +00:00
|
|
|
// KEY-LOCK indicator
|
2023-12-11 23:45:09 +00:00
|
|
|
if (gEeprom.KEY_LOCK) {
|
|
|
|
memcpy(line + x, BITMAP_KeyLock, sizeof(BITMAP_KeyLock));
|
2023-09-19 19:04:02 +00:00
|
|
|
x += sizeof(BITMAP_KeyLock);
|
|
|
|
x1 = x;
|
2023-09-19 06:59:06 +00:00
|
|
|
}
|
2023-12-11 23:45:09 +00:00
|
|
|
else if (gWasFKeyPressed) {
|
|
|
|
memcpy(line + x, BITMAP_F_Key, sizeof(BITMAP_F_Key));
|
2023-09-19 19:04:02 +00:00
|
|
|
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
|
2023-12-25 00:35:06 +00:00
|
|
|
char s[8] = "";
|
2023-12-11 23:52:26 +00:00
|
|
|
unsigned int x2 = LCD_WIDTH - sizeof(BITMAP_BatteryLevel1) - 0;
|
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-12-11 23:45:09 +00:00
|
|
|
switch (gSetting_battery_text) {
|
2023-09-19 19:04:02 +00:00
|
|
|
default:
|
|
|
|
case 0:
|
|
|
|
break;
|
2023-12-25 00:35:06 +00:00
|
|
|
|
2023-12-11 23:45:09 +00:00
|
|
|
case 1: { // voltage
|
2023-09-19 19:04:02 +00:00
|
|
|
const uint16_t voltage = (gBatteryVoltageAverage <= 999) ? gBatteryVoltageAverage : 999; // limit to 9.99V
|
|
|
|
sprintf(s, "%u.%02uV", voltage / 100, voltage % 100);
|
|
|
|
break;
|
|
|
|
}
|
2023-12-25 00:35:06 +00:00
|
|
|
|
2023-09-19 19:04:02 +00:00
|
|
|
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
|
|
|
break;
|
|
|
|
}
|
2023-12-11 23:45:09 +00:00
|
|
|
|
|
|
|
unsigned int space_needed = (7 * strlen(s));
|
|
|
|
if (x2 >= (x1 + space_needed))
|
2023-12-25 00:35:06 +00:00
|
|
|
UI_PrintStringSmallBufferNormal(s, line + x2 - space_needed);
|
2023-09-19 06:59:06 +00:00
|
|
|
}
|
2023-12-25 00:35:06 +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-12-25 00:35:06 +00:00
|
|
|
|
2023-09-18 14:06:35 +00:00
|
|
|
// USB-C charge indicator
|
2023-10-27 18:11:22 +00:00
|
|
|
if (gChargingWithTypeC)
|
2023-12-11 23:45:09 +00:00
|
|
|
memcpy(line + x, BITMAP_USB_C, sizeof(BITMAP_USB_C));
|
2023-09-19 19:04:02 +00:00
|
|
|
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-10-09 23:37:29 +00:00
|
|
|
UI_DrawBattery(line + x, gBatteryDisplayLevel, gLowBatteryBlink);
|
2023-12-25 00:35:06 +00:00
|
|
|
|
2023-09-19 19:04:02 +00:00
|
|
|
// **************
|
2023-09-09 07:03:56 +00:00
|
|
|
|
|
|
|
ST7565_BlitStatusLine();
|
|
|
|
}
|