From f0eaa108ad349e5846d0b641e4a5ea753d771089 Mon Sep 17 00:00:00 2001 From: TT Date: Sat, 5 Nov 2016 03:37:11 +0900 Subject: [PATCH] save trace and marker data --- flash.c | 4 +--- main.c | 10 ++++++++++ nanovna.h | 17 ++++++++++++++--- plot.c | 6 ++++-- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/flash.c b/flash.c index 6c9d3ae..4ef99f9 100644 --- a/flash.c +++ b/flash.c @@ -111,10 +111,8 @@ caldata_recall(int id) if (checksum(src, sizeof(config_t)) != 0) return -1; -#if 0 memcpy(dst, src, sizeof(config_t)); -#else active = src; -#endif + return 0; } diff --git a/main.c b/main.c index 2f8e643..f3b0363 100644 --- a/main.c +++ b/main.c @@ -348,6 +348,16 @@ config_t current_config = { /* cal_status */ 0, /* frequencies */ {}, /* cal_data */ {}, + /* trace[4] */ { + { 1, TRC_LOGMAG, 0, 1.0, RGB565(0,255,255), 0 }, + { 1, TRC_LOGMAG, 1, 1.0, RGB565(255,0,40), 0 }, + { 1, TRC_SMITH, 0, 1.0, RGB565(0,0,255), 1 }, + { 1, TRC_PHASE, 1, 1.0, RGB565(50,255,0), 1 } + }, + /* markers[4] */ { + { 1, 30 }, { 0, 40 }, { 0, 60 }, { 0, 80 } + }, + /* active_marker */ 0, /* checksum */ 0 }; config_t *active = ¤t_config; diff --git a/nanovna.h b/nanovna.h index e06feda..f948b59 100644 --- a/nanovna.h +++ b/nanovna.h @@ -104,7 +104,8 @@ typedef struct { uint8_t polar; } trace_t; -extern trace_t trace[TRACES_MAX]; +//extern trace_t trace[TRACES_MAX]; + extern float measured[2][101][2]; void trace_get_info(int t, char *buf, int len); @@ -115,8 +116,8 @@ typedef struct { int index; } marker_t; -extern marker_t markers[4]; -extern int active_marker; +//extern marker_t markers[4]; +//extern int active_marker; #define CAL_LOAD 0 #define CAL_OPEN 1 @@ -168,6 +169,11 @@ typedef struct { uint32_t _frequencies[101]; float _cal_data[5][101][2]; + + trace_t _trace[TRACES_MAX]; + marker_t _markers[4]; + int _active_marker; + int32_t checksum; } config_t; @@ -183,6 +189,11 @@ extern config_t current_config; #define frequencies active->_frequencies #define cal_data active->_cal_data +#define trace current_config._trace +#define markers current_config._markers +#define active_marker current_config._active_marker + + int caldata_save(int id); int caldata_recall(int id); diff --git a/plot.c b/plot.c index 8c1a2e6..3bedc54 100644 --- a/plot.c +++ b/plot.c @@ -16,13 +16,14 @@ void markmap_all_markers(void); //#define GRID_COLOR 0x0863 uint16_t grid_color = 0x1084; +#if 0 trace_t trace[TRACES_MAX] = { { 1, TRC_LOGMAG, 0, 1.0, RGB565(0,255,255), 0 }, { 1, TRC_LOGMAG, 1, 1.0, RGB565(255,0,40), 0 }, { 1, TRC_SMITH, 0, 1.0, RGB565(0,0,255), 1 }, { 1, TRC_PHASE, 1, 1.0, RGB565(50,255,0), 1 } }; - +#endif #define CELLWIDTH 32 #define CELLHEIGHT 32 @@ -54,12 +55,13 @@ uint16_t markmap[2][8]; uint16_t current_mappage = 0; +#if 0 marker_t markers[4] = { { 1, 30 }, { 0, 40 }, { 0, 60 }, { 0, 80 } }; int active_marker = 0; - +#endif int32_t fstart = 0;