Move bandwidth option from properties to config

Little fixes
This commit is contained in:
DiSlord 2020-04-02 16:36:59 +03:00
parent 30ff60a3de
commit e09ee19646
4 changed files with 19 additions and 17 deletions

4
dsp.c
View file

@ -26,6 +26,7 @@ int16_t samp_buf[SAMPLE_LEN];
int16_t ref_buf[SAMPLE_LEN];
#endif
#if 1
const int16_t sincos_tbl[48][2] = {
{ 10533, 31029 }, { 27246, 18205 }, { 32698, -2143 }, { 24636, -21605 },
{ 6393, -32138 }, {-14493, -29389 }, {-29389, -14493 }, {-32138, 6393 },
@ -40,7 +41,8 @@ const int16_t sincos_tbl[48][2] = {
{ 32138, 6393 }, { 29389, -14493 }, { 14493, -29389 }, { -6393, -32138 },
{-24636, -21605 }, {-32698, -2143 }, {-27246, 18205 }, {-10533, 31029 }
};
#if 0
#else
int16_t sincos_tbl[AUDIO_SAMPLES_COUNT][2];
void generate_DSP_Table(int offset){
float audio_freq = AUDIO_ADC_FREQ;
// N = offset * AUDIO_SAMPLES_COUNT / audio_freq; should be integer

21
main.c
View file

@ -707,7 +707,8 @@ config_t config = {
// .touch_cal = { 252, 450, 111, 150 }, //4.0" LCD
.freq_mode = FREQ_MODE_START_STOP,
.harmonic_freq_threshold = 300000000,
.vbat_offset = 500
.vbat_offset = 500,
.bandwidth = BANDWIDTH_1000
};
properties_t current_props;
@ -745,7 +746,6 @@ void load_default_properties(void)
current_props._active_marker = 0;
current_props._domain_mode = 0;
current_props._marker_smith_format = MS_RLC;
current_props._bandwidth = BANDWIDTH_1000;
//Checksum add on caldata_save
//current_props.checksum = 0;
}
@ -787,8 +787,8 @@ void i2s_end_callback(I2SDriver *i2sp, size_t offset, size_t n)
int16_t *p = &rx_buffer[offset];
(void)i2sp;
if (wait_count > 0){
if (wait_count <= bandwidth+1){
if (wait_count == bandwidth+1)
if (wait_count <= config.bandwidth+1){
if (wait_count == config.bandwidth+1)
reset_dsp_accumerator();
dsp_process(p, n);
}
@ -810,7 +810,7 @@ static const I2SConfig i2sconfig = {
0 // i2spr
};
#define DSP_START(delay) {wait_count = delay + bandwidth;}
#define DSP_START(delay) {wait_count = delay + config.bandwidth;}
#define DSP_WAIT_READY while (wait_count) {if (operation_requested && break_on_operation) return false; __WFI();}
#define DSP_WAIT while (wait_count) {__WFI();}
#define RESET_SWEEP {p_sweep = 0;}
@ -862,9 +862,9 @@ VNA_SHELL_FUNCTION(cmd_bandwidth)
{
if (argc != 1)
goto result;
bandwidth = my_atoui(argv[0]);
config.bandwidth = my_atoui(argv[0]);
result:
shell_printf("bandwidth %d (%dHz)\r\n", bandwidth, (AUDIO_ADC_FREQ/AUDIO_SAMPLES_COUNT)/(bandwidth+1));
shell_printf("bandwidth %d (%dHz)\r\n", config.bandwidth, (AUDIO_ADC_FREQ/AUDIO_SAMPLES_COUNT)/(config.bandwidth+1));
}
VNA_SHELL_FUNCTION(cmd_scan)
@ -1322,11 +1322,11 @@ cal_collect(int type)
return;
}
// Run sweep for collect data (use minimum BANDWIDTH_100, or bigger if set)
uint8_t bw = bandwidth; // store current setting
uint8_t bw = config.bandwidth; // store current setting
if (bw < BANDWIDTH_100)
bandwidth = BANDWIDTH_100;
config.bandwidth = BANDWIDTH_100;
sweep(false);
bandwidth = bw; // restore
config.bandwidth = bw; // restore
// Copy calibration data
memcpy(cal_data[dst], measured[src], sizeof measured[0]);
redraw_request |= REDRAW_CAL_STATUS;
@ -2085,6 +2085,7 @@ VNA_SHELL_FUNCTION(cmd_color)
#ifdef ENABLE_I2C_COMMAND
VNA_SHELL_FUNCTION(cmd_i2c){
(void)argc;
uint8_t page = my_atoui(argv[0]);
uint8_t reg = my_atoui(argv[1]);
uint8_t data = my_atoui(argv[2]);

View file

@ -244,7 +244,8 @@ typedef struct config {
int8_t freq_mode;
uint32_t harmonic_freq_threshold;
uint16_t vbat_offset;
uint8_t _reserved[22];
uint8_t bandwidth;
uint8_t _reserved[21];
uint32_t checksum;
} config_t;
@ -393,8 +394,7 @@ typedef struct properties {
int8_t _active_marker;
uint8_t _domain_mode; /* 0bxxxxxffm : where ff: TD_FUNC m: DOMAIN_MODE */
uint8_t _marker_smith_format;
uint8_t _bandwidth;
uint8_t _reserved[50];
uint8_t _reserved[51];
uint32_t checksum;
} properties_t;
@ -420,7 +420,6 @@ extern properties_t current_props;
#define domain_mode current_props._domain_mode
#define velocity_factor current_props._velocity_factor
#define marker_smith_format current_props._marker_smith_format
#define bandwidth current_props._bandwidth
#define FREQ_IS_STARTSTOP() (!(config.freq_mode&FREQ_MODE_CENTER_SPAN))
#define FREQ_IS_CENTERSPAN() (config.freq_mode&FREQ_MODE_CENTER_SPAN)

4
ui.c
View file

@ -623,7 +623,7 @@ static void
menu_bandwidth_cb(int item, uint8_t data)
{
(void)item;
bandwidth = data;
config.bandwidth = data;
draw_menu();
}
@ -1377,7 +1377,7 @@ menu_item_modify_attribute(const menuitem_t *menu, int item,
*fg = config.menu_normal_color;
}
} else if (menu == menu_bandwidth) {
if (menu_bandwidth[item].data == bandwidth) {
if (menu_bandwidth[item].data == config.bandwidth) {
*bg = 0x0000;
*fg = 0xffff;
}