Merge pull request #130 from armel/feature_update

Feature update
This commit is contained in:
Armel FAUVEAU
2024-06-13 17:55:27 +02:00
committed by GitHub
22 changed files with 236 additions and 50 deletions

View File

@@ -4,9 +4,9 @@
# 1 = enable
# ---- STOCK QUANSHENG FERATURES ----
ENABLE_FMRADIO ?= 1
ENABLE_UART ?= 1
ENABLE_AIRCOPY ?= 0
ENABLE_FMRADIO ?= 1
ENABLE_NOAA ?= 0
ENABLE_VOICE ?= 0
ENABLE_VOX ?= 1
@@ -17,6 +17,7 @@ ENABLE_DTMF_CALLING ?= 0
ENABLE_FLASHLIGHT ?= 1
# ---- CUSTOM MODS ----
ENABLE_SPECTRUM ?= 1
ENABLE_BIG_FREQ ?= 1
ENABLE_SMALL_BOLD ?= 1
ENABLE_CUSTOM_MENU_LAYOUT ?= 1
@@ -35,13 +36,14 @@ ENABLE_FASTER_CHANNEL_SCAN ?= 1
ENABLE_RSSI_BAR ?= 1
ENABLE_AUDIO_BAR ?= 1
ENABLE_COPY_CHAN_TO_VFO ?= 1
ENABLE_SPECTRUM ?= 1
ENABLE_REDUCE_LOW_MID_TX_POWER?= 0
ENABLE_BYP_RAW_DEMODULATORS ?= 0
ENABLE_BLMIN_TMP_OFF ?= 0
ENABLE_SCAN_RANGES ?= 1
ENABLE_FEAT_F4HWN ?= 1
ENABLE_FEAT_F4HWN_FIXED_PWR ?= 0
ENABLE_FEAT_F4HWN_SCREENSHOT ?= 0
ENABLE_FEAT_F4HWN_PMR ?= 1
# ---- DEBUGGING ----
ENABLE_AM_FIX_SHOW_DATA ?= 0
@@ -211,7 +213,7 @@ ifeq ($(ENABLE_FEAT_F4HWN),1)
VERSION_STRING_1 ?= v0.22
AUTHOR_STRING_2 ?= F4HWN
VERSION_STRING_2 ?= v2.7
VERSION_STRING_2 ?= v2.8
AUTHOR_STRING ?= $(AUTHOR_STRING_1)+$(AUTHOR_STRING_2)
VERSION_STRING ?= $(VERSION_STRING_2)
@@ -403,6 +405,12 @@ endif
ifeq ($(ENABLE_FEAT_F4HWN_FIXED_PWR),1)
CFLAGS += -DENABLE_FEAT_F4HWN_FIXED_PWR
endif
ifeq ($(ENABLE_FEAT_F4HWN_SCREENSHOT),1)
CFLAGS += -DENABLE_FEAT_F4HWN_SCREENSHOT
endif
ifeq ($(ENABLE_FEAT_F4HWN_PMR),1)
CFLAGS += -DENABLE_FEAT_F4HWN_PMR
endif
LDFLAGS =
LDFLAGS += -z noexecstack -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld -Wl,--gc-sections

View File

@@ -77,11 +77,11 @@ Special thanks to Jean-Cyrille F6IWW, Fabrice 14RC123, David F4BPP, Olivier 14RC
* move USB icon to left of battery information,
* add RX and TX timers,
* new actions:
* SWITCH RxMode,
* SWITCH PTT,
* SWITCH WIDE NARROW,
* RX MODE,
* MAIN ONLY,
* PTT,
* WIDE NARROW,
* 1750Hz,
* BlMin Tmp Off,
* new key combinations:
* add the F + UP or F + DOWN key combination to dynamically change the Squelch level,
* add the F + F1 or F + F2 key combination to dynamically change the Step,

View File

@@ -43,6 +43,10 @@
#include "ui/inputbox.h"
#include "ui/ui.h"
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
#include "screenshot.h"
#endif
#if defined(ENABLE_FMRADIO)
static void ACTION_Scan_FM(bool bRestart);
#endif
@@ -103,6 +107,7 @@ void (*action_opt_table[])(void) = {
#ifdef ENABLE_FEAT_F4HWN
[ACTION_OPT_RXMODE] = &ACTION_RxMode,
[ACTION_OPT_MAINONLY] = &ACTION_MainOnly,
[ACTION_OPT_PTT] = &ACTION_Ptt,
[ACTION_OPT_WN] = &ACTION_Wn,
[ACTION_OPT_BACKLIGHT] = &ACTION_BackLight,
@@ -314,6 +319,11 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{
funcShort = funcLong;
// For screenshot
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
getScreenShot();
#endif
if (!bKeyPressed) //ignore release if held
return;
}
@@ -455,23 +465,54 @@ void ACTION_BlminTmpOff(void)
#endif
#ifdef ENABLE_FEAT_F4HWN
void ACTION_Update(void)
{
gSaveRxMode = false;
gFlagReconfigureVfos = true;
gUpdateStatus = true;
}
void ACTION_RxMode(void)
{
static bool cycle = 0;
switch(cycle) {
case 0:
gEeprom.DUAL_WATCH = (gEeprom.DUAL_WATCH == 0) ? 1 : 0;
gEeprom.DUAL_WATCH = !gEeprom.DUAL_WATCH;
cycle = 1;
break;
case 1:
gEeprom.CROSS_BAND_RX_TX = (gEeprom.CROSS_BAND_RX_TX == 0) ? 1 : 0;
gEeprom.CROSS_BAND_RX_TX = !gEeprom.CROSS_BAND_RX_TX;
cycle = 0;
break;
}
gFlagReconfigureVfos = true;
gUpdateStatus = true;
ACTION_Update();
}
void ACTION_MainOnly(void)
{
static bool cycle = 0;
static uint8_t dw = 0;
static uint8_t cb = 0;
switch(cycle) {
case 0:
dw = gEeprom.DUAL_WATCH;
cb = gEeprom.CROSS_BAND_RX_TX;
gEeprom.DUAL_WATCH = 0;
gEeprom.CROSS_BAND_RX_TX = 0;
cycle = 1;
break;
case 1:
gEeprom.DUAL_WATCH = dw;
gEeprom.CROSS_BAND_RX_TX = cb;
cycle = 0;
break;
}
ACTION_Update();
}
void ACTION_Ptt(void)

View File

@@ -37,6 +37,7 @@ void ACTION_SwitchDemodul(void);
#ifdef ENABLE_FEAT_F4HWN
void ACTION_RxMode(void);
void ACTION_MainOnly(void);
void ACTION_Ptt(void);
void ACTION_Wn(void);
void ACTION_BackLightOnDemand(void);

View File

@@ -710,6 +710,9 @@ static void CheckRadioInterrupts(void)
if (interrupts.sqlLost) {
g_SquelchLost = true;
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, true);
#ifdef ENABLE_FEAT_F4HWN
gRxTimerCountdown_500ms = 7200;
#endif
}
if (interrupts.sqlFound) {

View File

@@ -583,6 +583,13 @@ void MENU_AcceptSetting(void)
case MENU_TDR:
gEeprom.DUAL_WATCH = (gEeprom.TX_VFO + 1) * (gSubMenuSelection & 1);
gEeprom.CROSS_BAND_RX_TX = (gEeprom.TX_VFO + 1) * ((gSubMenuSelection & 2) > 0);
#ifdef ENABLE_FEAT_F4HWN
gDW = gEeprom.DUAL_WATCH;
gCB = gEeprom.CROSS_BAND_RX_TX;
gSaveRxMode = true;
#endif
gFlagReconfigureVfos = true;
gUpdateStatus = true;
break;

View File

@@ -27,6 +27,10 @@
#include "ui/helper.h"
#include "ui/main.h"
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
#include "screenshot.h"
#endif
struct FrequencyBandInfo {
uint32_t lower;
uint32_t upper;
@@ -572,6 +576,10 @@ static void ToggleBacklight() {
} else {
BACKLIGHT_TurnOff();
}
// For screenshot
#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT
getScreenShot();
#endif
}
static void ToggleStepsCount() {
@@ -732,6 +740,38 @@ static void DrawStatus() {
}
}
#ifndef ENABLE_FMRADIO
static void ShowChannelName(uint32_t f) {
unsigned int i;
char s[12];
memset(String, 0, sizeof(String));
if ( isListening ) {
for (i = 0; IS_MR_CHANNEL(i); i++) {
if (RADIO_CheckValidChannel(i, false, 0)) {
if (SETTINGS_FetchChannelFrequency(i) == f) {
memset(s, 0, sizeof(s));
SETTINGS_FetchChannelName(s, i);
if (s[0] != 0) {
if ( strlen(String) != 0 )
strcat(String, "/"); // Add a space to result
strcat(String, s);
}
break;
}
}
}
}
if (String[0] != 0) {
if ( strlen(String) > 19 ) {
String[19] = 0;
}
UI_PrintStringSmallBold(String, 8, 127, 1);
}
}
#endif
static void DrawF(uint32_t f) {
sprintf(String, "%u.%05u", f / 100000, f % 100000);
UI_PrintStringSmallNormal(String, 8, 127, 0);
@@ -740,6 +780,10 @@ static void DrawF(uint32_t f) {
GUI_DisplaySmallest(String, 116, 1, false, true);
sprintf(String, "%s", bwOptions[settings.listenBw]);
GUI_DisplaySmallest(String, 108, 7, false, true);
#ifndef ENABLE_FMRADIO
ShowChannelName(f);
#endif
}
static void DrawNums() {

View File

@@ -23,12 +23,6 @@ const uint8_t gFontPttClassic[2][6] =
{0x00, 0x7f, 0x40, 0x40, 0x40, 0x40},
};
const uint8_t gFontFM[2][6] =
{
{0x00, 0x7f, 0x9, 0x9, 0x9, 0x1},
{0x00, 0x7f, 0x2, 0x1c, 0x2, 0x7f},
};
const uint8_t gFontF[1][8] =
{
{0x7f, 0x00, 0x76, 0x76, 0x76, 0x76, 0x7e, 0x7f}, // 'F'
@@ -210,6 +204,17 @@ const uint8_t BITMAP_compand[6] =
0b00100100
};
const uint8_t BITMAP_Ready[7] =
{
0b00001000,
0b00010000,
0b00100000,
0b00010000,
0b00001000,
0b00000100,
0b00000010,
};
#ifndef ENABLE_CUSTOM_MENU_LAYOUT
const uint8_t BITMAP_CurrentIndicator[8] = {
0xFF,

View File

@@ -7,7 +7,6 @@
extern const uint8_t gFontPowerSave[2][6];
extern const uint8_t gFontPttOnePush[2][6];
extern const uint8_t gFontPttClassic[2][6];
extern const uint8_t gFontFM[2][6];
extern const uint8_t gFontF[1][8];
extern const uint8_t gFontS[1][6];
@@ -23,6 +22,7 @@ extern const uint8_t gFontHold[2][5];
extern const uint8_t BITMAP_BatteryLevel[2];
extern const uint8_t BITMAP_BatteryLevel1[17];
extern const uint8_t BITMAP_USB_C[9];
extern const uint8_t BITMAP_Ready[7];
#ifdef ENABLE_VOX
extern const uint8_t gFontVox[2][6];

View File

@@ -34,7 +34,7 @@ bool backlightOn;
void BACKLIGHT_InitHardware()
{
// 48MHz / 94 / 1024 ~ 500Hz
const uint32_t PWM_FREQUENCY_HZ = 1000;
const uint32_t PWM_FREQUENCY_HZ = 25000;
PWM_PLUS0_CLKSRC |= ((48000000 / 1024 / PWM_FREQUENCY_HZ) << 16);
PWM_PLUS0_PERIOD = 1023;

4
font.c
View File

@@ -483,7 +483,7 @@ const uint8_t gFontSmall[95-1][6] =
};
#endif
#ifdef ENABLE_SPECTRUM
//#ifdef ENABLE_SPECTRUM
const uint8_t gFont3x5[][3] =
{
{0x00, 0x00, 0x00}, // 32 - space
@@ -651,4 +651,4 @@ const uint8_t gFontSmall[95-1][6] =
// {0x03, 0x0b, 0x18}, // 190 - threequarters
// {0x18, 0x15, 0x10}, // 191 - questiondown
};
#endif
//#endif

View File

@@ -222,7 +222,7 @@ int32_t TX_freq_check(const uint32_t Frequency)
return 0;
break;
#ifdef ENABLE_FEAT_F4HWN
#ifdef ENABLE_FEAT_F4HWN_PMR
case F_LOCK_PMR:
if (Frequency >= 44600625 && Frequency <= 44619375)
return 0;

6
main.c
View File

@@ -94,6 +94,12 @@ void Main(void)
BOARD_ADC_GetBatteryInfo(&gBatteryCurrentVoltage, &gBatteryCurrent);
SETTINGS_InitEEPROM();
#ifdef ENABLE_FEAT_F4HWN
gDW = gEeprom.DUAL_WATCH;
gCB = gEeprom.CROSS_BAND_RX_TX;
#endif
SETTINGS_WriteBuildOptions();
SETTINGS_LoadCalibration();

3
misc.c
View File

@@ -116,6 +116,9 @@ enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
bool gSetting_set_gui = 0;
bool gSetting_set_ptt_session;
uint8_t gDebug;
uint8_t gDW = 0;
uint8_t gCB = 0;
bool gSaveRxMode = false;
#endif
#ifdef ENABLE_AUDIO_BAR

5
misc.h
View File

@@ -167,6 +167,10 @@ extern enum BacklightOnRxTx_t gSetting_backlight_on_tx_rx;
extern bool gSetting_set_met;
extern bool gSetting_set_gui;
extern bool gSetting_set_ptt_session;
extern uint8_t gDebug;
extern uint8_t gDW;
extern uint8_t gCB;
extern bool gSaveRxMode;
#endif
#ifdef ENABLE_AUDIO_BAR
@@ -350,7 +354,6 @@ extern volatile uint8_t boot_counter_10ms;
extern uint8_t gBacklightBrightnessOld;
extern uint8_t gPttOnePushCounter;
extern uint32_t gBlinkCounter;
extern uint8_t gDebug;
#endif
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit);

51
screenshot.h Normal file
View File

@@ -0,0 +1,51 @@
/* Copyright 2024 Armel F4HWN
* https://github.com/armel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "debugging.h"
#include "driver/st7565.h"
static inline void getScreenShot(void)
{
char str[2] = "";
LogUart("P1\n");
LogUart("128 64\n");
for(uint8_t b = 0; b < 8; b++)
{
for(uint8_t i = 0; i < 128; i++)
{
sprintf(str, "%d ", ((gStatusLine[i] >> b) & 0x01));
LogUart(str);
}
LogUart("\n");
}
for(uint8_t l = 0; l < 7; l++)
{
for(uint8_t b = 0; b < 8; b++)
{
for(uint8_t i = 0; i < 128; i++)
{
sprintf(str, "%d ", ((gFrameBuffer[l][i] >> b) & 0x01));
LogUart(str);
}
}
LogUart("\n");
}
LogUart("\n----------------\n");
}

View File

@@ -128,8 +128,10 @@ void SETTINGS_InitEEPROM(void)
#endif
// 0E98..0E9F
#ifdef ENABLE_PWRON_PASSWORD
EEPROM_ReadBuffer(0x0E98, Data, 8);
memcpy(&gEeprom.POWER_ON_PASSWORD, Data, 4);
#endif
// 0EA0..0EA7
EEPROM_ReadBuffer(0x0EA0, Data, 8);
@@ -502,7 +504,9 @@ void SETTINGS_SaveVfoIndices(void)
void SETTINGS_SaveSettings(void)
{
uint8_t State[8];
#ifdef ENABLE_PWRON_PASSWORD
uint32_t Password[2];
#endif
State[0] = gEeprom.CHAN_1_CALL;
State[1] = gEeprom.SQUELCH_LEVEL;
@@ -530,6 +534,11 @@ void SETTINGS_SaveSettings(void)
State[4] = gEeprom.DUAL_WATCH;
#ifdef ENABLE_FEAT_F4HWN
if(!gSaveRxMode)
{
State[2] = gCB;
State[4] = gDW;
}
if(gBackLight)
{
State[5] = gBacklightTimeOriginal;
@@ -557,11 +566,11 @@ void SETTINGS_SaveSettings(void)
State[7] = gEeprom.POWER_ON_DISPLAY_MODE;
EEPROM_WriteBuffer(0x0E90, State);
memset(Password, 0xFF, sizeof(Password));
#ifdef ENABLE_PWRON_PASSWORD
memset(Password, 0xFF, sizeof(Password));
Password[0] = gEeprom.POWER_ON_PASSWORD;
#endif
EEPROM_WriteBuffer(0x0E98, Password);
#endif
memset(State, 0xFF, sizeof(State));
#ifdef ENABLE_VOICE

View File

@@ -45,7 +45,7 @@ enum TxLockModes_t {
F_LOCK_GB,
F_LOCK_430,
F_LOCK_438,
#ifdef ENABLE_FEAT_F4HWN
#ifdef ENABLE_FEAT_F4HWN_PMR
F_LOCK_PMR,
#endif
F_LOCK_ALL, // disable TX on all frequencies
@@ -100,6 +100,7 @@ enum ACTION_OPT_t {
ACTION_OPT_BLMIN_TMP_OFF, //BackLight Minimum Temporay OFF
#ifdef ENABLE_FEAT_F4HWN
ACTION_OPT_RXMODE,
ACTION_OPT_MAINONLY,
ACTION_OPT_PTT,
ACTION_OPT_WN,
ACTION_OPT_BACKLIGHT,

View File

@@ -799,8 +799,6 @@ void UI_DisplayMain(void)
#ifdef ENABLE_FEAT_F4HWN
else
{
gRxTimerCountdown_500ms = 7200;
if(RxOnVfofrequency == frequency && !isMainOnly(false))
{
UI_PrintStringSmallNormal(">>", 14, 0, line);

View File

@@ -41,7 +41,7 @@ const t_menu_item MenuList[] =
{
// text, menu ID
{"Step", MENU_STEP },
{"TxPwr", MENU_TXP }, // was "TXP"
{"Power", MENU_TXP }, // was "TXP"
{"RxDCS", MENU_R_DCS }, // was "R_DCS"
{"RxCTCS", MENU_R_CTCS }, // was "R_CTCS"
{"TxDCS", MENU_T_DCS }, // was "T_DCS"
@@ -54,7 +54,7 @@ const t_menu_item MenuList[] =
#endif
{"BusyCL", MENU_BCL }, // was "BCL"
{"Compnd", MENU_COMPAND },
{"Demodu", MENU_AM }, // was "AM"
{"Mode", MENU_AM }, // was "AM"
{"ScAdd1", MENU_S_ADD1 },
{"ScAdd2", MENU_S_ADD2 },
{"ChSave", MENU_MEM_CH }, // was "MEM-CH"
@@ -290,7 +290,7 @@ const char * const gSubMenu_F_LOCK[] =
"GB HAM\n144-148\n430-440",
"137-174\n400-430",
"137-174\n400-438",
#ifdef ENABLE_FEAT_F4HWN
#ifdef ENABLE_FEAT_F4HWN_PMR
"PMR 446",
#endif
"DISABLE\nALL",
@@ -394,16 +394,17 @@ const t_sidefunction gSubMenu_SIDEFUNCTIONS[] =
{"1750Hz", ACTION_OPT_1750},
#endif
{"LOCK\nKEYPAD", ACTION_OPT_KEYLOCK},
{"SWITCH\nVFO", ACTION_OPT_A_B},
{"VFO/MR", ACTION_OPT_VFO_MR},
{"SWITCH\nDEMODUL", ACTION_OPT_SWITCH_DEMODUL},
{"VFO A\nVFO B", ACTION_OPT_A_B},
{"VFO\nMEM", ACTION_OPT_VFO_MR},
{"MODE", ACTION_OPT_SWITCH_DEMODUL},
#ifdef ENABLE_BLMIN_TMP_OFF
{"BLMIN\nTMP OFF", ACTION_OPT_BLMIN_TMP_OFF}, //BackLight Minimum Temporay OFF
#endif
#ifdef ENABLE_FEAT_F4HWN
{"SWITCH\nRX MODE", ACTION_OPT_RXMODE},
{"SWITCH\nPTT", ACTION_OPT_PTT},
{"SWITCH\nWIDE\nNARROW", ACTION_OPT_WN},
{"RX MODE", ACTION_OPT_RXMODE},
{"MAIN ONLY", ACTION_OPT_MAINONLY},
{"PTT", ACTION_OPT_PTT},
{"WIDE\nNARROW", ACTION_OPT_WN},
#endif
};

View File

@@ -34,7 +34,6 @@
#include "ui/ui.h"
#include "ui/status.h"
static void convertTime(uint8_t *line, uint8_t type)
{
char str[8] = "";
@@ -91,13 +90,6 @@ void UI_DisplayStatus()
x1 = x + 10;
}
else
#endif
#ifdef ENABLE_FMRADIO
if (gFmRadioMode) { // FM indicator
memcpy(line + x, gFontFM, sizeof(gFontFM));
x1 = x + sizeof(gFontFM);
}
else
#endif
{ // SCAN indicator
if (gScanStateDir != SCAN_OFF || SCANNER_IsScanning()) {

View File

@@ -26,6 +26,7 @@
#include "ui/welcome.h"
#include "ui/status.h"
#include "version.h"
#include "bitmaps.h"
void UI_DisplayReleaseKeys(void)
{
@@ -108,8 +109,20 @@ void UI_DisplayWelcome(void)
gFrameBuffer[4][i] ^= 0xFF;
}
#ifdef ENABLE_SPECTRUM
#ifdef ENABLE_FMRADIO
UI_PrintStringSmallNormal(Based, 0, 127, 5);
UI_PrintStringSmallNormal(Credits, 0, 127, 6);
#else
UI_PrintStringSmallNormal("Bandscope ", 0, 127, 5);
memcpy(gFrameBuffer[5] + 95, BITMAP_Ready, sizeof(BITMAP_Ready));
UI_PrintStringSmallNormal("Broadcast ", 0, 127, 6);
#endif
#else
UI_PrintStringSmallNormal("Bandscope ", 0, 127, 5);
UI_PrintStringSmallNormal("Broadcast ", 0, 127, 6);
memcpy(gFrameBuffer[6] + 95, BITMAP_Ready, sizeof(BITMAP_Ready));
#endif
#else
UI_PrintStringSmallNormal(Version, 0, 127, 6);
#endif