Skip to content

Commit

Permalink
Ignore all long-press/function keys whilst in menu
Browse files Browse the repository at this point in the history
  • Loading branch information
OneOfEleven committed Oct 5, 2023
1 parent e042b21 commit 609df5f
Show file tree
Hide file tree
Showing 14 changed files with 132 additions and 99 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ENABLE_NOAA := 0
ENABLE_VOICE := 0
ENABLE_VOX := 0
ENABLE_ALARM := 0
ENABLE_TX1750 := 1
ENABLE_TX1750 := 0
ENABLE_BIG_FREQ := 0
ENABLE_SMALL_BOLD := 1
ENABLE_KEEP_MEM_NAME := 1
Expand All @@ -31,7 +31,7 @@ ENABLE_AM_FIX_SHOW_DATA := 1
ENABLE_SQUELCH_MORE_SENSITIVE := 1
ENABLE_FASTER_CHANNEL_SCAN := 0
ENABLE_RSSI_BAR := 1
ENABLE_AUDIO_BAR := 1
ENABLE_AUDIO_BAR := 0
ENABLE_COPY_CHAN_TO_VFO := 1
#ENABLE_SINGLE_VFO_CHAN := 1
#ENABLE_BAND_SCOPE := 1
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ To compile directly in windows without the need of a linux virtual machine:
1. Download and install "gcc-arm-none-eabi-10.3-2021.10-win32.exe" from https://developer.arm.com/downloads/-/gnu-rm
2. Download and install "gnu_make-3.81.exe" from https://gnuwin32.sourceforge.net/packages/make.htm
3. You may (or not) need to manualy add gcc path to you OS environment PATH.
3. You may need to (I didn't) manualy add gcc path to your OS environment PATH.
ie add C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2021.10\bin
4. You may (or not) need to reboot your PC after installing the above
4. You may need to reboot your PC after installing the above
```

Then you can run 'win_make.bat' from the directory you saved this source code too.
Expand Down
25 changes: 12 additions & 13 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -677,17 +677,17 @@ static void MR_NextChannel(void)
// this bit doesn't yet work if the other VFO is a frequency
case SCAN_NEXT_CHAN_DUAL_WATCH:
// dual watch is enabled - include the other VFO in the scan
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
{
chan = (gEeprom.RX_VFO + 1) & 1u;
chan = gEeprom.ScreenChannel[chan];
if (IS_MR_CHANNEL(chan))
{
gCurrentScanList = SCAN_NEXT_CHAN_DUAL_WATCH;
gNextMrChannel = chan;
break;
}
}
// if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF)
// {
// chan = (gEeprom.RX_VFO + 1) & 1u;
// chan = gEeprom.ScreenChannel[chan];
// if (IS_MR_CHANNEL(chan))
// {
// gCurrentScanList = SCAN_NEXT_CHAN_DUAL_WATCH;
// gNextMrChannel = chan;
// break;
// }
// }

default:
case SCAN_NEXT_CHAN_MR:
Expand Down Expand Up @@ -2163,8 +2163,7 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return;

if (!bKeyHeld)
{
// keypad is locked, tell the user
{ // keypad is locked, tell the user
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
gKeypadLocked = 4; // 2 seconds
gUpdateDisplay = true;
Expand Down
22 changes: 16 additions & 6 deletions app/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,22 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld)
if (!bKeyPressed)
return;

#ifdef ENABLE_VOICE
gAnotherVoiceID = gEeprom.KEY_LOCK ? VOICE_ID_UNLOCK : VOICE_ID_LOCK;
#endif

gEeprom.KEY_LOCK = !gEeprom.KEY_LOCK;
gRequestSaveSettings = true;
if (gScreenToDisplay != DISPLAY_MENU &&
gScreenToDisplay != DISPLAY_FM &&
#ifdef ENABLE_FMRADIO
!gFmRadioMode &&
#endif
gCurrentFunction != FUNCTION_TRANSMIT)
{ // toggle the keyboad lock

#ifdef ENABLE_VOICE
gAnotherVoiceID = gEeprom.KEY_LOCK ? VOICE_ID_UNLOCK : VOICE_ID_LOCK;
#endif

gEeprom.KEY_LOCK = !gEeprom.KEY_LOCK;

gRequestSaveSettings = true;
}
}
else
{
Expand Down
23 changes: 6 additions & 17 deletions app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
uint8_t Band;
uint8_t Vfo = gEeprom.TX_VFO;

if (gScreenToDisplay == DISPLAY_MENU)
return;

switch (Key)
{
case KEY_0:
Expand Down Expand Up @@ -560,30 +563,16 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld)
gCssScanMode == CSS_SCAN_MODE_OFF)
{ // copy channel to VFO

//const unsigned int vfo = (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF) ? gEeprom.RX_VFO : gEeprom.TX_VFO;
unsigned int vfo = gEeprom.TX_VFO;
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B)
vfo = 1;
else
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_A)
vfo = 0;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B)
vfo = 1;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A)
vfo = 0;
if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF)
vfo = (vfo + 1) & 1u;
const unsigned int vfo = get_rx_VFO();

if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo]))
{ // swap to the VFO

const unsigned int channel = FREQ_CHANNEL_FIRST + gEeprom.VfoInfo[vfo].Band;

gEeprom.ScreenChannel[vfo] = channel;
gEeprom.ScreenChannel[vfo] = channel;
gEeprom.VfoInfo[vfo].CHANNEL_SAVE = channel;
gEeprom.TX_VFO = vfo;
gEeprom.TX_VFO = vfo;

RADIO_SelectVfos();
RADIO_ApplyOffset(gRxVfo);
Expand Down
2 changes: 1 addition & 1 deletion board.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ void BOARD_Init(void)
BOARD_PORTCON_Init();
BOARD_GPIO_Init();
BOARD_ADC_Init();
ST7565_Init();
ST7565_Init(true);
#ifdef ENABLE_FMRADIO
BK1080_Init(0, false);
#endif
Expand Down
75 changes: 43 additions & 32 deletions driver/st7565.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ void ST7565_BlitFullScreen(void)
}

#if 0
// whats the delay for I wonder ? .. it slows down scanning :(
// whats the delay for I wonder, it holds things up :(
SYSTEM_DelayMs(20);
#else
SYSTEM_DelayMs(1);
// SYSTEM_DelayMs(1);
#endif

SPI_ToggleMasterMode(&SPI0->CR, true);
Expand Down Expand Up @@ -119,6 +119,9 @@ void ST7565_FillScreen(uint8_t Value)
{
unsigned int i;

// reset some of the displays settings to try and overcome the radios hardware problem - RF corrupting the display
ST7565_Init(false);

SPI_ToggleMasterMode(&SPI0->CR, false);
for (i = 0; i < 8; i++)
{
Expand All @@ -135,18 +138,21 @@ void ST7565_FillScreen(uint8_t Value)
SPI_ToggleMasterMode(&SPI0->CR, true);
}

void ST7565_Init(void)
void ST7565_Init(const bool full)
{
SPI0_Init();

ST7565_Configure_GPIO_B11();

SPI_ToggleMasterMode(&SPI0->CR, false);

ST7565_WriteByte(0xE2); // internal reset

SYSTEM_DelayMs(120);

if (full)
{
SPI0_Init();

ST7565_Configure_GPIO_B11();

SPI_ToggleMasterMode(&SPI0->CR, false);

ST7565_WriteByte(0xE2); // internal reset

SYSTEM_DelayMs(120);
}

ST7565_WriteByte(0xA2); // bias 9
ST7565_WriteByte(0xC0); // com normal
ST7565_WriteByte(0xA1); // reverse ?
Expand All @@ -157,30 +163,35 @@ void ST7565_Init(void)
ST7565_WriteByte(0xA4); // all points normal
ST7565_WriteByte(0x24); //
ST7565_WriteByte(0x81); // volume first ?
ST7565_WriteByte(0x1f); // contrast ?
ST7565_WriteByte(0x2B); // power control ?

SYSTEM_DelayMs(1);

ST7565_WriteByte(0x2E); // power control ?

SYSTEM_DelayMs(1);

ST7565_WriteByte(0x2F); //
ST7565_WriteByte(0x2F); //
ST7565_WriteByte(0x2F); //
ST7565_WriteByte(0x2F); //

SYSTEM_DelayMs(40);

ST7565_WriteByte(0x40); // start line ?
ST7565_WriteByte(0xAF); // display on ?

if (full)
{
ST7565_WriteByte(0x1f); // contrast ?
ST7565_WriteByte(0x2B); // power control ?

SYSTEM_DelayMs(1);

ST7565_WriteByte(0x2E); // power control ?

SYSTEM_DelayMs(1);

ST7565_WriteByte(0x2F); //
ST7565_WriteByte(0x2F); //
ST7565_WriteByte(0x2F); //
ST7565_WriteByte(0x2F); //

SYSTEM_DelayMs(40);

ST7565_WriteByte(0x40); // start line ?
ST7565_WriteByte(0xAF); // display on ?
}

SPI_WaitForUndocumentedTxFifoStatusBit();

SPI_ToggleMasterMode(&SPI0->CR, true);

ST7565_FillScreen(0x00);
if (full)
ST7565_FillScreen(0x00);
}

void ST7565_Configure_GPIO_B11(void)
Expand Down
2 changes: 1 addition & 1 deletion driver/st7565.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const u
void ST7565_BlitFullScreen(void);
void ST7565_BlitStatusLine(void);
void ST7565_FillScreen(uint8_t Value);
void ST7565_Init(void);
void ST7565_Init(const bool full);
void ST7565_Configure_GPIO_B11(void);
void ST7565_SelectColumnAndLine(uint8_t Column, uint8_t Line);
void ST7565_WriteByte(uint8_t Value);
Expand Down
Binary file modified firmware.bin
Binary file not shown.
Binary file modified firmware.packed.bin
Binary file not shown.
35 changes: 34 additions & 1 deletion misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <string.h>

#include "misc.h"
#include "settings.h"

const uint8_t fm_resume_countdown_500ms = 2500 / 500; // 2.5 seconds
const uint8_t fm_radio_countdown_500ms = 2000 / 500; // 2 seconds
Expand Down Expand Up @@ -259,7 +260,39 @@ int16_t gCurrentRSSI[2] = {0, 0}; // now one per VFO

uint8_t gIsLocked = 0xFF;

// --------
unsigned int get_rx_VFO(void)
{
unsigned int rx_vfo = gEeprom.TX_VFO;
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B)
rx_vfo = 0;
else
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_A)
rx_vfo = 1;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B)
rx_vfo = 1;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A)
rx_vfo = 0;
return rx_vfo;
}

unsigned int get_tx_VFO(void)
{
unsigned int tx_vfo = gEeprom.TX_VFO;
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_B)
tx_vfo = 1;
else
if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_CHAN_A)
tx_vfo = 0;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_B)
tx_vfo = 1;
else
if (gEeprom.DUAL_WATCH == DUAL_WATCH_CHAN_A)
tx_vfo = 0;
return tx_vfo;
}

void NUMBER_Get(char *pDigits, uint32_t *pInteger)
{
Expand Down
3 changes: 3 additions & 0 deletions misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ extern int16_t gCurrentRSSI[2]; // now one per VFO
extern uint8_t gIsLocked;
extern volatile uint8_t boot_counter_10ms;

unsigned int get_tx_VFO(void);
unsigned int get_rx_VFO(void);

void NUMBER_Get(char *pDigits, uint32_t *pInteger);
void NUMBER_ToDigits(uint32_t Value, char *pDigits);
int32_t NUMBER_AddWithWraparound(int32_t Base, int32_t Add, int32_t LowerLimit, int32_t UpperLimit);
Expand Down
Loading

0 comments on commit 609df5f

Please sign in to comment.