forked from nanovna-v2/NanoVNA2-firmware
-
Notifications
You must be signed in to change notification settings - Fork 3
/
globals.hpp
81 lines (58 loc) · 2.17 KB
/
globals.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#pragma once
#include <stdint.h>
#include "common.hpp"
#include "board.hpp"
// global variables, to be defined in globals.cpp that can be accessed by all modules.
// DO NOT ADD STATEFUL FUNCTIONS HERE.
// think thrice before adding anything here.
// TODO(gabu-chan): eliminate these variables, make each module provide hooks
// for events that can be acted upon rather than let modules directly
// modify global state.
constexpr int registerSize = 256;
constexpr int registersSizeMask = registerSize - 1;
extern uint8_t registers[registerSize];
extern uint16_t redraw_request;
extern volatile bool sweep_enabled;
extern int16_t vbat;
extern int16_t lastsaveid;
extern properties_t current_props;
#define MARKER_INVALID -1
extern int8_t previous_marker;
extern config_t config;
// measured frequency domain data
extern complexf measuredFreqDomain[2][SWEEP_POINTS_MAX];
// measured data, possibly transformed
extern complexf measured[2][SWEEP_POINTS_MAX];
enum EcalStates {
ECAL_STATE_MEASURING,
ECAL_STATE_2NDSWEEP,
ECAL_STATE_DONE
};
extern volatile EcalStates ecalState;
extern uistat_t uistat;
#define frequency0 current_props._frequency0
#define frequency1 current_props._frequency1
#define sweep_points current_props._sweep_points
#define cal_status current_props._cal_status
#define frequencies current_props._frequencies
#define cal_data current_props._cal_data
#define electrical_delay current_props._electrical_delay
#define trace current_props._trace
#define markers current_props._markers
#define active_marker current_props._active_marker
#define domain_mode current_props._domain_mode
#define velocity_factor current_props._velocity_factor
#define marker_smith_format current_props._marker_smith_format
extern volatile int MEASUREMENT_NPERIODS_NORMAL;
extern volatile int MEASUREMENT_NPERIODS_CALIBRATING;
extern volatile int MEASUREMENT_ECAL_INTERVAL;
extern volatile int MEASUREMENT_NWAIT_SWITCH;
static inline float get_trace_refpos(int t) {
return trace[t].refpos;
}
static inline float get_trace_scale(int t) {
return trace[t].scale * trace_info[trace[t].type].scale_unit;
}
static inline const char* get_trace_typename(int t) {
return trace_info[trace[t].type].name;
}