From 23dbad1a532151a61edd8e435a2c625358e19cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Tue, 3 Jun 2025 23:56:25 +0200 Subject: [PATCH] Support older standard --- Makefile | 2 +- app/messages.c | 46 ++++++++++++++++++++++++++-------------------- app/spectrum.h | 3 ++- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index ec36f25..3ef6b2b 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ ENABLE_DTMF_CALLING ?= 0 ENABLE_FLASHLIGHT ?= 0 # ---- CUSTOM MODS ---- -ENABLE_SPECTRUM ?= 1 +ENABLE_SPECTRUM ?= 0 ENABLE_BIG_FREQ ?= 0 ENABLE_SMALL_BOLD ?= 0 ENABLE_CUSTOM_MENU_LAYOUT ?= 1 diff --git a/app/messages.c b/app/messages.c index c5486f2..d5dfdfe 100644 --- a/app/messages.c +++ b/app/messages.c @@ -122,25 +122,31 @@ void MESSAGES_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { memset(dataPacket.data, 0, DataPacketDataSize); prepareDataPacket(); //dataPacket.flags = 0x80 | (gCurrentVfo->OUTPUT_POWER & 0x07); - if (dataPacket.src == 665) { + if (dataPacket.src == 665 || dataPacket.src == 664) { - const uint32_t id24 = 0xFFFFFF & (dataPacket.dest >> 4); - const uint8_t btn = 0x0F & (dataPacket.dest); - // mask just in case + uint8_t out[5]; + if (dataPacket.src == 665) { + const uint32_t id24 = 0xFFFFFF & (dataPacket.dest >> 4); + const uint8_t btn = 0x0F & (dataPacket.dest); + // mask just in case // uint32_t id24 = 0x00A38C; // uint8_t btn = 0x04; - uint8_t out[10]; - // 3-byte big-endian ID - out[0] = (id24 >> 16) & 0xFF; - out[1] = (id24 >> 8) & 0xFF; - out[2] = (id24 >> 0) & 0xFF; + // 3-byte big-endian ID + out[0] = (id24 >> 16) & 0xFF; + out[1] = (id24 >> 8) & 0xFF; + out[2] = (id24 >> 0) & 0xFF; - // first nibble redundancy copy: 0xBB if btn=0xB - out[3] = (btn << 4) | 0x04; + // first nibble redundancy copy: 0xBB if btn=0xB + out[3] = (btn << 4) | 0x04; - // second copy with MSB flipped (btn ^ 0x8) in the high nibble - out[4] = ((btn ^ 0x8) << 4); + // second copy with MSB flipped (btn ^ 0x8) in the high nibble + out[4] = ((btn ^ 0x8) << 4); + } + else { + out[0] = (dataPacket.dest >> 8) & 0xFF; + out[1] = dataPacket.dest & 0xFF; + } BK4819_EnterTxMute(); RADIO_SetTxParameters(); @@ -160,28 +166,28 @@ void MESSAGES_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_PA_ENABLE, false); SYSTEM_DelayMs(20); - for (unsigned int x = 0; x < 24; x++) { - for (unsigned int y = 0; y < sizeof(out); y++) { + for (unsigned int x = 0; x < 15; x++) { + for (unsigned int y = 0; y < (dataPacket.src == 665 ? 5 : 2); y++) { for (unsigned char i = 7; i < 8; i--) { if ((out[y] >> i) & 1) { // datX |= BK4819_REG_30_ENABLE_PA_GAIN; BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_PA_ENABLE, true); - SYSTICK_DelayUs(400 * 3 - 350); + SYSTICK_DelayUs(400 * (dataPacket.src == 665 ? 3 : 2) - 325); BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_PA_ENABLE, false); // datX &= ~BK4819_REG_30_ENABLE_PA_GAIN; - SYSTICK_DelayUs(400 * 1 - 350); + SYSTICK_DelayUs(400 * 1 - 325); } else { BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_PA_ENABLE, true); // datX |= BK4819_REG_30_ENABLE_PA_GAIN; - SYSTICK_DelayUs(400 * 1 - 350); + SYSTICK_DelayUs(400 * 1 - 325); BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_PA_ENABLE, false); // datX &= ~BK4819_REG_30_ENABLE_PA_GAIN; - SYSTICK_DelayUs(400 * 3 - 350); + SYSTICK_DelayUs(400 * (dataPacket.src == 665 ? 3 : 2) - 325); } } } BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_PA_ENABLE, false); - SYSTEM_DelayMs(3); + SYSTEM_DelayMs((dataPacket.src == 665 ? 3 : 15)); } BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_PA_ENABLE, false); SYSTEM_DelayMs(100); diff --git a/app/spectrum.h b/app/spectrum.h index 1f15513..8d9b136 100644 --- a/app/spectrum.h +++ b/app/spectrum.h @@ -180,8 +180,9 @@ typedef struct PeakInfo uint16_t i; } PeakInfo; +#ifdef ENABLE_SPECTRUM void APP_RunSpectrum(void); - +#endif #endif /* ifndef SPECTRUM_H */ // vim: ft=c