2015-12-01 21:30:52 -08:00
/*
* Copyright ( C ) 2014 Jared Boone , ShareBrained Technology , Inc .
2018-05-21 18:46:48 +01:00
* Copyright ( C ) 2018 Furrtek
2015-12-01 21:30:52 -08:00
*
* This file is part of PortaPack .
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 , or ( at your option )
* any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; see the file COPYING . If not , write to
* the Free Software Foundation , Inc . , 51 Franklin Street ,
* Boston , MA 02110 - 1301 , USA .
*/
2015-12-08 15:28:33 -08:00
# ifndef __ANALOG_AUDIO_APP_H__
# define __ANALOG_AUDIO_APP_H__
2015-12-01 21:30:52 -08:00
# include "receiver_model.hpp"
2016-01-31 09:13:44 -08:00
# include "ui_receiver.hpp"
2023-06-18 12:11:04 -07:00
# include "ui_freq_field.hpp"
2015-12-01 21:30:52 -08:00
# include "ui_spectrum.hpp"
2016-04-30 13:56:54 -07:00
# include "ui_record_view.hpp"
2022-04-15 08:43:44 -04:00
# include "app_settings.hpp"
2023-06-14 00:57:20 -07:00
# include "radio_state.hpp"
2017-11-28 08:52:04 +01:00
# include "tone_key.hpp"
2015-12-01 21:30:52 -08:00
namespace ui {
2025-03-23 23:08:12 +01:00
class AnalogAudioView ;
2016-02-02 13:42:00 -08:00
class AMOptionsView : public View {
2023-05-19 08:16:05 +12:00
public :
2025-03-23 23:08:12 +01:00
AMOptionsView ( AnalogAudioView * view , Rect parent_rect , const Style * style ) ;
2023-05-19 08:16:05 +12:00
private :
Text label_config {
{ 0 * 8 , 0 * 16 , 2 * 8 , 1 * 16 } ,
" BW " ,
} ;
OptionsField options_config {
{ 3 * 8 , 0 * 16 } ,
2023-07-24 09:09:22 -07:00
6 , // Max option length
2023-05-19 08:16:05 +12:00
{
2023-07-24 09:09:22 -07:00
// Using common messages from freqman_ui.cpp
2023-05-19 08:16:05 +12:00
} } ;
2025-03-23 23:08:12 +01:00
OptionsField zoom_config {
{ 23 * 8 , 0 * 16 } ,
7 ,
{ { " ZOOM x1 " , 0 } ,
2025-04-04 14:04:06 +02:00
{ " ZOOM x2 " , 6 } } // offset index AM modes array FIR filters.
2025-03-23 23:08:12 +01:00
} ;
2016-02-02 13:42:00 -08:00
} ;
2025-03-05 04:27:18 +01:00
class AMFMAptOptionsView : public View {
public :
2025-03-23 23:08:12 +01:00
AMFMAptOptionsView ( AnalogAudioView * view , Rect parent_rect , const Style * style ) ;
2025-03-05 04:27:18 +01:00
private :
Text label_config {
{ 0 * 8 , 0 * 16 , 2 * 8 , 1 * 16 } ,
" BW " ,
} ;
OptionsField options_config {
{ 3 * 8 , 0 * 16 } ,
2025-03-23 23:08:12 +01:00
6 , // Max option length chars
2025-03-05 04:27:18 +01:00
{
// Using common messages from freqman_ui.cpp In HF USB , Here we only need USB Audio demod, + post-FM demod fsubcarrier FM tone to get APT signal.
} } ;
2025-03-23 23:08:12 +01:00
OptionsField zoom_config {
{ 23 * 8 , 0 * 16 } ,
7 ,
{ { " ZOOM x1 " , 0 } ,
{ " ZOOM x2 " , 6 } } // offset index array filters.
} ;
2025-03-05 04:27:18 +01:00
} ;
2016-02-02 13:42:00 -08:00
class NBFMOptionsView : public View {
2023-05-19 08:16:05 +12:00
public :
2023-06-18 22:48:29 -07:00
NBFMOptionsView ( Rect parent_rect , const Style * style ) ;
2023-05-19 08:16:05 +12:00
private :
Text label_config {
{ 0 * 8 , 0 * 16 , 2 * 8 , 1 * 16 } ,
" BW " ,
} ;
OptionsField options_config {
{ 3 * 8 , 0 * 16 } ,
2023-07-24 09:09:22 -07:00
3 , // Max option length
2023-05-19 08:16:05 +12:00
{
2023-07-24 09:09:22 -07:00
// Using common messages from freqman_ui.cpp
2023-05-19 08:16:05 +12:00
} } ;
Text text_squelch {
2023-07-02 18:53:51 -05:00
{ 7 * 8 , 0 * 16 , 8 * 8 , 1 * 16 } ,
2023-05-19 08:16:05 +12:00
" SQ /99 " } ;
NumberField field_squelch {
2023-07-02 18:53:51 -05:00
{ 10 * 8 , 0 * 16 } ,
2023-05-19 08:16:05 +12:00
2 ,
{ 0 , 99 } ,
1 ,
' ' ,
} ;
2016-02-02 13:42:00 -08:00
} ;
2023-05-07 16:08:45 +02:00
class WFMOptionsView : public View {
2023-05-19 08:16:05 +12:00
public :
2023-06-18 22:48:29 -07:00
WFMOptionsView ( Rect parent_rect , const Style * style ) ;
2023-05-19 08:16:05 +12:00
private :
Text label_config {
{ 0 * 8 , 0 * 16 , 2 * 8 , 1 * 16 } ,
" BW " ,
} ;
OptionsField options_config {
{ 3 * 8 , 0 * 16 } ,
2023-07-24 09:09:22 -07:00
4 , // Max option length
2023-05-19 08:16:05 +12:00
{
2023-07-24 09:09:22 -07:00
// Using common messages from freqman_ui.cpp
2023-05-19 08:16:05 +12:00
} } ;
2023-05-07 16:08:45 +02:00
} ;
2020-07-31 13:47:40 +03:00
class SPECOptionsView : public View {
2023-05-19 08:16:05 +12:00
public :
2023-06-18 22:48:29 -07:00
SPECOptionsView ( AnalogAudioView * view , Rect parent_rect , const Style * style ) ;
2023-05-19 08:16:05 +12:00
private :
Text label_config {
{ 0 * 8 , 0 * 16 , 2 * 8 , 1 * 16 } ,
" BW " ,
} ;
OptionsField options_config {
{ 3 * 8 , 0 * 16 } ,
4 ,
{
{ " 20m " , 20000000 } ,
{ " 10m " , 10000000 } ,
{ " 5m " , 5000000 } ,
{ " 2m " , 2000000 } ,
{ " 1m " , 1000000 } ,
{ " 500k " , 500000 } ,
{ " 100k " , 100000 } ,
} } ;
Text text_speed {
{ 9 * 8 , 0 * 16 , 8 * 8 , 1 * 16 } ,
" SP /63 " } ;
NumberField field_speed {
{ 12 * 8 , 0 * 16 } ,
2 ,
{ 0 , 63 } ,
1 ,
' ' ,
} ;
2024-03-09 23:46:38 +01:00
Text text_rx_cal {
{ 19 * 8 , 0 * 16 , 11 * 8 , 1 * 16 } , // 18 (x col.) x char_size, 12 (length) x 8 blanking space to delete previous chars.
" Rx_IQ_CAL " } ;
2024-03-09 17:36:48 -06:00
NumberField field_rx_iq_phase_cal {
2024-03-09 23:46:38 +01:00
{ 28 * 8 , 0 * 16 } ,
2 ,
2024-03-09 17:36:48 -06:00
{ 0 , 63 } , // 5 or 6 bits IQ CAL phase adjustment (range updated later)
2024-03-09 23:46:38 +01:00
1 ,
' ' ,
} ;
2020-07-31 13:47:40 +03:00
} ;
2016-01-31 09:13:44 -08:00
class AnalogAudioView : public View {
2023-05-19 08:16:05 +12:00
public :
AnalogAudioView ( NavigationView & nav ) ;
2023-07-04 16:26:26 -07:00
AnalogAudioView ( NavigationView & nav , ReceiverModel : : settings_t override ) ;
2023-05-19 08:16:05 +12:00
~ AnalogAudioView ( ) ;
2023-06-18 22:48:29 -07:00
void set_parent_rect ( Rect new_parent_rect ) override ;
2023-05-19 08:16:05 +12:00
void focus ( ) override ;
std : : string title ( ) const override { return " Audio RX " ; } ;
size_t get_spec_bw_index ( ) ;
void set_spec_bw ( size_t index , uint32_t bw ) ;
uint16_t get_spec_trigger ( ) ;
void set_spec_trigger ( uint16_t trigger ) ;
2024-03-09 23:46:38 +01:00
uint8_t get_spec_iq_phase_calibration_value ( ) ;
void set_spec_iq_phase_calibration_value ( uint8_t cal_value ) ;
2025-03-23 23:08:12 +01:00
uint8_t get_zoom_factor ( uint8_t mode ) ;
void set_zoom_factor ( uint8_t mode , uint8_t zoom ) ;
2025-04-04 15:43:26 +02:00
uint8_t get_previous_AM_mode_option ( ) ;
void set_previous_AM_mode_option ( uint8_t mode ) ;
uint8_t get_previous_zoom_option ( ) ;
void set_previous_zoom_option ( uint8_t zoom ) ;
2023-05-19 08:16:05 +12:00
private :
static constexpr ui : : Dim header_height = 3 * 16 ;
2023-06-18 12:11:04 -07:00
NavigationView & nav_ ;
2023-06-14 00:57:20 -07:00
RxRadioState radio_state_ { } ;
2024-03-09 23:46:38 +01:00
uint8_t iq_phase_calibration_value { 15 } ; // initial default RX IQ phase calibration value , used for both max2837 & max2839
2025-03-23 23:08:12 +01:00
uint8_t zoom_factor_am { 0 } ; // initial zoom factor in AM mode
uint8_t zoom_factor_amfm { 0 } ; // initial zoom factor in AMFM mode
2025-04-04 15:43:26 +02:00
uint8_t previous_AM_mode_option { 0 } ; // GUI 5 AM modes : (0..4 ) (DSB9K, DSB6K, USB,LSB, CW). Used to select proper FIR filter (0..11) AM mode + offset 0 (zoom+1) or +6 (if zoom+2)
uint8_t previous_zoom { 0 } ; // GUI ZOOM+1, ZOOM+2 , equivalent to two values offset 0 (zoom+1) or +6 (if zoom+2)
//
2023-06-11 11:47:13 -07:00
app_settings : : SettingsManager settings_ {
2024-03-09 23:46:38 +01:00
" rx_audio " ,
app_settings : : Mode : : RX ,
{
{ " iq_phase_calibration " sv , & iq_phase_calibration_value } , // we are saving and restoring that CAL from Settings.
2025-03-23 23:08:12 +01:00
{ " zoom_factor_am " sv , & zoom_factor_am } , // we are saving and restoring AM ZOOM factor from Settings.
{ " zoom_factor_amfm " sv , & zoom_factor_amfm } , // we are saving and restoring AMFM ZOOM factor from Settings.
2025-04-04 15:43:26 +02:00
{ " previous_AM_mode_option " sv , & previous_AM_mode_option } , // we are saving and restoring AMFM ZOOM factor from Settings.
{ " previous_zoom " sv , & previous_zoom } , // we are saving and restoring AMFM ZOOM factor from Settings.
2024-03-09 23:46:38 +01:00
} } ;
2023-05-19 08:16:05 +12:00
const Rect options_view_rect { 0 * 8 , 1 * 16 , 30 * 8 , 1 * 16 } ;
const Rect nbfm_view_rect { 0 * 8 , 1 * 16 , 18 * 8 , 1 * 16 } ;
size_t spec_bw_index = 0 ;
uint32_t spec_bw = 20000000 ;
uint16_t spec_trigger = 63 ;
RSSI rssi {
2023-06-18 12:11:04 -07:00
{ 21 * 8 , 0 , 6 * 8 , 4 } } ;
2023-05-19 08:16:05 +12:00
Channel channel {
2023-06-18 12:11:04 -07:00
{ 21 * 8 , 5 , 6 * 8 , 4 } } ;
2023-05-19 08:16:05 +12:00
Audio audio {
2023-06-18 12:11:04 -07:00
{ 21 * 8 , 10 , 6 * 8 , 4 } } ;
2023-05-19 08:16:05 +12:00
2023-06-18 12:11:04 -07:00
RxFrequencyField field_frequency {
2023-05-19 08:16:05 +12:00
{ 5 * 8 , 0 * 16 } ,
2023-06-18 12:11:04 -07:00
nav_ } ;
2023-05-19 08:16:05 +12:00
LNAGainField field_lna {
{ 15 * 8 , 0 * 16 } } ;
VGAGainField field_vga {
{ 18 * 8 , 0 * 16 } } ;
OptionsField options_modulation {
{ 0 * 8 , 0 * 16 } ,
4 ,
2025-03-07 17:28:11 +01:00
{
{ " AM " , toUType ( ReceiverModel : : Mode : : AMAudio ) } ,
{ " NFM " , toUType ( ReceiverModel : : Mode : : NarrowbandFMAudio ) } ,
{ " WFM " , toUType ( ReceiverModel : : Mode : : WidebandFMAudio ) } ,
{ " SPEC " , toUType ( ReceiverModel : : Mode : : SpectrumAnalysis ) } ,
{ " AMFM " , toUType ( ReceiverModel : : Mode : : AMAudioFMApt ) } // Added to handle HF WeatherFax , SSB (USB demod) + Tone_Subcarrier FM demod
} } ;
2023-05-19 08:16:05 +12:00
2023-06-04 12:56:46 -07:00
AudioVolumeField field_volume {
{ 28 * 8 , 0 * 16 } } ;
2023-05-19 08:16:05 +12:00
Text text_ctcss {
2023-07-02 18:53:51 -05:00
{ 16 * 8 , 1 * 16 , 14 * 8 , 1 * 16 } ,
2023-05-19 08:16:05 +12:00
" " } ;
std : : unique_ptr < Widget > options_widget { } ;
RecordView record_view {
{ 0 * 8 , 2 * 16 , 30 * 8 , 1 * 16 } ,
u " AUD " ,
u " AUDIO " ,
RecordView : : FileType : : WAV ,
4096 ,
4 } ;
2023-06-29 22:34:19 -07:00
spectrum : : WaterfallView waterfall { true } ;
2023-05-19 08:16:05 +12:00
void on_baseband_bandwidth_changed ( uint32_t bandwidth_hz ) ;
2023-06-18 22:48:29 -07:00
void on_modulation_changed ( ReceiverModel : : Mode modulation ) ;
2023-05-19 08:16:05 +12:00
void on_show_options_frequency ( ) ;
void on_show_options_rf_gain ( ) ;
void on_show_options_modulation ( ) ;
void on_frequency_step_changed ( rf : : Frequency f ) ;
void on_reference_ppm_correction_changed ( int32_t v ) ;
void remove_options_widget ( ) ;
void set_options_widget ( std : : unique_ptr < Widget > new_widget ) ;
2023-06-18 22:48:29 -07:00
void update_modulation ( ReceiverModel : : Mode modulation ) ;
2023-05-19 08:16:05 +12:00
2023-06-18 22:48:29 -07:00
void handle_coded_squelch ( uint32_t value ) ;
2023-05-19 08:16:05 +12:00
2024-09-04 20:26:31 +02:00
void on_freqchg ( int64_t freq ) ;
2023-05-19 08:16:05 +12:00
MessageHandlerRegistration message_handler_coded_squelch {
Message : : ID : : CodedSquelch ,
2023-06-18 22:48:29 -07:00
[ this ] ( const Message * p ) {
2023-05-19 08:16:05 +12:00
const auto message = * reinterpret_cast < const CodedSquelchMessage * > ( p ) ;
this - > handle_coded_squelch ( message . value ) ;
} } ;
2024-09-04 20:26:31 +02:00
MessageHandlerRegistration message_handler_freqchg {
Message : : ID : : FreqChangeCommand ,
[ this ] ( Message * const p ) {
const auto message = static_cast < const FreqChangeCommandMessage * > ( p ) ;
this - > on_freqchg ( message - > freq ) ;
} } ;
2015-12-01 21:30:52 -08:00
} ;
} /* namespace ui */
2023-05-19 08:16:05 +12:00
# endif /*__ANALOG_AUDIO_APP_H__*/