Skip to content

Commit

Permalink
Merge pull request #367 from armel/feature_update_v4
Browse files Browse the repository at this point in the history
Feature update v4
  • Loading branch information
armel authored Feb 22, 2025
2 parents d365896 + aee4406 commit ba5257f
Show file tree
Hide file tree
Showing 47 changed files with 894 additions and 239 deletions.
57 changes: 16 additions & 41 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,24 @@
name: Build Firmware

on:
push:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-22.04
container:
image: archlinux:latest
steps:
- name: base-devel
run: pacman -Syyu base-devel --noconfirm
- name: arm-none-eabi-gcc
run: pacman -Syyu arm-none-eabi-gcc --noconfirm
- name: arm-none-eabi-newlib
run: pacman -Syyu arm-none-eabi-newlib --noconfirm
- name: git
run: pacman -Syyu git --noconfirm
- name: python-pip
run: pacman -Syyu python-pip --noconfirm
- name: python-crcmod
run: pacman -Syyu python-crcmod --noconfirm
runs-on: ubuntu-latest

- name: Checkout
uses: actions/checkout@v3

- name: safe.directory
run: git config --global --add safe.directory /__w/uv-k5-firmware-custom/uv-k5-firmware-custom
- name: Make
run: make
- name: size
run: arm-none-eabi-size firmware
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: firmware
path: firmware*.bin
- name: Compile firmware
run: |
chmod +x compile-with-docker.sh
./compile-with-docker.sh
- name: Upload binaries to release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: firmware.packed.bin
asset_name: egzumer_$tag.packed.bin
tag: ${{ github.ref }}
overwrite: true
release_name: release ${{ github.ref_name }}

- name: Upload firmware artifact
uses: actions/upload-artifact@v4
with:
name: firmware-artifact
path: compiled-firmware/f4hwn.packed.bin
31 changes: 23 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# 0 = disable
# 1 = enable

# ---- STOCK QUANSHENG FERATURES ----
# ---- STOCK QUANSHENG FEATURES ----
ENABLE_FMRADIO ?= 0
ENABLE_UART ?= 1
ENABLE_AIRCOPY ?= 0
Expand Down Expand Up @@ -46,15 +46,18 @@ ENABLE_FEAT_F4HWN_SPECTRUM ?= 1
ENABLE_FEAT_F4HWN_RX_TX_TIMER ?= 1
ENABLE_FEAT_F4HWN_CHARGING_C ?= 0
ENABLE_FEAT_F4HWN_SLEEP ?= 1
ENABLE_FEAT_F4HWN_RESTORE_SCAN ?= 1
ENABLE_FEAT_F4HWN_RESUME_STATE ?= 1
ENABLE_FEAT_F4HWN_NARROWER ?= 1
ENABLE_FEAT_F4HWN_CONTRAST ?= 1
ENABLE_FEAT_F4HWN_INV ?= 1
ENABLE_FEAT_F4HWN_CTR ?= 1
ENABLE_FEAT_F4HWN_RESCUE_OPS ?= 0
ENABLE_FEAT_F4HWN_VOL ?= 0
ENABLE_FEAT_F4HWN_RESET_CHANNEL ?= 0
ENABLE_FEAT_F4HWN_PMR ?= 0
ENABLE_FEAT_F4HWN_GMRS_FRS_MURS ?= 0
ENABLE_FEAT_F4HWN_CA ?= 1
ENABLE_FEAT_F4HWN_DEBUG ?= 0
ENABLE_REGA ?= 0

# ---- DEBUGGING ----
ENABLE_AM_FIX_SHOW_DATA ?= 0
Expand Down Expand Up @@ -135,6 +138,9 @@ OBJS += app/app.o
OBJS += app/chFrScanner.o
OBJS += app/common.o
OBJS += app/dtmf.o
ifeq ($(ENABLE_REGA),1)
OBJS += app/rega.o
endif
ifeq ($(ENABLE_FLASHLIGHT),1)
OBJS += app/flashlight.o
endif
Expand Down Expand Up @@ -224,7 +230,7 @@ ifeq ($(ENABLE_FEAT_F4HWN),1)
VERSION_STRING_1 ?= v0.22

AUTHOR_STRING_2 ?= F4HWN
VERSION_STRING_2 ?= v3.9
VERSION_STRING_2 ?= v4.0

EDITION_STRING ?= Custom

Expand Down Expand Up @@ -399,6 +405,9 @@ endif
ifeq ($(ENABLE_DTMF_CALLING),1)
CFLAGS += -DENABLE_DTMF_CALLING
endif
ifeq ($(ENABLE_REGA),1)
CFLAGS += -DENABLE_REGA
endif
ifeq ($(ENABLE_AGC_SHOW_DATA),1)
CFLAGS += -DENABLE_AGC_SHOW_DATA
endif
Expand Down Expand Up @@ -436,14 +445,17 @@ endif
ifeq ($(ENABLE_FEAT_F4HWN_SLEEP),1)
CFLAGS += -DENABLE_FEAT_F4HWN_SLEEP
endif
ifeq ($(ENABLE_FEAT_F4HWN_RESTORE_SCAN),1)
CFLAGS += -DENABLE_FEAT_F4HWN_RESTORE_SCAN
ifeq ($(ENABLE_FEAT_F4HWN_RESUME_STATE),1)
CFLAGS += -DENABLE_FEAT_F4HWN_RESUME_STATE
endif
ifeq ($(ENABLE_FEAT_F4HWN_NARROWER),1)
CFLAGS += -DENABLE_FEAT_F4HWN_NARROWER
endif
ifeq ($(ENABLE_FEAT_F4HWN_CONTRAST),1)
CFLAGS += -DENABLE_FEAT_F4HWN_CONTRAST
ifeq ($(ENABLE_FEAT_F4HWN_INV),1)
CFLAGS += -DENABLE_FEAT_F4HWN_INV
endif
ifeq ($(ENABLE_FEAT_F4HWN_CTR),1)
CFLAGS += -DENABLE_FEAT_F4HWN_CTR
endif
ifneq ($(filter $(ENABLE_FEAT_F4HWN_RESCUE_OPS),1 2),)
CFLAGS += -DENABLE_FEAT_F4HWN_RESCUE_OPS=$(ENABLE_FEAT_F4HWN_RESCUE_OPS)
Expand All @@ -463,6 +475,9 @@ endif
ifeq ($(ENABLE_FEAT_F4HWN_CA),1)
CFLAGS += -DENABLE_FEAT_F4HWN_CA
endif
ifeq ($(ENABLE_FEAT_F4HWN_DEBUG),1)
CFLAGS += -DENABLE_FEAT_F4HWN_DEBUG
endif

LDFLAGS =
LDFLAGS += -z noexecstack -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld -Wl,--gc-sections
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Anyway, have fun.
# Donations

Special thanks to Jean-Cyrille F6IWW, Fabrice 14RC123, David F4BPP, Olivier 14RC206, Frédéric F4ESO, Stéphane F5LGW, Jorge Ornelas (4 times), Laurent F4AXK, Christophe Morel, Clayton W0LED, Pierre Antoine F6FWB, Jean-Claude 14FRS3306, Thierry F4GVO, Eric F1NOU, PricelessToolkit, Ady M6NYJ, Tom McGovern, Joseph Roth, Pierre-Yves Colin, Frank DJ7FG, Marcel Testaz, Brian Frobisher, Yannick F4JFO, Paolo Bussola, Dirk DL8DF, Levente Szőke (2 times), Bernard-Michel Herrera, Jérôme Saintespes, Paul Davies, RS, Johan F4WAT, Robert Wörle, Rafael Sundorf, Paul Harker, Peter Fintl, Pascal F4ICR (2 times), Mike DL2MF, Eric KI1C (2 times), Phil G0ELM, Jérôme Lambert, Meinhard Frank Günther and Eliot Vedel for their [donations](https://www.paypal.com/paypalme/F4HWN). That’s so kind of them. Thanks so much 🙏🏻
Special thanks to Jean-Cyrille F6IWW (2 times), Fabrice 14RC123, David F4BPP, Olivier 14RC206, Frédéric F4ESO, Stéphane F5LGW, Jorge Ornelas (4 times), Laurent F4AXK, Christophe Morel, Clayton W0LED, Pierre Antoine F6FWB, Jean-Claude 14FRS3306, Thierry F4GVO, Eric F1NOU, PricelessToolkit, Ady M6NYJ, Tom McGovern (3 times), Joseph Roth, Pierre-Yves Colin, Frank DJ7FG, Marcel Testaz, Brian Frobisher, Yannick F4JFO, Paolo Bussola, Dirk DL8DF, Levente Szőke (2 times), Bernard-Michel Herrera, Jérôme Saintespes, Paul Davies, RS, Johan F4WAT, Robert Wörle, Rafael Sundorf, Paul Harker, Peter Fintl, Pascal F4ICR (2 times), Mike DL2MF, Eric KI1C (2 times), Phil G0ELM, Jérôme Lambert, Meinhard Frank Günther, Eliot Vedel, Alfonso EA7KDF, Jean-François F1EVM and Robert DC1RDB for their [donations](https://www.paypal.com/paypalme/F4HWN). That’s so kind of them. Thanks so much 🙏🏻

## Table of Contents

Expand Down Expand Up @@ -97,6 +97,8 @@ Special thanks to Jean-Cyrille F6IWW, Fabrice 14RC123, David F4BPP, Olivier 14RC
* improve ScnRev menu (CARRIER from 250ms to 20s, STOP, TIMEOUT from 5s to 2m)
* improve KeyLck menu (OFF, delay from 15s to 10m)
* add HAM CA F Lock band (for Canadian zone),
* add PMR 446 F Lock band,
* add FRS/GMRS/MURS F Lock band,
* remove blink and SOS functionality,
* remove AM Fix menu (AM Fix is ENABLED by default),
* add support of 3500mAh battery,
Expand All @@ -116,13 +118,14 @@ Special thanks to Jean-Cyrille F6IWW, Fabrice 14RC123, David F4BPP, Olivier 14RC
* scan lists [1, 2, 3],
* scan all (all channels with ou without list),
* add scan list shortcuts,
* add scan resume mode on startup,
* add resume mode on startup (scan, bandscope and broadcast FM),
* new actions:
* RX MODE,
* MAIN ONLY,
* PTT,
* WIDE NARROW,
* 1750Hz,
* MUTE,
* POWER HIGH (RescueOps),
* REMOVE OFFSET (RescueOps),
* new key combinations:
Expand Down Expand Up @@ -238,7 +241,10 @@ This is the least demanding option as you don't have to install enything on your

### Docker build method

If you have docker installed you can use [compile-with-docker.bat](./compile-with-docker.bat) (Windows) or [compile-with-docker.sh](./compile-with-docker.sh) (Linux/Mac), the output files are created in `compiled-firmware` folder. This method gives significantly smaller binaries, I've seen differences up to 1kb, so it can fit more functionalities this way. The challenge can be (or not) installing docker itself.
If you have docker installed you can use [compile-with-docker.bat](./compile-with-docker.bat) (Windows) or [compile-with-docker.sh](./compile-with-docker.sh) (Linux/Mac), the output files are created in `compiled-firmware` folder. This method gives significantly smaller binaries, I've seen differences up to 1kb, so it can fit more functionalities this way. The challenge can be (or not) installing docker itself.

> [!TIP]
> On Linux/Mac, you may need to uncomment and customize the DOCKER_NETWORK environment variable at the beginning of the [compile-with-docker.sh](./compile-with-docker.sh) script. Note: this can introduce security risks by removing network isolation. However, if you encounter issues and are using a specific network environment (with a proxy or a firewall), this may help.
### Windows environment build method

Expand Down
37 changes: 35 additions & 2 deletions app/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
#include "settings.h"
#include "ui/inputbox.h"
#include "ui/ui.h"
#ifdef ENABLE_REGA
#include "app/rega.h"
#endif

#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
#include "screenshot.h"
Expand Down Expand Up @@ -111,13 +114,22 @@ void (*action_opt_table[])(void) = {
[ACTION_OPT_PTT] = &ACTION_Ptt,
[ACTION_OPT_WN] = &ACTION_Wn,
[ACTION_OPT_BACKLIGHT] = &ACTION_BackLight,
#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO)
[ACTION_OPT_MUTE] = &ACTION_Mute,
#else
[ACTION_OPT_MUTE] = &FUNCTION_NOP,
#endif
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
[ACTION_OPT_POWER_HIGH] = &ACTION_Power_High,
[ACTION_OPT_REMOVE_OFFSET] = &ACTION_Remove_Offset,
#endif
#else
[ACTION_OPT_RXMODE] = &FUNCTION_NOP,
#endif
#ifdef ENABLE_REGA
[ACTION_OPT_REGA_ALARM] = &ACTION_RegaAlarm,
[ACTION_OPT_REGA_TEST] = &ACTION_RegaTest,
#endif
};

static_assert(ARRAY_SIZE(action_opt_table) == ACTION_OPT_LEN);
Expand Down Expand Up @@ -224,7 +236,7 @@ void ACTION_Scan(bool bRestart)

// channel mode. Keep scanning but toggle between scan lists
gEeprom.SCAN_LIST_DEFAULT = (gEeprom.SCAN_LIST_DEFAULT + 1) % 6;
#ifdef ENABLE_FEAT_F4HWN_RESTORE_SCAN
#ifdef ENABLE_FEAT_F4HWN_RESUME_STATE
SETTINGS_WriteCurrentState();
#endif

Expand All @@ -233,7 +245,7 @@ void ACTION_Scan(bool bRestart)
gScanPauseDelayIn_10ms = 1;
gScheduleScanListen = false;
} else {
#ifdef ENABLE_FEAT_F4HWN_RESTORE_SCAN
#ifdef ENABLE_FEAT_F4HWN_RESUME_STATE
if(gScanRangeStart == 0) // No ScanRange
{
gEeprom.CURRENT_STATE = 1;
Expand Down Expand Up @@ -625,6 +637,27 @@ void ACTION_BackLightOnDemand(void)
BACKLIGHT_TurnOn();
}

#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO)
void ACTION_Mute(void)
{
// Toggle mute state
gMute = !gMute;

// Update the registers
#ifdef ENABLE_FMRADIO
BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, gMute ? 0x0A10 : 0x0A1F);
#endif
gEeprom.VOLUME_GAIN = gMute ? 0 : gEeprom.VOLUME_GAIN_BACKUP;
BK4819_WriteRegister(BK4819_REG_48,
(11u << 12) | // ??? .. 0 ~ 15, doesn't seem to make any difference
(0u << 10) | // AF Rx Gain-1
(gEeprom.VOLUME_GAIN << 4) | // AF Rx Gain-2
(gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2)

gUpdateStatus = true;
}
#endif

#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
void ACTION_Power_High(void)
{
Expand Down
3 changes: 3 additions & 0 deletions app/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ void ACTION_SwitchDemodul(void);
void ACTION_Wn(void);
void ACTION_BackLightOnDemand(void);
void ACTION_BackLight(void);
#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO)
void ACTION_Mute(void);
#endif
#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS
void ACTION_Power_High(void);
void ACTION_Remove_Offset(void);
Expand Down
26 changes: 12 additions & 14 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@ void (*ProcessKeysFunctions[])(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
#endif
};

#ifdef ENABLE_REGA
// This is a hack for REGA as I need a special display element only for it with no key
static_assert(ARRAY_SIZE(ProcessKeysFunctions) == DISPLAY_N_ELEM-1);
#else
static_assert(ARRAY_SIZE(ProcessKeysFunctions) == DISPLAY_N_ELEM);


#endif

static void CheckForIncoming(void)
{
Expand Down Expand Up @@ -966,19 +969,10 @@ void APP_Update(void)
//if (gKeyReading1 != KEY_INVALID)
// gPttWasReleased = true;
}
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
ST7565_ContrastAndInv();
#endif
}
/*
if (gSetting_set_ptt_session) // Improve OnePush if TOT
{
ProcessKey(KEY_PTT, false, false);
gPttIsPressed = false;
gPttOnePushCounter = 0;
if (gKeyReading1 != KEY_INVALID)
gPttWasReleased = true;
ST7565_ContrastAndInv();
}
*/
#endif

APP_EndTransmission();
Expand Down Expand Up @@ -1213,7 +1207,9 @@ static void CheckKeys(void)
if (gKeyReading1 != KEY_INVALID)
gPttWasReleased = true;
gPttOnePushCounter = 0;
ST7565_ContrastAndInv();
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
ST7565_ContrastAndInv();
#endif
}
}
else
Expand All @@ -1233,7 +1229,9 @@ static void CheckKeys(void)
gPttIsPressed = false;
if (gKeyReading1 != KEY_INVALID)
gPttWasReleased = true;
#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV)
ST7565_ContrastAndInv();
#endif
}
}
else
Expand Down
21 changes: 20 additions & 1 deletion app/chFrScanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void CHFRSCANNER_Start(const bool storeBackupSettings, const int8_t scan_directi
gScanPauseMode = false;
}

/*
void CHFRSCANNER_ContinueScanning(void)
{
if (IS_FREQ_CHANNEL(gNextMrChannel))
Expand All @@ -99,6 +100,24 @@ void CHFRSCANNER_ContinueScanning(void)
gRxReceptionMode = RX_MODE_NONE;
gScheduleScanListen = false;
}
*/

void CHFRSCANNER_ContinueScanning(void)
{
if (gCurrentFunction == FUNCTION_INCOMING &&
(IS_FREQ_CHANNEL(gNextMrChannel) || gCurrentCodeType == CODE_TYPE_OFF))
{
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE);
}
else
{
IS_FREQ_CHANNEL(gNextMrChannel) ? NextFreqChannel() : NextMemChannel();
}

gScanPauseMode = false;
gRxReceptionMode = RX_MODE_NONE;
gScheduleScanListen = false;
}

void CHFRSCANNER_Found(void)
{
Expand Down Expand Up @@ -196,7 +215,7 @@ void CHFRSCANNER_Stop(void)
}
}

#ifdef ENABLE_FEAT_F4HWN_RESTORE_SCAN
#ifdef ENABLE_FEAT_F4HWN_RESUME_STATE
gEeprom.CURRENT_STATE = 0;
SETTINGS_WriteCurrentState();
#endif
Expand Down
Loading

0 comments on commit ba5257f

Please sign in to comment.