/* * Copyright (C) EdgeTX * * Based on code named * opentx - https://github.com/opentx/opentx * th9x - http://code.google.com/p/th9x * er9x - http://code.google.com/p/er9x * gruvin9x - http://code.google.com/p/gruvin9x * * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #ifndef TELEMETRYDATA_H #define TELEMETRYDATA_H #include "rawsource.h" #include class FrSkyAlarmData { Q_DECLARE_TR_FUNCTIONS(FrSkyAlarmData) public: FrSkyAlarmData() { clear(); } unsigned int level; // 0=none, 1=Yellow, 2=Orange, 3=Red unsigned int greater; // 0=LT(<), 1=GT(>) unsigned int value; // 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc. void clear() { memset(this, 0, sizeof(FrSkyAlarmData)); } static QString alarmLevelName(int alarm) { switch (alarm) { case 1: return tr("Yellow"); case 2: return tr("Orange"); case 3: return tr("Red"); default: return "----"; } } }; class FrSkyChannelData { Q_DECLARE_TR_FUNCTIONS(FrSkyChannelData) public: FrSkyChannelData() { clear(); } unsigned int ratio; // 0.0 means not used, 0.1V steps EG. 6.6 Volts = 66. 25.1V = 251, etc. unsigned int type; // future use: 0=volts, 1=ml... int offset; unsigned int multiplier; FrSkyAlarmData alarms[2]; float getRatio() const; RawSourceRange getRange() const; void clear() { memset(reinterpret_cast(this), 0, sizeof(FrSkyChannelData)); } static QString unitString(int units) { switch(units) { case 1: return QCoreApplication::translate("FrSkyChannelData", "---"); default: return QCoreApplication::translate("FrSkyChannelData", "V"); } } }; struct FrSkyBarData { RawSource source; int barMin; // minimum for bar display int barMax; // ditto for max display (would usually = ratio) }; struct FrSkyLineData { RawSource source[3]; }; struct TelemetryScriptData { char filename[8+1]; }; // from radio/src/dataconstants.h #define TELEM_LABEL_LEN 4 enum TelemetryUnit { UNIT_RAW, UNIT_VOLTS, UNIT_AMPS, UNIT_MILLIAMPS, UNIT_KTS, UNIT_METERS_PER_SECOND, UNIT_FEET_PER_SECOND, UNIT_KMH, UNIT_SPEED = UNIT_KMH, UNIT_MPH, UNIT_METERS, UNIT_DIST = UNIT_METERS, UNIT_FEET, UNIT_CELSIUS, UNIT_TEMPERATURE = UNIT_CELSIUS, UNIT_FAHRENHEIT, UNIT_PERCENT, UNIT_MAH, UNIT_WATTS, UNIT_MILLIWATTS, UNIT_DB, UNIT_RPMS, UNIT_G, UNIT_DEGREE, UNIT_RADIANS, UNIT_MILLILITERS, UNIT_FLOZ, UNIT_MILLILITERS_PER_MINUTE, UNIT_HERTZ, UNIT_MS, UNIT_US, UNIT_KM, UNIT_DBM, UNIT_MAX = UNIT_DBM, UNIT_SPARE6, UNIT_SPARE7, UNIT_SPARE8, UNIT_SPARE9, UNIT_SPARE10, UNIT_HOURS, UNIT_MINUTES, UNIT_SECONDS, // FrSky format used for these fields, could be another format in the future UNIT_FIRST_VIRTUAL, UNIT_CELLS = UNIT_FIRST_VIRTUAL, UNIT_DATETIME, UNIT_GPS, UNIT_BITFIELD, UNIT_TEXT, // Internal units (not stored in sensor unit) UNIT_GPS_LONGITUDE, UNIT_GPS_LATITUDE, UNIT_DATETIME_YEAR, UNIT_DATETIME_DAY_MONTH, UNIT_DATETIME_HOUR_MIN, UNIT_DATETIME_SEC }; enum TelemetryScreenEnum { TELEMETRY_SCREEN_NONE, TELEMETRY_SCREEN_NUMBERS, TELEMETRY_SCREEN_BARS, TELEMETRY_SCREEN_SCRIPT }; class FrSkyScreenData { public: FrSkyScreenData() { clear(); } typedef struct { FrSkyBarData bars[4]; FrSkyLineData lines[4]; TelemetryScriptData script; } FrSkyScreenBody; unsigned int type; FrSkyScreenBody body; void clear(); }; enum TelemetryVarioSources { TELEMETRY_VARIO_SOURCE_ALTI, TELEMETRY_VARIO_SOURCE_ALTI_PLUS, TELEMETRY_VARIO_SOURCE_VSPEED, TELEMETRY_VARIO_SOURCE_A1, TELEMETRY_VARIO_SOURCE_A2, TELEMETRY_VARIO_SOURCE_DTE, }; enum TelemetryVoltsSources { TELEMETRY_VOLTS_SOURCE_A1, TELEMETRY_VOLTS_SOURCE_A2, TELEMETRY_VOLTS_SOURCE_A3, TELEMETRY_VOLTS_SOURCE_A4, TELEMETRY_VOLTS_SOURCE_FAS, TELEMETRY_VOLTS_SOURCE_CELLS }; enum TelemetryCurrentSources { TELEMETRY_CURRENT_SOURCE_NONE, TELEMETRY_CURRENT_SOURCE_A1, TELEMETRY_CURRENT_SOURCE_A2, TELEMETRY_CURRENT_SOURCE_A3, TELEMETRY_CURRENT_SOURCE_A4, TELEMETRY_CURRENT_SOURCE_FAS }; class FrSkyData { public: FrSkyData() { clear(); } FrSkyChannelData channels[4]; unsigned int usrProto; int blades; unsigned int voltsSource; unsigned int altitudeSource; unsigned int currentSource; FrSkyScreenData screens[4]; unsigned int varioSource; bool varioCenterSilent; int varioMin; int varioCenterMin; // if increment in 0.2m/s = 3.0m/s max int varioCenterMax; int varioMax; bool mAhPersistent; unsigned int storedMah; int fasOffset; bool ignoreSensorIds; void clear(); }; class MavlinkData { public: MavlinkData() { clear();} unsigned int rc_rssi_scale; unsigned int pc_rssi_en; void clear() { memset(this, 0, sizeof(MavlinkData)); } }; #endif // TELEMETRYDATA_H