Skip to content

Commit

Permalink
创建多普勒
Browse files Browse the repository at this point in the history
  • Loading branch information
losehu committed Jan 30, 2024
1 parent 5a413ed commit 2266e94
Show file tree
Hide file tree
Showing 17 changed files with 151 additions and 233 deletions.
28 changes: 20 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ ENABLE_MDC1200_CONTACT ?= 1
ENABLE_UART_RW_BK_REGS ?= 0
ENABLE_AUDIO_BAR_DEFAULT ?= 0
ENABLE_EEPROM_TYPE = 0
ENABLE_CHINESE_FULL = 0
ENABLE_CHINESE_FULL = 4
ENABLE_DOCK ?= 0
ENABLE_CUSTOM_SIDEFUNCTIONS ?= 1
ENABLE_SIDEFUNCTIONS_SEND ?= 1
Expand All @@ -63,9 +63,11 @@ ENABLE_TIMER ?= 0
ENABLE_RTC ?= 0

ENABLE_WARNING ?= 1
ENABLE_MESSENGER ?=1
ENABLE_MESSENGER_DELIVERY_NOTIFICATION ?= 1
ENABLE_MESSENGER_NOTIFICATION ?= 1
ENABLE_MESSENGER ?=0
ENABLE_MESSENGER_DELIVERY_NOTIFICATION ?= 0
ENABLE_MESSENGER_NOTIFICATION ?= 0

ENABLE_DOPPLER ?=1
#############################################################
PACKED_FILE_SUFFIX = LOSEHU119
ifeq ($(ENABLE_CHINESE_FULL),1)
Expand Down Expand Up @@ -100,9 +102,9 @@ CFLAGS =

ifeq ($(ENABLE_CHINESE_FULL),0)
ENABLE_EEPROM_TYPE=0
ENABLE_MESSENGER =0
ENABLE_MESSENGER_DELIVERY_NOTIFICATION =0
ENABLE_MESSENGER_NOTIFICATION =0
ENABLE_MESSENGER =0
ENABLE_MESSENGER_DELIVERY_NOTIFICATION = 0
ENABLE_MESSENGER_NOTIFICATION = 0
$(info Normal)
endif

Expand All @@ -128,9 +130,16 @@ OBJS =
# Startup files
OBJS += start.o
OBJS += init.o
OBJS += ui/messenger.o
OBJS += app/messenger.o

ifeq ($(ENABLE_MESSENGER),1)
OBJS += ui/messenger.o
endif

ifeq ($(ENABLE_DOPPLER),1)
OBJS += app/doppler.o
endif

ifeq ($(ENABLE_OVERLAY),1)
OBJS += sram-overlay.o
endif
Expand Down Expand Up @@ -345,6 +354,9 @@ endif
ifeq ($(ENABLE_MESSENGER),1)
CFLAGS += -DENABLE_MESSENGER
endif
ifeq ($(ENABLE_DOPPLER),1)
CFLAGS += -DENABLE_DOPPLER
endif
ifeq ($(ENABLE_MESSENGER_DELIVERY_NOTIFICATION),1)
CFLAGS += -DENABLE_MESSENGER_DELIVERY_NOTIFICATION
endif
Expand Down
5 changes: 4 additions & 1 deletion app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@
#ifdef ENABLE_MESSENGER
#include "app/messenger.h"
#endif

#ifdef ENABLE_DOPPLER
#include "app/doppler.h"
#endif
#include "ui/battery.h"
#include "ui/inputbox.h"
#include "ui/main.h"
Expand Down Expand Up @@ -111,6 +113,7 @@ void (*ProcessKeysFunctions[])(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
#ifdef ENABLE_AIRCOPY
[DISPLAY_AIRCOPY] = &AIRCOPY_ProcessKeys,
#endif

};

static_assert(ARRAY_SIZE(ProcessKeysFunctions) == DISPLAY_N_ELEM);
Expand Down
22 changes: 22 additions & 0 deletions app/doppler.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// Created by RUPC on 2024/1/30.
//
#include "app/mdc1200.h"
#include <string.h>
#include "driver/keyboard.h"
#include "driver/st7565.h"
#include "driver/bk4819.h"
#include "external/printf/printf.h"
#include "misc.h"
#include "settings.h"
#include "radio.h"
#include "app.h"
#include "audio.h"
#include "functions.h"
#include "frequencies.h"
#include "driver/system.h"
#include "ui/ui.h"
#include "driver/uart.h"
#include "stdbool.h"

#include "app/doppler.h"
13 changes: 13 additions & 0 deletions app/doppler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// Created by RUPC on 2024/1/30.
//

#ifndef PICTURE_PY_DOPPLER_H
#define PICTURE_PY_DOPPLER_H
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "driver/keyboard.h"


#endif //PICTURE_PY_DOPPLER_H
3 changes: 3 additions & 0 deletions app/dtmf.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef ENABLE_DOPPLER
#include "app/doppler.h"
#endif
#include "app/messenger.h"
#include <string.h>
#include <stdio.h> // NULL
Expand Down
48 changes: 37 additions & 11 deletions app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,23 @@
#include "ui/inputbox.h"
#include "ui/ui.h"
#include <stdlib.h>

#ifdef ENABLE_MESSENGER
#include "app/messenger.h"
#endif
#ifdef ENABLE_DOPPLER
#include "app/doppler.h"
#endif

void toggle_chan_scanlist(void) { // toggle the selected channels scanlist setting
if (SCANNER_IsScanning())
return;
if (!IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
#ifdef ENABLE_SCAN_RANGES
gScanRangeStart = gScanRangeStart ? 0 : gTxVfo->pRX->Frequency;
gScanRangeStop = gEeprom.VfoInfo[!gEeprom.TX_VFO].freq_config_RX.Frequency;
if(gScanRangeStart > gScanRangeStop)
SWAP(gScanRangeStart, gScanRangeStop);
if(gScanRangeStart > gScanRangeStop)
SWAP(gScanRangeStart, gScanRangeStop);
#endif
return;
}
Expand Down Expand Up @@ -356,8 +361,8 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
} else if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower) {
const uint32_t center = (BX4819_band1.upper + BX4819_band2.lower) / 2;
Frequency = (Frequency < center) ? BX4819_band1.upper : BX4819_band2.lower;
} else if (Frequency > frequencyBandTable[BAND_N_ELEM- 1].upper) {
Frequency = frequencyBandTable[BAND_N_ELEM- 1].upper;
} else if (Frequency > frequencyBandTable[BAND_N_ELEM - 1].upper) {
Frequency = frequencyBandTable[BAND_N_ELEM - 1].upper;
}

const FREQUENCY_Band_t band = FREQUENCY_GetBand(Frequency);
Expand Down Expand Up @@ -429,8 +434,14 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
}

static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld) {


if (!bKeyHeld && bKeyPressed) { // exit key pressed





gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
#ifdef ENABLE_DTMF_CALLING
if (gDTMF_CallState != DTMF_CALL_STATE_NONE &&
Expand All @@ -440,6 +451,8 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld) {
return;
}
#endif


#ifdef ENABLE_FMRADIO
if (!gFmRadioMode)
#endif
Expand Down Expand Up @@ -487,6 +500,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld) {
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
}
}

}

static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) {
Expand Down Expand Up @@ -520,10 +534,10 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) {

#ifdef ENABLE_MESSENGER
if (gWasFKeyPressed) {
hasNewMessage = 0;
gRequestDisplayScreen = DISPLAY_MSG;
return;
}
hasNewMessage = 0;
gRequestDisplayScreen = DISPLAY_MSG;
return;
}
#endif


Expand Down Expand Up @@ -618,15 +632,26 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld) {

gUpdateStatus = true;
}

static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) {
uint8_t Channel = gEeprom.ScreenChannel[gEeprom.TX_VFO];
if (gWasFKeyPressed) {
gWasFKeyPressed = false;
gEeprom.BEEP_CONTROL = !gEeprom.BEEP_CONTROL;
gRequestSaveSettings = 1;

if(Direction==1) {
gEeprom.BEEP_CONTROL = !gEeprom.BEEP_CONTROL;
gRequestSaveSettings = 1;
}
#ifdef ENABLE_DOPPLER
if (Direction==-1) {
DOPPLER_MODE=1;
APP_RunSpectrum();
gRequestDisplayScreen = DISPLAY_MAIN;
}
#endif
return;
}

if (bKeyHeld || !bKeyPressed) { // key held or released

if (gInputBoxIndex > 0)
Expand All @@ -640,7 +665,7 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
// if released long button press and not in freq mode
#ifdef ENABLE_VOICE
AUDIO_SetDigitVoice(0, gTxVfo->CHANNEL_SAVE + 1); // say channel number
gAnotherVoiceID = (VOICE_ID_t)0xFE;
gAnotherVoiceID = (VOICE_ID_t)0xFE;
#endif
return;
}
Expand Down Expand Up @@ -714,6 +739,7 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)

gPttWasReleased = true;
}

void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
last_rx_vfo = -1;
#ifdef ENABLE_FMRADIO
Expand Down
26 changes: 21 additions & 5 deletions app/spectrum.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "am_fix.h"
#include "audio.h"
#include "misc.h"
#include "driver/eeprom.h"

#ifdef ENABLE_SCAN_RANGES
#include "chFrScanner.h"
#endif
Expand All @@ -40,6 +40,7 @@ const uint16_t RSSI_MAX_VALUE = 65535;

static uint32_t initialFreq;
static char String[32];
bool DOPPLER_MODE=0;

bool isInitialized = false;
bool isListening = true;
Expand Down Expand Up @@ -650,7 +651,7 @@ static void DrawSpectrum() {
}
}

static void DrawStatus() {
void DrawStatus() {
#ifdef SPECTRUM_EXTRA_VALUES
sprintf(String, "%d/%d P:%d T:%d", settings.dbMin, settings.dbMax,
Rssi2DBm(peak.rssi), Rssi2DBm(settings.rssiTriggerLevel));
Expand Down Expand Up @@ -1036,6 +1037,7 @@ static void RenderStill() {

static void Render() {
UI_DisplayClear();

switch (currentState) {
case SPECTRUM:
RenderSpectrum();
Expand Down Expand Up @@ -1241,9 +1243,14 @@ void APP_RunSpectrum() {
}
else
#endif
currentFreq = initialFreq = gTxVfo->pRX->Frequency -
// if( DOPPLER_MODE) {
//// currentFreq=43850000;
//
// }else
// {
currentFreq = initialFreq = gTxVfo->pRX->Frequency -
((GetStepsCount() / 2) * GetScanStep());

// }
BackupRegisters();

isListening = true; // to turn off RX later
Expand All @@ -1262,8 +1269,17 @@ void APP_RunSpectrum() {
memset(rssiHistory, 0, sizeof(rssiHistory));

isInitialized = true;
if( DOPPLER_MODE) {
SetState(STILL);
TuneToPeak();
SetF(43850000);

}
while (isInitialized) {
Tick();
}
}
}




2 changes: 2 additions & 0 deletions app/spectrum.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ typedef struct PeakInfo {
} PeakInfo;

void APP_RunSpectrum(void);
void DrawStatus() ;
extern bool DOPPLER_MODE;

#endif /* ifndef SPECTRUM_H */

Expand Down
2 changes: 0 additions & 2 deletions app/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ static void CMD_051B(const uint8_t *pBuffer) {
static void CMD_051D(const uint8_t *pBuffer) {
const CMD_051D_t *pCmd = (const CMD_051D_t *) pBuffer;
REPLY_051D_t Reply;
bool bReloadEeprom;
#ifdef ENABLE_BLOCK
bool bIsLocked;
#endif
Expand All @@ -301,7 +300,6 @@ static void CMD_051D(const uint8_t *pBuffer) {

gSerialConfigCountDown_500ms = 12; // 6 sec

bReloadEeprom = false;

#ifdef ENABLE_FMRADIO
gFmRadioCountdown_500ms = fm_radio_countdown_500ms;
Expand Down
3 changes: 3 additions & 0 deletions functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#ifdef ENABLE_MESSENGER
#include "app/messenger.h"
#endif
#ifdef ENABLE_DOPPLER
#include "app/doppler.h"
#endif
#if defined(ENABLE_FMRADIO)
#include "driver/bk1080.h"
#endif
Expand Down
Loading

0 comments on commit 2266e94

Please sign in to comment.