sbar-calibration-new-layout

pull/16/head release-18
Piotr Lewandowski 2023-07-06 00:46:29 +02:00
rodzic 474fccbcfe
commit 554d44752a
5 zmienionych plików z 109 dodań i 27 usunięć

Wyświetl plik

@ -1,4 +1,12 @@
# UV_K5_playground
## src/rssi_sbar ![auto release build](https://github.com/piotr022/UV_K5_playground/actions/workflows/c-cpp.yml/badge.svg)
![rssi printer](./docs/rssi_sbar.png)
sbar with calibrated S steps
* download mod [uv_k5_01_26_rssi_sbar_encoded.bin](https://github.com/piotr022/UV_K5_playground/releases/latest)
* flash with original quansheng update tool
Please, consider paying tribute to the two fallen Quashengs that were bricked during the development process. Their sacrifice played a crucial role in shaping this project. To show your appreciation and support for our ongoing work, you can make a [donation](https://paypal.me/sq9p).
## src/spectrum ![auto release build](https://github.com/piotr022/UV_K5_playground/actions/workflows/c-cpp.yml/badge.svg)
![rssi printer](./docs/spectrum.png)
It's still in beta. It prints a spectrum graph that covers +/- 1 MHz from the center frequency. Overall, it prints 2 MHz of the band.
@ -8,8 +16,6 @@ It's still in beta. It prints a spectrum graph that covers +/- 1 MHz from the ce
* (optional) turn down the volume
* to disable, power off radio xD
Please, consider paying tribute to the two fallen Quashengs that were bricked during the development process. Their sacrifice played a crucial role in shaping this project. To show your appreciation and support for our ongoing work, you can make a [donation](https://paypal.me/sq9p).
## src/rssi_printer ![auto release build](https://github.com/piotr022/UV_K5_playground/actions/workflows/c-cpp.yml/badge.svg)
![rssi printer](./docs/rssi_printer.png)
mod for printing rx signal level (RSSI) in numerical format, also includes small signal level chart.

BIN
docs/rssi_sbar.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 251 KiB

Wyświetl plik

@ -55,10 +55,10 @@ struct TGpio
#define GPIOA_BASE 0x40060000
#define GPIOA ((TGpio*)GPIOC_BASE)
#define GPIOA ((TGpio*)GPIOA_BASE)
#define GPIOB_BASE 0x40060800
#define GPIOB ((TGpio*)GPIOC_BASE)
#define GPIOB ((TGpio*)GPIOB_BASE)
#define GPIOC_BASE 0x40061000
#define GPIOC ((TGpio*)GPIOC_BASE)

Wyświetl plik

@ -52,6 +52,7 @@ namespace System
{
unsigned char* pDisplayBuffer;
unsigned char* pSmallDigs;
unsigned char* pSmallLeters;
};
inline const TOrgFunctions OrgFunc_01_26 =
@ -71,7 +72,7 @@ namespace System
{
.pDisplayBuffer = (decltype(TOrgData::pDisplayBuffer)) 0x20000704,
.pSmallDigs = (decltype(TOrgData::pSmallDigs)) 0xD620,
.pSmallLeters = (decltype(TOrgData::pSmallLeters)) 0xD348,
};
}

Wyświetl plik

@ -2,15 +2,55 @@
#include "system.hpp"
#include "uv_k5_display.hpp"
namespace Rssi
{
inline const unsigned char U8RssiMap[] =
{
141,
135,
129,
123,
117,
111,
105,
99,
93,
83,
73,
63,
53,
};
struct TRssi
{
TRssi(unsigned char u8Val)
{
unsigned char i;
for (i = 0; i < sizeof(U8RssiMap); i++)
{
if (u8Val >= U8RssiMap[i])
{
u8SValue = i + 1;
return;
}
}
u8SValue = i + 1;
}
unsigned char u8SValue;
};
}
class CRssiPrinter
{
public:
static constexpr auto ChartStartX = 32;
public:
static constexpr auto ChartStartX = 5 * 7 + 8 + 3*7;//32;
static constexpr auto BlockSizeX = 4;
static constexpr auto BlockSizeY = 7;
static constexpr auto BlockSpace = 1;
static constexpr auto BlocksCnt = (128 - ChartStartX) / (BlockSizeX + BlockSpace);
static void Handle(const System::TOrgFunctions& Fw, const System::TOrgData& FwData)
static constexpr auto LinearBlocksCnt = 9;
static void Handle(const System::TOrgFunctions &Fw, const System::TOrgData &FwData)
{
static bool bIsCleared = true;
static unsigned char u8SqlDelayCnt = 0xFF;
@ -19,25 +59,25 @@ class CRssiPrinter
const TUV_K5SmallNumbers FontSmallNr(FwData.pSmallDigs);
CDisplay Display(DisplayBuff);
if(!(GPIOC->DATA & 0b1))
if (!(GPIOC->DATA & 0b1))
{
return;
}
auto* pMenuCheckData = (unsigned char*)DisplayBuff.GetCoursorData(DisplayBuff.GetCoursorPosition(2, 6*8 + 1));
if(Fw.BK4819Read(0x0C) & 0b10)
auto *pMenuCheckData = (unsigned char *)DisplayBuff.GetCoursorData(DisplayBuff.GetCoursorPosition(2, 6 * 8 + 1));
if (Fw.BK4819Read(0x0C) & 0b10)
{
u8SqlDelayCnt = 0;
}
if(u8SqlDelayCnt > 20 || *pMenuCheckData == 0xFF)
auto *pDData = (unsigned char *)DisplayBuff.GetCoursorData(DisplayBuff.GetCoursorPosition(3, 0));
if (u8SqlDelayCnt > 20 || *pMenuCheckData == 0xFF)
{
if(!bIsCleared)
if (!bIsCleared)
{
bIsCleared = true;
auto* pDData = (unsigned char*)DisplayBuff.GetCoursorData(DisplayBuff.GetCoursorPosition(3, 0));
memset(pDData, 0, DisplayBuff.SizeX);
if(*pMenuCheckData != 0xFF)
if (*pMenuCheckData != 0xFF)
{
Fw.FlushFramebufferToScreen();
}
@ -49,23 +89,21 @@ class CRssiPrinter
u8SqlDelayCnt++;
bIsCleared = false;
auto* pDData = (unsigned char*)DisplayBuff.GetCoursorData(DisplayBuff.GetCoursorPosition(3, 0));
memset(pDData, 0, DisplayBuff.SizeX);
Display.SetCoursor(3, 0);
Display.SetFont(&FontSmallNr);
char C8RssiString[] = "g000";
unsigned char u8Rssi = ((Fw.BK4819Read(0x67) >> 1) & 0xFF);
if(!u8Rssi)
if (!u8Rssi)
{
return;
}
if(u8Rssi > 160)
if (u8Rssi > 160)
{
u8Rssi -= 160;
C8RssiString[0] = ' ';
}
else
{
@ -73,23 +111,60 @@ class CRssiPrinter
C8RssiString[0] = '-';
}
C8RssiString[1] = '0' + u8Rssi / 100;
C8RssiString[2] = '0' + (u8Rssi / 10) % 10;
C8RssiString[3] = '0' + u8Rssi % 10;
unsigned char u8RssiCpy = u8Rssi;
unsigned char hundreds = 0;
while (u8RssiCpy >= 100)
{
hundreds++;
u8RssiCpy -= 100;
}
unsigned char tens = 0;
while (u8RssiCpy >= 10)
{
tens++;
u8RssiCpy -= 10;
}
C8RssiString[1] = '0' + hundreds;
C8RssiString[2] = '0' + tens;
C8RssiString[3] = '0' + u8RssiCpy;
Display.Print(C8RssiString);
unsigned char u8Sub = (u8Rssi * BlocksCnt) >> 7;
unsigned char u8BlocksToFill = (u8Sub > BlocksCnt ? BlocksCnt : u8Sub);
u8BlocksToFill = BlocksCnt - u8BlocksToFill;
for(unsigned char i = 0; i < u8BlocksToFill; i++)
u8BlocksToFill = Rssi::TRssi(u8Rssi).u8SValue;
char C8SignalString[] = " ";
if (u8BlocksToFill > 9)
{
memcpy(pDData + 5*7, FwData.pSmallLeters + 109 - 3*8, 8);
C8SignalString[1] = '0';
C8SignalString[0] = '0' + u8BlocksToFill - 9;
}
else
{
memcpy(pDData + 5 * 7, FwData.pSmallLeters + 109, 8);
C8SignalString[0] = '0' + u8BlocksToFill;
C8SignalString[1] = ' ';
}
Display.SetCoursor(3, 5 * 7 + 8);
Display.Print(C8SignalString);
for (unsigned char i = 0; i < u8BlocksToFill; i++)
{
unsigned char u8BlockHeight = i + 1 > BlockSizeY ? BlockSizeY : i + 1;
unsigned char u8X = i * (BlockSizeX + BlockSpace) + ChartStartX;
Display.DrawRectangle(u8X, 24, BlockSizeX, BlockSizeY, true);
Display.DrawRectangle(u8X, 24 + BlockSizeY - u8BlockHeight, BlockSizeX,
u8BlockHeight, i < LinearBlocksCnt);
}
// Turn the proper pixel on, and the ones below it on as well
// The code to turn just the correct pixel on is: U8ScreenHistory[u8ChartPosition - ChartStartX] = (1 << u8PrintShift) & 0xFF;
// U8ScreenHistory[u8ChartPosition - ChartStartX] = ~(0xFF >> (7 - u8PrintShift));
// memcpy(pDData, FwData.pSmallLeters, 256 * 2);
Fw.FlushFramebufferToScreen();
}
};