From 24b2139afb98573e881e3da16f444de85f23f567 Mon Sep 17 00:00:00 2001 From: Piotr Lewandowski Date: Sat, 1 Jul 2023 22:22:27 +0200 Subject: [PATCH] rssi_printer --- .vscode/launch.json | 4 +- .vscode/tasks.json | 2 +- CMakeLists.txt | 4 +- libs/CMakeLists.txt | 4 +- libs/k5_uv_system/CMakeLists.txt | 20 ++++ .../k5_uv_system}/gen_vect_table.py | 0 .../system => libs/k5_uv_system}/system.cpp | 0 .../system => libs/k5_uv_system}/system.hpp | 26 ++++- libs/lcd/CMakeLists.txt | 22 ++++ libs/lcd/lcd.cpp | 1 + libs/lcd/lcd.hpp | 90 ++++++++++++++++ libs/lcd/uv_k5_display.hpp | 99 ++++++++++++++++++ openocd_scripts/dp32g030.cfg | 2 +- src/CMakeLists.txt | 2 +- .../k5_26_encrypted_18to1300MHz.ver.bin | Bin 0 -> 16 bytes src/par_runner/main.cpp | 38 ------- .../CMakeLists.txt | 12 ++- src/{par_runner => rssi_printer}/dp32g030.s | 0 src/{par_runner => rssi_printer}/exec.hpp | 0 src/{par_runner => rssi_printer}/fw_merger.py | 0 .../hardware/hardware.cpp | 2 +- .../hardware/hardware.hpp | 0 src/rssi_printer/main.cpp | 26 +++++ src/{par_runner => rssi_printer}/memory.ld | 2 +- .../registers.hpp | 0 src/rssi_printer/rssi_printer.hpp | 77 ++++++++++++++ 26 files changed, 381 insertions(+), 52 deletions(-) create mode 100644 libs/k5_uv_system/CMakeLists.txt rename {src/par_runner/system => libs/k5_uv_system}/gen_vect_table.py (100%) rename {src/par_runner/system => libs/k5_uv_system}/system.cpp (100%) rename {src/par_runner/system => libs/k5_uv_system}/system.hpp (64%) create mode 100644 libs/lcd/CMakeLists.txt create mode 100644 libs/lcd/lcd.cpp create mode 100644 libs/lcd/lcd.hpp create mode 100644 libs/lcd/uv_k5_display.hpp create mode 100644 src/orginal_fw/k5_26_encrypted_18to1300MHz.ver.bin delete mode 100644 src/par_runner/main.cpp rename src/{par_runner => rssi_printer}/CMakeLists.txt (81%) rename src/{par_runner => rssi_printer}/dp32g030.s (100%) rename src/{par_runner => rssi_printer}/exec.hpp (100%) rename src/{par_runner => rssi_printer}/fw_merger.py (100%) rename src/{par_runner => rssi_printer}/hardware/hardware.cpp (96%) rename src/{par_runner => rssi_printer}/hardware/hardware.hpp (100%) create mode 100644 src/rssi_printer/main.cpp rename src/{par_runner => rssi_printer}/memory.ld (96%) rename src/{par_runner => rssi_printer}/registers.hpp (100%) create mode 100644 src/rssi_printer/rssi_printer.hpp diff --git a/.vscode/launch.json b/.vscode/launch.json index 3ed1951..420a7ed 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,7 +4,7 @@ { "svdFile": "./.vscode/stm32g030.svd", "cwd": "${workspaceRoot}", - "executable": "./build/src/par_runner/par_runner", + "executable": "./build/src/rssi_printer/rssi_printer", "name": "kwaczek DBG", "request": "launch", "type": "cortex-debug", @@ -25,7 +25,7 @@ { "svdFile": "./.vscode/stm32g030.svd", "cwd": "${workspaceRoot}", - "executable": "./build/src/par_runner/par_runner", + "executable": "./build/src/rssi_printer/rssi_printer", "name": "attach kwaczek", "request": "attach", "type": "cortex-debug", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index f17a4ed..b7db7fe 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -4,7 +4,7 @@ { "label": "flash firmware", "type": "shell", - "command": "openocd -f interface/cmsis-dap.cfg -f ./openocd_scripts/dp32g030.cfg -c 'reset halt' -c 'write_image ./build/src/par_runner/par_runner_with_bootloader.bin 0' -c 'shutdown'", + "command": "openocd -f interface/cmsis-dap.cfg -f ./openocd_scripts/dp32g030.cfg -c 'reset halt' -c 'write_image ./build/src/rssi_printer/rssi_printer_with_bootloader.bin 0' -c 'shutdown'", "presentation": { "reveal": "always", "panel": "shared" diff --git a/CMakeLists.txt b/CMakeLists.txt index f376e21..7b5221b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.15) set(OPTI_FLAG s) -set(CMAKE_BUILD_TYPE Debug) +set(CMAKE_BUILD_TYPE MinSizeRelease) set(STM32_DEFINES "-DSTM32F0 -DSTM32F030x8 -DSTM32") @@ -21,7 +21,7 @@ set(CMAKE_CXX_EXTENSIONS ON) set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) -set(COMPILER_OPTIONS -mthumb -mcpu=cortex-m0plus -mfpu=auto -mfloat-abi=soft -fno-exceptions +set(COMPILER_OPTIONS -mthumb -mcpu=cortex-m0 -mfpu=auto -mfloat-abi=soft -fno-exceptions -msoft-float -fdata-sections -ffunction-sections -Wall $<$:-Wno-register> -Wno-unknown-pragmas -O${OPTI_FLAG} $<$:-fno-rtti> $<$:--debug -DDEBUG> diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index 3cb222b..4f3c4f7 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -1,2 +1,4 @@ add_subdirectory(g030_drivers) -add_subdirectory(f030_drivers) \ No newline at end of file +add_subdirectory(f030_drivers) +add_subdirectory(k5_uv_system) +add_subdirectory(lcd) \ No newline at end of file diff --git a/libs/k5_uv_system/CMakeLists.txt b/libs/k5_uv_system/CMakeLists.txt new file mode 100644 index 0000000..2b6571d --- /dev/null +++ b/libs/k5_uv_system/CMakeLists.txt @@ -0,0 +1,20 @@ +set(NAME uv_k5_system) +add_library(${NAME} STATIC) + +target_include_directories(${NAME} INTERFACE + . +) + +target_include_directories(${NAME} PRIVATE + . +) + +target_sources(${NAME} PRIVATE + system.cpp +) + +target_link_libraries(${NAME} +) + +target_compile_options(${NAME} PRIVATE ${COMPILER_OPTIONS}) + diff --git a/src/par_runner/system/gen_vect_table.py b/libs/k5_uv_system/gen_vect_table.py similarity index 100% rename from src/par_runner/system/gen_vect_table.py rename to libs/k5_uv_system/gen_vect_table.py diff --git a/src/par_runner/system/system.cpp b/libs/k5_uv_system/system.cpp similarity index 100% rename from src/par_runner/system/system.cpp rename to libs/k5_uv_system/system.cpp diff --git a/src/par_runner/system/system.hpp b/libs/k5_uv_system/system.hpp similarity index 64% rename from src/par_runner/system/system.hpp rename to libs/k5_uv_system/system.hpp index 9d929a4..dfb8d5b 100644 --- a/src/par_runner/system/system.hpp +++ b/libs/k5_uv_system/system.hpp @@ -1,3 +1,4 @@ +#pragma once namespace System { using VoidFxPointer = void(*)(void); @@ -16,7 +17,15 @@ namespace System unsigned int u32StartPixel, unsigned int u32StopPixel, unsigned int u32LineNumber, - unsigned int u32Centered); + unsigned int u32PxPerChar, + unsigned int u32Centered, + unsigned int u32MenuLen, + unsigned int u32AsciiIdx, + unsigned int u32Unknown0, + unsigned int u32Unknown1, + unsigned int u32Unknown2, + unsigned int u32Unknown3 + ); void(*FillScreenMemory)(unsigned int u32Param1); void(*DelayMs)(unsigned int u32Ms); @@ -24,6 +33,13 @@ namespace System 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); + }; + + struct TOrgData + { + unsigned char* pDisplayBuffer; + unsigned char* pSmallDigs; }; inline const TOrgFunctions OrgFunc_01_26 = @@ -35,5 +51,13 @@ namespace System .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)) + }; + + inline const TOrgData OrgData_01_26 = + { + .pDisplayBuffer = (decltype(TOrgData::pDisplayBuffer)) 0x20000704, + .pSmallDigs = (decltype(TOrgData::pSmallDigs)) 0xD620, + }; } \ No newline at end of file diff --git a/libs/lcd/CMakeLists.txt b/libs/lcd/CMakeLists.txt new file mode 100644 index 0000000..5b7ead2 --- /dev/null +++ b/libs/lcd/CMakeLists.txt @@ -0,0 +1,22 @@ +set(NAME lcd) + +add_library(${NAME} STATIC) + +target_include_directories(${NAME} INTERFACE + . +) + +target_include_directories(${NAME} PRIVATE + . +) + +target_sources(${NAME} PRIVATE + lcd.cpp +) + +target_link_libraries(${NAME} + uv_k5_system +) + +target_compile_options(${NAME} PRIVATE ${COMPILER_OPTIONS}) + diff --git a/libs/lcd/lcd.cpp b/libs/lcd/lcd.cpp new file mode 100644 index 0000000..3f0e2d9 --- /dev/null +++ b/libs/lcd/lcd.cpp @@ -0,0 +1 @@ +#include "lcd.hpp" \ No newline at end of file diff --git a/libs/lcd/lcd.hpp b/libs/lcd/lcd.hpp new file mode 100644 index 0000000..d3b9f4d --- /dev/null +++ b/libs/lcd/lcd.hpp @@ -0,0 +1,90 @@ +#pragma once +#include +#include + +struct ILcd +{ + virtual void UpdateScreen() = 0; +}; + +template +struct IBitmap +{ + constexpr IBitmap(const unsigned char* _pBuffStart) :pBuffStart(_pBuffStart){}; + static constexpr auto SizeX = _SizeX; + static constexpr auto SizeY = _SizeY; + static constexpr auto LineHeight = _LineHeight; + static constexpr auto Lines = _SizeX / _LineHeight; + static constexpr unsigned short GetCoursorPosition(unsigned char u8Line, unsigned char u8XPos) + { + return (u8Line * SizeX) + u8XPos; + } + + virtual bool GetPixel(unsigned char u8X, unsigned char u8Y) const = 0; + virtual void SetPixel(unsigned char u8X, unsigned char u8Y) const = 0; + virtual void* GetCoursorData(unsigned short u16CoursorPosition) const {return nullptr;} + + const unsigned char* pBuffStart; +}; + +struct IFont +{ + virtual bool GetPixel(char c8Character, unsigned char u8X, unsigned char u8Y) const = 0; + virtual unsigned char* GetRaw(char c8Character) const = 0; + virtual unsigned char GetSizeX(char c8Character) const = 0; + virtual unsigned char GetSizeY(char c8Character) const = 0; +}; + +template +class CDisplay +{ + public: + constexpr CDisplay(BitmapType& _Bitmap) + :Bitmap(_Bitmap), pCurrentFont(nullptr), u16CoursorPosition(0) + {} + + void SetCoursor(unsigned char u8Line, unsigned char u8X) const + { + u16CoursorPosition = (u8Line * Bitmap.SizeX) + u8X; + } + + void SetFont(const IFont* pFont) const + { + pCurrentFont = pFont; + } + + unsigned char PrintCharacter(const char c8Character) const + { + if(!pCurrentFont) + { + return 0; + } + + const auto* const pFontRawData = pCurrentFont->GetRaw(c8Character); + auto* pCoursorPosition = Bitmap.GetCoursorData(u16CoursorPosition); + auto const CopySize = pCurrentFont->GetSizeY(c8Character) * (BitmapType::LineHeight / 8); + if(pCoursorPosition && !(BitmapType::LineHeight % 8)) + { + if(pFontRawData) + memcpy(pCoursorPosition, pFontRawData, CopySize); + else + memset(pCoursorPosition, 0, CopySize); + } + + u16CoursorPosition += pCurrentFont->GetSizeY(c8Character); + return 0; + } + + void Print(const char* C8String) + { + for(unsigned char i = 0; i < strlen(C8String); i++) + { + PrintCharacter(C8String[i]); + } + } + + private: + const BitmapType& Bitmap; + mutable const IFont* pCurrentFont; + mutable unsigned short u16CoursorPosition; +}; \ No newline at end of file diff --git a/libs/lcd/uv_k5_display.hpp b/libs/lcd/uv_k5_display.hpp new file mode 100644 index 0000000..cee9baa --- /dev/null +++ b/libs/lcd/uv_k5_display.hpp @@ -0,0 +1,99 @@ +#pragma once +#include "lcd.hpp" + +struct TUV_K5Display : public IBitmap<128, 96, 8> +{ + constexpr TUV_K5Display(const unsigned char* p8ScreenData) : IBitmap(p8ScreenData){}; + bool GetPixel(unsigned char u8X, unsigned char u8Y) const override + { + return 0; + } + + void SetPixel(unsigned char u8X, unsigned char u8Y) const override + { + + } + + void* GetCoursorData(unsigned short u16CoursorPosition) const override + { + return (void*) (&pBuffStart[u16CoursorPosition]); + } +}; + +struct TUV_K5SmallNumbers : public IFont +{ + static constexpr auto FixedSizeY = 7; + constexpr TUV_K5SmallNumbers(unsigned char* _p8FontData) + :pFontData(_p8FontData){} + + bool GetPixel(char c8Character, unsigned char u8X, unsigned char u8Y) const override + { + return 0; + } + + unsigned char* GetRaw(char c8Character) const override + { + if(c8Character < '0' || c8Character > '9') // 45 - minus + { + if(c8Character == '-') + { + return pFontData + (FixedSizeY * 10); + } + + return nullptr; + } + + return pFontData + ((c8Character - '0') * FixedSizeY); + } + + unsigned char GetSizeX(char c8Character) const override + { + return 8; + } + + unsigned char GetSizeY(char c8Character) const override + { + return FixedSizeY; + } + + unsigned char* const pFontData; +}; + +struct TUV_K5Small : public IFont +{ + static constexpr auto FixedSizeY = 7; + constexpr TUV_K5Small(unsigned char* _p8FontData) + :pFontData(_p8FontData){} + + bool GetPixel(char c8Character, unsigned char u8X, unsigned char u8Y) const override + { + return 0; + } + + unsigned char* GetRaw(char c8Character) const override + { + if(c8Character < '0' || c8Character > '9') // 45 - minus + { + if(c8Character == '-') + { + return pFontData + (FixedSizeY * 10); + } + + return nullptr; + } + + return pFontData + ((c8Character - '0') * FixedSizeY); + } + + unsigned char GetSizeX(char c8Character) const override + { + return 8; + } + + unsigned char GetSizeY(char c8Character) const override + { + return FixedSizeY; + } + + unsigned char* const pFontData; +}; \ No newline at end of file diff --git a/openocd_scripts/dp32g030.cfg b/openocd_scripts/dp32g030.cfg index a1d5139..a9b4a19 100644 --- a/openocd_scripts/dp32g030.cfg +++ b/openocd_scripts/dp32g030.cfg @@ -1,5 +1,5 @@ transport select swd -adapter speed 16000 +adapter speed 32000 reset_config srst_only srst_nogate connect_assert_srst set _CHIP_NAME DP32G0xx diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3cc9bec..87a2ac7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,3 @@ add_subdirectory(orginal_fw) -add_subdirectory(par_runner) +add_subdirectory(rssi_printer) # add_subdirectory(ocl_loader) \ No newline at end of file diff --git a/src/orginal_fw/k5_26_encrypted_18to1300MHz.ver.bin b/src/orginal_fw/k5_26_encrypted_18to1300MHz.ver.bin new file mode 100644 index 0000000000000000000000000000000000000000..26c66e578e213bb664c5c5b2197835ac379f179e GIT binary patch literal 16 QcmXrgGceRMGGl-N01;^cSO5S3 literal 0 HcmV?d00001 diff --git a/src/par_runner/main.cpp b/src/par_runner/main.cpp deleted file mode 100644 index ca43fc2..0000000 --- a/src/par_runner/main.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "system/system.hpp" -#include "hardware/hardware.hpp" -#include "registers.hpp" - -Hardware::THardware Hw; -const System::TOrgFunctions Fw = System::OrgFunc_01_26; - -int main() -{ - System::JumpToOrginalFw(); - return 0; -} - -void MultiIrq_Handler(unsigned int u32IrqSource) -{ - if(GPIOA->DATA & GPIO_PIN_3) // exit key - { - Hw.FlashLight.BlinkSync(1); - - Fw.BK4819Write(0x58, 0b01111100110011); - for(int i = 0; i < 8; i++) - { - Fw.BK4819Write(0x5F, 0xAB); - } - - Fw.BK4819Read(0x1); - // Fw.BK4819Write(0x5D, 0xF << 5); - // Fw.BK4819Write(0x59, 0b1 << 11); - // Fw.BK4819Write(0x58, 0b01111100110011); - - } - - unsigned char u8Pa10_13 = (GPIOA->DATA >> 10) & 0xF; - if(u8Pa10_13) - { - Hw.FlashLight.BlinkSync(u8Pa10_13); - } -} \ No newline at end of file diff --git a/src/par_runner/CMakeLists.txt b/src/rssi_printer/CMakeLists.txt similarity index 81% rename from src/par_runner/CMakeLists.txt rename to src/rssi_printer/CMakeLists.txt index bfe6714..33a130e 100644 --- a/src/par_runner/CMakeLists.txt +++ b/src/rssi_printer/CMakeLists.txt @@ -1,10 +1,9 @@ -set(NAME par_runner) +set(NAME rssi_printer) set(MCU_TARGET_FILES_DIR ../mcu_target_common) add_executable(${NAME} ${MCU_TARGET_FILES_DIR}/stm32f030xc.s main.cpp - system/system.cpp hardware/hardware.cpp dp32g030.s ) @@ -12,6 +11,8 @@ add_executable(${NAME} target_link_libraries(${NAME} f030_drivers orginal_fw + uv_k5_system + lcd ) target_include_directories(${NAME} PUBLIC @@ -68,6 +69,11 @@ add_custom_command(TARGET ${NAME} ) add_custom_target(${NAME}_flash - COMMAND openocd -f interface/cmsis-dap.cfg -f ${PROJECT_SOURCE_DIR}/openocd_scripts/dp32g030.cfg -c "write_image ${PROJECT_SOURCE_DIR}/build/src/par_runner/par_runner.bin 0x1000" -c "halt" -c "shutdown" + COMMAND openocd -f interface/cmsis-dap.cfg -f ${PROJECT_SOURCE_DIR}/openocd_scripts/dp32g030.cfg -c "write_image ${PROJECT_SOURCE_DIR}/build/src/rssi_printer/rssi_printer.bin 0x1000" -c "halt" -c "shutdown" + DEPENDS ${NAME} +) + +add_custom_target(${NAME}_encoded + COMMAND python ${PROJECT_SOURCE_DIR}/tools/fw_tools/python-utils/fw_pack.py ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.bin ${CMAKE_CURRENT_SOURCE_DIR}/../orginal_fw/k5_26_encrypted_18to1300MHz.ver.bin ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_encoded.bin DEPENDS ${NAME} ) \ No newline at end of file diff --git a/src/par_runner/dp32g030.s b/src/rssi_printer/dp32g030.s similarity index 100% rename from src/par_runner/dp32g030.s rename to src/rssi_printer/dp32g030.s diff --git a/src/par_runner/exec.hpp b/src/rssi_printer/exec.hpp similarity index 100% rename from src/par_runner/exec.hpp rename to src/rssi_printer/exec.hpp diff --git a/src/par_runner/fw_merger.py b/src/rssi_printer/fw_merger.py similarity index 100% rename from src/par_runner/fw_merger.py rename to src/rssi_printer/fw_merger.py diff --git a/src/par_runner/hardware/hardware.cpp b/src/rssi_printer/hardware/hardware.cpp similarity index 96% rename from src/par_runner/hardware/hardware.cpp rename to src/rssi_printer/hardware/hardware.cpp index 37336b7..63ae73b 100644 --- a/src/par_runner/hardware/hardware.cpp +++ b/src/rssi_printer/hardware/hardware.cpp @@ -43,7 +43,7 @@ void TFlashLight::BlinkSync(unsigned char u8BlinksCnt) for(unsigned char i = 0; i < u8BlinksCnt*2; i++) { Toggle(); - System.Delay(100000); + System.Delay(200000); } Off(); diff --git a/src/par_runner/hardware/hardware.hpp b/src/rssi_printer/hardware/hardware.hpp similarity index 100% rename from src/par_runner/hardware/hardware.hpp rename to src/rssi_printer/hardware/hardware.hpp diff --git a/src/rssi_printer/main.cpp b/src/rssi_printer/main.cpp new file mode 100644 index 0000000..f121663 --- /dev/null +++ b/src/rssi_printer/main.cpp @@ -0,0 +1,26 @@ +#include "system.hpp" +#include "hardware/hardware.hpp" +#include "registers.hpp" +#include "uv_k5_display.hpp" +#include "rssi_printer.hpp" +#include + +Hardware::THardware Hw; +const System::TOrgFunctions& Fw = System::OrgFunc_01_26; +const System::TOrgData& FwData = System::OrgData_01_26; + +int main() +{ + System::JumpToOrginalFw(); + return 0; +} + +void MultiIrq_Handler(unsigned int u32IrqSource) +{ + static unsigned int u32StupidCounter = 1; + //GPIOA->DATA & GPIO_PIN_3 + if((!(u32StupidCounter++ % 15) && u32StupidCounter > 200)) // exit key + { + CRssiPrinter::Handle(Fw, FwData); + } +} \ No newline at end of file diff --git a/src/par_runner/memory.ld b/src/rssi_printer/memory.ld similarity index 96% rename from src/par_runner/memory.ld rename to src/rssi_printer/memory.ld index 23e14b6..471d325 100644 --- a/src/par_runner/memory.ld +++ b/src/rssi_printer/memory.ld @@ -2,7 +2,7 @@ ENTRY(Reset_Handler) MEMORY { - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 4K + RAM (rwx) : ORIGIN = 0x2000138B, LENGTH = 4K FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 60K } diff --git a/src/par_runner/registers.hpp b/src/rssi_printer/registers.hpp similarity index 100% rename from src/par_runner/registers.hpp rename to src/rssi_printer/registers.hpp diff --git a/src/rssi_printer/rssi_printer.hpp b/src/rssi_printer/rssi_printer.hpp new file mode 100644 index 0000000..91d3506 --- /dev/null +++ b/src/rssi_printer/rssi_printer.hpp @@ -0,0 +1,77 @@ +#pragma once +#include "system.hpp" +#include "uv_k5_display.hpp" + +class CRssiPrinter +{ + public: + static constexpr auto ChartStartX = 4*7 + 4; + static void Handle(const System::TOrgFunctions& Fw, const System::TOrgData& FwData) + { + static bool bIsCleared = false; + static unsigned char u8ChartPosition = 0; + TUV_K5Display DisplayBuff(FwData.pDisplayBuffer); + const TUV_K5SmallNumbers FontSmallNr(FwData.pSmallDigs); + CDisplay Display(DisplayBuff); + + auto* pMenuCheckData = (unsigned char*)DisplayBuff.GetCoursorData(DisplayBuff.GetCoursorPosition(3, ChartStartX)); + bool bIsSqlOpen = (Fw.BK4819Read(0x0C) & 0b10); + if(!bIsSqlOpen || *pMenuCheckData == 0xFF) + { + if(!bIsCleared) + { + bIsCleared = true; + u8ChartPosition = ChartStartX; + auto* pDData = (unsigned char*)DisplayBuff.GetCoursorData(DisplayBuff.GetCoursorPosition(3, 0)); + memset(pDData, 0, DisplayBuff.SizeX); + Fw.FlushFramebufferToScreen(); + } + + return; + } + + Display.SetCoursor(3, 0); + Display.SetFont(&FontSmallNr); + + char C8RssiString[] = "g000"; + unsigned char u8Rssi = ((Fw.BK4819Read(0x67) >> 1) & 0xFF); + if(!u8Rssi) + { + return; + } + + if(u8Rssi > 160) + { + u8Rssi -= 160; + C8RssiString[0] = ' '; + } + else + { + u8Rssi = 160 - u8Rssi; + C8RssiString[0] = '-'; + } + + C8RssiString[1] = '0' + u8Rssi / 100; + C8RssiString[2] = '0' + (u8Rssi / 10) % 10; + C8RssiString[3] = '0' + u8Rssi % 10; + + Display.Print(C8RssiString); + + if(u8ChartPosition < ChartStartX || u8ChartPosition >= TUV_K5Display::SizeX) + u8ChartPosition = ChartStartX; + + unsigned char u8Sub = (u8Rssi * 7) >> 7; + unsigned char u8PrintShift = (u8Sub > 7 ? 7 : u8Sub); + auto* pDData = (unsigned char*)DisplayBuff.GetCoursorData(DisplayBuff.GetCoursorPosition(3, 0) + u8ChartPosition); + *pDData = (1 << u8PrintShift) & 0xFF; + if(u8ChartPosition + 4 < DisplayBuff.SizeX) + { + for(unsigned char i = 0; i < 4; i++) + { + *(++pDData) = 0; + } + } + u8ChartPosition++; + Fw.FlushFramebufferToScreen(); + } +}; \ No newline at end of file