0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 22:31:25 +03:00

98 lines
2.4 KiB
C
Raw Normal View History

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