mirror of
https://github.com/opentx/opentx.git
synced 2025-07-18 22:05:10 +03:00
Some reserve in telemetry sources added
This commit is contained in:
parent
a47ac42996
commit
7e43a88d3f
6 changed files with 127 additions and 63 deletions
|
@ -232,8 +232,9 @@ class SourcesConversionTable: public ConversionTable {
|
|||
}
|
||||
}
|
||||
|
||||
if (afterrelease21March2013)
|
||||
if (afterrelease21March2013) {
|
||||
addConversion(RawSource(SOURCE_TYPE_TELEMETRY, 0), val++);
|
||||
}
|
||||
|
||||
for (int i=1; i<TELEMETRY_SOURCE_ACC; i++) {
|
||||
if (version < 216) {
|
||||
|
@ -241,6 +242,12 @@ class SourcesConversionTable: public ConversionTable {
|
|||
continue;
|
||||
}
|
||||
addConversion(RawSource(SOURCE_TYPE_TELEMETRY, i), val++);
|
||||
if (version >= 216 && IS_ARM(board)) {
|
||||
if (i==TELEMETRY_SOURCE_DTE)
|
||||
val += 5;
|
||||
if (i==TELEMETRY_SOURCE_POWER_MAX)
|
||||
val += 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -314,6 +321,57 @@ class SwitchField: public ConversionField< SignedField<N> > {
|
|||
int _switch;
|
||||
};
|
||||
|
||||
template <int N>
|
||||
class TelemetrySourceField: public TransformedField {
|
||||
public:
|
||||
TelemetrySourceField(unsigned int & source, BoardEnum board, unsigned int version):
|
||||
TransformedField(internalField),
|
||||
internalField(_source),
|
||||
source(source),
|
||||
board(board),
|
||||
version(version),
|
||||
_source(0)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void beforeExport()
|
||||
{
|
||||
_source = source;
|
||||
|
||||
if (source > 0 && !IS_AFTER_RELEASE_21_MARCH_2013(board, version))
|
||||
_source--;
|
||||
|
||||
if (IS_ARM(board) && version >= 216) {
|
||||
if (source > 1+TELEMETRY_SOURCE_DTE)
|
||||
_source += 5;
|
||||
if (source > 1+TELEMETRY_SOURCE_POWER_MAX)
|
||||
_source += 5;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void afterImport()
|
||||
{
|
||||
source = _source;
|
||||
|
||||
if (source > 0 && !IS_AFTER_RELEASE_21_MARCH_2013(board, version))
|
||||
source++;
|
||||
|
||||
if (IS_ARM(board) && version >= 216) {
|
||||
if (source > 1+TELEMETRY_SOURCE_DTE)
|
||||
source -= 5;
|
||||
if (source > 1+TELEMETRY_SOURCE_POWER_MAX)
|
||||
source -= 5;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
UnsignedField<N> internalField;
|
||||
unsigned int & source;
|
||||
BoardEnum board;
|
||||
unsigned int version;
|
||||
unsigned int _source;
|
||||
};
|
||||
|
||||
template <int N>
|
||||
class SourceField: public ConversionField< UnsignedField<N> > {
|
||||
public:
|
||||
|
@ -1783,15 +1841,15 @@ class FrskyScreenField: public DataField {
|
|||
version(version)
|
||||
{
|
||||
for (int i=0; i<4; i++) {
|
||||
bars.Append(new UnsignedField<8>(_screen.body.bars[i].source));
|
||||
bars.Append(new UnsignedField<8>(_screen.body.bars[i].barMin));
|
||||
bars.Append(new UnsignedField<8>(_screen.body.bars[i].barMax));
|
||||
bars.Append(new TelemetrySourceField<8>(screen.body.bars[i].source, board, version));
|
||||
bars.Append(new UnsignedField<8>(screen.body.bars[i].barMin));
|
||||
bars.Append(new UnsignedField<8>(screen.body.bars[i].barMax));
|
||||
}
|
||||
|
||||
int columns=(IS_TARANIS(board) ? 3:2);
|
||||
for (int i=0; i<4; i++) {
|
||||
for (int j=0; j<columns; j++) {
|
||||
numbers.Append(new UnsignedField<8>(_screen.body.lines[i].source[j]));
|
||||
numbers.Append(new TelemetrySourceField<8>(screen.body.lines[i].source[j], board, version));
|
||||
}
|
||||
}
|
||||
if (!IS_TARANIS(board)) {
|
||||
|
@ -1803,23 +1861,6 @@ class FrskyScreenField: public DataField {
|
|||
|
||||
virtual void ExportBits(QBitArray & output)
|
||||
{
|
||||
_screen = screen;
|
||||
|
||||
bool afterrelease21March2013 = IS_AFTER_RELEASE_21_MARCH_2013(board, version);
|
||||
if (!afterrelease21March2013) {
|
||||
for (int i=0; i<4; i++) {
|
||||
if (_screen.body.bars[i].source > 0)
|
||||
_screen.body.bars[i].source--;
|
||||
}
|
||||
int columns=(IS_TARANIS(board) ? 3:2);
|
||||
for (int i=0; i<4; i++) {
|
||||
for (int j=0; j<columns;j++) {
|
||||
if (_screen.body.lines[i].source[j] > 0)
|
||||
_screen.body.lines[i].source[j]--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (screen.type == 0)
|
||||
numbers.ExportBits(output);
|
||||
else
|
||||
|
@ -1828,34 +1869,14 @@ class FrskyScreenField: public DataField {
|
|||
|
||||
virtual void ImportBits(QBitArray & input)
|
||||
{
|
||||
_screen = screen;
|
||||
|
||||
bool afterrelease21March2013 = IS_AFTER_RELEASE_21_MARCH_2013(board, version);
|
||||
|
||||
// NOTA: screen.type should have been imported first!
|
||||
if (screen.type == 0) {
|
||||
numbers.ImportBits(input);
|
||||
if (!afterrelease21March2013) {
|
||||
int columns=(IS_TARANIS(board) ? 3:2);
|
||||
for (int i=0; i<4; i++) {
|
||||
for (int j=0; j<columns;j++) {
|
||||
if (_screen.body.lines[i].source[j] > 0)
|
||||
_screen.body.lines[i].source[j]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
bars.ImportBits(input);
|
||||
if (!afterrelease21March2013) {
|
||||
for (int i=0; i<4; i++) {
|
||||
if (_screen.body.bars[i].source > 0)
|
||||
_screen.body.bars[i].source++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
screen = _screen;
|
||||
}
|
||||
|
||||
virtual unsigned int size()
|
||||
|
@ -1869,7 +1890,6 @@ class FrskyScreenField: public DataField {
|
|||
|
||||
protected:
|
||||
FrSkyScreenData & screen;
|
||||
FrSkyScreenData _screen;
|
||||
BoardEnum board;
|
||||
unsigned int version;
|
||||
StructField bars;
|
||||
|
|
|
@ -1815,7 +1815,7 @@ enum FlightModesItems {
|
|||
ITEM_PHASES_LAST = ITEM_PHASES_COUNT-1
|
||||
};
|
||||
|
||||
bool isTrimModeAvailable(int16_t mode)
|
||||
bool isTrimModeAvailable(int mode)
|
||||
{
|
||||
return (mode == TRIM_MODE_NONE || (mode%2) == 0 || (mode/2) != (m_posVert-1));
|
||||
}
|
||||
|
@ -5738,7 +5738,7 @@ void menuModelTelemetry(uint8_t event)
|
|||
if (attr && (s_editMode>0 || p1valdiff)) {
|
||||
switch (m_posHorz) {
|
||||
case 0:
|
||||
bar.source = checkIncDecModel(event, barSource, 0, TELEM_DISPLAY_MAX);
|
||||
bar.source = CHECK_INCDEC_MODELVAR_ZERO_CHECK(event, barSource, TELEM_DISPLAY_MAX, isTelemetrySourceAvailable);
|
||||
if (checkIncDec_Ret) {
|
||||
bar.barMin = 0;
|
||||
bar.barMax = 255 - maxBarTelemValue(bar.source);
|
||||
|
@ -5766,7 +5766,7 @@ void menuModelTelemetry(uint8_t event)
|
|||
#endif
|
||||
lcd_putsiAtt(pos[c], y, STR_VTELEMCHNS, value, cellAttr);
|
||||
if (cellAttr && (s_editMode>0 || p1valdiff)) {
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, value, (lineIndex==3 && c==0) ? TELEM_STATUS_MAX : TELEM_DISPLAY_MAX);
|
||||
CHECK_INCDEC_MODELVAR_ZERO_CHECK(event, value, (lineIndex==3 && c==0) ? TELEM_STATUS_MAX : TELEM_DISPLAY_MAX, isTelemetrySourceAvailable);
|
||||
}
|
||||
}
|
||||
if (attr && m_posHorz == NUM_LINE_ITEMS) {
|
||||
|
|
|
@ -1185,7 +1185,7 @@ void drawStatusLine()
|
|||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
bool isSourceAvailable(int16_t source)
|
||||
bool isSourceAvailable(int source)
|
||||
{
|
||||
#if defined(PCBTARANIS)
|
||||
if (source>=MIXSRC_FIRST_INPUT && source<=MIXSRC_LAST_INPUT) {
|
||||
|
@ -1228,10 +1228,24 @@ bool isSourceAvailable(int16_t source)
|
|||
return false;
|
||||
#endif
|
||||
|
||||
if (source>=MIXSRC_FIRST_TELEM && source<=MIXSRC_LAST_TELEM)
|
||||
return isTelemetrySourceAvailable(source-MIXSRC_FIRST_TELEM+1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isInputSourceAvailable(int16_t source)
|
||||
bool isTelemetrySourceAvailable(int source)
|
||||
{
|
||||
if (source >= TELEM_RESERVE1 && source <= TELEM_RESERVE5)
|
||||
return false;
|
||||
|
||||
if (source >= TELEM_RESERVE6 && source <= TELEM_RESERVE10)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isInputSourceAvailable(int source)
|
||||
{
|
||||
if (source>=MIXSRC_Rud && source<=MIXSRC_MAX)
|
||||
return true;
|
||||
|
@ -1243,12 +1257,12 @@ bool isInputSourceAvailable(int16_t source)
|
|||
return true;
|
||||
|
||||
if (source>=MIXSRC_FIRST_TELEM && source<=MIXSRC_LAST_TELEM)
|
||||
return true;
|
||||
return isTelemetrySourceAvailable(source-MIXSRC_FIRST_TELEM+1);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isSwitchAvailableInLogicalSwitches(int16_t swtch)
|
||||
bool isSwitchAvailableInLogicalSwitches(int swtch)
|
||||
{
|
||||
if (swtch < 0) {
|
||||
if (swtch <= -SWSRC_ON)
|
||||
|
@ -1277,7 +1291,7 @@ bool isSwitchAvailableInLogicalSwitches(int16_t swtch)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool isSwitchAvailable(int16_t swtch)
|
||||
bool isSwitchAvailable(int swtch)
|
||||
{
|
||||
if (!isSwitchAvailableInLogicalSwitches(swtch)) {
|
||||
return false;
|
||||
|
@ -1291,13 +1305,12 @@ bool isSwitchAvailable(int16_t swtch)
|
|||
return true;
|
||||
}
|
||||
|
||||
// Not available yet, will be needed if we implement the Range function later...
|
||||
bool isLogicalSwitchFunctionAvailable(int16_t function)
|
||||
bool isLogicalSwitchFunctionAvailable(int function)
|
||||
{
|
||||
return function != LS_FUNC_RANGE;
|
||||
}
|
||||
|
||||
bool isAssignableFunctionAvailable(int16_t function)
|
||||
bool isAssignableFunctionAvailable(int function)
|
||||
{
|
||||
switch (function) {
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ extern int8_t s_editMode; // global editmode
|
|||
#define HIDDEN_ROW ((uint8_t)-2)
|
||||
|
||||
#if defined(CPUARM)
|
||||
typedef bool (*IsValueAvailable)(int16_t);
|
||||
typedef bool (*IsValueAvailable)(int);
|
||||
int16_t checkIncDec(uint8_t event, int16_t i_pval, int16_t i_min, int16_t i_max, uint8_t i_flags=0, IsValueAvailable isValueAvailable=NULL);
|
||||
#else
|
||||
int16_t checkIncDec(uint8_t event, int16_t i_pval, int16_t i_min, int16_t i_max, uint8_t i_flags=0);
|
||||
|
@ -190,10 +190,18 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max);
|
|||
var = checkIncDecModelZero(event,var,max)
|
||||
|
||||
#if defined(CPUARM)
|
||||
bool isLogicalSwitchFunctionAvailable(int16_t function);
|
||||
bool isAssignableFunctionAvailable(int16_t function);
|
||||
bool isSwitchAvailable(int16_t swtch);
|
||||
bool isSwitchAvailableInLogicalSwitches(int16_t swtch);
|
||||
#define CHECK_INCDEC_MODELVAR_ZERO_CHECK(event, var, max, check) \
|
||||
var = checkIncDec(event, var, 0, max, EE_MODEL, check)
|
||||
#else
|
||||
#define CHECK_INCDEC_MODELVAR_ZERO_CHECK(event, var, max, check) \
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, var, max)
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
bool isLogicalSwitchFunctionAvailable(int function);
|
||||
bool isAssignableFunctionAvailable(int function);
|
||||
bool isSwitchAvailable(int swtch);
|
||||
bool isSwitchAvailableInLogicalSwitches(int swtch);
|
||||
#define AUTOSWITCH_ENTER_LONG() (attr && event==EVT_KEY_LONG(KEY_ENTER))
|
||||
#define CHECK_INCDEC_MODELSWITCH(event, var, min, max) \
|
||||
var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SWITCH|NO_INCDEC_MARKS, isSwitchAvailable)
|
||||
|
@ -207,8 +215,9 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max);
|
|||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
bool isSourceAvailable(int16_t source);
|
||||
bool isInputSourceAvailable(int16_t source);
|
||||
bool isSourceAvailable(int source);
|
||||
bool isTelemetrySourceAvailable(int source);
|
||||
bool isInputSourceAvailable(int source);
|
||||
#define CHECK_INCDEC_MODELSOURCE(event, var, min, max) \
|
||||
var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SOURCE|NO_INCDEC_MARKS, isSourceAvailable)
|
||||
#elif defined(AUTOSOURCE)
|
||||
|
|
|
@ -962,6 +962,13 @@ enum TelemetrySource {
|
|||
TELEM_VSPD,
|
||||
TELEM_ASPD,
|
||||
TELEM_DTE,
|
||||
#if defined(CPUARM)
|
||||
TELEM_RESERVE1,
|
||||
TELEM_RESERVE2,
|
||||
TELEM_RESERVE3,
|
||||
TELEM_RESERVE4,
|
||||
TELEM_RESERVE5,
|
||||
#endif
|
||||
TELEM_MIN_A1,
|
||||
TELEM_MIN_A2,
|
||||
TELEM_MIN_ALT,
|
||||
|
@ -975,6 +982,13 @@ enum TelemetrySource {
|
|||
TELEM_MIN_VFAS,
|
||||
TELEM_MAX_CURRENT,
|
||||
TELEM_MAX_POWER,
|
||||
#if defined(CPUARM)
|
||||
TELEM_RESERVE6,
|
||||
TELEM_RESERVE7,
|
||||
TELEM_RESERVE8,
|
||||
TELEM_RESERVE9,
|
||||
TELEM_RESERVE10,
|
||||
#endif
|
||||
TELEM_ACC,
|
||||
TELEM_GPS_TIME,
|
||||
TELEM_CSW_MAX = TELEM_MAX_POWER,
|
||||
|
|
|
@ -256,6 +256,7 @@
|
|||
#define TR_FUNCSOUNDS TR("Bp1\0""Bp2\0""Bp3\0""Wrn1""Wrn2""Chee""Rata""Tick""Sirn""Ring""SciF""Robt""Chrp""Tada""Crck""Alrm", "Beep1 ""Beep2 ""Beep3 ""Warn1 ""Warn2 ""Cheep ""Ratata""Tick ""Siren ""Ring ""SciFi ""Robot ""Chirp ""Tada ""Crickt""AlmClk")
|
||||
|
||||
#define LEN_VTELEMCHNS "\004"
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
#define TR_RSSI_0 "SWR\0"
|
||||
#define TR_RSSI_1 "RSSI"
|
||||
|
@ -263,7 +264,14 @@
|
|||
#define TR_RSSI_0 "Tx\0 "
|
||||
#define TR_RSSI_1 "Rx\0 "
|
||||
#endif
|
||||
#define TR_VTELEMCHNS "---\0""Batt""Tmr1""Tmr2" TR_RSSI_0 TR_RSSI_1 "A1\0 ""A2\0 ""Alt\0""Rpm\0""Fuel""T1\0 ""T2\0 ""Spd\0""Dist""GAlt""Cell""Cels""Vfas""Curr""Cnsp""Powr""AccX""AccY""AccZ""Hdg\0""VSpd""ASpd""dTE\0""A1-\0""A2-\0""Alt-""Alt+""Rpm+""T1+\0""T2+\0""Spd+""Dst+""Cel-""Vfs-""Cur+""Pwr+""Acc\0""Time"
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define TR_TELEM_RESERVE "[--]"
|
||||
#else
|
||||
#define TR_TELEM_RESERVE
|
||||
#endif
|
||||
|
||||
#define TR_VTELEMCHNS "---\0""Batt""Tmr1""Tmr2" TR_RSSI_0 TR_RSSI_1 "A1\0 ""A2\0 ""Alt\0""Rpm\0""Fuel""T1\0 ""T2\0 ""Spd\0""Dist""GAlt""Cell""Cels""Vfas""Curr""Cnsp""Powr""AccX""AccY""AccZ""Hdg\0""VSpd""ASpd""dTE\0" TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE "A1-\0""A2-\0""Alt-""Alt+""Rpm+""T1+\0""T2+\0""Spd+""Dst+""Cel-""Vfs-""Cur+""Pwr+" TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE TR_TELEM_RESERVE "Acc\0""Time"
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define LEN_VUNITSSYSTEM TR("\006", "\010")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue