This repository has been archived by the owner on Mar 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
/
main.c
118 lines (107 loc) · 3.04 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/* 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 "app/radio.h"
#include "driver/battery.h"
#include "helper/dtmf.h"
#include "helper/inputbox.h"
#include "misc.h"
#include "radio/settings.h"
#include "ui/gfx.h"
#include "ui/helper.h"
#include "ui/main.h"
#include "ui/vfo.h"
static void DrawStatusBar(void)
{
DISPLAY_Fill(0, 159, 0, 96, COLOR_BLACK);
DISPLAY_DrawRectangle0(0, 41, 160, 1, gSettings.BorderColor);
if (gSettings.DtmfState == DTMF_STATE_STUNNED) {
UI_DrawStatusIcon(4, ICON_LOCK, true, COLOR_RED);
} else {
UI_DrawStatusIcon(4, ICON_LOCK, gSettings.Lock, COLOR_WHITE);
}
UI_DrawStatusIcon(56, ICON_DUAL_WATCH, gSettings.DualStandby, COLOR_WHITE);
UI_DrawStatusIcon(80, ICON_VOX, gSettings.Vox, COLOR_WHITE);
UI_DrawRoger();
UI_DrawRepeaterMode();
UI_DrawStatusIcon(139, ICON_BATTERY, true, COLOR_WHITE);
UI_DrawBattery();
}
void UI_DrawMain(bool bSkipStatus)
{
if (bSkipStatus) {
DISPLAY_Fill(0, 159, 0, 81, COLOR_BLACK);
DISPLAY_DrawRectangle0(0, 41, 160, 1, gSettings.BorderColor);
} else {
DrawStatusBar();
}
if (gSettings.DualDisplay == 0 && (gRadioMode != RADIO_MODE_RX || gSettings.CurrentVfo == gCurrentVfo)) {
UI_DrawVfo(gSettings.CurrentVfo);
UI_DrawVoltage(!gSettings.CurrentVfo);
} else {
UI_DrawVfo(!gCurrentVfo);
UI_DrawVfo(gCurrentVfo);
}
if (gInputBoxWriteIndex != 0) {
if (gSettings.WorkMode) {
UI_DrawDigits(gInputBox, gSettings.CurrentVfo);
} else {
UI_DrawFrequencyEx(gInputBox, gSettings.CurrentVfo, gFrequencyReverse);
}
}
if (gRadioMode != RADIO_MODE_RX && gRadioMode != RADIO_MODE_TX) {
UI_DrawMainBitmap(true, gSettings.CurrentVfo);
}
if (gRadioMode == RADIO_MODE_RX && gDTMF_WriteIndex != 0) {
gDataDisplay = false;
UI_DrawDTMFString();
if (gDTMF_Settings.Display) {
gDataDisplay = true;
}
}
}
void UI_DrawRepeaterMode(void)
{
switch (gSettings.RepeaterMode) {
case 1:
UI_DrawStatusIcon(109, ICON_RR, true, COLOR_WHITE);
break;
case 2:
UI_DrawStatusIcon(109, ICON_TR, true, COLOR_WHITE);
break;
default:
UI_DrawStatusIcon(109, ICON_TR, false, COLOR_WHITE);
break;
}
}
void UI_DrawBattery(void)
{
uint8_t i;
uint16_t Color;
for (i = 15; i > 0; i--) {
if (gBatteryVoltage > gCalibration.BatteryCalibration[i - 1]) {
break;
}
}
if (i < 6) {
Color = COLOR_RED;
} else if (i < 11) {
Color = COLOR_RGB(31, 41, 0);
} else {
Color = COLOR_GREEN;
}
DISPLAY_DrawRectangle0(142, 86, 15 - i, 8, gColorBackground);
DISPLAY_DrawRectangle0(157 - i, 86, i, 8, Color);
}