Moved RSSI display to ui/.

This commit is contained in:
Dual Tachyon 2023-08-28 19:44:58 +01:00
parent 7b6ed41849
commit bb78207a18
6 changed files with 120 additions and 72 deletions

View File

@ -61,6 +61,7 @@ OBJS += ui/helper.o
OBJS += ui/inputbox.o
OBJS += ui/main.o
OBJS += ui/menu.o
OBJS += ui/rssi.o
OBJS += ui/scanner.o
OBJS += main.o

View File

@ -44,6 +44,7 @@
#include "sram-overlay.h"
#include "ui/inputbox.h"
#include "ui/menu.h"
#include "ui/rssi.h"
static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);
void FUN_000069f8(FUNCTION_Type_t Function);
@ -942,7 +943,7 @@ void APP_Update(void)
gThisCanEnable_BK4819_Rxon = false;
} else if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF || gStepDirection != 0 || g_20000381 != 0 || g_20000382 != 0) {
gCurrentRSSI = BK4819_GetRSSI();
GUI_DisplayRSSI(gCurrentRSSI);
UI_UpdateRSSI(gCurrentRSSI);
gBatterySave = gEeprom.BATTERY_SAVE * 10;
gThisCanEnable_BK4819_Rxon = true;
BK4819_DisableVox();
@ -1226,7 +1227,7 @@ void APP_TimeSlice500ms(void)
}
if (gCurrentFunction != FUNCTION_POWER_SAVE) {
gCurrentRSSI = BK4819_GetRSSI();
GUI_DisplayRSSI(gCurrentRSSI);
UI_UpdateRSSI(gCurrentRSSI);
if (gCurrentFunction == FUNCTION_TRANSMIT) {
goto LAB_00004b08;
}

67
gui.c
View File

@ -304,70 +304,3 @@ void GUI_SelectNextDisplay(GUI_DisplayType_t Display)
}
}
void GUI_RenderRSSI(uint8_t RssiLevel, uint8_t VFO)
{
uint8_t *pLine;
uint8_t Line;
bool bIsClearMode;
if (gCurrentFunction == FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN) {
return;
}
if (VFO == 0) {
pLine = gFrameBuffer[2];
Line = 3;
} else {
pLine = gFrameBuffer[6];
Line = 7;
}
memset(pLine, 0, 23);
if (RssiLevel == 0) {
pLine = NULL;
bIsClearMode = true;
} else {
memcpy(pLine, BITMAP_Antenna,5);
memcpy(pLine + 5,BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1));
if (RssiLevel >= 2) {
memcpy(pLine + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2));
}
if (RssiLevel >= 3) {
memcpy(pLine + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3));
}
if (RssiLevel >= 4) {
memcpy(pLine + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4));
}
if (RssiLevel >= 5) {
memcpy(pLine + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5));
}
if (RssiLevel >= 6) {
memcpy(pLine + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6));
}
bIsClearMode = false;
}
ST7565_DrawLine(0, Line, 23 , pLine, bIsClearMode);
}
void GUI_DisplayRSSI(uint16_t RSSI)
{
uint8_t Level;
if (RSSI >= gEEPROM_RSSI_CALIB[gInfoCHAN_A->Band][3]) {
Level = 6;
} else if (RSSI >= gEEPROM_RSSI_CALIB[gInfoCHAN_A->Band][2]) {
Level = 4;
} else if (RSSI >= gEEPROM_RSSI_CALIB[gInfoCHAN_A->Band][1]) {
Level = 2;
} else if (RSSI >= gEEPROM_RSSI_CALIB[gInfoCHAN_A->Band][0]) {
Level = 1;
} else {
Level = 0;
}
if (gVFO_RSSI_Level[gEeprom.RX_CHANNEL] != Level) {
gVFO_RSSI_Level[gEeprom.RX_CHANNEL] = Level;
GUI_RenderRSSI(Level, gEeprom.RX_CHANNEL);
}
}

3
gui.h
View File

@ -50,8 +50,5 @@ void GUI_DisplayStatusLine(void);
void GUI_DisplayScreen(void);
void GUI_SelectNextDisplay(GUI_DisplayType_t Display);
void GUI_RenderRSSI(uint8_t RssiLevel, uint8_t VFO);
void GUI_DisplayRSSI(uint16_t RSSI);
#endif

93
ui/rssi.c Normal file
View File

@ -0,0 +1,93 @@
/* 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 "bitmaps.h"
#include "driver/st7565.h"
#include "functions.h"
#include "gui.h"
#include "misc.h"
#include "settings.h"
#include "ui/rssi.h"
static void Render(uint8_t RssiLevel, uint8_t VFO)
{
uint8_t *pLine;
uint8_t Line;
bool bIsClearMode;
if (gCurrentFunction == FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN) {
return;
}
if (VFO == 0) {
pLine = gFrameBuffer[2];
Line = 3;
} else {
pLine = gFrameBuffer[6];
Line = 7;
}
memset(pLine, 0, 23);
if (RssiLevel == 0) {
pLine = NULL;
bIsClearMode = true;
} else {
memcpy(pLine, BITMAP_Antenna,5);
memcpy(pLine + 5,BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1));
if (RssiLevel >= 2) {
memcpy(pLine + 8, BITMAP_AntennaLevel2, sizeof(BITMAP_AntennaLevel2));
}
if (RssiLevel >= 3) {
memcpy(pLine + 11, BITMAP_AntennaLevel3, sizeof(BITMAP_AntennaLevel3));
}
if (RssiLevel >= 4) {
memcpy(pLine + 14, BITMAP_AntennaLevel4, sizeof(BITMAP_AntennaLevel4));
}
if (RssiLevel >= 5) {
memcpy(pLine + 17, BITMAP_AntennaLevel5, sizeof(BITMAP_AntennaLevel5));
}
if (RssiLevel >= 6) {
memcpy(pLine + 20, BITMAP_AntennaLevel6, sizeof(BITMAP_AntennaLevel6));
}
bIsClearMode = false;
}
ST7565_DrawLine(0, Line, 23 , pLine, bIsClearMode);
}
void UI_UpdateRSSI(uint16_t RSSI)
{
uint8_t Level;
if (RSSI >= gEEPROM_RSSI_CALIB[gInfoCHAN_A->Band][3]) {
Level = 6;
} else if (RSSI >= gEEPROM_RSSI_CALIB[gInfoCHAN_A->Band][2]) {
Level = 4;
} else if (RSSI >= gEEPROM_RSSI_CALIB[gInfoCHAN_A->Band][1]) {
Level = 2;
} else if (RSSI >= gEEPROM_RSSI_CALIB[gInfoCHAN_A->Band][0]) {
Level = 1;
} else {
Level = 0;
}
if (gVFO_RSSI_Level[gEeprom.RX_CHANNEL] != Level) {
gVFO_RSSI_Level[gEeprom.RX_CHANNEL] = Level;
Render(Level, gEeprom.RX_CHANNEL);
}
}

23
ui/rssi.h Normal file
View File

@ -0,0 +1,23 @@
/* 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.
*/
#ifndef UI_RSSI_H
#define UI_RSSI_H
void UI_UpdateRSSI(uint16_t RSSI);
#endif