MCPcopy Create free account
hub / github.com/OpenHD/OpenHD / get_all_settings

Method get_all_settings

OpenHD/ohd_telemetry/src/GroundTelemetry.cpp:292–380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290}
291
292std::vector<openhd::Setting> GroundTelemetry::get_all_settings() {
293 std::vector<openhd::Setting> ret{};
294 // and this allows an advanced user to change its air unit to a ground unit
295 // only expose this setting if OpenHD uses the file workaround to figure out
296 // air or ground.
297 if (openhd::tmp::file_air_or_ground_exists()) {
298 auto c_config_boot_as_air = [](std::string, int value) {
299 return openhd::tmp::handle_telemetry_change(value);
300 };
301 ret.push_back(openhd::Setting{"CONFIG_BOOT_AIR",
302 openhd::IntSetting{0, c_config_boot_as_air}});
303 }
304#ifdef OPENHD_TELEMETRY_SDL_FOR_JOYSTICK_FOUND
305 if (true) {
306 auto c_config_enable_joystick = [this](std::string, int value) {
307 if (!openhd::validate_yes_or_no(value)) return false;
308 m_gnd_settings->unsafe_get_settings().enable_rc_over_joystick = value;
309 m_gnd_settings->persist();
310 if (m_gnd_settings->unsafe_get_settings().enable_rc_over_joystick) {
311 enable_joystick();
312 } else {
313 disable_joystick();
314 }
315 return true;
316 };
317 ret.push_back(openhd::Setting{
318 "ENABLE_JOY_RC",
319 openhd::IntSetting{
320 static_cast<int>(
321 m_gnd_settings->get_settings().enable_rc_over_joystick),
322 c_config_enable_joystick}});
323 // We always expose these params, regardless if joy is enabled or disabled
324 auto c_rc_over_joystick_update_rate_hz = [this](std::string, int value) {
325 if (!openhd::telemetry::ground::valid_joystick_update_rate(value))
326 return false;
327 m_gnd_settings->unsafe_get_settings().rc_over_joystick_update_rate_hz =
328 value;
329 m_gnd_settings->persist();
330 if (m_rc_joystick_sender) {
331 m_rc_joystick_sender->change_update_rate(value);
332 }
333 return true;
334 };
335 ret.push_back(openhd::Setting{
336 "RC_UPDATE_HZ",
337 openhd::IntSetting{
338 static_cast<int>(
339 m_gnd_settings->get_settings().rc_over_joystick_update_rate_hz),
340 c_rc_over_joystick_update_rate_hz}});
341 auto c_rc_over_joystick_channel_mapping = [this](std::string,
342 std::string value) {
343 m_console->debug("Change channel mapping {}", value);
344 const auto parsed = openhd::convert_string_to_channel_mapping(value);
345 if (parsed == std::nullopt) {
346 m_console->warn("Not a valid channel mapping");
347 return false;
348 }
349 m_gnd_settings->unsafe_get_settings().rc_channel_mapping = value;

Callers

nothing calls this directly

Calls 10

handle_telemetry_changeFunction · 0.85
validate_yes_or_noFunction · 0.85
push_backMethod · 0.80
persistMethod · 0.80
change_update_rateMethod · 0.80
debugMethod · 0.80

Tested by

no test coverage detected