Skip to content

Commit

Permalink
Удалены FM и сигнал тревоги
Browse files Browse the repository at this point in the history
  • Loading branch information
rebezhir committed Sep 10, 2023
1 parent 90aec85 commit 95d986c
Show file tree
Hide file tree
Showing 28 changed files with 51 additions and 1,194 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ sram-overlay.bin

*.bin
firmware
make.sh
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ OBJS += external/printf/printf.o
OBJS += driver/adc.o
OBJS += driver/aes.o
OBJS += driver/backlight.o
OBJS += driver/bk1080.o
OBJS += driver/bk4819.o
OBJS += driver/crc.o
OBJS += driver/eeprom.o
Expand All @@ -33,7 +32,6 @@ OBJS += driver/uart.o
OBJS += app/action.o
OBJS += app/app.o
OBJS += app/dtmf.o
OBJS += app/fm.o
OBJS += app/generic.o
OBJS += app/main.o
OBJS += app/menu.o
Expand All @@ -53,7 +51,6 @@ OBJS += radio.o
OBJS += scheduler.o
OBJS += settings.o
OBJS += ui/battery.o
OBJS += ui/fmradio.o
OBJS += ui/helper.o
OBJS += ui/inputbox.o
OBJS += ui/lock.o
Expand Down
74 changes: 13 additions & 61 deletions app/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@

#include "app/app.h"
#include "app/dtmf.h"
#include "app/fm.h"
#include "app/scanner.h"
#include "audio.h"
#include "bsp/dp32g030/gpio.h"
#include "driver/bk1080.h"
#include "driver/bk4819.h"
#include "driver/gpio.h"
#include "functions.h"
Expand Down Expand Up @@ -69,42 +67,11 @@ static void ACTION_Monitor(void) {
gScanPauseMode = true;
}
RADIO_SetupRegisters(true);
if (gFmRadioMode) {
FM_Start();
gRequestDisplayScreen = DISPLAY_FM;
} else {
gRequestDisplayScreen = gScreenToDisplay;
}
gRequestDisplayScreen = gScreenToDisplay;
}

void ACTION_Scan(bool bRestart) {
if (gFmRadioMode) {
if (gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_MONITOR &&
gCurrentFunction != FUNCTION_TRANSMIT) {
uint16_t Frequency;

GUI_SelectNextDisplay(DISPLAY_FM);
if (gFM_ScanState != FM_SCAN_OFF) {
FM_PlayAndUpdate();
gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
} else {
if (bRestart) {
gFM_AutoScan = true;
gFM_ChannelPosition = 0;
FM_EraseChannels();
Frequency = gEeprom.FM_LowerLimit;
} else {
gFM_AutoScan = false;
gFM_ChannelPosition = 0;
Frequency = gEeprom.FM_FrequencyPlaying;
}
BK1080_GetFrequencyDeviation(Frequency);
FM_Tune(Frequency, 1, bRestart);
gAnotherVoiceID = VOICE_ID_SCANNING_BEGIN;
}
}
} else if (gScreenToDisplay != DISPLAY_SCANNER) {
if (gScreenToDisplay != DISPLAY_SCANNER) {
RADIO_SelectVfos();
GUI_SelectNextDisplay(DISPLAY_MAIN);
if (gScanState != SCAN_OFF) {
Expand All @@ -126,35 +93,20 @@ void ACTION_Vox(void) {
gUpdateStatus = true;
}

static void ACTION_AlarmOr1750(bool b1750) {
static void ACTION_1750(void) {
gInputBoxIndex = 0;
if (b1750) {
gAlarmState = ALARM_STATE_TX1750;
} else {
gAlarmState = ALARM_STATE_TXALARM;
}
gAlarmState = ALARM_STATE_TX1750;
gAlarmRunningCounter = 0;
gFlagPrepareTX = true;
gRequestDisplayScreen = DISPLAY_MAIN;
}

void ACTION_FM(void) {
if (gCurrentFunction != FUNCTION_TRANSMIT &&
gCurrentFunction != FUNCTION_MONITOR) {
if (gFmRadioMode) {
FM_TurnOff();
gInputBoxIndex = 0;
gVoxResumeCountdown = 80;
gFlagReconfigureVfos = true;
gRequestDisplayScreen = DISPLAY_MAIN;
return;
}
RADIO_SelectVfos();
RADIO_SetupRegisters(true);
FM_Start();
gInputBoxIndex = 0;
gRequestDisplayScreen = DISPLAY_FM;
}
void ACTION_SwitchAB(void) {
//временная заглушка
}

void ACTION_VFOMR(void) {
//временная заглушка
}

void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
Expand Down Expand Up @@ -218,13 +170,13 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
ACTION_Vox();
break;
case 6:
ACTION_AlarmOr1750(false);
ACTION_VFOMR();
break;
case 7:
ACTION_FM();
ACTION_SwitchAB();
break;
case 8:
ACTION_AlarmOr1750(true);
ACTION_1750();
break;
}
}
6 changes: 2 additions & 4 deletions app/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@

#include "driver/keyboard.h"

//static void ACTION_FlashLight(void)

void ACTION_Power(void);
//static void ACTION_Monitor(void)
void ACTION_Scan(bool bFlag);
void ACTION_Vox(void);
//static void ACTION_AlarmOr1750(bool b1750)
void ACTION_FM(void);


void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld);

Expand Down
87 changes: 8 additions & 79 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
#include "app/app.h"

#include <string.h>

#include "ARMCM0.h"
#include "app/action.h"
#include "app/dtmf.h"
#include "app/fm.h"
#include "app/generic.h"
#include "app/main.h"
#include "app/menu.h"
Expand All @@ -31,7 +29,6 @@
#include "board.h"
#include "bsp/dp32g030/gpio.h"
#include "driver/backlight.h"
#include "driver/bk1080.h"
#include "driver/bk4819.h"
#include "driver/gpio.h"
#include "driver/keyboard.h"
Expand Down Expand Up @@ -279,9 +276,6 @@ static void APP_HandleFunction(void) {
}

void APP_StartListening(FUNCTION_Type_t Function) {
if (gFmRadioMode) {
BK1080_Init(0, false);
}
gVFO_RSSI_Level[gEeprom.RX_CHANNEL == 0] = 0;
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gEnableSpeaker = true;
Expand Down Expand Up @@ -328,7 +322,7 @@ void APP_StartListening(FUNCTION_Type_t Function) {
}
}
FUNCTION_Select(Function);
if (Function == FUNCTION_MONITOR || gFmRadioMode) {
if (Function == FUNCTION_MONITOR) {
GUI_SelectNextDisplay(DISPLAY_MAIN);
return;
}
Expand Down Expand Up @@ -513,7 +507,7 @@ static void APP_HandleVox(void) {
}
if (gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_MONITOR && gScanState == SCAN_OFF &&
gCssScanMode == CSS_SCAN_MODE_OFF && !gFmRadioMode) {
gCssScanMode == CSS_SCAN_MODE_OFF) {
if (gVOX_NoiseDetected) {
if (g_VOX_Lost) {
gVoxStopCountdown = 100;
Expand Down Expand Up @@ -572,9 +566,7 @@ void APP_Update(void) {
if (gCurrentFunction != FUNCTION_TRANSMIT) {
APP_HandleFunction();
}
if (gFmRadioCountdown) {
return;
}


if (gScreenToDisplay != DISPLAY_SCANNER && gScanState != SCAN_OFF &&
gScheduleScanListen && !gPttIsPressed && gVoiceWriteIndex == 0) {
Expand Down Expand Up @@ -607,8 +599,7 @@ void APP_Update(void) {
gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) {
if (gScheduleDualWatch && gVoiceWriteIndex == 0) {
if (gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF) {
if (!gPttIsPressed && !gFmRadioMode &&
gDTMF_CallState == DTMF_CALL_STATE_NONE &&
if (!gPttIsPressed && gDTMF_CallState == DTMF_CALL_STATE_NONE &&
gCurrentFunction != FUNCTION_POWER_SAVE) {
DUALWATCH_Alternate();
if (gRxVfoIsActive && gScreenToDisplay == DISPLAY_MAIN) {
Expand All @@ -623,21 +614,14 @@ void APP_Update(void) {
}
}

if (gFM_ScanState != FM_SCAN_OFF && gScheduleFM &&
gCurrentFunction != FUNCTION_MONITOR &&
gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_TRANSMIT) {
FM_Play();
gScheduleFM = false;
}

if (gEeprom.VOX_SWITCH) {
APP_HandleVox();
}

if (gSchedulePowerSave) {
if (gEeprom.BATTERY_SAVE == 0 || gScanState != SCAN_OFF ||
gCssScanMode != CSS_SCAN_MODE_OFF || gFmRadioMode ||
gCssScanMode != CSS_SCAN_MODE_OFF ||
gPttIsPressed || gScreenToDisplay != DISPLAY_MAIN ||
gKeyBeingHeld || gDTMF_CallState != DTMF_CALL_STATE_NONE) {
gBatterySaveCountdown = 1000;
Expand Down Expand Up @@ -777,12 +761,6 @@ void APP_TimeSlice10ms(void) {
}
}

// Skipping authentic device checks

if (gFmRadioCountdown) {
return;
}

if (gFlashLightState == FLASHLIGHT_BLINK &&
(gFlashLightBlinkCounter & 15U) == 0) {
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
Expand Down Expand Up @@ -839,13 +817,7 @@ void APP_TimeSlice10ms(void) {
}
}
}
if (gFmRadioMode && gFM_RestoreCountdown) {
gFM_RestoreCountdown--;
if (gFM_RestoreCountdown == 0) {
FM_Start();
GUI_SelectNextDisplay(DISPLAY_FM);
}
}

if (gScreenToDisplay == DISPLAY_SCANNER) {
uint32_t Result;
int32_t Delta;
Expand Down Expand Up @@ -945,7 +917,6 @@ void APP_TimeSlice10ms(void) {
}

void APP_TimeSlice500ms(void) {
// Skipped authentic device check

if (gKeypadLocked) {
gKeypadLocked--;
Expand All @@ -954,12 +925,7 @@ void APP_TimeSlice500ms(void) {
}
}

// Skipped authentic device check

if (gFmRadioCountdown) {
gFmRadioCountdown--;
return;
}
if (gReducedService) {
BOARD_ADC_GetBatteryInfo(&gBatteryCurrentVoltage, &gBatteryCurrent);
if (gBatteryCurrent > 500 ||
Expand All @@ -971,7 +937,6 @@ void APP_TimeSlice500ms(void) {

gBatteryCheckCounter++;

// Skipped authentic device check

if (gCurrentFunction != FUNCTION_TRANSMIT) {
if ((gBatteryCheckCounter & 1) == 0) {
Expand All @@ -987,8 +952,7 @@ void APP_TimeSlice500ms(void) {
gCurrentRSSI = BK4819_GetRSSI();
UI_UpdateRSSI(gCurrentRSSI);
}
if ((gFM_ScanState == FM_SCAN_OFF || gAskToSave) &&
gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF) {
if (gAskToSave && (gScanState == SCAN_OFF) && (gCssScanMode == CSS_SCAN_MODE_OFF)) {
if (gBacklightCountdown) {
gBacklightCountdown--;
if (gBacklightCountdown == 0) {
Expand Down Expand Up @@ -1026,33 +990,13 @@ void APP_TimeSlice500ms(void) {
gDTMF_InputIndex = 0;
gAskToSave = false;
gAskToDelete = false;
if (gFmRadioMode &&
gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_MONITOR &&
gCurrentFunction != FUNCTION_TRANSMIT) {
GUI_SelectNextDisplay(DISPLAY_FM);
} else {
GUI_SelectNextDisplay(DISPLAY_MAIN);
}
GUI_SelectNextDisplay(DISPLAY_MAIN);
}
}
}
}
}

if (!gPttIsPressed && gFM_ResumeCountdown) {
gFM_ResumeCountdown--;
if (gFM_ResumeCountdown == 0) {
RADIO_SetVfoState(VFO_STATE_NORMAL);
if (gCurrentFunction != FUNCTION_RECEIVE &&
gCurrentFunction != FUNCTION_TRANSMIT &&
gCurrentFunction != FUNCTION_MONITOR && gFmRadioMode) {
FM_Start();
GUI_SelectNextDisplay(DISPLAY_FM);
}
}
}

if (gLowBattery) {
gLowBatteryBlink = ++gLowBatteryCountdown & 1;
UI_DisplayBattery(gLowBatteryCountdown);
Expand Down Expand Up @@ -1186,10 +1130,6 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
SETTINGS_SaveSettings();
gFlagSaveSettings = false;
}
if (gFlagSaveFM) {
SETTINGS_SaveFM();
gFlagSaveFM = false;
}
if (gFlagSaveChannel) {
SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_CHANNEL,
gTxVfo, gFlagSaveChannel);
Expand Down Expand Up @@ -1356,9 +1296,6 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
case DISPLAY_MAIN:
MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld);
break;
case DISPLAY_FM:
FM_ProcessKeys(Key, bKeyPressed, bKeyHeld);
break;
case DISPLAY_MENU:
MENU_ProcessKeys(Key, bKeyPressed, bKeyHeld);
break;
Expand Down Expand Up @@ -1399,14 +1336,6 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
gRequestSaveSettings = false;
gUpdateStatus = true;
}
if (gRequestSaveFM) {
if (!bKeyHeld) {
SETTINGS_SaveFM();
} else {
gFlagSaveFM = true;
}
gRequestSaveFM = false;
}
if (gRequestSaveVFO) {
if (!bKeyHeld) {
SETTINGS_SaveVfoIndices();
Expand Down
Loading

0 comments on commit 95d986c

Please sign in to comment.