5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #ifndef OPENTX_DATASTRUCTS_218_H
22 #define OPENTX_DATASTRUCTS_218_H
24 #define MAX_TIMERS_218 3
25 #define MAX_GVARS_218 9
28 #define NUM_SWITCHES_218 8
29 #elif defined(PCBXLITE)
30 #define NUM_SWITCHES_218 4
32 #define NUM_SWITCHES_218 6
34 #define NUM_SWITCHES_218 18 // yes, it's a lot!
36 #define NUM_SWITCHES_218 8
40 #define LEN_SWITCH_NAME_218 3
41 #define LEN_ANA_NAME_218 3
42 #define LEN_MODEL_FILENAME_218 16
43 #define LEN_BLUETOOTH_NAME_218 10
45 #define LEN_SWITCH_NAME_218 3
46 #define LEN_ANA_NAME_218 3
47 #define LEN_BLUETOOTH_NAME_218 10
50 #define LEN_GVAR_NAME_218 3
53 #define LEN_MODEL_NAME_218 15
54 #define LEN_TIMER_NAME_218 8
55 #define LEN_FLIGHT_MODE_NAME_218 10
56 #define LEN_BITMAP_NAME_218 10
57 #define LEN_EXPOMIX_NAME_218 6
58 #define LEN_CHANNEL_NAME_218 6
59 #define LEN_INPUT_NAME_218 4
60 #define LEN_CURVE_NAME_218 3
61 #define LEN_FUNCTION_NAME_218 6
62 #define MAX_CURVES_218 32
63 #define MAX_CURVE_POINTS_218 512
65 #define LEN_MODEL_NAME_218 12
66 #define LEN_TIMER_NAME_218 8
67 #define LEN_FLIGHT_MODE_NAME_218 10
68 #define LEN_BITMAP_NAME_218 10
69 #define LEN_EXPOMIX_NAME_218 8
70 #define LEN_CHANNEL_NAME_218 6
71 #define LEN_INPUT_NAME_218 4
72 #define LEN_CURVE_NAME_218 3
73 #define LEN_FUNCTION_NAME_218 8
74 #define MAX_CURVES_218 32
75 #define MAX_CURVE_POINTS_218 512
77 #define LEN_MODEL_NAME_218 10
78 #define LEN_TIMER_NAME_218 3
79 #define LEN_FLIGHT_MODE_NAME_218 6
80 #define LEN_EXPOMIX_NAME_218 6
81 #define LEN_CHANNEL_NAME_218 4
82 #define LEN_INPUT_NAME_218 3
83 #define LEN_CURVE_NAME_218 3
84 #define LEN_FUNCTION_NAME_218 6
85 #define MAX_CURVES_218 16
86 #define MAX_CURVE_POINTS_218 512
90 #define MAX_MODELS_218 60
91 #define MAX_OUTPUT_CHANNELS_218 32 // number of real output channels CH1-CH32
92 #define MAX_FLIGHT_MODES_218 9
93 #define MAX_MIXERS_218 64
94 #define MAX_EXPOS_218 64
95 #define MAX_LOGICAL_SWITCHES_218 64
96 #define MAX_SPECIAL_FUNCTIONS_218 64 // number of functions assigned to switches
97 #define MAX_SCRIPTS_218 9
98 #define MAX_INPUTS_218 32
99 #define MAX_TRAINER_CHANNELS_218 16
100 #define MAX_TELEMETRY_SENSORS_218 32
101 #define MAX_CUSTOM_SCREENS_218 5
102 #elif defined(PCBTARANIS)
103 #define MAX_MODELS_218 60
104 #define MAX_OUTPUT_CHANNELS_218 32 // number of real output channels CH1-CH32
105 #define MAX_FLIGHT_MODES_218 9
106 #define MAX_MIXERS_218 64
107 #define MAX_EXPOS_218 64
108 #define MAX_LOGICAL_SWITCHES_218 64
109 #define MAX_SPECIAL_FUNCTIONS_218 64 // number of functions assigned to switches
110 #define MAX_SCRIPTS_218 7
111 #define MAX_INPUTS_218 32
112 #define MAX_TRAINER_CHANNELS_218 16
113 #define MAX_TELEMETRY_SENSORS_218 32
114 #elif defined(PCBSKY9X)
115 #define MAX_MODELS_218 60
116 #define MAX_OUTPUT_CHANNELS_218 32 // number of real output channels CH1-CH32
117 #define MAX_FLIGHT_MODES_218 9
118 #define MAX_MIXERS_218 64
119 #define MAX_EXPOS_218 32
120 #define MAX_LOGICAL_SWITCHES_218 64
121 #define MAX_SPECIAL_FUNCTIONS_218 64 // number of functions assigned to switches
122 #define MAX_INPUTS_218 32
123 #define MAX_TRAINER_CHANNELS_218 16
124 #define MAX_TELEMETRY_SENSORS_218 32
127 #if defined(COLORLCD)
128 typedef uint32_t swarnstate218_t
;
129 #elif defined(PCBX9E)
130 typedef uint64_t swconfig218_t
;
131 typedef uint64_t swarnstate218_t
;
132 typedef uint32_t swarnenable218_t
;
133 #elif defined(PCBTARANIS)
134 typedef uint16_t swconfig218_t
;
135 typedef uint16_t swarnstate218_t
;
136 typedef uint8_t swarnenable218_t
;
138 typedef uint8_t swarnstate218_t
;
139 typedef uint8_t swarnenable218_t
;
142 PACK(typedef struct {
145 uint8_t channelsStart
;
146 int8_t channelsCount
; // 0=8 channels
147 uint8_t failsafeMode
:4; // only 3 bits used
149 uint8_t invertedSerial
:1; // telemetry serial inverted from standard
150 int16_t failsafeChannels
[MAX_OUTPUT_CHANNELS_218
];
155 uint8_t outputType
:1; // false = open drain, true = push pull
159 uint8_t rfProtocolExtra
:2;
161 uint8_t customProto
:1;
162 uint8_t autoBindMode
:1;
163 uint8_t lowPowerMode
:1;
167 uint8_t power
:2; // 0=10 mW, 1=100 mW, 2=500 mW, 3=1W
169 uint8_t receiverTelemetryOff
:1; // false = receiver telem enabled
170 uint8_t receiverHigherChannels
:1; // false = pwm out 1-8, true 9-16
171 uint8_t external_antenna
:1; // false = internal antenna, true = external antenna
177 uint8_t noninverted
:1;
179 int8_t refreshRate
; // definition as framelength for ppm (* 5 + 225 = time in 1/10 ms)
184 PACK(typedef struct {
185 int32_t mode
:9; // timer trigger source -> off, abs, stk, stk%, sw/!sw, !m_sw/!m_sw
188 uint32_t countdownBeep
:2;
189 uint32_t minuteBeep
:1;
190 uint32_t persistent
:2;
191 int32_t countdownStart
:2;
192 uint32_t direction
:1;
193 char name
[LEN_TIMER_NAME_218
];
196 #if defined(PCBSKY9X)
197 #define ROTENC_DATA int16_t rotaryEncoders[1];
202 PACK(typedef struct {
203 trim_t trim
[NUM_TRIMS
];
204 char name
[LEN_FLIGHT_MODE_NAME_218
];
205 int16_t swtch
:9; // swtch of phase[0] is not used
210 gvar_t gvars
[MAX_GVARS_218
];
211 }) FlightModeData_v218
;
213 PACK(typedef struct {
214 int16_t weight
:11; // GV1=-1024, -GV1=1023
216 uint16_t srcRaw
:10; // srcRaw=0 means not used
217 uint16_t carryTrim
:1;
218 uint16_t mixWarn
:2; // mixer warning
219 uint16_t mltpx
:2; // multiplex method: 0 means +=, 1 means *=, 2 means :=
223 uint32_t flightModes
:9;
229 char name
[LEN_EXPOMIX_NAME_218
];
232 PACK(typedef struct {
239 uint32_t flightModes
:9;
242 char name
[LEN_EXPOMIX_NAME_218
];
247 PACK(typedef struct {
250 int8_t points
:6; // describes number of points - 5
251 char name
[LEN_CURVE_NAME_218
];
254 PACK(typedef struct {
259 PACK(typedef struct { // Logical Switches data
264 uint32_t andswtype
:1;
269 }) LogicalSwitchData_v218
;
271 #if defined(PCBTARANIS)
272 #define CFN_SPARE_TYPE int32_t
274 #define CFN_SPARE_TYPE int16_t
277 PACK(typedef struct {
282 char name
[LEN_FUNCTION_NAME_218
];
289 CFN_SPARE_TYPE spare2
;
298 }) CustomFunctionData_v218
;
300 PACK(struct GVarData_v218
{
301 char name
[LEN_GVAR_NAME_218
];
310 #if defined(COLORLCD)
311 PACK(struct FrSkyTelemetryData_v217
{
312 uint8_t varioSource
:7;
313 uint8_t varioCenterSilent
:1;
314 int8_t varioCenterMax
;
315 int8_t varioCenterMin
;
320 union FrSkyScreenData
{
321 FrSkyBarData bars
[4];
322 FrSkyLineData lines
[4];
323 #if defined(PCBTARANIS)
324 TelemetryScriptData script
;
327 PACK(struct FrSkyTelemetryData_v217
{
329 uint8_t altitudeSource
;
330 uint8_t screensType
; // 2bits per screen (None/Gauges/Numbers/Script)
331 FrSkyScreenData screens
[MAX_TELEMETRY_SCREENS
];
332 uint8_t varioSource
:7;
333 uint8_t varioCenterSilent
:1;
334 int8_t varioCenterMax
;
335 int8_t varioCenterMin
;
341 #if defined(PCBHORUS)
342 #define MODELDATA_EXTRA_218 uint8_t spare:3; uint8_t trainerMode:3; uint8_t potsWarnMode:2; ModuleData_v218 moduleData[NUM_MODULES+1]; ScriptData scriptsData[MAX_SCRIPTS_218]; char inputNames[MAX_INPUTS_218][LEN_INPUT_NAME_218]; uint8_t potsWarnEnabled; int8_t potsWarnPosition[3 + 4];
343 #elif defined(PCBTARANIS)
344 #define MODELDATA_EXTRA_218 uint8_t spare:3; uint8_t trainerMode:3; uint8_t potsWarnMode:2; ModuleData_v218 moduleData[NUM_MODULES+1]; ScriptData scriptsData[MAX_SCRIPTS_218]; char inputNames[MAX_INPUTS_218][LEN_INPUT_NAME_218]; uint8_t potsWarnEnabled; int8_t potsWarnPosition[STORAGE_NUM_POTS + STORAGE_NUM_SLIDERS];
345 #elif defined(PCBSKY9X)
346 #define MODELDATA_EXTRA_218 uint8_t spare:6; uint8_t potsWarnMode:2; ModuleData_v218 moduleData[NUM_MODULES+1]; char inputNames[MAX_INPUTS_218][LEN_INPUT_NAME_218]; uint8_t potsWarnEnabled; int8_t potsWarnPosition[STORAGE_NUM_POTS + STORAGE_NUM_SLIDERS]; uint8_t rxBattAlarms[2];
349 PACK(struct TelemetrySensor_218
{
351 uint16_t id
; // data identifier, for FrSky we can reuse existing ones. Source unit is derived from type.
352 uint16_t persistentValue
;
357 uint8_t rxIndex
:3; // 1 bit for module index, 2 bits for receiver index
362 char label
[TELEM_LABEL_LEN
]; // user defined label
363 uint8_t type
:1; // 0=custom / 1=calculated
364 uint8_t unit
:5; // user can choose what unit to display each value in
366 uint8_t autoOffset
:1;
369 uint8_t persistent
:1;
370 uint8_t onlyPositive
:1;
398 #if defined(PCBHORUS)
399 PACK(struct CustomScreenData_v218
{
401 Layout::PersistentData layoutData
;
404 CustomScreenData screenData[MAX_CUSTOM_SCREENS]; \
405 Topbar::PersistentData topbarData; \
407 #elif defined(PCBTARANIS)
408 #define VIEW_DATA uint8_t view;
413 #if LEN_BITMAP_NAME > 0
414 #define MODEL_HEADER_BITMAP_FIELD_218 char bitmap[10];
416 #define MODEL_HEADER_BITMAP_FIELD_218
419 PACK(struct ModelHeader_v218
{
420 char name
[LEN_MODEL_NAME
]; // must be first for eeLoadModelName
421 uint8_t modelId
[NUM_MODULES
];
422 MODEL_HEADER_BITMAP_FIELD_218
425 #if defined(COLORLCD)
426 #define SWITCH_WARNING_DATA_218
428 #define SWITCH_WARNING_DATA_218 swarnenable218_t switchWarningEnable;
431 PACK(struct ModelData_v218
{
432 ModelHeader_v218 header
;
433 TimerData_v218 timers
[MAX_TIMERS_218
];
434 uint8_t telemetryProtocol
:3;
435 uint8_t thrTrim
:1; // Enable Throttle Trim
436 uint8_t noGlobalFunctions
:1;
437 uint8_t displayTrims
:2;
438 uint8_t ignoreSensorIds
:1;
439 int8_t trimInc
:3; // Trim Increments
440 uint8_t disableThrottleWarning
:1;
441 uint8_t displayChecklist
:1;
442 uint8_t extendedLimits
:1;
443 uint8_t extendedTrims
:1;
444 uint8_t throttleReversed
:1;
445 BeepANACenter beepANACenter
;
446 MixData_v218 mixData
[MAX_MIXERS_218
];
447 LimitData limitData
[MAX_OUTPUT_CHANNELS_218
];
448 ExpoData_v218 expoData
[MAX_EXPOS_218
];
450 CurveData_v218 curves
[MAX_CURVES_218
];
451 int8_t points
[MAX_CURVE_POINTS_218
];
453 LogicalSwitchData_v218 logicalSw
[MAX_LOGICAL_SWITCHES_218
];
454 CustomFunctionData_v218 customFn
[MAX_SPECIAL_FUNCTIONS_218
];
455 SwashRingData swashR
;
456 FlightModeData_v218 flightModeData
[MAX_FLIGHT_MODES_218
];
460 swarnstate218_t switchWarningState
;
462 SWITCH_WARNING_DATA_218
464 GVarData_v218 gvars
[MAX_GVARS_218
];
466 FrSkyTelemetryData_v217 frsky
;
467 RssiAlarmData rssiAlarms
;
471 TelemetrySensor_218 telemetrySensors
[MAX_TELEMETRY_SENSORS_218
];
473 TARANIS_PCBX9E_FIELD(uint8_t toplcdTimer
)
475 // TODO conversion for custom screens?
479 #if defined(PCBHORUS)
480 #define EXTRA_GENERAL_FIELDS_218 \
481 uint8_t auxSerialMode:4; \
482 uint8_t slidersConfig:4; \
483 uint32_t switchConfig; \
484 uint8_t potsConfig; /* two bits per pot */ \
485 char switchNames[NUM_SWITCHES_218][LEN_SWITCH_NAME_218]; \
486 char anaNames[NUM_STICKS+3+4][LEN_ANA_NAME_218]; \
487 char currModelFilename[LEN_MODEL_FILENAME_218+1]; \
489 uint8_t blOffBright:7; \
490 char bluetoothName[LEN_BLUETOOTH_NAME_218];
491 #elif defined(PCBTARANIS)
492 #if defined(STORAGE_BLUETOOTH) && !defined(PCBX9D) && !defined(PCBX9DP)
493 #define BLUETOOTH_FIELDS_218 \
495 char bluetoothName[LEN_BLUETOOTH_NAME_218];
497 #define BLUETOOTH_FIELDS_218
499 #define EXTRA_GENERAL_FIELDS_218 \
500 uint8_t auxSerialMode:4; \
501 uint8_t slidersConfig:4; \
502 uint8_t potsConfig; /* two bits per pot */\
503 uint8_t backlightColor; \
504 swarnstate218_t switchUnlockStates; \
505 swconfig218_t switchConfig; \
506 char switchNames[NUM_SWITCHES_218][LEN_SWITCH_NAME_218]; \
507 char anaNames[NUM_STICKS+STORAGE_NUM_POTS+STORAGE_NUM_SLIDERS][LEN_ANA_NAME_218]; \
509 #elif defined(PCBSKY9X)
510 #define EXTRA_GENERAL_FIELDS_218 \
511 int8_t txCurrentCalibration; \
512 int8_t temperatureWarn; \
515 int8_t temperatureCalib; \
516 uint8_t optrexDisplay; \
517 uint8_t sticksGain; \
518 uint8_t rotarySteps; \
519 char switchNames[NUM_SWITCHES_218][LEN_SWITCH_NAME_218]; \
520 char anaNames[NUM_STICKS+STORAGE_NUM_POTS+STORAGE_NUM_SLIDERS][LEN_ANA_NAME_218];
522 #define EXTRA_GENERAL_FIELDS_218 EXTRA_GENERAL_FIELDS_GENERAL_218
525 #if defined(COLORLCD)
526 #include "gui/480x272/theme.h"
527 #define THEME_NAME_LEN 8
529 char themeName[THEME_NAME_LEN]; \
530 Theme::PersistentData themeData;
535 #if defined(PCBHORUS)
536 #define NUM_CALIBRATION_INPUTS 13
538 #define NUM_CALIBRATION_INPUTS (NUM_STICKS+STORAGE_NUM_POTS+STORAGE_NUM_SLIDERS)
541 PACK(struct RadioData_v218
{
544 CalibData calib
[NUM_CALIBRATION_INPUTS
];
546 N_HORUS_FIELD(int8_t currModel
);
547 N_HORUS_FIELD(uint8_t contrast
);
549 int8_t txVoltageCalibration
;
550 int8_t backlightMode
;
551 TrainerData_v218 trainer
;
552 uint8_t view
; // index of view in main screen
555 int8_t beepMode
:2; // -2=quiet, -1=only alarms, 0=no keys, 1=all
556 uint8_t alarmsFlash
:1;
557 uint8_t disableMemoryWarning
:1;
558 uint8_t disableAlarmWarning
:1;
562 uint8_t inactivityTimer
;
563 uint8_t telemetryBaudrate
:3;
566 int8_t switchesDelay
;
567 uint8_t lightAutoOff
;
568 uint8_t templateSetup
; // RETA order for receiver channels
569 int8_t PPM_Multiplier
;
571 N_HORUS_FIELD(N_TARANIS_FIELD(uint8_t reNavigation
));
572 N_HORUS_FIELD(N_TARANIS_FIELD(uint8_t stickReverse
));
574 int8_t hapticStrength
:3;
576 uint8_t unexpectedShutdown
:1;
577 uint8_t speakerPitch
;
578 int8_t speakerVolume
;
582 uint8_t backlightBright
;
583 uint32_t globalTimer
;
584 uint8_t bluetoothBaudrate
:4;
585 uint8_t bluetoothMode
:4;
588 uint8_t jitterFilter
:1; /* 0 - active */
589 uint8_t disableRssiPoweroffAlarm
:1;
591 uint8_t spareExtraArm
:3;
595 int8_t varioVolume
:4;
596 int8_t backgroundVolume
:4;
600 CustomFunctionData_v218 customFn
[MAX_SPECIAL_FUNCTIONS_218
];
602 EXTRA_GENERAL_FIELDS_218
609 #define CHKSIZE(x, y) check_size<struct x, y>()
611 static inline void check_struct_218()
613 #if defined(PCBHORUS)
614 CHKSIZE(ModelData_v218
, 9380);
615 #elif defined(PCBX9E)
616 CHKSIZE(ModelData_v218
, 6520);
617 #elif defined(PCBX9D)
618 CHKSIZE(RadioData_v218
, 872);
625 #endif //OPENTX_DATASTRUCTS_218_H