1 /* 2 * oscilloscope.cpp 3 * 4 * Created on: 26 Feb 2020 5 * Author: crocoduck 6 */ 7 8 #include <metadata/plugins.h> 9 #include <metadata/ports.h> 10 #include <metadata/developers.h> 11 12 namespace lsp 13 { 14 static const int osclilloscope_classes[] = { C_UTILITY, -1}; 15 16 static const port_item_t ovs_mode[] = 17 { 18 {"None", "oscilloscope.oversampler.none"}, 19 {"2X", "oscilloscope.oversampler.2x"}, 20 {"3X", "oscilloscope.oversampler.3x"}, 21 {"4X", "oscilloscope.oversampler.4x"}, 22 {"6X", "oscilloscope.oversampler.6x"}, 23 {"8X", "oscilloscope.oversampler.8x"}, 24 {NULL, NULL} 25 }; 26 27 static const port_item_t osc_mode[] = 28 { 29 {"XY", "oscilloscope.mode.xy"}, 30 {"Triggered", "oscilloscope.mode.triggered"}, 31 {"Goniometer", "oscilloscope.mode.goniometer"}, 32 {NULL, NULL} 33 }; 34 35 static const port_item_t osc_channels_x2[] = 36 { 37 {"1", NULL }, 38 {"2", NULL }, 39 {NULL, NULL} 40 }; 41 42 static const port_item_t osc_channels_x4[] = 43 { 44 {"1", NULL }, 45 {"2", NULL }, 46 {"3", NULL }, 47 {"4", NULL }, 48 {NULL, NULL} 49 }; 50 51 static const port_item_t sweep_type[] = 52 { 53 {"Sawtooth", "oscilloscope.sweeptype.sawtooth"}, 54 {"Triangular", "oscilloscope.sweeptype.triangular"}, 55 {"Sine", "oscilloscope.sweeptype.sine"}, 56 {NULL, NULL} 57 }; 58 59 static const port_item_t osc_trg_input[] = 60 { 61 {"Y", "oscilloscope.trigger.input.y"}, 62 {"EXT", "oscilloscope.trigger.input.ext"}, 63 {NULL, NULL} 64 }; 65 66 static const port_item_t osc_trg_mode[] = 67 { 68 {"Single", "oscilloscope.trigger.mode.single"}, 69 {"Manual", "oscilloscope.trigger.mode.manual"}, 70 {"Repeat", "oscilloscope.trigger.mode.repeat"}, 71 {NULL, NULL} 72 }; 73 74 static const port_item_t osc_trg_type[] = 75 { 76 {"None", "oscilloscope.trigger.type.none"}, 77 {"Simple Rising Edge", "oscilloscope.trigger.type.simple_rising_edge"}, 78 {"Simple Falling Edge", "oscilloscope.trigger.type.simple_falling_edge"}, 79 {"Advanced Rising Edge", "oscilloscope.trigger.type.advanced_rising_edge"}, 80 {"Advanced Falling Edge", "oscilloscope.trigger.type.advanced_falling_edge"}, 81 {NULL, NULL} 82 }; 83 84 static const port_item_t osc_coupling[] = 85 { 86 {"AC", "oscilloscope.coupling.ac"}, 87 {"DC", "oscilloscope.coupling.dc"}, 88 {NULL, NULL} 89 }; 90 91 #define CHANNEL_AUDIO_PORTS(id, label) \ 92 AUDIO_INPUT("in_x" id, "Input x" label), \ 93 AUDIO_INPUT("in_y" id, "Input y" label), \ 94 AUDIO_INPUT("in_ext" id, "Input external" label), \ 95 AUDIO_OUTPUT("out_x" id, "Output x" label), \ 96 AUDIO_OUTPUT("out_y" id, "Output y" label) 97 98 #define COMMON_CONTROLS \ 99 CONTROL("sh_sz", "Strobe History Size", U_NONE, oscilloscope_base_metadata::STROBE_HISTORY), \ 100 LOG_CONTROL("xyrt", "XY Record Time", U_MSEC, oscilloscope_base_metadata::XY_RECORD_TIME), \ 101 LOG_CONTROL("maxdots", "Maximum Dots for Plotting", U_NONE, oscilloscope_base_metadata::MAXDOTS), \ 102 SWITCH("freeze", "Global Freeze Switch", 0.0f) 103 104 #define CHANNEL_SELECTOR(osc_channels) \ 105 COMBO("osc_cs", "Oscilloscope Channel Selector", 0, osc_channels) 106 107 #define CHANNEL_SWITCHES(id, label) \ 108 SWITCH("glsw" id, "Global Switch" label, 0.0f), \ 109 SWITCH("frz" id, "Freeze Switch" label, 0.0f), \ 110 SWITCH("chsl" id, "Solo Switch" label, 0.0f), \ 111 SWITCH("chmt" id, "Mute Switch" label, 0.0f) 112 113 #define OP_CONTROLS(id, label) \ 114 COMBO("ovmo" id, "Oversampler Mode" label, oscilloscope_base_metadata::OSC_OVS_DFL, ovs_mode), \ 115 COMBO("scmo" id, "Mode" label, oscilloscope_base_metadata::MODE_DFL, osc_mode) 116 117 #define CP_CONTROLS(id, label) \ 118 COMBO("sccx" id, "Coupling X" label, oscilloscope_base_metadata::COUPLING_DFL, osc_coupling), \ 119 COMBO("sccy" id, "Coupling Y" label, oscilloscope_base_metadata::COUPLING_DFL, osc_coupling), \ 120 COMBO("scce" id, "Coupling EXT" label, oscilloscope_base_metadata::COUPLING_DFL, osc_coupling) 121 122 #define HOR_CONTROLS(id, label) \ 123 COMBO("swtp" id, "Sweep Type" label, oscilloscope_base_metadata::SWEEP_TYPE_DFL, sweep_type), \ 124 LOG_CONTROL("tmdv" id, "Time Division" label, U_MSEC, oscilloscope_base_metadata::TIME_DIVISION), \ 125 LOG_CONTROL("hzdv" id, "Horizontal Division" label, U_NONE, oscilloscope_base_metadata::HORIZONTAL_DIVISION), \ 126 CONTROL("hzps" id, "Horizontal Position" label, U_PERCENT, oscilloscope_base_metadata::TIME_POSITION) 127 128 #define VER_CONTROLS(id, label) \ 129 LOG_CONTROL("vedv" id, "Vertical Division" label, U_NONE, oscilloscope_base_metadata::VERTICAL_DIVISION), \ 130 CONTROL("veps" id, "Vertical Position" label, U_PERCENT, oscilloscope_base_metadata::VERTICAL_POSITION) 131 132 #define TRG_CONTROLS(id, label) \ 133 CONTROL("trhy" id, "Trigger Hysteresis" label, U_PERCENT, oscilloscope_base_metadata::TRIGGER_HYSTERESIS), \ 134 CONTROL("trlv" id, "Trigger Level" label, U_PERCENT, oscilloscope_base_metadata::TRIGGER_LEVEL), \ 135 LOG_CONTROL("trho" id, "Trigger Hold Time" label, U_SEC, oscilloscope_base_metadata::TRIGGER_HOLD_TIME), \ 136 COMBO("trmo" id, "Trigger Mode" label, oscilloscope_base_metadata::TRIGGER_MODE_DFL, osc_trg_mode), \ 137 COMBO("trtp" id, "Trigger Type" label, oscilloscope_base_metadata::TRIGGER_TYPE_DFL, osc_trg_type), \ 138 COMBO("trin" id, "Trigger Input" label, oscilloscope_base_metadata::TRIGGER_INPUT_DFL, osc_trg_input), \ 139 TRIGGER("trre" id, "Trigger Reset") 140 141 #define CHANNEL_CONTROLS(id, label) \ 142 OP_CONTROLS(id, label), \ 143 CP_CONTROLS(id, label), \ 144 HOR_CONTROLS(id, label), \ 145 VER_CONTROLS(id, label), \ 146 TRG_CONTROLS(id, label) 147 148 #define OSC_VISUALOUTS(id, label) \ 149 STREAM("oscv" id, "Stream buffer" label, 3, 128, 0x4000) 150 151 static const port_t oscilloscope_x1_ports[] = 152 { 153 CHANNEL_AUDIO_PORTS("_1", " 1"), 154 COMMON_CONTROLS, 155 CHANNEL_CONTROLS("_1", " 1"), 156 OSC_VISUALOUTS("_1", " 1"), 157 PORTS_END 158 }; 159 160 static const port_t oscilloscope_x2_ports[] = 161 { 162 CHANNEL_AUDIO_PORTS("_1", " 1"), 163 CHANNEL_AUDIO_PORTS("_2", " 2"), 164 165 COMMON_CONTROLS, 166 CHANNEL_SELECTOR(osc_channels_x2), 167 168 CHANNEL_CONTROLS("", " Global"), 169 CHANNEL_CONTROLS("_1", " 1"), 170 CHANNEL_CONTROLS("_2", " 2"), 171 172 CHANNEL_SWITCHES("_1", " 1"), 173 CHANNEL_SWITCHES("_2", " 2"), 174 175 OSC_VISUALOUTS("_1", " 1"), 176 OSC_VISUALOUTS("_2", " 2"), 177 178 PORTS_END 179 }; 180 181 static const port_t oscilloscope_x4_ports[] = 182 { 183 CHANNEL_AUDIO_PORTS("_1", " 1"), 184 CHANNEL_AUDIO_PORTS("_2", " 2"), 185 CHANNEL_AUDIO_PORTS("_3", " 3"), 186 CHANNEL_AUDIO_PORTS("_4", " 4"), 187 188 COMMON_CONTROLS, 189 CHANNEL_SELECTOR(osc_channels_x4), 190 191 CHANNEL_CONTROLS("", " Global"), 192 CHANNEL_CONTROLS("_1", " 1"), 193 CHANNEL_CONTROLS("_2", " 2"), 194 CHANNEL_CONTROLS("_3", " 3"), 195 CHANNEL_CONTROLS("_4", " 4"), 196 197 CHANNEL_SWITCHES("_1", " 1"), 198 CHANNEL_SWITCHES("_2", " 2"), 199 CHANNEL_SWITCHES("_3", " 3"), 200 CHANNEL_SWITCHES("_4", " 4"), 201 202 OSC_VISUALOUTS("_1", " 1"), 203 OSC_VISUALOUTS("_2", " 2"), 204 OSC_VISUALOUTS("_3", " 3"), 205 OSC_VISUALOUTS("_4", " 4"), 206 207 PORTS_END 208 }; 209 210 const plugin_metadata_t oscilloscope_x1_metadata::metadata = 211 { 212 "Oscilloscope x1", 213 "Oscilloscope x1", 214 "O1", // Oscilloscope x1 215 &developers::s_tronci, 216 "oscilloscope_x1", 217 "qbla", 218 LSP_OSCILLOSCOPE_BASE + 0, 219 LSP_VERSION(1, 0, 0), 220 osclilloscope_classes, 221 E_INLINE_DISPLAY | E_DUMP_STATE, 222 oscilloscope_x1_ports, 223 "util/oscilloscope/x1.xml", 224 NULL, 225 NULL 226 }; 227 228 const plugin_metadata_t oscilloscope_x2_metadata::metadata = 229 { 230 "Oscilloscope x2", 231 "Oscilloscope x2", 232 "O2", // Oscilloscope x2 233 &developers::s_tronci, 234 "oscilloscope_x2", 235 "ubsb", 236 LSP_OSCILLOSCOPE_BASE + 1, 237 LSP_VERSION(1, 0, 0), 238 osclilloscope_classes, 239 E_INLINE_DISPLAY | E_DUMP_STATE, 240 oscilloscope_x2_ports, 241 "util/oscilloscope/x2.xml", 242 NULL, 243 NULL 244 }; 245 246 const plugin_metadata_t oscilloscope_x4_metadata::metadata = 247 { 248 "Oscilloscope x4", 249 "Oscilloscope x4", 250 "O4", // Oscilloscope x4 251 &developers::s_tronci, 252 "oscilloscope_x4", 253 "atvi", 254 LSP_OSCILLOSCOPE_BASE + 2, 255 LSP_VERSION(1, 0, 0), 256 osclilloscope_classes, 257 E_INLINE_DISPLAY | E_DUMP_STATE, 258 oscilloscope_x4_ports, 259 "util/oscilloscope/x4.xml", 260 NULL, 261 NULL 262 }; 263 264 } 265