* Introduce yaml in Companion * EdgeTX Companion Replace some OpenTX refs Data conversion to v220 Update Timers ui to cater for mode field split * Fix some simulators crashing when started from Companion * Disable firmware and app update checking and downloads from companion * Some more rebranding * Disable manual download actions and another rebrand * Fix cmake warning * Fix mode ON conversion gtests and enable switch in model edit * Stop update message when updates turned off * OpenTX #8580 Fixes missing negative sign for telemetry sources * OpenTX #8604 fix curves tooltip colors * OpenTX #8616 Fix release notes url references * OpenTX #8548 Align file sync folder references * OpenTX #8548 Link field once * OpenTX #8550 Confirmation prompt before write models and settings to radio * OpenTX #8550 Translate strings * Title and splash images * Change DEB package maintainer * Start NV14 * NV14 continued * NV14 sim * Timer countdownStart data conversion and ui fixes * Fix screen width * Merge OpenTX PR 8675 * NV14 sim add computer keys and mouse to activate some functions * Only allow supported protocols for each module on conversion * Clear mismatched modules on conversion * Replace colorlcd theme and layout blobs with detailed data structs in companion * NV14 has 2 topbar zones * Fix layout init * Fix layout init again * Reset to eepromimportexport.h to main branch * Import/export does not like enum fields * Model edit add custom screens tab for color and bw telemetry * Free memory
104 lines
2.9 KiB
C++
104 lines
2.9 KiB
C++
/*
|
|
* Copyright (C) OpenTX
|
|
*
|
|
* Based on code named
|
|
* 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.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "boards.h"
|
|
#include "constants.h"
|
|
|
|
#include <QtCore>
|
|
|
|
class Firmware;
|
|
class ModelData;
|
|
class GeneralSettings;
|
|
class RadioDataConversionState;
|
|
|
|
enum RawSwitchType {
|
|
SWITCH_TYPE_NONE,
|
|
SWITCH_TYPE_SWITCH,
|
|
SWITCH_TYPE_VIRTUAL,
|
|
SWITCH_TYPE_MULTIPOS_POT,
|
|
SWITCH_TYPE_TRIM,
|
|
SWITCH_TYPE_ROTARY_ENCODER,
|
|
SWITCH_TYPE_ON,
|
|
SWITCH_TYPE_OFF,
|
|
SWITCH_TYPE_ONE,
|
|
SWITCH_TYPE_FLIGHT_MODE,
|
|
SWITCH_TYPE_TIMER_MODE,
|
|
SWITCH_TYPE_TELEMETRY,
|
|
SWITCH_TYPE_SENSOR,
|
|
SWITCH_TYPE_ACT,
|
|
MAX_SWITCH_TYPE
|
|
};
|
|
|
|
class RawSwitch {
|
|
Q_DECLARE_TR_FUNCTIONS(RawSwitch)
|
|
|
|
public:
|
|
enum SwitchContext
|
|
{
|
|
LogicalSwitchesContext = 0x01,
|
|
SpecialFunctionsContext = 0x02,
|
|
GlobalFunctionsContext = 0x04,
|
|
TimersContext = 0x08,
|
|
MixesContext = 0x10,
|
|
|
|
AllModelContexts = SpecialFunctionsContext | LogicalSwitchesContext | TimersContext | MixesContext,
|
|
AllSwitchContexts = AllModelContexts | GlobalFunctionsContext
|
|
};
|
|
|
|
RawSwitch() { clear(); }
|
|
|
|
explicit RawSwitch(int value):
|
|
type(RawSwitchType(abs(value)/256)),
|
|
index(value >= 0 ? abs(value)%256 : -(abs(value)%256))
|
|
{
|
|
}
|
|
|
|
RawSwitch(RawSwitchType type, int index=0):
|
|
type(type),
|
|
index(index)
|
|
{
|
|
}
|
|
|
|
inline const int toValue() const
|
|
{
|
|
return index >= 0 ? (type * 256 + index) : -(type * 256 - index);
|
|
}
|
|
|
|
RawSwitch convert(RadioDataConversionState & cstate);
|
|
QString toString(Board::Type board = Board::BOARD_UNKNOWN, const GeneralSettings * const generalSettings = NULL, const ModelData * const modelData = NULL) const;
|
|
bool isAvailable(const ModelData * const model = NULL, const GeneralSettings * const gs = NULL, Board::Type board = Board::BOARD_UNKNOWN) const;
|
|
bool isSet() const { return type != SWITCH_TYPE_NONE || index != 0; }
|
|
void clear() { type = SWITCH_TYPE_NONE; index = 0; }
|
|
QStringList getSwitchList(Boards board) const;
|
|
|
|
bool operator== ( const RawSwitch& other) const {
|
|
return (this->type == other.type) && (this->index == other.index);
|
|
}
|
|
|
|
bool operator!= ( const RawSwitch& other) const {
|
|
return (this->type != other.type) || (this->index != other.index);
|
|
}
|
|
|
|
RawSwitchType type;
|
|
int index;
|
|
};
|