kopia lustrzana https://github.com/piotr022/UV_K5_playground
rodzic
74da1c24ec
commit
b4dad1ec2c
|
@ -12,6 +12,7 @@ target_include_directories(${NAME} PRIVATE
|
|||
target_sources(${NAME} PRIVATE
|
||||
system.cpp
|
||||
vtable.s
|
||||
api.s
|
||||
)
|
||||
|
||||
target_link_libraries(${NAME}
|
||||
|
|
|
@ -0,0 +1,159 @@
|
|||
.globl PrintTextOnScreen
|
||||
PrintTextOnScreen = 0x874C + 1;
|
||||
|
||||
.globl DelayMs
|
||||
DelayMs = 0xD0EC + 1;
|
||||
|
||||
.globl DelayUs
|
||||
DelayUs = 0xD100 + 1;
|
||||
|
||||
.globl WriteSerialData
|
||||
WriteSerialData = 0xBE44 + 1;
|
||||
|
||||
.globl BK4819Write
|
||||
BK4819Write = 0xAF00 + 1;
|
||||
|
||||
.globl BK4819Read
|
||||
BK4819Read = 0xA960 + 1;
|
||||
|
||||
.globl FlushFramebufferToScreen
|
||||
FlushFramebufferToScreen = 0xB638 + 1;
|
||||
|
||||
.globl PollKeyboard
|
||||
PollKeyboard = 0xb0b8 + 1;
|
||||
|
||||
.globl FormatString
|
||||
FormatString = 0xC6E8 + 1;
|
||||
|
||||
.globl PrintSmallDigits
|
||||
PrintSmallDigits = 0x870C + 1;
|
||||
|
||||
.globl PrintFrequency
|
||||
PrintFrequency = 0x864C + 1;
|
||||
|
||||
.globl AirCopy72
|
||||
AirCopy72 = 0xA67C + 1;
|
||||
|
||||
.globl AirCopyFskSetup
|
||||
AirCopyFskSetup = 0xA518 + 1;
|
||||
|
||||
.globl BK4819Reset
|
||||
BK4819Reset = 0xa7cc + 1;
|
||||
|
||||
.globl IntDivide
|
||||
IntDivide = 0x128 + 1;
|
||||
|
||||
.globl BK4819WriteFrequency
|
||||
BK4819WriteFrequency = 0xaabc + 1;
|
||||
|
||||
.globl BK4819SetPaGain
|
||||
BK4819SetPaGain = 0xaad4 + 1;
|
||||
|
||||
.globl BK4819ConfigureAndStartTxFsk
|
||||
BK4819ConfigureAndStartTxFsk = 0x1cd8 + 1;
|
||||
|
||||
.globl BK4819ConfigureAndStartRxFsk
|
||||
BK4819ConfigureAndStartRxFsk = 0xa63c + 1;
|
||||
|
||||
.globl BK4819SetGpio
|
||||
BK4819SetGpio = 0xa794 + 1;
|
||||
|
||||
.globl FlushStatusbarBufferToScreen
|
||||
FlushStatusbarBufferToScreen = 0xb6b0 + 1;
|
||||
|
||||
.globl UpdateStatusBar
|
||||
UpdateStatusBar = 0x9c10 + 1;
|
||||
|
||||
.globl AdcReadout
|
||||
AdcReadout = 0x9d7c + 1;
|
||||
|
||||
.globl SomeAmStuff
|
||||
SomeAmStuff = 0xc158 + 1;
|
||||
|
||||
.globl IRQ_RESET
|
||||
IRQ_RESET = 0xd4 + 1;
|
||||
|
||||
.globl IRQ_SYSTICK
|
||||
IRQ_SYSTICK = 0xc398 + 1;
|
||||
|
||||
.globl ConfigureTrimValuesFromNVR
|
||||
ConfigureTrimValuesFromNVR = 0x20000230 + 1;
|
||||
|
||||
.globl FLASH_ReadNvrWord
|
||||
FLASH_ReadNvrWord = 0x20000214 + 1;
|
||||
|
||||
.globl SystemReset
|
||||
SystemReset = 0x200001f8 + 1;
|
||||
|
||||
.globl FLASH_SetProgramTime
|
||||
FLASH_SetProgramTime = 0x200001d4 + 1;
|
||||
|
||||
.globl FLASH_SetMode
|
||||
FLASH_SetMode = 0x200001b4 + 1;
|
||||
|
||||
.globl FLASH_WakeFromDeepSleep
|
||||
FLASH_WakeFromDeepSleep = 0x20000194 + 1;
|
||||
|
||||
.globl FLASH_SetEraseTime
|
||||
FLASH_SetEraseTime = 0x20000170 + 1;
|
||||
|
||||
.globl FLASH_SetReadMode
|
||||
FLASH_SetReadMode = 0x20000148 + 1;
|
||||
|
||||
.globl FLASH_Set_NVR_SEL
|
||||
FLASH_Set_NVR_SEL = 0x20000128 + 1;
|
||||
|
||||
.globl FLASH_ReadByAPB
|
||||
FLASH_ReadByAPB = 0x200000e8 + 1;
|
||||
|
||||
.globl FLASH_ReadByAHB
|
||||
FLASH_ReadByAHB = 0x200000dc + 1;
|
||||
|
||||
.globl FLASH_Unlock
|
||||
FLASH_Unlock = 0x200000d0 + 1;
|
||||
|
||||
.globl FLASH_Lock
|
||||
FLASH_Lock = 0x200000c4 + 1;
|
||||
|
||||
.globl FLASH_MaskUnlock
|
||||
FLASH_MaskUnlock = 0x200000b0 + 1;
|
||||
|
||||
.globl FLASH_SetMaskSel
|
||||
FLASH_SetMaskSel = 0x20000094 + 1;
|
||||
|
||||
.globl FLASH_MaskLock
|
||||
FLASH_MaskLock = 0x20000080 + 1;
|
||||
|
||||
.globl FLASH_Init
|
||||
FLASH_Init = 0x2000005c + 1;
|
||||
|
||||
.globl FLASH_Start
|
||||
FLASH_Start = 0x20000044 + 1;
|
||||
|
||||
.globl FLASH_IsInitBusy
|
||||
FLASH_IsInitBusy = 0x2000002c + 1;
|
||||
|
||||
.globl FLASH_IsBusy
|
||||
FLASH_IsBusy = 0x20000014 + 1;
|
||||
|
||||
.globl FLASH_RebootToBootloader
|
||||
FLASH_RebootToBootloader = 0x20000000 + 1;
|
||||
|
||||
.globl gDisplayBuffer
|
||||
gDisplayBuffer = 0x20000704;
|
||||
|
||||
.globl gSmallDigs
|
||||
gSmallDigs = 0xD620;
|
||||
|
||||
.globl gSmallLeters
|
||||
gSmallLeters = 0xD348;
|
||||
|
||||
.globl gFlashLightStatus
|
||||
gFlashLightStatus = 0x200003b3;
|
||||
|
||||
.globl gStatusBarData
|
||||
gStatusBarData = 0x20000684;
|
||||
|
||||
.globl gVoltage
|
||||
gVoltage = 0x20000406;
|
||||
|
|
@ -21,5 +21,5 @@ void System::CopyDataSection()
|
|||
|
||||
extern "C" unsigned int __wrap___udivsi3(unsigned int a, unsigned int b)
|
||||
{
|
||||
return OrgFunc_01_26.IntDivide(a, b);
|
||||
return IntDivide(a, b);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,70 @@
|
|||
#pragma once
|
||||
|
||||
extern "C" {
|
||||
void PrintTextOnScreen(const char* U8Text,
|
||||
unsigned int u32StartPixel,
|
||||
unsigned int u32StopPixel,
|
||||
unsigned int u32LineNumber,
|
||||
unsigned int u32PxPerChar,
|
||||
unsigned int u32Centered
|
||||
);
|
||||
|
||||
void DelayMs(unsigned int u32Ms);
|
||||
void DelayUs(unsigned int u32Us);
|
||||
int WriteSerialData(unsigned char* p8Data, unsigned char u8Len);
|
||||
void BK4819Write(unsigned int u32Address, unsigned int u32Data);
|
||||
unsigned int BK4819Read(unsigned int u32Address);
|
||||
void FlushFramebufferToScreen(void);
|
||||
unsigned int PollKeyboard(void);
|
||||
char* FormatString(char *, const char *, ...);
|
||||
void PrintSmallDigits(unsigned int u32Len, const int* p32Number, int s32X, int s32Y);
|
||||
void PrintFrequency(int frequency,int xpos,int ypos,int param_4,int param_5);
|
||||
void AirCopy72(unsigned char*);
|
||||
void AirCopyFskSetup();
|
||||
void BK4819Reset();
|
||||
int IntDivide(int s32Divident, int s32Divisor);
|
||||
void BK4819WriteFrequency(unsigned int u32Frequency);
|
||||
void BK4819SetPaGain(unsigned short u16PaBias, unsigned int u32Frequency);
|
||||
void BK4819ConfigureAndStartTxFsk();
|
||||
void BK4819ConfigureAndStartRxFsk();
|
||||
void BK4819SetGpio(unsigned int u32Pin, bool bState);
|
||||
void FlushStatusbarBufferToScreen();
|
||||
void UpdateStatusBar();
|
||||
void AdcReadout(unsigned short* p16Data1, unsigned short* p16Data2);
|
||||
void SomeAmStuff(unsigned int u32Param);
|
||||
void IRQ_RESET(void);
|
||||
void IRQ_SYSTICK(void);
|
||||
// API available in the SRAM overlay installed by FW
|
||||
void ConfigureTrimValuesFromNVR(void);
|
||||
unsigned int FLASH_ReadNvrWord(unsigned int u32Offset);
|
||||
void SystemReset(void);
|
||||
void FLASH_SetProgramTime(void);
|
||||
void FLASH_SetMode(unsigned int u32Mode);
|
||||
void FLASH_WakeFromDeepSleep(void);
|
||||
void FLASH_SetEraseTime(void);
|
||||
void FLASH_SetReadMode(unsigned int u32Mode);
|
||||
void FLASH_Set_NVR_SEL(unsigned int u32Sel);
|
||||
unsigned int FLASH_ReadByAPB(unsigned int u32Offset);
|
||||
unsigned int FLASH_ReadByAHB(unsigned int u32Offset);
|
||||
void FLASH_Unlock(void);
|
||||
void FLASH_Lock(void);
|
||||
void FLASH_MaskUnlock(void);
|
||||
void FLASH_SetMaskSel(unsigned int u32Mask);
|
||||
void FLASH_MaskLock(void);
|
||||
void FLASH_Init(unsigned int u32ReadMode);
|
||||
void FLASH_Start(void);
|
||||
int FLASH_IsInitBusy(void);
|
||||
int FLASH_IsBusy(void);
|
||||
int FLASH_RebootToBootloader(void);
|
||||
};
|
||||
|
||||
extern unsigned char gDisplayBuffer[];
|
||||
extern unsigned char gSmallDigs[];
|
||||
extern unsigned char gSmallLeters[];
|
||||
extern unsigned char gFlashLightStatus;
|
||||
extern unsigned char gStatusBarData[];
|
||||
extern unsigned short gVoltage;
|
||||
|
||||
namespace System
|
||||
{
|
||||
using VoidFxPointer = void(*)(void);
|
||||
|
@ -32,94 +98,6 @@ namespace System
|
|||
};
|
||||
|
||||
void CopyDataSection();
|
||||
|
||||
struct TOrgFunctions
|
||||
{
|
||||
void(*PrintTextOnScreen)(const char* U8Text,
|
||||
unsigned int u32StartPixel,
|
||||
unsigned int u32StopPixel,
|
||||
unsigned int u32LineNumber,
|
||||
unsigned int u32PxPerChar,
|
||||
unsigned int u32Centered
|
||||
);
|
||||
|
||||
void(*DelayMs)(unsigned int u32Ms);
|
||||
void(*DelayUs)(unsigned int u32Us);
|
||||
int(*WriteSerialData)(unsigned char* p8Data, unsigned char u8Len);
|
||||
void(*BK4819Write)(unsigned int u32Address, unsigned int u32Data);
|
||||
unsigned int(*BK4819Read)(unsigned int u32Address);
|
||||
void(*FlushFramebufferToScreen)(void);
|
||||
unsigned int(*PollKeyboard)(void);
|
||||
char* (*FormatString)(char *, const char *, ...);
|
||||
void(*PrintSmallDigits)(unsigned int u32Len, const int* p32Number, int s32X, int s32Y);
|
||||
void(*PrintFrequency)(int frequency,int xpos,int ypos,int param_4,int param_5);
|
||||
void(*AirCopy72)(unsigned char*);
|
||||
void(*AirCopyFskSetup)();
|
||||
void(*BK4819Reset)();
|
||||
int(*IntDivide)(int s32Divident, int s32Divisor);
|
||||
void(*BK4819WriteFrequency)(unsigned int u32Frequency);
|
||||
void(*BK4819SetPaGain)(unsigned short u16PaBias, unsigned int u32Frequency);
|
||||
void(*BK4819ConfigureAndStartTxFsk)();
|
||||
void(*BK4819ConfigureAndStartRxFsk)();
|
||||
void(*BK4819SetGpio)(unsigned int u32Pin, bool bState);
|
||||
void(*FlushStatusbarBufferToScreen)();
|
||||
void(*UpdateStatusBar)();
|
||||
void(*AdcReadout)(unsigned short* p16Data1, unsigned short* p16Data2);
|
||||
void(*SomeAmStuff)(unsigned int u32Param);
|
||||
void (*IRQ_RESET)(void);
|
||||
void (*IRQ_SYSTICK)(void);
|
||||
|
||||
};
|
||||
|
||||
struct TOrgData
|
||||
{
|
||||
unsigned char* pDisplayBuffer;
|
||||
unsigned char* pSmallDigs;
|
||||
unsigned char* pSmallLeters;
|
||||
unsigned char* p8FlashLightStatus;
|
||||
unsigned char* pStatusBarData;
|
||||
unsigned short* p16Voltage;
|
||||
};
|
||||
|
||||
inline const TOrgFunctions OrgFunc_01_26 =
|
||||
{
|
||||
.PrintTextOnScreen = (decltype(TOrgFunctions::PrintTextOnScreen))(0x874C + 1),
|
||||
.DelayMs = (decltype(TOrgFunctions::DelayMs)) (0xD0EC + 1),
|
||||
.DelayUs = (decltype(TOrgFunctions::DelayUs)) (0xD100 + 1),
|
||||
.WriteSerialData = (int(*)(unsigned char*, unsigned char))(0xBE44 + 1),
|
||||
.BK4819Write = (decltype(TOrgFunctions::BK4819Write) (0xAF00 + 1)),
|
||||
.BK4819Read = (decltype(TOrgFunctions::BK4819Read) (0xA960 + 1)),
|
||||
.FlushFramebufferToScreen = (decltype(TOrgFunctions::FlushFramebufferToScreen) (0xB638 + 1)),
|
||||
.PollKeyboard = (decltype(TOrgFunctions::PollKeyboard) (0xb0b8 + 1)),
|
||||
.FormatString = (decltype(TOrgFunctions::FormatString) (0xC6E8 + 1)),
|
||||
.PrintSmallDigits = (decltype(TOrgFunctions::PrintSmallDigits) (0x870C + 1)),
|
||||
.PrintFrequency = (decltype(TOrgFunctions::PrintFrequency) (0x864C + 1)),
|
||||
.AirCopy72 = (decltype(TOrgFunctions::AirCopy72) (0xA67C + 1)),
|
||||
.AirCopyFskSetup = (decltype(TOrgFunctions::AirCopyFskSetup) (0xA518 + 1)),
|
||||
.BK4819Reset = (decltype(TOrgFunctions::BK4819Reset) (0xa7cc + 1)),
|
||||
.IntDivide = (decltype(TOrgFunctions::IntDivide) (0x128 + 1)),
|
||||
.BK4819WriteFrequency = (decltype(TOrgFunctions::BK4819WriteFrequency) (0xaabc + 1)),
|
||||
.BK4819SetPaGain = (decltype(TOrgFunctions::BK4819SetPaGain) (0xaad4 + 1)),
|
||||
.BK4819ConfigureAndStartTxFsk = (decltype(TOrgFunctions::BK4819ConfigureAndStartTxFsk) (0x1cd8 + 1)),
|
||||
.BK4819ConfigureAndStartRxFsk = (decltype(TOrgFunctions::BK4819ConfigureAndStartRxFsk) (0xa63c + 1)),
|
||||
.BK4819SetGpio = (decltype(TOrgFunctions::BK4819SetGpio) (0xa794 + 1)),
|
||||
.FlushStatusbarBufferToScreen = (decltype(TOrgFunctions::FlushStatusbarBufferToScreen) (0xb6b0 + 1)),
|
||||
.UpdateStatusBar = (decltype(TOrgFunctions::UpdateStatusBar) (0x9c10 + 1)),
|
||||
.AdcReadout = (decltype(TOrgFunctions::AdcReadout) (0x9d7c + 1)),
|
||||
.SomeAmStuff = (decltype(TOrgFunctions::SomeAmStuff) (0xc158 + 1)),
|
||||
.IRQ_RESET = (decltype(TOrgFunctions::IRQ_RESET) (0xd4 + 1)),
|
||||
.IRQ_SYSTICK = (decltype(TOrgFunctions::IRQ_SYSTICK) (0xc398 + 1))
|
||||
};
|
||||
|
||||
inline const TOrgData OrgData_01_26 =
|
||||
{
|
||||
.pDisplayBuffer = (decltype(TOrgData::pDisplayBuffer)) 0x20000704,
|
||||
.pSmallDigs = (decltype(TOrgData::pSmallDigs)) 0xD620,
|
||||
.pSmallLeters = (decltype(TOrgData::pSmallLeters)) 0xD348,
|
||||
.p8FlashLightStatus = (decltype(TOrgData::p8FlashLightStatus)) 0x200003b3,
|
||||
.pStatusBarData = (decltype(TOrgData::pStatusBarData)) 0x20000684,
|
||||
.p16Voltage = (decltype(TOrgData::p16Voltage)) 0x20000406,
|
||||
};
|
||||
}
|
||||
|
||||
extern "C" void __libc_init_array();
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "registers.hpp"
|
||||
#include "system.hpp"
|
||||
#include <functional>
|
||||
#include <cstring>
|
||||
|
||||
static constexpr auto operator""_Hz(unsigned long long Hertz) {
|
||||
return Hertz / 10;
|
||||
|
@ -50,7 +51,7 @@ enum class eState : unsigned char {
|
|||
};
|
||||
|
||||
using CallbackRxDoneType = CCallback<void, unsigned char, bool>;
|
||||
template <const System::TOrgFunctions &Fw> class CBK4819 {
|
||||
class CBK4819 {
|
||||
CallbackRxDoneType CallbackRxDone;
|
||||
unsigned char *p8RxBuff;
|
||||
unsigned char u8RxBuffSize;
|
||||
|
@ -60,100 +61,100 @@ public:
|
|||
|
||||
// void SetFrequency(unsigned int u32FrequencyD10)
|
||||
// {
|
||||
// Fw.BK4819WriteFrequency(u32FrequencyD10);
|
||||
// BK4819WriteFrequency(u32FrequencyD10);
|
||||
// }
|
||||
|
||||
static unsigned int GetFrequency() {
|
||||
return (Fw.BK4819Read(0x39) << 16) | Fw.BK4819Read(0x38);
|
||||
return (BK4819Read(0x39) << 16) | BK4819Read(0x38);
|
||||
}
|
||||
|
||||
static signed short GetRssi() {
|
||||
short s16Rssi = ((Fw.BK4819Read(0x67) >> 1) & 0xFF);
|
||||
short s16Rssi = ((BK4819Read(0x67) >> 1) & 0xFF);
|
||||
return s16Rssi - 160;
|
||||
}
|
||||
|
||||
bool IsTx() { return Fw.BK4819Read(0x30) & 0b10; }
|
||||
bool IsTx() { return BK4819Read(0x30) & 0b10; }
|
||||
|
||||
bool IsSqlOpen() { return Fw.BK4819Read(0x0C) & 0b10; }
|
||||
bool IsSqlOpen() { return BK4819Read(0x0C) & 0b10; }
|
||||
|
||||
static void SetFrequency(unsigned int u32Freq) {
|
||||
Fw.BK4819Write(0x39, ((u32Freq >> 16) & 0xFFFF));
|
||||
Fw.BK4819Write(0x38, (u32Freq & 0xFFFF));
|
||||
auto OldReg = Fw.BK4819Read(0x30);
|
||||
Fw.BK4819Write(0x30, 0);
|
||||
Fw.BK4819Write(0x30, OldReg);
|
||||
BK4819Write(0x39, ((u32Freq >> 16) & 0xFFFF));
|
||||
BK4819Write(0x38, (u32Freq & 0xFFFF));
|
||||
auto OldReg = BK4819Read(0x30);
|
||||
BK4819Write(0x30, 0);
|
||||
BK4819Write(0x30, OldReg);
|
||||
}
|
||||
|
||||
void SetAgcTable(unsigned short *p16AgcTable) {
|
||||
for (unsigned char i = 0; i < 5; i++) {
|
||||
Fw.BK4819Write(0x10 + i, p16AgcTable[i]);
|
||||
BK4819Write(0x10 + i, p16AgcTable[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void GetAgcTable(unsigned short *p16AgcTable) {
|
||||
for (unsigned char i = 0; i < 5; i++) {
|
||||
p16AgcTable[i] = Fw.BK4819Read(0x10 + i);
|
||||
p16AgcTable[i] = BK4819Read(0x10 + i);
|
||||
}
|
||||
}
|
||||
|
||||
void SetDeviationPresent(unsigned char u8Present) {
|
||||
auto Reg40 = Fw.BK4819Read(0x40);
|
||||
auto Reg40 = BK4819Read(0x40);
|
||||
Reg40 &= ~(1 << 12);
|
||||
Reg40 |= (u8Present << 12);
|
||||
Fw.BK4819Write(0x40, Reg40);
|
||||
BK4819Write(0x40, Reg40);
|
||||
}
|
||||
|
||||
void SetCalibration(unsigned char bOn) {
|
||||
auto Reg30 = Fw.BK4819Read(0x31);
|
||||
auto Reg30 = BK4819Read(0x31);
|
||||
Reg30 &= ~(1 << 3);
|
||||
Reg30 |= (bOn << 3);
|
||||
Fw.BK4819Write(0x31, Reg30);
|
||||
BK4819Write(0x31, Reg30);
|
||||
}
|
||||
|
||||
unsigned char GetAFAmplitude() { return Fw.BK4819Read(0x6F) & 0b1111111; }
|
||||
unsigned char GetAFAmplitude() { return BK4819Read(0x6F) & 0b1111111; }
|
||||
|
||||
static void ToggleAFDAC(bool enabled) {
|
||||
auto Reg = Fw.BK4819Read(0x30);
|
||||
auto Reg = BK4819Read(0x30);
|
||||
Reg &= ~(1 << 9);
|
||||
if (enabled)
|
||||
Reg |= (1 << 9);
|
||||
Fw.BK4819Write(0x30, Reg);
|
||||
BK4819Write(0x30, Reg);
|
||||
}
|
||||
|
||||
static void ToggleRXDSP(bool enabled) {
|
||||
auto Reg = Fw.BK4819Read(0x30);
|
||||
auto Reg = BK4819Read(0x30);
|
||||
Reg &= ~1;
|
||||
if (enabled)
|
||||
Reg |= 1;
|
||||
Fw.BK4819Write(0x30, Reg);
|
||||
BK4819Write(0x30, Reg);
|
||||
}
|
||||
|
||||
void SendSyncAirCopyMode72(unsigned char *p8Data) {
|
||||
Fw.BK4819ConfigureAndStartTxFsk();
|
||||
Fw.AirCopyFskSetup();
|
||||
Fw.AirCopy72(p8Data);
|
||||
Fw.BK4819SetGpio(1, false);
|
||||
BK4819ConfigureAndStartTxFsk();
|
||||
AirCopyFskSetup();
|
||||
AirCopy72(p8Data);
|
||||
BK4819SetGpio(1, false);
|
||||
}
|
||||
|
||||
void DisablePa() { Fw.BK4819Write(0x30, Fw.BK4819Read(0x30) & ~0b1010); }
|
||||
void DisablePa() { BK4819Write(0x30, BK4819Read(0x30) & ~0b1010); }
|
||||
|
||||
void SetFskMode(eFskMode Mode) {
|
||||
auto const &ModeParams = ModesBits[(int)Mode];
|
||||
auto Reg58 = Fw.BK4819Read(0x58);
|
||||
auto Reg58 = BK4819Read(0x58);
|
||||
Reg58 &= ~((0b111 << 1) | (0b111 << 10) | (0b111 << 13));
|
||||
Reg58 |= (ModeParams.u8RxBandWidthBits << 1) |
|
||||
(ModeParams.u8RxModeBits << 10) | (ModeParams.u8TxModeBits << 13);
|
||||
Fw.BK4819Write(0x58, 0);
|
||||
Fw.BK4819Write(0x58, Reg58);
|
||||
BK4819Write(0x58, 0);
|
||||
BK4819Write(0x58, Reg58);
|
||||
}
|
||||
|
||||
void FixIrqEnRegister() // original firmware overrides IRQ_EN reg, so we need
|
||||
// to reenable it
|
||||
{
|
||||
auto const OldIrqEnReg = Fw.BK4819Read(0x3F);
|
||||
auto const OldIrqEnReg = BK4819Read(0x3F);
|
||||
if ((OldIrqEnReg & (eIrq::FifoAlmostFull | eIrq::RxDone)) !=
|
||||
(eIrq::FifoAlmostFull | eIrq::RxDone)) {
|
||||
Fw.BK4819Write(0x3F, OldIrqEnReg | eIrq::FifoAlmostFull | eIrq::RxDone);
|
||||
BK4819Write(0x3F, OldIrqEnReg | eIrq::FifoAlmostFull | eIrq::RxDone);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,28 +169,28 @@ public:
|
|||
u8RxBuffSize = u8DataLen;
|
||||
u16RxDataLen = 0;
|
||||
|
||||
Fw.AirCopyFskSetup();
|
||||
Fw.BK4819ConfigureAndStartRxFsk();
|
||||
AirCopyFskSetup();
|
||||
BK4819ConfigureAndStartRxFsk();
|
||||
State = eState::RxPending;
|
||||
}
|
||||
|
||||
void DisableFskModem() {
|
||||
auto const FskSettings = Fw.BK4819Read(0x58);
|
||||
Fw.BK4819Write(0x58, FskSettings & ~1);
|
||||
auto const FskSettings = BK4819Read(0x58);
|
||||
BK4819Write(0x58, FskSettings & ~1);
|
||||
}
|
||||
|
||||
void ClearRxFifoBuff() {
|
||||
auto const Reg59 = Fw.BK4819Read(0x59);
|
||||
Fw.BK4819Write(0x59, 1 << 14);
|
||||
Fw.BK4819Write(0x59, Reg59);
|
||||
auto const Reg59 = BK4819Read(0x59);
|
||||
BK4819Write(0x59, 1 << 14);
|
||||
BK4819Write(0x59, Reg59);
|
||||
}
|
||||
|
||||
unsigned short GetIrqReg() {
|
||||
Fw.BK4819Write(0x2, 0);
|
||||
return Fw.BK4819Read(0x2);
|
||||
BK4819Write(0x2, 0);
|
||||
return BK4819Read(0x2);
|
||||
}
|
||||
|
||||
bool CheckCrc() { return Fw.BK4819Read(0x0B) & (1 << 4); }
|
||||
bool CheckCrc() { return BK4819Read(0x0B) & (1 << 4); }
|
||||
|
||||
bool IsLockedByOrgFw() { return !(GPIOC->DATA & 0b1); }
|
||||
|
||||
|
@ -209,7 +210,7 @@ public:
|
|||
|
||||
if (State == eState::RxPending) {
|
||||
FixIrqEnRegister();
|
||||
if (!(Fw.BK4819Read(0x0C) & 1)) // irq request indicator
|
||||
if (!(BK4819Read(0x0C) & 1)) // irq request indicator
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -232,7 +233,7 @@ public:
|
|||
private:
|
||||
void HandleFifoAlmostFull() {
|
||||
for (unsigned char i = 0; i < 4; i++) {
|
||||
auto const RxData = Fw.BK4819Read(0x5F);
|
||||
auto const RxData = BK4819Read(0x5F);
|
||||
if (p8RxBuff && u16RxDataLen < u8RxBuffSize - 2) {
|
||||
memcpy(p8RxBuff + u16RxDataLen, &RxData, 2);
|
||||
}
|
||||
|
|
|
@ -3,13 +3,11 @@
|
|||
#include "registers.hpp"
|
||||
|
||||
template <
|
||||
const System::TOrgFunctions &Fw,
|
||||
const System::TOrgData &FwData,
|
||||
TUV_K5Display &DisplayBuff,
|
||||
CDisplay<TUV_K5Display> &Display,
|
||||
CDisplay<TUV_K5Display> &DisplayStatusBar,
|
||||
const TUV_K5SmallNumbers &FontSmallNr,
|
||||
Radio::CBK4819<Fw> &RadioDriver>
|
||||
Radio::CBK4819 &RadioDriver>
|
||||
class CAmTx : public IView
|
||||
{
|
||||
static constexpr bool bAmpTests = true;
|
||||
|
@ -31,9 +29,9 @@ public:
|
|||
|
||||
if constexpr (bAmpTests)
|
||||
{
|
||||
// Fw.BK4819Write(0x29, 0);
|
||||
// Fw.BK4819Write(0x2B, 0);
|
||||
// Fw.BK4819Write(0x19, 0);
|
||||
// BK4819Write(0x29, 0);
|
||||
// BK4819Write(0x2B, 0);
|
||||
// BK4819Write(0x19, 0);
|
||||
// RadioDriver.SetDeviationPresent(0);
|
||||
HandleTests();
|
||||
if (!CheckForPtt())
|
||||
|
@ -46,7 +44,7 @@ public:
|
|||
}
|
||||
|
||||
RadioDriver.SetDeviationPresent(0);
|
||||
auto InitialBias = Fw.BK4819Read(0x36);
|
||||
auto InitialBias = BK4819Read(0x36);
|
||||
|
||||
u32StartFreq = RadioDriver.GetFrequency();
|
||||
|
||||
|
@ -59,7 +57,7 @@ public:
|
|||
|
||||
RadioDriver.SetFrequency(u32StartFreq);
|
||||
RadioDriver.SetDeviationPresent(1);
|
||||
Fw.BK4819Write(0x36, InitialBias);
|
||||
BK4819Write(0x36, InitialBias);
|
||||
|
||||
Context.ViewStack.Pop();
|
||||
return eScreenRefreshFlag::NoRefresh;
|
||||
|
@ -76,16 +74,16 @@ public:
|
|||
// if (MicAmp < 0)
|
||||
// MicAmp = 0;
|
||||
unsigned short U16AdcData[2];
|
||||
Fw.AdcReadout(U16AdcData, U16AdcData+1);
|
||||
Fw.FormatString(S8DebugStr, "in 1: %05i ", U16AdcData[0]);
|
||||
Fw.PrintTextOnScreen(S8DebugStr, 0, 127, 0, 8, 0);
|
||||
Fw.FormatString(S8DebugStr, "in 2: %05i ", U16AdcData[1]);
|
||||
Fw.PrintTextOnScreen(S8DebugStr, 0, 127, 2, 8, 0);
|
||||
AdcReadout(U16AdcData, U16AdcData+1);
|
||||
FormatString(S8DebugStr, "in 1: %05i ", U16AdcData[0]);
|
||||
PrintTextOnScreen(S8DebugStr, 0, 127, 0, 8, 0);
|
||||
FormatString(S8DebugStr, "in 2: %05i ", U16AdcData[1]);
|
||||
PrintTextOnScreen(S8DebugStr, 0, 127, 2, 8, 0);
|
||||
}
|
||||
|
||||
void HandleMicInput()
|
||||
{
|
||||
unsigned short u16ActualAmp = Fw.BK4819Read(0x64);
|
||||
unsigned short u16ActualAmp = BK4819Read(0x64);
|
||||
s32DeltaAmp = u16OldAmp - u16ActualAmp;
|
||||
u16OldAmp = u16ActualAmp;
|
||||
}
|
||||
|
@ -98,7 +96,7 @@ public:
|
|||
MicAmp = 0b111;
|
||||
if (MicAmp < 0)
|
||||
MicAmp = 0;
|
||||
Fw.BK4819Write(0x36, ((MicAmp & 0b111) << 3) | (MicAmp & 0b111));
|
||||
BK4819Write(0x36, ((MicAmp & 0b111) << 3) | (MicAmp & 0b111));
|
||||
}
|
||||
|
||||
void HandleTxWfm()
|
||||
|
@ -145,7 +143,7 @@ public:
|
|||
if (GPIOC->DATA & GPIO_PIN_3)
|
||||
{
|
||||
GPIOC->DATA &= ~GPIO_PIN_3;
|
||||
*FwData.p8FlashLightStatus = 3;
|
||||
gFlashLightStatus = 3;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -154,17 +152,17 @@ public:
|
|||
|
||||
void DrawAmIcon(bool bDraw)
|
||||
{
|
||||
memset(FwData.pStatusBarData, 0, 14);
|
||||
memset(gStatusBarData, 0, 14);
|
||||
if (!bDraw)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(FwData.pStatusBarData, FwData.pSmallLeters + 223, 12);
|
||||
unsigned char *pNegative = FwData.pStatusBarData;
|
||||
memcpy(gStatusBarData, gSmallLeters + 223, 12);
|
||||
unsigned char *pNegative = gStatusBarData;
|
||||
for (unsigned char i = 0; i < 14; i++)
|
||||
{
|
||||
*pNegative++ ^= 0xFF;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "keyboard.hpp"
|
||||
|
||||
inline char S8Label[20];
|
||||
template <const System::TOrgFunctions &Fw>
|
||||
class CHeater : public IMenuElement
|
||||
{
|
||||
bool bEnabled = false;
|
||||
|
@ -28,23 +27,22 @@ class CHeater : public IMenuElement
|
|||
bEnabled = !bEnabled;
|
||||
if(bEnabled)
|
||||
{
|
||||
Fw.BK4819SetGpio(1, true);
|
||||
BK4819SetGpio(1, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Fw.BK4819SetGpio(1, false);
|
||||
BK4819SetGpio(1, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <const System::TOrgFunctions &Fw>
|
||||
class CAmRx : public IMenuElement
|
||||
{
|
||||
unsigned char u8Mode = 0;
|
||||
public:
|
||||
const char *GetLabel() override
|
||||
{
|
||||
Fw.FormatString(S8Label, "AM RX %u", u8Mode);
|
||||
FormatString(S8Label, "AM RX %u", u8Mode);
|
||||
return S8Label;
|
||||
}
|
||||
|
||||
|
@ -59,11 +57,11 @@ class CAmRx : public IMenuElement
|
|||
if(u8Mode > 2)
|
||||
u8Mode = 0;
|
||||
|
||||
// Fw.SomeAmStuff(u8Mode);
|
||||
// SomeAmStuff(u8Mode);
|
||||
}
|
||||
};
|
||||
|
||||
template <const System::TOrgFunctions &Fw, Radio::CBK4819<Fw> &RadioDriver>
|
||||
template <Radio::CBK4819 &RadioDriver>
|
||||
class CMicVal : public IMenuElement
|
||||
{
|
||||
unsigned char u8Mode = 0;
|
||||
|
@ -71,7 +69,7 @@ class CMicVal : public IMenuElement
|
|||
public:
|
||||
const char *GetLabel() override
|
||||
{
|
||||
Fw.FormatString(S8Label, "MIC in %u", Fw.BK4819Read(0x64));
|
||||
FormatString(S8Label, "MIC in %u", BK4819Read(0x64));
|
||||
return S8Label;
|
||||
}
|
||||
|
||||
|
@ -80,7 +78,7 @@ class CMicVal : public IMenuElement
|
|||
}
|
||||
};
|
||||
|
||||
template <const System::TOrgFunctions &Fw, Radio::CBK4819<Fw> &RadioDriver>
|
||||
template <Radio::CBK4819 &RadioDriver>
|
||||
class CRssiVal : public IMenuElement
|
||||
{
|
||||
unsigned char u8Mode = 0;
|
||||
|
@ -89,11 +87,11 @@ class CRssiVal : public IMenuElement
|
|||
public:
|
||||
const char *GetLabel() override
|
||||
{
|
||||
Fw.FormatString(S8Label, "RSSI %i", RadioDriver.GetRssi());
|
||||
FormatString(S8Label, "RSSI %i", RadioDriver.GetRssi());
|
||||
return S8Label;
|
||||
}
|
||||
|
||||
void HandleUserAction(unsigned char u8Button) override
|
||||
{
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
#include "keyboard.hpp"
|
||||
#include "registers.hpp"
|
||||
|
||||
template <const System::TOrgFunctions &Fw,
|
||||
const System::TOrgData &FwData,
|
||||
template <
|
||||
unsigned char BackgroundViewPrescaler,
|
||||
unsigned char MainViewPrescaler,
|
||||
unsigned char RegisteredViews>
|
||||
|
@ -48,7 +47,7 @@ class CViewManager
|
|||
% MainViewPrescaler))
|
||||
{
|
||||
if(!MainViewContext.OriginalFwStatus.b1RadioSpiCommInUse)
|
||||
Keyboard.Handle(Fw.PollKeyboard());
|
||||
Keyboard.Handle(PollKeyboard());
|
||||
|
||||
u8ScreenRefreshFlag |=
|
||||
pViewStackTop->HandleMainView(MainViewContext);
|
||||
|
@ -56,12 +55,12 @@ class CViewManager
|
|||
|
||||
if(u8ScreenRefreshFlag & eScreenRefreshFlag::MainScreen)
|
||||
{
|
||||
Fw.FlushFramebufferToScreen();
|
||||
FlushFramebufferToScreen();
|
||||
}
|
||||
|
||||
if(u8ScreenRefreshFlag & eScreenRefreshFlag::StatusBar)
|
||||
{
|
||||
Fw.FlushStatusbarBufferToScreen();
|
||||
FlushStatusbarBufferToScreen();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,8 +83,8 @@ class CViewManager
|
|||
|
||||
inline void CheckOriginalFwStatus()
|
||||
{
|
||||
const auto *pMenuCheckData = (unsigned char *)(FwData.pDisplayBuffer + 2*128 + 6 * 8 + 1);
|
||||
const auto *pFrequencyScanCheckData = (unsigned char *)(FwData.pDisplayBuffer + 6*128 + 3 * 8 + 2);
|
||||
const auto *pMenuCheckData = (unsigned char *)(gDisplayBuffer + 2*128 + 6 * 8 + 1);
|
||||
const auto *pFrequencyScanCheckData = (unsigned char *)(gDisplayBuffer + 6*128 + 3 * 8 + 2);
|
||||
MainViewContext.OriginalFwStatus.b1MenuDrawed = *pMenuCheckData == 0xFF;
|
||||
MainViewContext.OriginalFwStatus.b1FrequencyScan = *pFrequencyScanCheckData;
|
||||
MainViewContext.OriginalFwStatus.b1RadioSpiCommInUse = !(GPIOC->DATA & 0b1);
|
||||
|
@ -109,4 +108,4 @@ class CViewManager
|
|||
pTop->HandleReleasedButton(MainViewContext, u8Key);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -8,8 +8,6 @@ struct IMenuElement
|
|||
virtual void HandleUserAction(unsigned char u8Button) = 0;
|
||||
};
|
||||
|
||||
template <const System::TOrgFunctions &Fw,
|
||||
const System::TOrgData &FwData>
|
||||
class CMenu : public IView
|
||||
{
|
||||
static constexpr auto MenuLines = 3;
|
||||
|
@ -73,18 +71,18 @@ public:
|
|||
|
||||
void DrawMenu()
|
||||
{
|
||||
memset(FwData.pDisplayBuffer, 0, 128*6);
|
||||
memset(gDisplayBuffer, 0, 128*6);
|
||||
for(unsigned char u8Line = 0; u8Line < MenuLines; u8Line++)
|
||||
{
|
||||
auto* Element = GetElement(u8Selected - 1 + u8Line);
|
||||
if(!Element)
|
||||
continue;
|
||||
|
||||
Fw.PrintTextOnScreen(Element->GetLabel(), 0, 127, u8Line << 1, 8, 0);
|
||||
PrintTextOnScreen(Element->GetLabel(), 0, 127, u8Line << 1, 8, 0);
|
||||
}
|
||||
|
||||
for(auto i = 0; i < 256; i++)
|
||||
FwData.pDisplayBuffer[i + 2*128] ^= 0xFF;
|
||||
gDisplayBuffer[i + 2*128] ^= 0xFF;
|
||||
}
|
||||
|
||||
IMenuElement* GetElement(signed char s8Idx)
|
||||
|
@ -102,10 +100,10 @@ public:
|
|||
if (GPIOC->DATA & GPIO_PIN_3)
|
||||
{
|
||||
GPIOC->DATA &= ~GPIO_PIN_3;
|
||||
*FwData.p8FlashLightStatus = 3;
|
||||
gFlashLightStatus = 3;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -8,9 +8,7 @@
|
|||
template <
|
||||
TUV_K5Display &DisplayBuff,
|
||||
CDisplay<TUV_K5Display> &Display,
|
||||
const System::TOrgFunctions &Fw,
|
||||
const System::TOrgData &FwData,
|
||||
Radio::CBK4819<Fw> &RadioDriver>
|
||||
Radio::CBK4819 &RadioDriver>
|
||||
class CMessenger : public IView
|
||||
{
|
||||
public:
|
||||
|
@ -66,7 +64,7 @@ public:
|
|||
if (u8RxDoneLabelCnt < 100)
|
||||
{
|
||||
u8RxDoneLabelCnt++;
|
||||
Fw.PrintTextOnScreen("> RX <", 0, 128, 2, 8, 1);
|
||||
PrintTextOnScreen("> RX <", 0, 128, 2, 8, 1);
|
||||
}
|
||||
|
||||
switch (State)
|
||||
|
@ -100,8 +98,8 @@ public:
|
|||
void PrintTxData()
|
||||
{
|
||||
char C8PrintBuff[30];
|
||||
Fw.FormatString(C8PrintBuff, ">%s", T9.C8WorkingBuff);
|
||||
Fw.PrintTextOnScreen(C8PrintBuff, 0, 128, 0, 8, 0);
|
||||
FormatString(C8PrintBuff, ">%s", T9.C8WorkingBuff);
|
||||
PrintTextOnScreen(C8PrintBuff, 0, 128, 0, 8, 0);
|
||||
}
|
||||
|
||||
void PrintRxData()
|
||||
|
@ -109,9 +107,9 @@ public:
|
|||
// char *tempRxBuff = S8RxBuff + MaxCharsInLine;
|
||||
// char C8Temp = tempRxBuff[MaxCharsInLine];
|
||||
// S8RxBuff[MaxCharsInLine] = '\0';
|
||||
Fw.PrintTextOnScreen(S8RxBuff, 1, 128, 3, 8, 0);
|
||||
PrintTextOnScreen(S8RxBuff, 1, 128, 3, 8, 0);
|
||||
// S8RxBuff[MaxCharsInLine] = C8Temp;
|
||||
// Fw.PrintTextOnScreen(tempRxBuff, 1, 128, 5, 8, 0);
|
||||
// PrintTextOnScreen(tempRxBuff, 1, 128, 5, 8, 0);
|
||||
}
|
||||
|
||||
void HandleInitTx()
|
||||
|
@ -124,7 +122,7 @@ public:
|
|||
State = eState::InitRx;
|
||||
}
|
||||
|
||||
Fw.PrintTextOnScreen("> TX <", 0, 128, 2, 8, 1);
|
||||
PrintTextOnScreen("> TX <", 0, 128, 2, 8, 1);
|
||||
}
|
||||
void RxDoneHandler(unsigned char u8DataLen, bool bCrcOk)
|
||||
{
|
||||
|
@ -142,12 +140,12 @@ private:
|
|||
{
|
||||
bEnabled = true;
|
||||
GPIOC->DATA &= ~GPIO_PIN_3;
|
||||
*FwData.p8FlashLightStatus = 3;
|
||||
gFlashLightStatus = 3;
|
||||
}
|
||||
|
||||
if (bEnabled)
|
||||
{
|
||||
// Keyboard.Handle(Fw.PollKeyboard());
|
||||
// Keyboard.Handle(PollKeyboard());
|
||||
}
|
||||
|
||||
return bEnabled;
|
||||
|
@ -161,7 +159,7 @@ private:
|
|||
|
||||
void ClearDrawings()
|
||||
{
|
||||
memset(FwData.pDisplayBuffer, 0, (DisplayBuff.SizeX / 8) * DisplayBuff.SizeY);
|
||||
memset(gDisplayBuffer, 0, (DisplayBuff.SizeX / 8) * DisplayBuff.SizeY);
|
||||
}
|
||||
|
||||
void HandlePressedButton(unsigned char u8Button) override
|
||||
|
@ -194,4 +192,4 @@ private:
|
|||
bool bEnabled;
|
||||
eState State;
|
||||
unsigned char u8RxDoneLabelCnt;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
#include "manager.hpp"
|
||||
|
||||
template <
|
||||
System::TOrgFunctions &Fw,
|
||||
System::TOrgData &FwData,
|
||||
TUV_K5Display &DisplayBuff,
|
||||
CDisplay<TUV_K5Display> &Display,
|
||||
TUV_K5SmallNumbers &FontSmallNr>
|
||||
|
@ -25,7 +23,7 @@ public:
|
|||
return eScreenRefreshFlag::NoRefresh;
|
||||
}
|
||||
|
||||
if (Fw.BK4819Read(0x0C) & 0b10)
|
||||
if (BK4819Read(0x0C) & 0b10)
|
||||
{
|
||||
u8SqlDelayCnt = 0;
|
||||
}
|
||||
|
@ -55,7 +53,7 @@ public:
|
|||
Display.SetFont(&FontSmallNr);
|
||||
|
||||
char C8RssiString[] = "g000";
|
||||
unsigned char u8Rssi = ((Fw.BK4819Read(0x67) >> 1) & 0xFF);
|
||||
unsigned char u8Rssi = ((BK4819Read(0x67) >> 1) & 0xFF);
|
||||
if (!u8Rssi)
|
||||
{
|
||||
return eScreenRefreshFlag::NoRefresh;
|
||||
|
@ -101,4 +99,4 @@ public:
|
|||
u8ChartPosition++;
|
||||
return eScreenRefreshFlag::MainScreen;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -49,13 +49,11 @@ namespace Rssi
|
|||
}
|
||||
|
||||
template <
|
||||
const System::TOrgFunctions &Fw,
|
||||
const System::TOrgData &FwData,
|
||||
TUV_K5Display &DisplayBuff,
|
||||
CDisplay<TUV_K5Display> &Display,
|
||||
CDisplay<TUV_K5Display> &DisplayStatusBar,
|
||||
const TUV_K5SmallNumbers &FontSmallNr,
|
||||
Radio::CBK4819<Fw> &RadioDriver>
|
||||
Radio::CBK4819 &RadioDriver>
|
||||
class CRssiSbar : public IView, public IMenuElement
|
||||
{
|
||||
public:
|
||||
|
@ -67,7 +65,7 @@ public:
|
|||
static constexpr auto LinearBlocksCnt = 9;
|
||||
static constexpr auto VoltageOffset = 77;
|
||||
static constexpr auto MaxBarPoints = 13;
|
||||
static inline unsigned char *const pDData = FwData.pDisplayBuffer + 128 * 3;
|
||||
static inline unsigned char *const pDData = gDisplayBuffer + 128 * 3;
|
||||
|
||||
unsigned int u32DrawVoltagePsc = 0;
|
||||
Rssi::TRssi RssiData;
|
||||
|
@ -188,7 +186,7 @@ public:
|
|||
{
|
||||
if (bPtt) // print TX
|
||||
{
|
||||
memcpy(pDData + 5 * 7, FwData.pSmallLeters + 128 * 2 + 8 * 3 + 2, 15);
|
||||
memcpy(pDData + 5 * 7, gSmallLeters + 128 * 2 + 8 * 3 + 2, 15);
|
||||
unsigned char *pNegative = pDData + 5 * 7 - 2;
|
||||
for (unsigned char i = 0; i < 19; i++)
|
||||
{
|
||||
|
@ -205,13 +203,13 @@ public:
|
|||
}
|
||||
else if (u8SValue > 9)
|
||||
{
|
||||
memcpy(pDData + 5 * 7, FwData.pSmallLeters + 109 - 3 * 8, 8);
|
||||
memcpy(pDData + 5 * 7, gSmallLeters + 109 - 3 * 8, 8);
|
||||
C8SignalString[1] = '0';
|
||||
C8SignalString[0] = '0' + u8SValue - 9;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(pDData + 5 * 7, FwData.pSmallLeters + 109, 8);
|
||||
memcpy(pDData + 5 * 7, gSmallLeters + 109, 8);
|
||||
C8SignalString[0] = '0' + u8SValue;
|
||||
C8SignalString[1] = ' ';
|
||||
}
|
||||
|
@ -234,20 +232,20 @@ public:
|
|||
|
||||
void PrintBatteryVoltage()
|
||||
{
|
||||
if(*(FwData.pStatusBarData + VoltageOffset + 4 * 6 + 1) ||
|
||||
*(FwData.pStatusBarData + VoltageOffset + 4 * 6 - 6))
|
||||
if(gStatusBarData[VoltageOffset + 4 * 6 + 1] ||
|
||||
gStatusBarData[VoltageOffset + 4 * 6 - 6])
|
||||
{ // disable printing when function or charging icon are printed
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned short u16Voltage = *FwData.p16Voltage > 1000 ? 999 : *FwData.p16Voltage;
|
||||
unsigned short u16Voltage = gVoltage > 1000 ? 999 : gVoltage;
|
||||
|
||||
memset(FwData.pStatusBarData + VoltageOffset, 0, 4 * 5);
|
||||
memset(gStatusBarData + VoltageOffset, 0, 4 * 5);
|
||||
DisplayStatusBar.SetCoursor(0, VoltageOffset);
|
||||
DisplayStatusBar.PrintFixedDigitsNumber2(u16Voltage, 2, 1);
|
||||
memset(FwData.pStatusBarData + VoltageOffset + 7 + 1, 0b1100000, 2); // dot
|
||||
memset(gStatusBarData + VoltageOffset + 7 + 1, 0b1100000, 2); // dot
|
||||
DisplayStatusBar.SetCoursor(0, VoltageOffset + 7 + 4);
|
||||
DisplayStatusBar.PrintFixedDigitsNumber2(u16Voltage, 0, 2);
|
||||
memcpy(FwData.pStatusBarData + VoltageOffset + 4 * 6 + 2, FwData.pSmallLeters + 128 * 2 + 102, 5); // V character
|
||||
memcpy(gStatusBarData + VoltageOffset + 4 * 6 + 2, gSmallLeters + 128 * 2 + 102, 5); // V character
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -3,26 +3,19 @@
|
|||
#include "messenger.hpp"
|
||||
#include "radio.hpp"
|
||||
|
||||
const System::TOrgFunctions &Fw = System::OrgFunc_01_26;
|
||||
const System::TOrgData &FwData = System::OrgData_01_26;
|
||||
Radio::CBK4819 RadioDriver;
|
||||
|
||||
Radio::CBK4819<System::OrgFunc_01_26> RadioDriver;
|
||||
|
||||
CMessenger<
|
||||
System::OrgFunc_01_26,
|
||||
System::OrgData_01_26,
|
||||
RadioDriver>
|
||||
Messenger;
|
||||
CMessenger<RadioDriver> Messenger;
|
||||
|
||||
int main()
|
||||
{
|
||||
Fw.IRQ_RESET();
|
||||
IRQ_RESET();
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" void Reset_Handler()
|
||||
{
|
||||
Fw.IRQ_RESET();
|
||||
IRQ_RESET();
|
||||
}
|
||||
|
||||
extern "C" void SysTick_Handler()
|
||||
|
@ -37,5 +30,5 @@ extern "C" void SysTick_Handler()
|
|||
|
||||
RadioDriver.InterruptHandler();
|
||||
Messenger.Handle();
|
||||
Fw.IRQ_SYSTICK();
|
||||
}
|
||||
IRQ_SYSTICK();
|
||||
}
|
||||
|
|
|
@ -5,25 +5,18 @@
|
|||
#include "rssi_sbar.hpp"
|
||||
#include "manager.hpp"
|
||||
|
||||
const System::TOrgFunctions &Fw = System::OrgFunc_01_26;
|
||||
const System::TOrgData &FwData = System::OrgData_01_26;
|
||||
|
||||
TUV_K5Display DisplayBuff(FwData.pDisplayBuffer);
|
||||
const TUV_K5SmallNumbers FontSmallNr(FwData.pSmallDigs);
|
||||
TUV_K5Display DisplayBuff(gDisplayBuffer);
|
||||
const TUV_K5SmallNumbers FontSmallNr(gSmallDigs);
|
||||
CDisplay Display(DisplayBuff);
|
||||
|
||||
Radio::CBK4819<System::OrgFunc_01_26> RadioDriver;
|
||||
Radio::CBK4819 RadioDriver;
|
||||
CMessenger<
|
||||
DisplayBuff,
|
||||
Display,
|
||||
System::OrgFunc_01_26,
|
||||
System::OrgData_01_26,
|
||||
RadioDriver>
|
||||
Messenger;
|
||||
|
||||
CRssiSbar<
|
||||
System::OrgFunc_01_26,
|
||||
System::OrgData_01_26,
|
||||
DisplayBuff,
|
||||
Display,
|
||||
FontSmallNr>
|
||||
|
@ -31,8 +24,6 @@ CRssiSbar<
|
|||
|
||||
static IView * const Views[] = {&Messenger, &RssiSbar};
|
||||
CViewManager<
|
||||
System::OrgFunc_01_26,
|
||||
System::OrgData_01_26,
|
||||
16, 2, sizeof(Views) / sizeof(*Views)>
|
||||
Manager(Views);
|
||||
|
||||
|
@ -60,4 +51,4 @@ extern "C" void SysTick_Handler()
|
|||
RadioDriver.InterruptHandler();
|
||||
Manager.Handle();
|
||||
Fw.IRQ_SYSTICK();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
#include "radio.hpp"
|
||||
#include "t9.hpp"
|
||||
|
||||
template <const System::TOrgFunctions &Fw,
|
||||
const System::TOrgData &FwData,
|
||||
Radio::CBK4819<Fw> &RadioDriver>
|
||||
template <Radio::CBK4819 &RadioDriver>
|
||||
class CMessenger
|
||||
{
|
||||
public:
|
||||
|
@ -23,7 +21,7 @@ public:
|
|||
};
|
||||
|
||||
CMessenger()
|
||||
: DisplayBuff(FwData.pDisplayBuffer),
|
||||
: DisplayBuff(gDisplayBuffer),
|
||||
Display(DisplayBuff),
|
||||
Keyboard(*this),
|
||||
T9(S8TxBuff),
|
||||
|
@ -45,7 +43,7 @@ public:
|
|||
{
|
||||
bDisplayCleared = true;
|
||||
ClearDrawings();
|
||||
Fw.FlushFramebufferToScreen();
|
||||
FlushFramebufferToScreen();
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -61,22 +59,22 @@ public:
|
|||
|
||||
Display.DrawHLine(3, 3 + 10, 1 * 8 + T9.GetIdx() * 8 + 2);
|
||||
// print tx data
|
||||
Fw.FormatString(C8PrintBuff, ">%s", T9.C8WorkingBuff);
|
||||
Fw.PrintTextOnScreen(C8PrintBuff, 0, 128, 0, 8, 0);
|
||||
FormatString(C8PrintBuff, ">%s", T9.C8WorkingBuff);
|
||||
PrintTextOnScreen(C8PrintBuff, 0, 128, 0, 8, 0);
|
||||
|
||||
// print rx data
|
||||
char C8Temp = S8RxBuff[MaxCharsInLine];
|
||||
S8RxBuff[MaxCharsInLine] = '\0';
|
||||
Fw.PrintTextOnScreen(S8RxBuff, 1, 128, 3, 8, 0);
|
||||
PrintTextOnScreen(S8RxBuff, 1, 128, 3, 8, 0);
|
||||
S8RxBuff[MaxCharsInLine] = C8Temp;
|
||||
Fw.PrintTextOnScreen(S8RxBuff + MaxCharsInLine, 1, 128, 5, 8, 0);
|
||||
PrintTextOnScreen(S8RxBuff + MaxCharsInLine, 1, 128, 5, 8, 0);
|
||||
|
||||
Display.DrawRectangle(0, (8 * 4) - 6, 127, 24 + 6, false);
|
||||
|
||||
if (u8RxDoneLabelCnt < 100)
|
||||
{
|
||||
u8RxDoneLabelCnt++;
|
||||
Fw.PrintTextOnScreen(" >> RX << ", 0, 128, 2, 8, 1);
|
||||
PrintTextOnScreen(" >> RX << ", 0, 128, 2, 8, 1);
|
||||
}
|
||||
|
||||
switch (State)
|
||||
|
@ -97,14 +95,14 @@ public:
|
|||
State = eState::InitRx;
|
||||
}
|
||||
|
||||
Fw.PrintTextOnScreen(" >> TX << ", 0, 128, 2, 8, 1);
|
||||
PrintTextOnScreen(" >> TX << ", 0, 128, 2, 8, 1);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Fw.FlushFramebufferToScreen();
|
||||
FlushFramebufferToScreen();
|
||||
}
|
||||
|
||||
void RxDoneHandler(unsigned char u8DataLen, bool bCrcOk)
|
||||
|
@ -123,12 +121,12 @@ private:
|
|||
{
|
||||
bEnabled = true;
|
||||
GPIOC->DATA &= ~GPIO_PIN_3;
|
||||
*FwData.p8FlashLightStatus = 3;
|
||||
gFlashLightStatus = 3;
|
||||
}
|
||||
|
||||
if (bEnabled)
|
||||
{
|
||||
Keyboard.Handle(Fw.PollKeyboard());
|
||||
Keyboard.Handle(PollKeyboard());
|
||||
}
|
||||
|
||||
return bEnabled;
|
||||
|
@ -142,7 +140,7 @@ private:
|
|||
|
||||
void ClearDrawings()
|
||||
{
|
||||
memset(FwData.pDisplayBuffer, 0, (DisplayBuff.SizeX / 8) * DisplayBuff.SizeY);
|
||||
memset(gDisplayBuffer, 0, (DisplayBuff.SizeX / 8) * DisplayBuff.SizeY);
|
||||
}
|
||||
|
||||
void HandlePressedButton(unsigned char u8Button)
|
||||
|
@ -178,4 +176,4 @@ private:
|
|||
bool bEnabled;
|
||||
eState State;
|
||||
unsigned char u8RxDoneLabelCnt;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -8,22 +8,18 @@
|
|||
|
||||
extern "C" void __libc_init_array();
|
||||
|
||||
const System::TOrgFunctions& Fw = System::OrgFunc_01_26;
|
||||
|
||||
Radio::CBK4819<System::OrgFunc_01_26> RadioDriver;
|
||||
CSpectrum<System::OrgFunc_01_26,
|
||||
System::OrgData_01_26, RadioDriver>
|
||||
Spectrum;
|
||||
Radio::CBK4819 RadioDriver;
|
||||
CSpectrum<RadioDriver> Spectrum;
|
||||
|
||||
int main()
|
||||
{
|
||||
Fw.IRQ_RESET();
|
||||
IRQ_RESET();
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" void Reset_Handler()
|
||||
{
|
||||
Fw.IRQ_RESET();
|
||||
IRQ_RESET();
|
||||
}
|
||||
|
||||
extern "C" void SysTick_Handler()
|
||||
|
@ -41,5 +37,5 @@ extern "C" void SysTick_Handler()
|
|||
{
|
||||
Spectrum.Handle();
|
||||
}
|
||||
Fw.IRQ_SYSTICK();
|
||||
}
|
||||
IRQ_SYSTICK();
|
||||
}
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
#include "uv_k5_display.hpp"
|
||||
#include "radio.hpp"
|
||||
|
||||
template <const System::TOrgFunctions &Fw,
|
||||
const System::TOrgData &FwData,
|
||||
Radio::CBK4819<Fw> &RadioDriver>
|
||||
template <Radio::CBK4819 &RadioDriver>
|
||||
class CSpectrum
|
||||
{
|
||||
public:
|
||||
|
@ -23,7 +21,7 @@ public:
|
|||
};
|
||||
|
||||
CSpectrum()
|
||||
: DisplayBuff(FwData.pDisplayBuffer), FontSmallNr(FwData.pSmallDigs), Display(DisplayBuff), State(eState::Init), u8RxCnt(0){};
|
||||
: DisplayBuff(gDisplayBuffer), FontSmallNr(gSmallDigs), Display(DisplayBuff), State(eState::Init), u8RxCnt(0){};
|
||||
|
||||
void Handle()
|
||||
{
|
||||
|
@ -38,14 +36,14 @@ public:
|
|||
{
|
||||
|
||||
|
||||
Fw.DelayMs(600);
|
||||
DelayMs(600);
|
||||
//memset(U8Buff, 0, sizeof(U8Buff));
|
||||
RadioDriver.RecieveAsyncAirCopyMode(U8Buff, sizeof(U8Buff), Radio::CallbackRxDoneType(this, &CSpectrum::RxDoneHandler));
|
||||
State = eState::RxPending;
|
||||
// while(State == eState::RxPending)
|
||||
// {
|
||||
// RadioDriver.InterruptHandler();
|
||||
// // if(Fw.PollKeyboard() != 0xFF)
|
||||
// // if(PollKeyboard() != 0xFF)
|
||||
// // {
|
||||
// // break;
|
||||
// // }
|
||||
|
@ -59,13 +57,13 @@ public:
|
|||
char kupa[20];
|
||||
U8Buff[10] = 0;
|
||||
DisplayBuff.ClearAll();
|
||||
Fw.FormatString(kupa, "RX DONE %u", u8RxCnt);
|
||||
Fw.PrintTextOnScreen(kupa, 0, 127, 0, 8, 0);
|
||||
Fw.FormatString(kupa, "LEN: %i", RadioDriver.u16RxDataLen);
|
||||
Fw.PrintTextOnScreen(kupa, 0, 127, 2, 8, 0);
|
||||
Fw.FormatString(kupa, "S: %s", U8Buff);
|
||||
Fw.PrintTextOnScreen(kupa, 0, 127, 4, 8, 0);
|
||||
Fw.FlushFramebufferToScreen();
|
||||
FormatString(kupa, "RX DONE %u", u8RxCnt);
|
||||
PrintTextOnScreen(kupa, 0, 127, 0, 8, 0);
|
||||
FormatString(kupa, "LEN: %i", RadioDriver.u16RxDataLen);
|
||||
PrintTextOnScreen(kupa, 0, 127, 2, 8, 0);
|
||||
FormatString(kupa, "S: %s", U8Buff);
|
||||
PrintTextOnScreen(kupa, 0, 127, 4, 8, 0);
|
||||
FlushFramebufferToScreen();
|
||||
|
||||
static unsigned int u32Cnt = 1;
|
||||
if(!(u32Cnt++%8))
|
||||
|
@ -74,29 +72,29 @@ public:
|
|||
State = eState::Init;
|
||||
}
|
||||
|
||||
// Fw.WriteSerialData((unsigned char *)"RX packet, hex: ", 17);
|
||||
// WriteSerialData((unsigned char *)"RX packet, hex: ", 17);
|
||||
// for (unsigned int i = 0; i < sizeof(U8Buff); i++)
|
||||
// {
|
||||
// Fw.FormatString(kupa, "%02X", U8Buff[i]);
|
||||
// Fw.WriteSerialData((unsigned char *)kupa, 1);
|
||||
// FormatString(kupa, "%02X", U8Buff[i]);
|
||||
// WriteSerialData((unsigned char *)kupa, 1);
|
||||
// }
|
||||
// Fw.WriteSerialData((unsigned char *)"\n", 1);
|
||||
// WriteSerialData((unsigned char *)"\n", 1);
|
||||
break;
|
||||
}
|
||||
|
||||
case eState::RxPending:
|
||||
{
|
||||
|
||||
//Fw.AirCopyFskSetup();
|
||||
//AirCopyFskSetup();
|
||||
char kupa[20];
|
||||
DisplayBuff.ClearAll();
|
||||
Fw.FormatString(kupa, "Rx: %u kHz", Fw.IntDivide(RadioDriver.GetFrequency(), 100));
|
||||
Fw.PrintTextOnScreen(kupa, 0, 127, 0, 8, 0);
|
||||
Fw.FormatString(kupa, "0x3F: 0x%04X", Fw.BK4819Read(0x3F));
|
||||
Fw.PrintTextOnScreen(kupa, 0, 127, 2, 8, 0);
|
||||
Fw.FormatString(kupa, "len: %i", Fw.BK4819Read(0x5D) >> 8);
|
||||
Fw.PrintTextOnScreen(kupa, 0, 127, 4, 8, 0);
|
||||
Fw.FlushFramebufferToScreen();
|
||||
FormatString(kupa, "Rx: %u kHz", IntDivide(RadioDriver.GetFrequency(), 100));
|
||||
PrintTextOnScreen(kupa, 0, 127, 0, 8, 0);
|
||||
FormatString(kupa, "0x3F: 0x%04X", BK4819Read(0x3F));
|
||||
PrintTextOnScreen(kupa, 0, 127, 2, 8, 0);
|
||||
FormatString(kupa, "len: %i", BK4819Read(0x5D) >> 8);
|
||||
PrintTextOnScreen(kupa, 0, 127, 4, 8, 0);
|
||||
FlushFramebufferToScreen();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -110,18 +108,18 @@ public:
|
|||
if(!(u32Cnt++%8))
|
||||
{
|
||||
u8TxCnt++;
|
||||
Fw.FormatString((char *)C8TxStr, "packet %i", u8TxCnt);
|
||||
FormatString((char *)C8TxStr, "packet %i", u8TxCnt);
|
||||
RadioDriver.SendSyncAirCopyMode72((unsigned char *)C8TxStr);
|
||||
}
|
||||
|
||||
DisplayBuff.ClearAll();
|
||||
Fw.FormatString(kupa, "TX: %u kHz", Fw.IntDivide(RadioDriver.GetFrequency(), 100));
|
||||
Fw.PrintTextOnScreen(kupa, 0, 127, 0, 8, 0);
|
||||
Fw.FormatString(kupa, "Irq: 0x%04X", RadioDriver.GetIrqReg());
|
||||
Fw.PrintTextOnScreen(kupa, 0, 127, 2, 8, 0);
|
||||
Fw.FormatString(kupa, "S: %s", C8TxStr);
|
||||
Fw.PrintTextOnScreen(kupa, 0, 127, 4, 8, 0);
|
||||
Fw.FlushFramebufferToScreen();
|
||||
FormatString(kupa, "TX: %u kHz", IntDivide(RadioDriver.GetFrequency(), 100));
|
||||
PrintTextOnScreen(kupa, 0, 127, 0, 8, 0);
|
||||
FormatString(kupa, "Irq: 0x%04X", RadioDriver.GetIrqReg());
|
||||
PrintTextOnScreen(kupa, 0, 127, 2, 8, 0);
|
||||
FormatString(kupa, "S: %s", C8TxStr);
|
||||
PrintTextOnScreen(kupa, 0, 127, 4, 8, 0);
|
||||
FlushFramebufferToScreen();
|
||||
|
||||
|
||||
return;
|
||||
|
@ -144,4 +142,4 @@ private:
|
|||
eState State;
|
||||
unsigned char U8Buff[72];
|
||||
unsigned char u8RxCnt;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -7,18 +7,17 @@
|
|||
|
||||
extern "C" void __libc_init_array();
|
||||
|
||||
const System::TOrgFunctions& Fw = System::OrgFunc_01_26;
|
||||
CSPong<System::OrgFunc_01_26, System::OrgData_01_26> Pong;
|
||||
CSPong Pong;
|
||||
|
||||
int main()
|
||||
{
|
||||
Fw.IRQ_RESET();
|
||||
IRQ_RESET();
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" void Reset_Handler()
|
||||
{
|
||||
Fw.IRQ_RESET();
|
||||
IRQ_RESET();
|
||||
}
|
||||
|
||||
extern "C" void SysTick_Handler()
|
||||
|
@ -36,5 +35,5 @@ extern "C" void SysTick_Handler()
|
|||
{
|
||||
Pong.Handle();
|
||||
}
|
||||
Fw.IRQ_SYSTICK();
|
||||
}
|
||||
IRQ_SYSTICK();
|
||||
}
|
||||
|
|
|
@ -3,14 +3,13 @@
|
|||
#include "uv_k5_display.hpp"
|
||||
#include "gpt_pong.hpp"
|
||||
|
||||
template <const System::TOrgFunctions &Fw, const System::TOrgData &FwData>
|
||||
class CSPong
|
||||
{
|
||||
public:
|
||||
static constexpr auto StepSize = 0xFFFF / TUV_K5Display::SizeX;
|
||||
static constexpr auto StepSizeFreq = 10'000;
|
||||
CSPong()
|
||||
: DisplayBuff(FwData.pDisplayBuffer), FontSmallNr(FwData.pSmallDigs), Display(DisplayBuff), x(DisplayBuff.SizeX / 2), y(DisplayBuff.SizeY / 2)
|
||||
: DisplayBuff(gDisplayBuffer), FontSmallNr(gSmallDigs), Display(DisplayBuff), x(DisplayBuff.SizeX / 2), y(DisplayBuff.SizeY / 2)
|
||||
,bEnabled(true){};
|
||||
|
||||
void Handle()
|
||||
|
@ -23,7 +22,7 @@ public:
|
|||
DisplayBuff.ClearAll();
|
||||
char C8RssiString[] = "000";
|
||||
|
||||
unsigned int u32Key = Fw.PollKeyboard();
|
||||
unsigned int u32Key = PollKeyboard();
|
||||
if(u32Key == 13) // exit key
|
||||
{
|
||||
bEnabled = false;
|
||||
|
@ -47,7 +46,7 @@ public:
|
|||
u32Cnt++;
|
||||
if((u32Cnt >> 8) % 2)
|
||||
{
|
||||
unsigned int* p32Buff = (unsigned int*)FwData.pDisplayBuffer;
|
||||
unsigned int* p32Buff = (unsigned int*)gDisplayBuffer;
|
||||
for(int i = 0; i < (DisplayBuff.SizeX * DisplayBuff.SizeY) / (8*4); i++)
|
||||
{
|
||||
*p32Buff = ~(*p32Buff);
|
||||
|
@ -56,7 +55,7 @@ public:
|
|||
}
|
||||
|
||||
|
||||
Fw.FlushFramebufferToScreen();
|
||||
FlushFramebufferToScreen();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -67,4 +66,4 @@ private:
|
|||
|
||||
unsigned char x, y;
|
||||
bool bEnabled;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -6,18 +6,16 @@
|
|||
#include <string.h>
|
||||
|
||||
Hardware::THardware Hw;
|
||||
const System::TOrgFunctions& Fw = System::OrgFunc_01_26;
|
||||
const System::TOrgData& FwData = System::OrgData_01_26;
|
||||
|
||||
int main()
|
||||
{
|
||||
Fw.IRQ_RESET();
|
||||
IRQ_RESET();
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" void Reset_Handler()
|
||||
{
|
||||
Fw.IRQ_RESET();
|
||||
IRQ_RESET();
|
||||
}
|
||||
|
||||
extern "C" void SysTick_Handler()
|
||||
|
@ -33,7 +31,7 @@ extern "C" void SysTick_Handler()
|
|||
static unsigned int u32StupidCounter = 1;
|
||||
if((!(u32StupidCounter++ % 15) && u32StupidCounter > 200)) // exit key
|
||||
{
|
||||
CRssiPrinter::Handle(Fw, FwData);
|
||||
CRssiPrinter::Handle();
|
||||
}
|
||||
Fw.IRQ_SYSTICK();
|
||||
}
|
||||
IRQ_SYSTICK();
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@ class CRssiPrinter
|
|||
{
|
||||
public:
|
||||
static constexpr auto ChartStartX = 4*7 + 4;
|
||||
static void Handle(const System::TOrgFunctions& Fw, const System::TOrgData& FwData)
|
||||
static void Handle(void)
|
||||
{
|
||||
static bool bIsCleared = true;
|
||||
static unsigned char u8ChartPosition = 0;
|
||||
static unsigned char u8SqlDelayCnt = 0xFF;
|
||||
static unsigned char U8ScreenHistory[128 - ChartStartX] = {0};
|
||||
TUV_K5Display DisplayBuff(FwData.pDisplayBuffer);
|
||||
const TUV_K5SmallNumbers FontSmallNr(FwData.pSmallDigs);
|
||||
TUV_K5Display DisplayBuff(gDisplayBuffer);
|
||||
const TUV_K5SmallNumbers FontSmallNr(gSmallDigs);
|
||||
CDisplay Display(DisplayBuff);
|
||||
|
||||
if(!(GPIOC->DATA & 0b1))
|
||||
|
@ -22,7 +22,7 @@ class CRssiPrinter
|
|||
}
|
||||
|
||||
auto* pMenuCheckData = (unsigned char*)DisplayBuff.GetCoursorData(DisplayBuff.GetCoursorPosition(2, 6*8 + 1));
|
||||
if(Fw.BK4819Read(0x0C) & 0b10)
|
||||
if(BK4819Read(0x0C) & 0b10)
|
||||
{
|
||||
u8SqlDelayCnt = 0;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class CRssiPrinter
|
|||
u8ChartPosition = 0;
|
||||
if(*pMenuCheckData != 0xFF)
|
||||
{
|
||||
Fw.FlushFramebufferToScreen();
|
||||
FlushFramebufferToScreen();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ class CRssiPrinter
|
|||
Display.SetFont(&FontSmallNr);
|
||||
|
||||
char C8RssiString[] = "g000";
|
||||
unsigned char u8Rssi = ((Fw.BK4819Read(0x67) >> 1) & 0xFF);
|
||||
unsigned char u8Rssi = ((BK4819Read(0x67) >> 1) & 0xFF);
|
||||
if(!u8Rssi)
|
||||
{
|
||||
return;
|
||||
|
@ -96,6 +96,6 @@ class CRssiPrinter
|
|||
memcpy(pDData, U8ScreenHistory, sizeof(U8ScreenHistory));
|
||||
|
||||
u8ChartPosition++;
|
||||
Fw.FlushFramebufferToScreen();
|
||||
FlushFramebufferToScreen();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -6,21 +6,16 @@
|
|||
#include "rssi_sbar.hpp"
|
||||
#include "manager.hpp"
|
||||
|
||||
const System::TOrgFunctions &Fw = System::OrgFunc_01_26;
|
||||
const System::TOrgData &FwData = System::OrgData_01_26;
|
||||
|
||||
TUV_K5Display DisplayBuff(FwData.pDisplayBuffer);
|
||||
const TUV_K5SmallNumbers FontSmallNr(FwData.pSmallDigs);
|
||||
TUV_K5Display DisplayBuff(gDisplayBuffer);
|
||||
const TUV_K5SmallNumbers FontSmallNr(gSmallDigs);
|
||||
CDisplay Display(DisplayBuff);
|
||||
|
||||
TUV_K5Display StatusBarBuff(FwData.pStatusBarData);
|
||||
TUV_K5Display StatusBarBuff(gStatusBarData);
|
||||
CDisplay DisplayStatusBar(StatusBarBuff);
|
||||
|
||||
Radio::CBK4819<System::OrgFunc_01_26> RadioDriver;
|
||||
Radio::CBK4819 RadioDriver;
|
||||
|
||||
CRssiSbar<
|
||||
System::OrgFunc_01_26,
|
||||
System::OrgData_01_26,
|
||||
DisplayBuff,
|
||||
Display,
|
||||
DisplayStatusBar,
|
||||
|
@ -30,8 +25,6 @@ CRssiSbar<
|
|||
|
||||
#ifdef AM_TX
|
||||
CAmTx<
|
||||
System::OrgFunc_01_26,
|
||||
System::OrgData_01_26,
|
||||
DisplayBuff,
|
||||
Display,
|
||||
DisplayStatusBar,
|
||||
|
@ -49,20 +42,18 @@ static IView *const Views[] =
|
|||
};
|
||||
|
||||
CViewManager<
|
||||
System::OrgFunc_01_26,
|
||||
System::OrgData_01_26,
|
||||
8, 2, sizeof(Views) / sizeof(*Views)>
|
||||
Manager(Views);
|
||||
|
||||
int main()
|
||||
{
|
||||
Fw.IRQ_RESET();
|
||||
IRQ_RESET();
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" void Reset_Handler()
|
||||
{
|
||||
Fw.IRQ_RESET();
|
||||
IRQ_RESET();
|
||||
}
|
||||
|
||||
extern "C" void SysTick_Handler()
|
||||
|
@ -77,5 +68,5 @@ extern "C" void SysTick_Handler()
|
|||
|
||||
RadioDriver.InterruptHandler();
|
||||
Manager.Handle();
|
||||
Fw.IRQ_SYSTICK();
|
||||
}
|
||||
IRQ_SYSTICK();
|
||||
}
|
||||
|
|
|
@ -7,21 +7,16 @@
|
|||
#include "manager.hpp"
|
||||
#include "heater.hpp"
|
||||
|
||||
const System::TOrgFunctions &Fw = System::OrgFunc_01_26;
|
||||
const System::TOrgData &FwData = System::OrgData_01_26;
|
||||
|
||||
TUV_K5Display DisplayBuff(FwData.pDisplayBuffer);
|
||||
const TUV_K5SmallNumbers FontSmallNr(FwData.pSmallDigs);
|
||||
TUV_K5Display DisplayBuff(gDisplayBuffer);
|
||||
const TUV_K5SmallNumbers FontSmallNr(gSmallDigs);
|
||||
CDisplay Display(DisplayBuff);
|
||||
|
||||
TUV_K5Display StatusBarBuff(FwData.pStatusBarData);
|
||||
TUV_K5Display StatusBarBuff(gStatusBarData);
|
||||
CDisplay DisplayStatusBar(StatusBarBuff);
|
||||
|
||||
Radio::CBK4819<System::OrgFunc_01_26> RadioDriver;
|
||||
Radio::CBK4819 RadioDriver;
|
||||
|
||||
CRssiSbar<
|
||||
System::OrgFunc_01_26,
|
||||
System::OrgData_01_26,
|
||||
DisplayBuff,
|
||||
Display,
|
||||
DisplayStatusBar,
|
||||
|
@ -29,8 +24,6 @@ CRssiSbar<
|
|||
RadioDriver>
|
||||
RssiSbar;
|
||||
// CAmTx<
|
||||
// System::OrgFunc_01_26,
|
||||
// System::OrgData_01_26,
|
||||
// DisplayBuff,
|
||||
// Display,
|
||||
// DisplayStatusBar,
|
||||
|
@ -38,32 +31,29 @@ CRssiSbar<
|
|||
// RadioDriver>
|
||||
// AmTx;
|
||||
|
||||
CHeater<System::OrgFunc_01_26> Heater;
|
||||
CAmRx<System::OrgFunc_01_26> AmRx;
|
||||
// CMicVal<System::OrgFunc_01_26, RadioDriver> MicVal;
|
||||
// CRssiVal<System::OrgFunc_01_26, RadioDriver> RssiVal;
|
||||
CHeater Heater;
|
||||
CAmRx AmRx;
|
||||
// CMicVal<RadioDriver> MicVal;
|
||||
// CRssiVal<RadioDriver> RssiVal;
|
||||
|
||||
static IMenuElement * const MainMenuElements[] = {&Heater, &AmRx, &RssiSbar};
|
||||
|
||||
CMenu<System::OrgFunc_01_26,
|
||||
System::OrgData_01_26> Menu(MainMenuElements);
|
||||
CMenu Menu(MainMenuElements);
|
||||
|
||||
static IView * const Views[] = {&RssiSbar, &Menu};
|
||||
CViewManager<
|
||||
System::OrgFunc_01_26,
|
||||
System::OrgData_01_26,
|
||||
8, 1, sizeof(Views) / sizeof(*Views)>
|
||||
Manager(Views);
|
||||
|
||||
int main()
|
||||
{
|
||||
Fw.IRQ_RESET();
|
||||
IRQ_RESET();
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" void Reset_Handler()
|
||||
{
|
||||
Fw.IRQ_RESET();
|
||||
IRQ_RESET();
|
||||
}
|
||||
|
||||
extern "C" void SysTick_Handler()
|
||||
|
@ -78,5 +68,5 @@ extern "C" void SysTick_Handler()
|
|||
|
||||
// RadioDriver.InterruptHandler();
|
||||
Manager.Handle();
|
||||
Fw.IRQ_SYSTICK();
|
||||
}
|
||||
IRQ_SYSTICK();
|
||||
}
|
||||
|
|
|
@ -6,21 +6,19 @@
|
|||
#include <string.h>
|
||||
|
||||
Hardware::THardware Hw;
|
||||
const System::TOrgFunctions& Fw = System::OrgFunc_01_26;
|
||||
const System::TOrgData& FwData = System::OrgData_01_26;
|
||||
|
||||
CSpectrum<System::OrgFunc_01_26, System::OrgData_01_26> Spectrum;
|
||||
CSpectrum Spectrum;
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
Fw.IRQ_RESET();
|
||||
IRQ_RESET();
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" void Reset_Handler()
|
||||
{
|
||||
Fw.IRQ_RESET();
|
||||
IRQ_RESET();
|
||||
}
|
||||
|
||||
extern "C" void SysTick_Handler()
|
||||
|
@ -37,8 +35,8 @@ extern "C" void SysTick_Handler()
|
|||
bFirstInit = true;
|
||||
}
|
||||
|
||||
bool bPreventWhileKeypadPolling = pStackedRegs->LR > (unsigned int)Fw.PollKeyboard &&
|
||||
pStackedRegs->PC < (unsigned int)Fw.PollKeyboard + 0x100; // i made a mistake and compared PC and LR, but this works fine xD
|
||||
bool bPreventWhileKeypadPolling = pStackedRegs->LR > (unsigned int)PollKeyboard &&
|
||||
pStackedRegs->PC < (unsigned int)PollKeyboard + 0x100; // i made a mistake and compared PC and LR, but this works fine xD
|
||||
|
||||
static unsigned int u32StupidCounter = 1;
|
||||
if(u32StupidCounter++ > 200 && !bPreventWhileKeypadPolling)
|
||||
|
@ -46,5 +44,5 @@ extern "C" void SysTick_Handler()
|
|||
Spectrum.Handle();
|
||||
}
|
||||
|
||||
Fw.IRQ_SYSTICK();
|
||||
}
|
||||
IRQ_SYSTICK();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ static constexpr auto operator""_MHz(unsigned long long KiloHertz)
|
|||
return KiloHertz * 1000_KHz;
|
||||
}
|
||||
|
||||
template <const System::TOrgFunctions &Fw, const System::TOrgData &FwData>
|
||||
class CSpectrum
|
||||
{
|
||||
public:
|
||||
|
@ -33,8 +32,8 @@ public:
|
|||
static constexpr auto PressDuration = 30;
|
||||
static constexpr auto BWStep = 200_KHz;
|
||||
CSpectrum()
|
||||
: DisplayBuff(FwData.pDisplayBuffer),
|
||||
FontSmallNr(FwData.pSmallDigs),
|
||||
: DisplayBuff(gDisplayBuffer),
|
||||
FontSmallNr(gSmallDigs),
|
||||
Display(DisplayBuff),
|
||||
bDisplayCleared(true),
|
||||
u32ScanRange(1_MHz),
|
||||
|
@ -58,9 +57,9 @@ public:
|
|||
{
|
||||
bDisplayCleared = true;
|
||||
ClearDrawings();
|
||||
Fw.FlushFramebufferToScreen();
|
||||
FlushFramebufferToScreen();
|
||||
SetFrequency(u32OldFreq);
|
||||
Fw.BK4819Write(0x47, u16OldAfSettings); // set previous AF settings
|
||||
BK4819Write(0x47, u16OldAfSettings); // set previous AF settings
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -69,8 +68,8 @@ public:
|
|||
if (bDisplayCleared)
|
||||
{
|
||||
u32OldFreq = GetFrequency();
|
||||
u16OldAfSettings = Fw.BK4819Read(0x47);
|
||||
Fw.BK4819Write(0x47, 0); // mute AF during scan
|
||||
u16OldAfSettings = BK4819Read(0x47);
|
||||
BK4819Write(0x47, 0); // mute AF during scan
|
||||
}
|
||||
|
||||
bDisplayCleared = false;
|
||||
|
@ -118,7 +117,7 @@ public:
|
|||
{
|
||||
if (!(u8Pos % (DisplayBuff.SizeX / LabelsCnt)) || u8Pos == DisplayBuff.SizeX - 1)
|
||||
{
|
||||
*(FwData.pDisplayBuffer + 2 * DisplayBuff.SizeX + u8Pos) = 0xFF;
|
||||
gDisplayBuffer[2 * DisplayBuff.SizeX + u8Pos] = 0xFF;
|
||||
}
|
||||
|
||||
auto const FreqOffset = (u8Pos * u32ScanRange) >> 7;
|
||||
|
@ -140,7 +139,7 @@ public:
|
|||
}
|
||||
}
|
||||
// Display.DrawRectangle(0,0, 7, 7, 0);
|
||||
memcpy(FwData.pDisplayBuffer + 8 * 2 + 10 * 6 + 2, FwData.pSmallLeters + 18 + 5, 7);
|
||||
memcpy(gDisplayBuffer + 8 * 2 + 10 * 6 + 2, gSmallLeters + 18 + 5, 7);
|
||||
Display.SetCoursor(0, 0);
|
||||
Display.PrintFixedDigitsNumber2(u32OldFreq);
|
||||
Display.SetCoursor(1, 0);
|
||||
|
@ -152,31 +151,31 @@ public:
|
|||
Display.SetCoursor(0, 8 * 2 + 10 * 7);
|
||||
Display.PrintFixedDigitsNumber2(u32Peak);
|
||||
|
||||
memcpy(FwData.pDisplayBuffer + 128 * 2 + u8PeakPos - 3, FwData.pSmallLeters + 18 + 5, 7);
|
||||
Fw.FlushFramebufferToScreen();
|
||||
memcpy(gDisplayBuffer + 128 * 2 + u8PeakPos - 3, gSmallLeters + 18 + 5, 7);
|
||||
FlushFramebufferToScreen();
|
||||
}
|
||||
|
||||
private:
|
||||
void SetFrequency(unsigned int u32Freq)
|
||||
{
|
||||
Fw.BK4819Write(0x39, ((u32Freq >> 16) & 0xFFFF));
|
||||
Fw.BK4819Write(0x38, (u32Freq & 0xFFFF));
|
||||
// Fw.BK4819Write(0x37,7951);
|
||||
Fw.BK4819Write(0x30, 0);
|
||||
Fw.BK4819Write(0x30, 0xbff1);
|
||||
BK4819Write(0x39, ((u32Freq >> 16) & 0xFFFF));
|
||||
BK4819Write(0x38, (u32Freq & 0xFFFF));
|
||||
// BK4819Write(0x37,7951);
|
||||
BK4819Write(0x30, 0);
|
||||
BK4819Write(0x30, 0xbff1);
|
||||
}
|
||||
|
||||
unsigned char GetRssi(unsigned int u32Freq)
|
||||
{
|
||||
SetFrequency(u32Freq);
|
||||
Fw.DelayUs(800);
|
||||
return ((Fw.BK4819Read(0x67) >> 1) & 0xFF);
|
||||
DelayUs(800);
|
||||
return ((BK4819Read(0x67) >> 1) & 0xFF);
|
||||
}
|
||||
|
||||
unsigned int GetFrequency()
|
||||
{
|
||||
unsigned short u16f1 = Fw.BK4819Read(0x39);
|
||||
unsigned short u16f2 = Fw.BK4819Read(0x38);
|
||||
unsigned short u16f1 = BK4819Read(0x39);
|
||||
unsigned short u16f2 = BK4819Read(0x38);
|
||||
return ((u16f1 << 16) | u16f2);
|
||||
}
|
||||
|
||||
|
@ -187,12 +186,12 @@ private:
|
|||
{
|
||||
bEnabled = true;
|
||||
GPIOC->DATA &= ~GPIO_PIN_3;
|
||||
*FwData.p8FlashLightStatus = 3;
|
||||
gFlashLightStatus = 3;
|
||||
}
|
||||
|
||||
if (bEnabled)
|
||||
{
|
||||
u8LastBtnPressed = Fw.PollKeyboard();
|
||||
u8LastBtnPressed = PollKeyboard();
|
||||
}
|
||||
|
||||
bool bPtt = !(GPIOC->DATA & GPIO_PIN_5);
|
||||
|
@ -206,7 +205,7 @@ private:
|
|||
|
||||
void ClearDrawings()
|
||||
{
|
||||
memset(FwData.pDisplayBuffer, 0, (DisplayBuff.SizeX / 8) * DisplayBuff.SizeY);
|
||||
memset(gDisplayBuffer, 0, (DisplayBuff.SizeX / 8) * DisplayBuff.SizeY);
|
||||
}
|
||||
|
||||
TUV_K5Display DisplayBuff;
|
||||
|
@ -223,4 +222,4 @@ private:
|
|||
unsigned char u8ResolutionDiv;
|
||||
bool bEnabled;
|
||||
char C8Info[20];
|
||||
};
|
||||
};
|
||||
|
|
|
@ -7,18 +7,16 @@
|
|||
#include <string.h>
|
||||
|
||||
Hardware::THardware Hw;
|
||||
const System::TOrgFunctions &Fw = System::OrgFunc_01_26;
|
||||
const System::TOrgData &FwData = System::OrgData_01_26;
|
||||
|
||||
Radio::CBK4819<System::OrgFunc_01_26> RadioDriver;
|
||||
CSpectrum<System::OrgFunc_01_26, System::OrgData_01_26, RadioDriver> Spectrum;
|
||||
Radio::CBK4819 RadioDriver;
|
||||
CSpectrum<RadioDriver> Spectrum;
|
||||
|
||||
int main() {
|
||||
Fw.IRQ_RESET();
|
||||
IRQ_RESET();
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" void Reset_Handler() { Fw.IRQ_RESET(); }
|
||||
extern "C" void Reset_Handler() { IRQ_RESET(); }
|
||||
|
||||
extern "C" void SysTick_Handler() {
|
||||
static bool bFirstInit = false;
|
||||
|
@ -30,5 +28,5 @@ extern "C" void SysTick_Handler() {
|
|||
|
||||
Spectrum.Handle();
|
||||
|
||||
Fw.IRQ_SYSTICK();
|
||||
IRQ_SYSTICK();
|
||||
}
|
||||
|
|
|
@ -11,8 +11,7 @@ typedef unsigned int u32;
|
|||
typedef signed long long i64;
|
||||
typedef unsigned long long u64;
|
||||
|
||||
template <const System::TOrgFunctions &Fw, const System::TOrgData &FwData,
|
||||
Radio::CBK4819<Fw> &RadioDriver>
|
||||
template <Radio::CBK4819 &RadioDriver>
|
||||
class CSpectrum {
|
||||
public:
|
||||
static constexpr auto ExitKey = 13;
|
||||
|
@ -29,7 +28,7 @@ public:
|
|||
u32 FStart, fMeasure;
|
||||
|
||||
CSpectrum()
|
||||
: DisplayBuff(FwData.pDisplayBuffer), FontSmallNr(FwData.pSmallDigs),
|
||||
: DisplayBuff(gDisplayBuffer), FontSmallNr(gSmallDigs),
|
||||
Display(DisplayBuff), scanDelay(800), sampleZoom(2), scanStep(25_KHz),
|
||||
frequencyChangeStep(100_KHz), rssiTriggerLevel(65), stickyPeakTrigger(false) {
|
||||
Display.SetFont(&FontSmallNr);
|
||||
|
@ -43,7 +42,7 @@ public:
|
|||
if (fMeasure != highestPeakF) {
|
||||
fMeasure = highestPeakF;
|
||||
RadioDriver.SetFrequency(fMeasure);
|
||||
Fw.BK4819Write(0x47, u16OldAfSettings);
|
||||
BK4819Write(0x47, u16OldAfSettings);
|
||||
RadioDriver.ToggleAFDAC(true);
|
||||
}
|
||||
|
||||
|
@ -64,7 +63,7 @@ public:
|
|||
fMeasure = FStart;
|
||||
|
||||
RadioDriver.ToggleAFDAC(false);
|
||||
Fw.BK4819Write(0x47, 0);
|
||||
BK4819Write(0x47, 0);
|
||||
|
||||
for (u8 i = 0; i < measurementsCount; ++i, fMeasure += scanStep) {
|
||||
rssi = rssiHistory[i] = GetRssi(fMeasure);
|
||||
|
@ -134,15 +133,15 @@ public:
|
|||
modulo(f, 500_KHz) < step && (barValue |= 0b00100000);
|
||||
modulo(f, 1_MHz) < step && (barValue |= 0b11000000);
|
||||
|
||||
*(FwData.pDisplayBuffer + BarPos + i) |= barValue;
|
||||
gDisplayBuffer[BarPos + i] |= barValue;
|
||||
}
|
||||
|
||||
// center
|
||||
*(FwData.pDisplayBuffer + BarPos + 64) |= 0b10101010;
|
||||
gDisplayBuffer[BarPos + 64] |= 0b10101010;
|
||||
}
|
||||
|
||||
inline void DrawArrow(u8 x) {
|
||||
u8 *peakPos = FwData.pDisplayBuffer + BarPos + x;
|
||||
u8 *peakPos = gDisplayBuffer + BarPos + x;
|
||||
x > 1 && (*(peakPos - 2) |= 0b01000000);
|
||||
x > 0 && (*(peakPos - 1) |= 0b01100000);
|
||||
(*(peakPos) |= 0b01110000);
|
||||
|
@ -205,15 +204,15 @@ public:
|
|||
DrawSpectrum();
|
||||
DrawRssiTriggerLevel();
|
||||
DrawNums();
|
||||
Fw.FlushFramebufferToScreen();
|
||||
FlushFramebufferToScreen();
|
||||
}
|
||||
|
||||
void Update() {
|
||||
if (bDisplayCleared) {
|
||||
currentFreq = RadioDriver.GetFrequency();
|
||||
OnUserInput();
|
||||
u16OldAfSettings = Fw.BK4819Read(0x47);
|
||||
Fw.BK4819Write(0x47, 0); // mute AF during scan
|
||||
u16OldAfSettings = BK4819Read(0x47);
|
||||
BK4819Write(0x47, 0); // mute AF during scan
|
||||
}
|
||||
bDisplayCleared = false;
|
||||
|
||||
|
@ -269,7 +268,7 @@ public:
|
|||
highestPeakX = 64;
|
||||
highestPeakF = currentFreq;
|
||||
|
||||
Fw.DelayUs(90000);
|
||||
DelayUs(90000);
|
||||
}
|
||||
|
||||
void Handle() {
|
||||
|
@ -285,7 +284,7 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
lastButtonPressed = Fw.PollKeyboard();
|
||||
lastButtonPressed = PollKeyboard();
|
||||
if (lastButtonPressed == ExitKey) {
|
||||
working = false;
|
||||
RestoreParams();
|
||||
|
@ -300,16 +299,16 @@ private:
|
|||
if (!bDisplayCleared) {
|
||||
bDisplayCleared = true;
|
||||
DisplayBuff.ClearAll();
|
||||
Fw.FlushFramebufferToScreen();
|
||||
FlushFramebufferToScreen();
|
||||
RadioDriver.SetFrequency(currentFreq);
|
||||
Fw.BK4819Write(0x47, u16OldAfSettings); // set previous AF settings
|
||||
BK4819Write(0x47, u16OldAfSettings); // set previous AF settings
|
||||
}
|
||||
}
|
||||
|
||||
inline void Listen(u32 duration) {
|
||||
for (u8 i = 0; i < 16 && lastButtonPressed == 255; ++i) {
|
||||
lastButtonPressed = Fw.PollKeyboard();
|
||||
Fw.DelayUs(duration >> 4);
|
||||
lastButtonPressed = PollKeyboard();
|
||||
DelayUs(duration >> 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -320,8 +319,8 @@ private:
|
|||
RadioDriver.ToggleRXDSP(true);
|
||||
}
|
||||
|
||||
Fw.DelayUs(scanDelay);
|
||||
return Fw.BK4819Read(0x67);
|
||||
DelayUs(scanDelay);
|
||||
return BK4819Read(0x67);
|
||||
}
|
||||
|
||||
u8 GetRssi(u32 f) {
|
||||
|
@ -332,7 +331,7 @@ private:
|
|||
inline bool IsFlashLightOn() { return GPIOC->DATA & GPIO_PIN_3; }
|
||||
inline void TurnOffFlashLight() {
|
||||
GPIOC->DATA &= ~GPIO_PIN_3;
|
||||
*FwData.p8FlashLightStatus = 3;
|
||||
gFlashLightStatus = 3;
|
||||
}
|
||||
|
||||
inline void ToggleBacklight() { GPIOB->DATA ^= GPIO_PIN_6; }
|
||||
|
|
|
@ -6,20 +6,18 @@
|
|||
#include <string.h>
|
||||
|
||||
Hardware::THardware Hw;
|
||||
const System::TOrgFunctions& Fw = System::OrgFunc_01_26;
|
||||
const System::TOrgData& FwData = System::OrgData_01_26;
|
||||
|
||||
CT9Texting<System::OrgFunc_01_26, System::OrgData_01_26> T9Texting;
|
||||
CT9Texting T9Texting;
|
||||
|
||||
int main()
|
||||
{
|
||||
Fw.IRQ_RESET();
|
||||
IRQ_RESET();
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" void Reset_Handler()
|
||||
{
|
||||
Fw.IRQ_RESET();
|
||||
IRQ_RESET();
|
||||
}
|
||||
|
||||
extern "C" void SysTick_Handler()
|
||||
|
@ -36,13 +34,13 @@ extern "C" void SysTick_Handler()
|
|||
bFirstInit = true;
|
||||
}
|
||||
|
||||
bool bPreventWhileKeypadPolling = pStackedRegs->LR > (unsigned int)Fw.PollKeyboard &&
|
||||
pStackedRegs->PC < (unsigned int)Fw.PollKeyboard + 0x100; // i made a mistake and compared PC and LR, but this works fine xD
|
||||
bool bPreventWhileKeypadPolling = pStackedRegs->LR > (unsigned int)PollKeyboard &&
|
||||
pStackedRegs->PC < (unsigned int)PollKeyboard + 0x100; // i made a mistake and compared PC and LR, but this works fine xD
|
||||
|
||||
static unsigned int u32StupidCounter = 1;
|
||||
if(u32StupidCounter++ > 200 && !bPreventWhileKeypadPolling)
|
||||
{
|
||||
T9Texting.Handle();
|
||||
}
|
||||
Fw.IRQ_SYSTICK();
|
||||
}
|
||||
IRQ_SYSTICK();
|
||||
}
|
||||
|
|
|
@ -3,12 +3,11 @@
|
|||
#include "uv_k5_display.hpp"
|
||||
#include "keyboard.hpp"
|
||||
|
||||
template <const System::TOrgFunctions &Fw, const System::TOrgData &FwData>
|
||||
class CT9Texting
|
||||
{
|
||||
public:
|
||||
CT9Texting()
|
||||
: DisplayBuff(FwData.pDisplayBuffer),
|
||||
: DisplayBuff(gDisplayBuffer),
|
||||
Display(DisplayBuff),
|
||||
Keyboard(*this),
|
||||
bDisplayCleared(true),
|
||||
|
@ -67,7 +66,7 @@ public:
|
|||
// Clear cMessage
|
||||
memset(cMessage, 0, 30);
|
||||
c_index = 0;
|
||||
Fw.FlushFramebufferToScreen();
|
||||
FlushFramebufferToScreen();
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -123,8 +122,8 @@ public:
|
|||
prev_key = key;
|
||||
// Display.DrawRectangle(0,0, 7, 7, 0);
|
||||
ClearDrawings();
|
||||
Fw.PrintTextOnScreen(cMessage, 0, 128, 0, 8, 0);
|
||||
Fw.FlushFramebufferToScreen();
|
||||
PrintTextOnScreen(cMessage, 0, 128, 0, 8, 0);
|
||||
FlushFramebufferToScreen();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -136,15 +135,15 @@ private:
|
|||
{
|
||||
bEnabled = true;
|
||||
GPIOC->DATA &= ~GPIO_PIN_3;
|
||||
*FwData.p8FlashLightStatus = 3;
|
||||
gFlashLightStatus = 3;
|
||||
}
|
||||
|
||||
if (bEnabled)
|
||||
{
|
||||
u8LastBtnPressed = Fw.PollKeyboard();
|
||||
u8LastBtnPressed = PollKeyboard();
|
||||
}
|
||||
|
||||
// u8LastBtnPressed = Fw.PollKeyboard();
|
||||
// u8LastBtnPressed = PollKeyboard();
|
||||
// if (u8LastBtnPressed == EnableKey)
|
||||
// {
|
||||
// u8PressCnt++;
|
||||
|
@ -161,7 +160,7 @@ private:
|
|||
|
||||
void ClearDrawings()
|
||||
{
|
||||
memset(FwData.pDisplayBuffer, 0, (DisplayBuff.SizeX / 8) * DisplayBuff.SizeY);
|
||||
memset(gDisplayBuffer, 0, (DisplayBuff.SizeX / 8) * DisplayBuff.SizeY);
|
||||
}
|
||||
|
||||
TUV_K5Display DisplayBuff;
|
||||
|
|
Ładowanie…
Reference in New Issue