dimval 0.2.0
Modern C++23 header-only library of dimensional values (units, measures, ranges)
Loading...
Searching...
No Matches
rf.hpp
Go to the documentation of this file.
1#pragma once
2
6
7#include <dimval/define.hpp>
8
9// -----------------------------------------------------------------------------
10// Logarithmic ratio units
11// -----------------------------------------------------------------------------
12
13DIMVAL_DEFINE_UNIT(Decibel,
14 "dB",
15 "dB",
16 "dB",
17 "decibel",
18 "log_ratio",
19 1.0,
20 ::comms::Icons::mdi::chart_bell_curve,
21 ::comms::Colors::mui::green[400],
22 static constexpr ::std::string_view formatter = "decibel";
23 static constexpr int default_precision = 2;)
24
25// 1 Np = 20/ln(10) dB ≈ 8.685889638 dB. Same kind as Decibel.
27 "Np",
28 "Np",
29 "Np",
30 "neper",
31 "log_ratio",
32 8.685889638065035,
33 ::comms::Icons::mdi::chart_bell_curve,
34 ::comms::Colors::mui::green[500],
35 static constexpr int default_precision = 2;)
36
37DIMVAL_DEFINE_UNIT(DecibelMilliwatt,
38 "dBm",
39 "dBm",
40 "dBm",
41 "decibel-milliwatt",
42 "log_power",
43 1.0,
44 ::comms::Icons::mdi::signal,
45 ::comms::Colors::mui::green[400],
46 static constexpr ::std::string_view formatter = "decibel";
47 static constexpr int default_precision = 2;)
48
49DIMVAL_DEFINE_UNIT(DecibelWatt,
50 "dBW",
51 "dBW",
52 "dBW",
53 "decibel-watt",
54 "log_power",
55 1.0,
56 ::comms::Icons::mdi::signal,
57 ::comms::Colors::mui::green[400],
58 static constexpr double offset = 30.0; // dBW + 30 = dBm.
59 static constexpr ::std::string_view formatter = "decibel";
60 static constexpr int default_precision = 2;)
61
62DIMVAL_DEFINE_UNIT(DecibelMicrovolt,
63 "dBuV",
64 "dBµV",
65 "dBµV",
66 "decibel-microvolt",
67 "log_voltage",
68 1.0,
69 ::comms::Icons::mdi::signal,
70 ::comms::Colors::mui::green[400],
71 static constexpr ::std::string_view formatter = "decibel";
72 static constexpr int default_precision = 2;)
73
74DIMVAL_DEFINE_UNIT(DecibelMillivolt,
75 "dBmV",
76 "dBmV",
77 "dBmV",
78 "decibel-millivolt",
79 "log_voltage",
80 1.0,
81 ::comms::Icons::mdi::signal,
82 ::comms::Colors::mui::green[400],
83 static constexpr double offset = -60.0; // dBmV - 60 = dBµV.
84 static constexpr ::std::string_view formatter = "decibel";
85 static constexpr int default_precision = 2;)
86
87// -----------------------------------------------------------------------------
88// Phase angle alternates (canonical: PhaseRadian; same kind as Radian/Degree)
89// -----------------------------------------------------------------------------
90
91DIMVAL_DEFINE_UNIT(PhaseDegree,
92 "phase_deg",
93 "°",
94 "°",
95 "phase degree",
96 "angle",
97 0.017453292519943295,
98 ::comms::Icons::mdi::angle_acute,
99 ::comms::Colors::mui::deep_purple[400],
100 static constexpr ::std::string_view formatter = "degree";
101 static constexpr int default_precision = 2;
102 static constexpr bool no_space_before_symbol = true;)
103
104DIMVAL_DEFINE_UNIT(PhaseRadian,
105 "phase_rad",
106 "rad",
107 "rad",
108 "phase radian",
109 "angle",
110 1.0,
111 ::comms::Icons::mdi::angle_acute,
112 ::comms::Colors::mui::deep_purple[500],
113 static constexpr int default_precision = 4;)
114
115// -----------------------------------------------------------------------------
116// Sheet resistance
117// -----------------------------------------------------------------------------
118
119DIMVAL_DEFINE_UNIT(OhmSquare,
120 "ohm_sq",
121 "Ω/□",
122 "Ω/□",
123 "ohms per square",
124 "sheet_resistance",
125 1.0,
126 ::comms::Icons::mdi::grid,
127 ::comms::Colors::mui::brown[500])
128
129// -----------------------------------------------------------------------------
130// Spectral density / noise units
131// -----------------------------------------------------------------------------
132
133DIMVAL_DEFINE_UNIT(VoltPerRootHertz,
134 "v_per_sqrt_hz",
135 "V/√Hz",
136 "V/√Hz",
137 "volt per root hertz",
138 "voltage_noise_density",
139 1.0,
140 ::comms::Icons::mdi::chart_line,
141 ::comms::Colors::mui::cyan[400])
142
143DIMVAL_DEFINE_UNIT(AmperePerRootHertz,
144 "a_per_sqrt_hz",
145 "A/√Hz",
146 "A/√Hz",
147 "ampere per root hertz",
148 "current_noise_density",
149 1.0,
150 ::comms::Icons::mdi::chart_line,
151 ::comms::Colors::mui::cyan[500])
152
153DIMVAL_DEFINE_UNIT(WattPerHertz,
154 "w_per_hz",
155 "W/Hz",
156 "W/Hz",
157 "watt per hertz",
158 "power_spectral_density",
159 1.0,
160 ::comms::Icons::mdi::chart_line,
161 ::comms::Colors::mui::cyan[600])
162
163DIMVAL_DEFINE_UNIT(DecibelPerHertz,
164 "db_per_hz",
165 "dB/Hz",
166 "dB/Hz",
167 "decibel per hertz",
168 "noise_density_db",
169 1.0,
170 ::comms::Icons::mdi::chart_line,
171 ::comms::Colors::mui::cyan[700],
172 static constexpr int default_precision = 2;)
Macros that expand into a CRTP unit/measure struct and a runtime auto-registration for it.
#define DIMVAL_DEFINE_UNIT(Tag, Id, Symbol, ShortName, LongName, Kind, Factor, Icon, Color,...)
Define a unit struct in ::dimval and auto-register its descriptor at static-init time.
Definition define.hpp:72