From 487b28177941496ec292b91882ec7749194ff835 Mon Sep 17 00:00:00 2001 From: Mikhail Yudin Date: Sun, 13 Aug 2023 14:46:53 +0700 Subject: [PATCH] feat: Strlen from fw, turn on green led on squelch open --- libs/k5_uv_system/api.s | 3 +++ libs/k5_uv_system/system.hpp | 1 + libs/lcd/lcd.hpp | 5 +++-- src/spectrum_fagci/spectrum.hpp | 13 +++---------- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/libs/k5_uv_system/api.s b/libs/k5_uv_system/api.s index 5f09def..d8c3f50 100644 --- a/libs/k5_uv_system/api.s +++ b/libs/k5_uv_system/api.s @@ -43,6 +43,9 @@ BK4819Reset = 0xa7cc + 1; .globl IntDivide IntDivide = 0x128 + 1; +.globl Strlen +Strlen = 0x1c0 + 1; + .globl BK4819SetChannelBandwidth BK4819SetChannelBandwidth = 0xaa48 + 1; diff --git a/libs/k5_uv_system/system.hpp b/libs/k5_uv_system/system.hpp index ed02fb6..c0ac537 100644 --- a/libs/k5_uv_system/system.hpp +++ b/libs/k5_uv_system/system.hpp @@ -23,6 +23,7 @@ extern "C" { void AirCopyFskSetup(); void BK4819Reset(); int IntDivide(int s32Divident, int s32Divisor); + int Strlen(const char *string); void BK4819SetChannelBandwidth(bool narrow); void BK4819WriteFrequency(unsigned int u32Frequency); void BK4819SetPaGain(unsigned short u16PaBias, unsigned int u32Frequency); diff --git a/libs/lcd/lcd.hpp b/libs/lcd/lcd.hpp index e13c26b..c649f1b 100644 --- a/libs/lcd/lcd.hpp +++ b/libs/lcd/lcd.hpp @@ -1,6 +1,7 @@ #pragma once #include #include +#include "system.hpp" struct ILcd { virtual void UpdateScreen() = 0; @@ -161,7 +162,7 @@ public: } void Print(const char *C8String) const { - for (unsigned char i = 0; i < strlen(C8String); i++) { + for (unsigned char i = 0; i < Strlen(C8String); i++) { PrintCharacter(C8String[i]); } } @@ -260,7 +261,7 @@ public: startIdx = 9 - u8DigsToCut - u8FixedDigtsCnt; const char *str = U8NumBuff + startIdx; - const char len = strlen(str); + const char len = Strlen(str); const char dot[1] = {64}; for (unsigned char i = 0; i < len; i++) { if (pointAt == len - i) { diff --git a/src/spectrum_fagci/spectrum.hpp b/src/spectrum_fagci/spectrum.hpp index 2ff7bee..6fdef6d 100644 --- a/src/spectrum_fagci/spectrum.hpp +++ b/src/spectrum_fagci/spectrum.hpp @@ -214,11 +214,11 @@ public: void Update() { if (peakRssi >= rssiTriggerLevel) { - // ToggleGreen(true); + ToggleGreen(true); Listen(); } if (peakRssi < rssiTriggerLevel) { - // ToggleGreen(false); + ToggleGreen(false); Scan(); } } @@ -288,14 +288,7 @@ private: void ResetPeak() { peakRssi = 0; } - void SetBW() { - /* auto Reg = BK4819Read(0x43); - Reg &= ~(0b11 << 4); - if (mode >= 3) - Reg |= 0b10 << 4; - BK4819Write(0x43, Reg); */ - BK4819SetChannelBandwidth(mode < 3); - } + void SetBW() { BK4819SetChannelBandwidth(mode < 3); } void MuteAF() { BK4819Write(0x47, 0); } void RestoreOldAFSettings() { BK4819Write(0x47, oldAFSettings); }