rewind sweep again when frequency updated

This commit is contained in:
TT 2017-01-02 15:45:25 +09:00
parent fd38f249ce
commit 6a704c8588
2 changed files with 22 additions and 8 deletions

13
main.c
View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014-2015, TAKAHASHI Tomohiro (TTRFTECH) edy555@gmail.com * Copyright (c) 2016-2017, TAKAHASHI Tomohiro (TTRFTECH) edy555@gmail.com
* All rights reserved. * All rights reserved.
* *
* This is free software; you can redistribute it and/or modify * This is free software; you can redistribute it and/or modify
@ -39,7 +39,7 @@ static MUTEX_DECL(mutex);
int32_t frequency_offset = 5000; int32_t frequency_offset = 5000;
int32_t frequency = 10000000; int32_t frequency = 10000000;
uint8_t drive_strength = SI5351_CLK_DRIVE_STRENGTH_2MA; uint8_t drive_strength = SI5351_CLK_DRIVE_STRENGTH_2MA;
int8_t frequency_updated = FALSE;
static THD_WORKING_AREA(waThread1, 440); static THD_WORKING_AREA(waThread1, 440);
static THD_FUNCTION(Thread1, arg) static THD_FUNCTION(Thread1, arg)
@ -376,11 +376,15 @@ void scan_lcd(void)
int delay; int delay;
//int first = TRUE; //int first = TRUE;
rewind:
frequency_updated = FALSE;
delay = set_frequency(frequencies[0]); delay = set_frequency(frequencies[0]);
delay += 2; delay += 2;
for (i = 0; i < sweep_points; i++) { for (i = 0; i < sweep_points; i++) {
tlv320aic3204_select_in3(); tlv320aic3204_select_in3();
wait_dsp(delay+2); wait_dsp(delay+2);
// blink LED while scanning
palClearPad(GPIOC, GPIOC_LED); palClearPad(GPIOC, GPIOC_LED);
/* calculate reflection coeficient */ /* calculate reflection coeficient */
@ -393,8 +397,12 @@ void scan_lcd(void)
calculate_gamma(measured[1][i]); calculate_gamma(measured[1][i]);
delay = set_frequency(frequencies[(i+1)%sweep_points]); delay = set_frequency(frequencies[(i+1)%sweep_points]);
// blink LED while scanning
palSetPad(GPIOC, GPIOC_LED); palSetPad(GPIOC, GPIOC_LED);
ui_process(); ui_process();
if (frequency_updated)
goto rewind;
} }
if (cal_status & CALSTAT_APPLY) if (cal_status & CALSTAT_APPLY)
@ -435,6 +443,7 @@ update_frequencies(void)
for (i = 0; i < sweep_points; i++) for (i = 0; i < sweep_points; i++)
frequencies[i] = start + span * i / (sweep_points - 1) * 100; frequencies[i] = start + span * i / (sweep_points - 1) * 100;
frequency_updated = TRUE;
// set grid layout // set grid layout
update_grid(); update_grid();
} }

17
ui.c
View file

@ -69,7 +69,7 @@ enum {
uint8_t ui_mode = UI_NORMAL; uint8_t ui_mode = UI_NORMAL;
uint8_t keypad_mode; uint8_t keypad_mode;
uint8_t selection = 0; int8_t selection = 0;
typedef struct { typedef struct {
uint8_t type; uint8_t type;
@ -471,14 +471,16 @@ static void
menu_stimulus_cb(int item) menu_stimulus_cb(int item)
{ {
switch (item) { switch (item) {
case 0: case 0: /* START */
case 1: case 1: /* STOP */
case 2: case 2: /* CENTER */
case 3: case 3: /* SPAN */
case 4: case 4: /* CW */
ui_mode_keypad(item); ui_mode_keypad(item);
ui_process_keypad(); ui_process_keypad();
break; break;
case 5: /* pause && resume */
break;
} }
} }
@ -583,6 +585,7 @@ const menuitem_t menu_stimulus[] = {
{ MT_CALLBACK, "CENTER", menu_stimulus_cb }, { MT_CALLBACK, "CENTER", menu_stimulus_cb },
{ MT_CALLBACK, "SPAN", menu_stimulus_cb }, { MT_CALLBACK, "SPAN", menu_stimulus_cb },
{ MT_CALLBACK, "CW", menu_stimulus_cb }, { MT_CALLBACK, "CW", menu_stimulus_cb },
{ MT_CALLBACK, "PAUSE", menu_stimulus_cb },
{ MT_CANCEL, "BACK", NULL }, { MT_CANCEL, "BACK", NULL },
{ MT_NONE, NULL, NULL } // sentinel { MT_NONE, NULL, NULL } // sentinel
}; };
@ -855,6 +858,7 @@ ui_mode_menu(void)
return; return;
ui_mode = UI_MENU; ui_mode = UI_MENU;
/* narrowen plotting area */
area_width = WIDTH - (64-14-4); area_width = WIDTH - (64-14-4);
area_height = HEIGHT; area_height = HEIGHT;
ensure_selection(); ensure_selection();
@ -1090,6 +1094,7 @@ void ui_process_touch(void)
switch (ui_mode) { switch (ui_mode) {
case UI_NORMAL: case UI_NORMAL:
touch_wait_release(); touch_wait_release();
selection = -1;
ui_mode_menu(); ui_mode_menu();
break; break;