mirror of
https://github.com/kamilsss655/uv-k5-firmware-custom
synced 2024-11-21 17:57:59 +00:00
Added spectrum analyzer from fagci
This commit is contained in:
parent
f4643adb2a
commit
3c44faaa99
14
Makefile
14
Makefile
@ -7,11 +7,11 @@ ENABLE_SWD := 0
|
||||
ENABLE_OVERLAY := 1
|
||||
ENABLE_UART := 1
|
||||
ENABLE_AIRCOPY := 0
|
||||
ENABLE_FMRADIO := 1
|
||||
ENABLE_FMRADIO := 0
|
||||
ENABLE_NOAA := 0
|
||||
ENABLE_VOICE := 0
|
||||
ENABLE_ALARM := 0
|
||||
ENABLE_BIG_FREQ := 0
|
||||
ENABLE_ALARM := 1
|
||||
ENABLE_BIG_FREQ := 1
|
||||
ENABLE_SMALL_BOLD := 1
|
||||
ENABLE_KEEP_MEM_NAME := 1
|
||||
ENABLE_WIDE_RX := 1
|
||||
@ -28,6 +28,7 @@ ENABLE_AM_FIX_SHOW_DATA := 1
|
||||
ENABLE_SQUELCH1_LOWER := 0
|
||||
ENABLE_RSSI_BAR := 1
|
||||
ENABLE_AUDIO_BAR := 1
|
||||
ENABLE_SPECTRUM := 1
|
||||
#ENABLE_COPY_CHAN_TO_VFO := 1
|
||||
#ENABLE_SINGLE_VFO_CHAN := 1
|
||||
#ENABLE_BAND_SCOPE := 1
|
||||
@ -88,6 +89,9 @@ endif
|
||||
OBJS += app/generic.o
|
||||
OBJS += app/main.o
|
||||
OBJS += app/menu.o
|
||||
ifeq ($(ENABLE_SPECTRUM), 1)
|
||||
OBJS += app/spectrum.o
|
||||
endif
|
||||
OBJS += app/scanner.o
|
||||
ifeq ($(ENABLE_UART),1)
|
||||
OBJS += app/uart.o
|
||||
@ -156,6 +160,10 @@ CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delet
|
||||
|
||||
CFLAGS += -DPRINTF_INCLUDE_CONFIG_H
|
||||
CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\"
|
||||
|
||||
ifeq ($(ENABLE_SPECTRUM),1)
|
||||
CFLAGS += -DENABLE_SPECTRUM
|
||||
endif
|
||||
ifeq ($(ENABLE_SWD),1)
|
||||
CFLAGS += -DENABLE_SWD
|
||||
endif
|
||||
|
@ -24,6 +24,9 @@
|
||||
#include "app/generic.h"
|
||||
#include "app/main.h"
|
||||
#include "app/scanner.h"
|
||||
#ifdef ENABLE_SPECTRUM
|
||||
#include "app/spectrum.h"
|
||||
#endif
|
||||
#include "audio.h"
|
||||
#include "driver/bk4819.h"
|
||||
#include "dtmf.h"
|
||||
@ -176,7 +179,10 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
|
||||
}
|
||||
gRequestSaveVFO = true;
|
||||
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
|
||||
#else
|
||||
#elif defined(ENABLE_SPECTRUM)
|
||||
APP_RunSpectrum();
|
||||
gRequestDisplayScreen = DISPLAY_MAIN;
|
||||
#else
|
||||
// toggle scanlist-1 and scanlist 2
|
||||
if (gScreenToDisplay != DISPLAY_SCANNER)
|
||||
{
|
||||
|
1185
app/spectrum.c
Normal file
1185
app/spectrum.c
Normal file
File diff suppressed because it is too large
Load Diff
172
app/spectrum.h
Normal file
172
app/spectrum.h
Normal file
@ -0,0 +1,172 @@
|
||||
/* Copyright 2023 fagci
|
||||
* https://github.com/fagci
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef SPECTRUM_H
|
||||
#define SPECTRUM_H
|
||||
|
||||
#include "../bitmaps.h"
|
||||
#include "../board.h"
|
||||
#include "../bsp/dp32g030/gpio.h"
|
||||
#include "../driver/bk4819-regs.h"
|
||||
#include "../driver/bk4819.h"
|
||||
#include "../driver/gpio.h"
|
||||
#include "../driver/keyboard.h"
|
||||
#include "../driver/st7565.h"
|
||||
#include "../driver/system.h"
|
||||
#include "../driver/systick.h"
|
||||
#include "../external/printf/printf.h"
|
||||
#include "../font.h"
|
||||
#include "../frequencies.h"
|
||||
#include "../helper/battery.h"
|
||||
#include "../misc.h"
|
||||
#include "../radio.h"
|
||||
#include "../settings.h"
|
||||
#include "../ui/helper.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
static const uint8_t DrawingEndY = 40;
|
||||
|
||||
static const uint8_t U8RssiMap[] = {
|
||||
121, 115, 109, 103, 97, 91, 85, 79, 73, 63,
|
||||
};
|
||||
|
||||
static const uint16_t scanStepValues[] = {
|
||||
1, 10, 50, 100,
|
||||
|
||||
250, 500, 625, 833, 1000, 1250, 2500, 10000,
|
||||
};
|
||||
|
||||
static const uint16_t scanStepBWRegValues[] = {
|
||||
// RX RXw TX BW
|
||||
// 0b0 000 000 001 01 1000
|
||||
// 1
|
||||
0b0000000001011000, // 6.25
|
||||
// 10
|
||||
0b0000000001011000, // 6.25
|
||||
// 50
|
||||
0b0000000001011000, // 6.25
|
||||
// 100
|
||||
0b0000000001011000, // 6.25
|
||||
// 250
|
||||
0b0000000001011000, // 6.25
|
||||
// 500
|
||||
0b0010010001011000, // 6.25
|
||||
// 625
|
||||
0b0100100001011000, // 6.25
|
||||
// 833
|
||||
0b0110110001001000, // 6.25
|
||||
// 1000
|
||||
0b0110110001001000, // 6.25
|
||||
// 1250
|
||||
0b0111111100001000, // 6.25
|
||||
// 2500
|
||||
0b0011011000101000, // 25
|
||||
// 10000
|
||||
0b0011011000101000, // 25
|
||||
};
|
||||
|
||||
static const uint16_t listenBWRegValues[] = {
|
||||
0b0011011000101000, // 25
|
||||
0b0111111100001000, // 12.5
|
||||
0b0100100001011000, // 6.25
|
||||
};
|
||||
|
||||
typedef enum State {
|
||||
SPECTRUM,
|
||||
FREQ_INPUT,
|
||||
STILL,
|
||||
} State;
|
||||
|
||||
typedef enum StepsCount {
|
||||
STEPS_128,
|
||||
STEPS_64,
|
||||
STEPS_32,
|
||||
STEPS_16,
|
||||
} StepsCount;
|
||||
|
||||
typedef enum ModulationType {
|
||||
MOD_FM,
|
||||
MOD_AM,
|
||||
MOD_USB,
|
||||
} ModulationType;
|
||||
|
||||
typedef enum ScanStep {
|
||||
S_STEP_0_01kHz,
|
||||
S_STEP_0_1kHz,
|
||||
S_STEP_0_5kHz,
|
||||
S_STEP_1_0kHz,
|
||||
|
||||
S_STEP_2_5kHz,
|
||||
S_STEP_5_0kHz,
|
||||
S_STEP_6_25kHz,
|
||||
S_STEP_8_33kHz,
|
||||
S_STEP_10_0kHz,
|
||||
S_STEP_12_5kHz,
|
||||
S_STEP_25_0kHz,
|
||||
S_STEP_100_0kHz,
|
||||
} ScanStep;
|
||||
|
||||
typedef struct SpectrumSettings {
|
||||
StepsCount stepsCount;
|
||||
ScanStep scanStepIndex;
|
||||
uint32_t frequencyChangeStep;
|
||||
uint16_t scanDelay;
|
||||
uint16_t rssiTriggerLevel;
|
||||
|
||||
bool backlightState;
|
||||
BK4819_FilterBandwidth_t bw;
|
||||
BK4819_FilterBandwidth_t listenBw;
|
||||
ModulationType modulationType;
|
||||
int dbMin;
|
||||
int dbMax;
|
||||
} SpectrumSettings;
|
||||
|
||||
typedef struct KeyboardState {
|
||||
KEY_Code_t current;
|
||||
KEY_Code_t prev;
|
||||
uint8_t counter;
|
||||
} KeyboardState;
|
||||
|
||||
typedef struct ScanInfo {
|
||||
uint16_t rssi, rssiMin, rssiMax;
|
||||
uint8_t i, iPeak;
|
||||
uint32_t f, fPeak;
|
||||
uint16_t scanStep;
|
||||
uint8_t measurementsCount;
|
||||
} ScanInfo;
|
||||
|
||||
typedef struct RegisterSpec {
|
||||
char *name;
|
||||
uint8_t num;
|
||||
uint8_t offset;
|
||||
uint16_t maxValue;
|
||||
uint16_t inc;
|
||||
} RegisterSpec;
|
||||
|
||||
typedef struct PeakInfo {
|
||||
uint16_t t;
|
||||
uint16_t rssi;
|
||||
uint8_t i;
|
||||
uint32_t f;
|
||||
} PeakInfo;
|
||||
|
||||
void APP_RunSpectrum(void);
|
||||
|
||||
#endif /* ifndef SPECTRUM_H */
|
||||
|
||||
// vim: ft=c
|
1
board.h
1
board.h
@ -18,6 +18,7 @@
|
||||
#define BOARD_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
void BOARD_FLASH_Init(void);
|
||||
void BOARD_GPIO_Init(void);
|
||||
|
168
font.c
168
font.c
@ -165,6 +165,174 @@ const uint8_t gFontSmallDigits[11][7] =
|
||||
{0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00} // '-'
|
||||
};
|
||||
*/
|
||||
|
||||
#ifdef ENABLE_SPECTRUM
|
||||
|
||||
const uint8_t gFont3x5[160][3] = {
|
||||
{0x00, 0x00, 0x00}, // 32 - space
|
||||
{0x00, 0x17, 0x00}, // 33 - exclam
|
||||
{0x03, 0x00, 0x03}, // 34 - quotedbl
|
||||
{0x1f, 0x0a, 0x1f}, // 35 - numbersign
|
||||
{0x0a, 0x1f, 0x05}, // 36 - dollar
|
||||
{0x09, 0x04, 0x12}, // 37 - percent
|
||||
{0x0f, 0x17, 0x1c}, // 38 - ampersand
|
||||
{0x00, 0x03, 0x00}, // 39 - quotesingle
|
||||
{0x00, 0x0e, 0x11}, // 40 - parenleft
|
||||
{0x11, 0x0e, 0x00}, // 41 - parenright
|
||||
{0x05, 0x02, 0x05}, // 42 - asterisk
|
||||
{0x04, 0x0e, 0x04}, // 43 - plus
|
||||
{0x10, 0x08, 0x00}, // 44 - comma
|
||||
{0x04, 0x04, 0x04}, // 45 - hyphen
|
||||
{0x00, 0x10, 0x00}, // 46 - period
|
||||
{0x18, 0x04, 0x03}, // 47 - slash
|
||||
{0x1e, 0x11, 0x0f}, // 48 - zero
|
||||
{0x02, 0x1f, 0x00}, // 49 - one
|
||||
{0x19, 0x15, 0x12}, // 50 - two
|
||||
{0x11, 0x15, 0x0a}, // 51 - three
|
||||
{0x07, 0x04, 0x1f}, // 52 - four
|
||||
{0x17, 0x15, 0x09}, // 53 - five
|
||||
{0x1e, 0x15, 0x1d}, // 54 - six
|
||||
{0x19, 0x05, 0x03}, // 55 - seven
|
||||
{0x1f, 0x15, 0x1f}, // 56 - eight
|
||||
{0x17, 0x15, 0x0f}, // 57 - nine
|
||||
{0x00, 0x0a, 0x00}, // 58 - colon
|
||||
{0x10, 0x0a, 0x00}, // 59 - semicolon
|
||||
{0x04, 0x0a, 0x11}, // 60 - less
|
||||
{0x0a, 0x0a, 0x0a}, // 61 - equal
|
||||
{0x11, 0x0a, 0x04}, // 62 - greater
|
||||
{0x01, 0x15, 0x03}, // 63 - question
|
||||
{0x0e, 0x15, 0x16}, // 64 - at
|
||||
{0x1e, 0x05, 0x1e}, // 65 - A
|
||||
{0x1f, 0x15, 0x0a}, // 66 - B
|
||||
{0x0e, 0x11, 0x11}, // 67 - C
|
||||
{0x1f, 0x11, 0x0e}, // 68 - D
|
||||
{0x1f, 0x15, 0x15}, // 69 - E
|
||||
{0x1f, 0x05, 0x05}, // 70 - F
|
||||
{0x0e, 0x15, 0x1d}, // 71 - G
|
||||
{0x1f, 0x04, 0x1f}, // 72 - H
|
||||
{0x11, 0x1f, 0x11}, // 73 - I
|
||||
{0x08, 0x10, 0x0f}, // 74 - J
|
||||
{0x1f, 0x04, 0x1b}, // 75 - K
|
||||
{0x1f, 0x10, 0x10}, // 76 - L
|
||||
{0x1f, 0x06, 0x1f}, // 77 - M
|
||||
{0x1f, 0x0e, 0x1f}, // 78 - N
|
||||
{0x0e, 0x11, 0x0e}, // 79 - O
|
||||
{0x1f, 0x05, 0x02}, // 80 - P
|
||||
{0x0e, 0x19, 0x1e}, // 81 - Q
|
||||
{0x1f, 0x0d, 0x16}, // 82 - R
|
||||
{0x12, 0x15, 0x09}, // 83 - S
|
||||
{0x01, 0x1f, 0x01}, // 84 - T
|
||||
{0x0f, 0x10, 0x1f}, // 85 - U
|
||||
{0x07, 0x18, 0x07}, // 86 - V
|
||||
{0x1f, 0x0c, 0x1f}, // 87 - W
|
||||
{0x1b, 0x04, 0x1b}, // 88 - X
|
||||
{0x03, 0x1c, 0x03}, // 89 - Y
|
||||
{0x19, 0x15, 0x13}, // 90 - Z
|
||||
{0x1f, 0x11, 0x11}, // 91 - bracketleft
|
||||
{0x02, 0x04, 0x08}, // 92 - backslash
|
||||
{0x11, 0x11, 0x1f}, // 93 - bracketright
|
||||
{0x02, 0x01, 0x02}, // 94 - asciicircum
|
||||
{0x10, 0x10, 0x10}, // 95 - underscore
|
||||
{0x01, 0x02, 0x00}, // 96 - grave
|
||||
{0x1a, 0x16, 0x1c}, // 97 - a
|
||||
{0x1f, 0x12, 0x0c}, // 98 - b
|
||||
{0x0c, 0x12, 0x12}, // 99 - c
|
||||
{0x0c, 0x12, 0x1f}, // 100 - d
|
||||
{0x0c, 0x1a, 0x16}, // 101 - e
|
||||
{0x04, 0x1e, 0x05}, // 102 - f
|
||||
{0x0c, 0x2a, 0x1e}, // 103 - g
|
||||
{0x1f, 0x02, 0x1c}, // 104 - h
|
||||
{0x00, 0x1d, 0x00}, // 105 - i
|
||||
{0x10, 0x20, 0x1d}, // 106 - j
|
||||
{0x1f, 0x0c, 0x12}, // 107 - k
|
||||
{0x11, 0x1f, 0x10}, // 108 - l
|
||||
{0x1e, 0x0e, 0x1e}, // 109 - m
|
||||
{0x1e, 0x02, 0x1c}, // 110 - n
|
||||
{0x0c, 0x12, 0x0c}, // 111 - o
|
||||
{0x3e, 0x12, 0x0c}, // 112 - p
|
||||
{0x0c, 0x12, 0x3e}, // 113 - q
|
||||
{0x1c, 0x02, 0x02}, // 114 - r
|
||||
{0x14, 0x1e, 0x0a}, // 115 - s
|
||||
{0x02, 0x1f, 0x12}, // 116 - t
|
||||
{0x0e, 0x10, 0x1e}, // 117 - u
|
||||
{0x0e, 0x18, 0x0e}, // 118 - v
|
||||
{0x1e, 0x1c, 0x1e}, // 119 - w
|
||||
{0x12, 0x0c, 0x12}, // 120 - x
|
||||
{0x06, 0x28, 0x1e}, // 121 - y
|
||||
{0x1a, 0x1e, 0x16}, // 122 - z
|
||||
{0x04, 0x1b, 0x11}, // 123 - braceleft
|
||||
{0x00, 0x1b, 0x00}, // 124 - bar
|
||||
{0x11, 0x1b, 0x04}, // 125 - braceright
|
||||
{0x02, 0x03, 0x01}, // 126 - asciitilde
|
||||
{0x00, 0x00, 0x00}, // 127 - empty
|
||||
{0x00, 0x00, 0x00}, // 128 - empty
|
||||
{0x00, 0x00, 0x00}, // 129 - empty
|
||||
{0x00, 0x00, 0x00}, // 130 - empty
|
||||
{0x00, 0x00, 0x00}, // 131 - empty
|
||||
{0x00, 0x00, 0x00}, // 132 - empty
|
||||
{0x00, 0x00, 0x00}, // 133 - empty
|
||||
{0x00, 0x00, 0x00}, // 134 - empty
|
||||
{0x00, 0x00, 0x00}, // 135 - empty
|
||||
{0x00, 0x00, 0x00}, // 136 - empty
|
||||
{0x00, 0x00, 0x00}, // 137 - empty
|
||||
{0x00, 0x00, 0x00}, // 138 - empty
|
||||
{0x00, 0x00, 0x00}, // 139 - empty
|
||||
{0x00, 0x00, 0x00}, // 140 - empty
|
||||
{0x00, 0x00, 0x00}, // 141 - empty
|
||||
{0x00, 0x00, 0x00}, // 142 - empty
|
||||
{0x00, 0x00, 0x00}, // 143 - empty
|
||||
{0x00, 0x00, 0x00}, // 144 - empty
|
||||
{0x00, 0x00, 0x00}, // 145 - empty
|
||||
{0x00, 0x00, 0x00}, // 146 - empty
|
||||
{0x00, 0x00, 0x00}, // 147 - empty
|
||||
{0x00, 0x00, 0x00}, // 148 - empty
|
||||
{0x00, 0x00, 0x00}, // 149 - empty
|
||||
{0x00, 0x00, 0x00}, // 150 - empty
|
||||
{0x00, 0x00, 0x00}, // 151 - empty
|
||||
{0x00, 0x00, 0x00}, // 152 - empty
|
||||
{0x00, 0x00, 0x00}, // 153 - empty
|
||||
{0x00, 0x00, 0x00}, // 154 - empty
|
||||
{0x00, 0x00, 0x00}, // 155 - empty
|
||||
{0x00, 0x00, 0x00}, // 156 - empty
|
||||
{0x00, 0x00, 0x00}, // 157 - empty
|
||||
{0x00, 0x00, 0x00}, // 158 - empty
|
||||
{0x00, 0x00, 0x00}, // 159 - empty
|
||||
{0x00, 0x00, 0x00}, // 160 - empty
|
||||
{0x00, 0x1d, 0x00}, // 161 - exclamdown
|
||||
{0x0e, 0x1b, 0x0a}, // 162 - cent
|
||||
{0x14, 0x1f, 0x15}, // 163 - sterling
|
||||
{0x15, 0x0e, 0x15}, // 164 - currency
|
||||
{0x0b, 0x1c, 0x0b}, // 165 - yen
|
||||
{0x00, 0x1b, 0x00}, // 166 - brokenbar
|
||||
{0x14, 0x1b, 0x05}, // 167 - section
|
||||
{0x01, 0x00, 0x01}, // 168 - dieresis
|
||||
{0x02, 0x05, 0x05}, // 169 - copyright
|
||||
{0x16, 0x15, 0x17}, // 170 - ordfeminine
|
||||
{0x02, 0x05, 0x00}, // 171 - guillemotleft
|
||||
{0x02, 0x02, 0x06}, // 172 - logicalnot
|
||||
{0x04, 0x04, 0x00}, // 173 - softhyphen
|
||||
{0x07, 0x03, 0x04}, // 174 - registered
|
||||
{0x01, 0x01, 0x01}, // 175 - macron
|
||||
{0x02, 0x05, 0x02}, // 176 - degree
|
||||
{0x12, 0x17, 0x12}, // 177 - plusminus
|
||||
{0x01, 0x07, 0x04}, // 178 - twosuperior
|
||||
{0x05, 0x07, 0x07}, // 179 - threesuperior
|
||||
{0x00, 0x02, 0x01}, // 180 - acute
|
||||
{0x1f, 0x08, 0x07}, // 181 - mu
|
||||
{0x02, 0x1d, 0x1f}, // 182 - paragraph
|
||||
{0x0e, 0x0e, 0x0e}, // 183 - periodcentered
|
||||
{0x10, 0x14, 0x08}, // 184 - cedilla
|
||||
{0x00, 0x07, 0x00}, // 185 - onesuperior
|
||||
{0x12, 0x15, 0x12}, // 186 - ordmasculine
|
||||
{0x00, 0x05, 0x02}, // 187 - guillemotright
|
||||
{0x03, 0x08, 0x18}, // 188 - onequarter
|
||||
{0x0b, 0x18, 0x10}, // 189 - onehalf
|
||||
{0x03, 0x0b, 0x18}, // 190 - threequarters
|
||||
{0x18, 0x15, 0x10}, // 191 - questiondown
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
const uint8_t gFontSmall[95][6] =
|
||||
{
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // ' '
|
||||
|
1
font.h
1
font.h
@ -23,6 +23,7 @@
|
||||
extern const uint8_t gFontBig[95][15];
|
||||
extern const uint8_t gFontBigDigits[11][26];
|
||||
//extern const uint8_t gFontSmallDigits[11][7];
|
||||
extern const uint8_t gFont3x5[160][3];
|
||||
extern const uint8_t gFontSmall[95][6];
|
||||
#ifdef ENABLE_SMALL_BOLD
|
||||
extern const uint8_t gFontSmallBold[95][6];
|
||||
|
@ -11,6 +11,6 @@
|
||||
const char Version[] = "OEFW-"VER;
|
||||
const char UART_Version[] = "UV-K5 Firmware, Open Edition, OEFW-"VER"\r\n";
|
||||
#else
|
||||
const char Version[] = "1o11-"VER;
|
||||
const char UART_Version[] = "UV-K5 Firmware, Open Edition, 1o11-"VER"\r\n";
|
||||
const char Version[] = "1o11+fagci-"VER;
|
||||
const char UART_Version[] = "UV-K5 Firmware, Open Edition, 1o11+fagci-"VER"\r\n";
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user