save domain mode

This commit is contained in:
cho45 2019-09-10 23:49:08 +09:00
parent 889d675836
commit 95ab399567
4 changed files with 23 additions and 14 deletions

6
main.c
View file

@ -56,8 +56,6 @@ int8_t redraw_requested = FALSE;
int8_t stop_the_world = FALSE;
int16_t vbat = 0;
uint8_t domain = DOMAIN_TIME;
uint8_t tdrfunc = TDR_IMPULSE;
static THD_WORKING_AREA(waThread1, 640);
static THD_FUNCTION(Thread1, arg)
{
@ -116,7 +114,7 @@ static
void
transform_domain(void)
{
if (domain != DOMAIN_TIME) return; // nothing to do for freq domain
if ((domain_mode & DOMAIN_MODE) != DOMAIN_TIME) return; // nothing to do for freq domain
// use spi_buffer as temporary buffer
// and calculate ifft for time domain
float* tmp = (float*)spi_buffer;
@ -132,7 +130,7 @@ transform_domain(void)
measured[ch][i][0] /= 128.0;
measured[ch][i][1] /= 128.0;
}
if (tdrfunc == TDR_STEP) {
if ( (domain_mode & TDR_FUNC_STEP) == TDR_FUNC_STEP ) {
for (int i = 1; i < 101; i++) {
measured[ch][i][0] += measured[ch][i-1][0];
measured[ch][i][1] += measured[ch][i-1][1];

View file

@ -33,9 +33,6 @@ enum {
TDR_IMPULSE, TDR_STEP
};
extern uint8_t domain;
extern uint8_t tdrfunc;
#define CAL_LOAD 0
#define CAL_OPEN 1
#define CAL_SHORT 2
@ -61,6 +58,13 @@ extern uint8_t tdrfunc;
#define ETERM_ET 3 /* error term transmission tracking */
#define ETERM_EX 4 /* error term isolation */
#define DOMAIN_MODE (1<<0)
#define DOMAIN_FREQ (0<<0)
#define DOMAIN_TIME (1<<0)
#define TDR_FUNC (1<<1)
#define TDR_FUNC_IMPULSE (0<<1)
#define TDR_FUNC_STEP (1<<1)
void cal_collect(int type);
void cal_done(void);
@ -294,6 +298,7 @@ typedef struct {
trace_t _trace[TRACES_MAX];
marker_t _markers[4];
int _active_marker;
uint8_t _domain_mode;
int32_t checksum;
} properties_t;
@ -317,6 +322,7 @@ extern int8_t previous_marker;
#define trace current_props._trace
#define markers current_props._markers
#define active_marker current_props._active_marker
#define domain_mode current_props._domain_mode
int caldata_save(int id);
int caldata_recall(int id);

2
plot.c
View file

@ -1367,7 +1367,7 @@ cell_draw_marker_info(int m, int n, int w, int h)
chsnprintf(buf, sizeof buf, "%d:", active_marker + 1);
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff);
xpos += 16;
if (domain == DOMAIN_FREQ) {
if ((domain_mode & DOMAIN_MODE) == DOMAIN_FREQ) {
frequency_string(buf, sizeof buf, frequencies[idx]);
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff);
} else {

17
ui.c
View file

@ -669,13 +669,17 @@ menu_tdr_cb(int item)
{
switch (item) {
case 0:
domain = (domain == DOMAIN_FREQ) ? DOMAIN_TIME : DOMAIN_FREQ;
if ((domain_mode & DOMAIN_MODE) == DOMAIN_TIME) {
domain_mode = (domain_mode & ~DOMAIN_MODE) | DOMAIN_FREQ;
} else {
domain_mode = (domain_mode & ~DOMAIN_MODE) | DOMAIN_TIME;
}
break;
case 1:
tdrfunc = TDR_IMPULSE;
domain_mode = (domain_mode & ~TDR_FUNC) | TDR_FUNC_IMPULSE;
break;
case 2:
tdrfunc = TDR_STEP;
domain_mode = (domain_mode & ~TDR_FUNC) | TDR_FUNC_STEP;
break;
}
@ -1249,6 +1253,7 @@ menu_item_modify_attribute(const menuitem_t *menu, int item,
|| (item == 2 && (cal_status & CALSTAT_LOAD))
|| (item == 3 && (cal_status & CALSTAT_ISOLN))
|| (item == 4 && (cal_status & CALSTAT_THRU))) {
domain_mode = (domain_mode & ~DOMAIN_MODE) | DOMAIN_FREQ;
*bg = 0x0000;
*fg = 0xffff;
}
@ -1263,9 +1268,9 @@ menu_item_modify_attribute(const menuitem_t *menu, int item,
*fg = 0xffff;
}
} else if (menu == menu_tdr) {
if ((item == 0 && domain == DOMAIN_TIME)
|| (item == 1 && tdrfunc == TDR_IMPULSE)
|| (item == 2 && tdrfunc == TDR_STEP)
if ((item == 0 && (domain_mode & DOMAIN_MODE) == DOMAIN_TIME)
|| (item == 1 && (domain_mode & TDR_FUNC) == TDR_FUNC_IMPULSE)
|| (item == 2 && (domain_mode & TDR_FUNC) == TDR_FUNC_STEP)
) {
*bg = 0x0000;
*fg = 0xffff;