Allow PPM Slave/jack trainer limits set in dataconstants.h

This commit is contained in:
Cliff
2021-09-13 19:36:37 -07:00
parent 6278335eb9
commit 0932636bea
2 changed files with 22 additions and 17 deletions
+6
View File
@@ -46,6 +46,8 @@
#define MAX_SPECIAL_FUNCTIONS 64 // number of functions assigned to switches #define MAX_SPECIAL_FUNCTIONS 64 // number of functions assigned to switches
#define MAX_SCRIPTS 9 #define MAX_SCRIPTS 9
#define MAX_INPUTS 32 #define MAX_INPUTS 32
#define MIN_TRAINER_CHANNELS 4
#define DEF_TRAINER_CHANNELS 8
#define MAX_TRAINER_CHANNELS 16 #define MAX_TRAINER_CHANNELS 16
#define MAX_TELEMETRY_SENSORS 60 #define MAX_TELEMETRY_SENSORS 60
#define MAX_CUSTOM_SCREENS 5 #define MAX_CUSTOM_SCREENS 5
@@ -59,6 +61,8 @@
#define MAX_SPECIAL_FUNCTIONS 64 // number of functions assigned to switches #define MAX_SPECIAL_FUNCTIONS 64 // number of functions assigned to switches
#define MAX_SCRIPTS 7 #define MAX_SCRIPTS 7
#define MAX_INPUTS 32 #define MAX_INPUTS 32
#define MIN_TRAINER_CHANNELS 4
#define DEF_TRAINER_CHANNELS 8
#define MAX_TRAINER_CHANNELS 16 #define MAX_TRAINER_CHANNELS 16
#define MAX_TELEMETRY_SENSORS 60 #define MAX_TELEMETRY_SENSORS 60
#elif defined(PCBTARANIS) #elif defined(PCBTARANIS)
@@ -71,6 +75,8 @@
#define MAX_SPECIAL_FUNCTIONS 64 // number of functions assigned to switches #define MAX_SPECIAL_FUNCTIONS 64 // number of functions assigned to switches
#define MAX_SCRIPTS 7 #define MAX_SCRIPTS 7
#define MAX_INPUTS 32 #define MAX_INPUTS 32
#define MIN_TRAINER_CHANNELS 4
#define DEF_TRAINER_CHANNELS 8
#define MAX_TRAINER_CHANNELS 16 #define MAX_TRAINER_CHANNELS 16
#define MAX_TELEMETRY_SENSORS 40 #define MAX_TELEMETRY_SENSORS 40
#else #else
+16 -17
View File
@@ -606,37 +606,36 @@ class TrainerModuleWindow : public FormGroup
} else } else
#endif #endif
if (g_model.trainerData.mode == TRAINER_MODE_SLAVE) { if (g_model.trainerData.mode == TRAINER_MODE_SLAVE) {
#define PPMCH_START_MIN 1
#define PPMCH_START_MAX (MAX_OUTPUT_CHANNELS - g_model.trainerData.channelsCount + 1 - DEF_TRAINER_CHANNELS)
#define PPMCH_END_MIN (g_model.trainerData.channelsStart + MIN_TRAINER_CHANNELS)
#define PPMCH_END_MAX min<uint8_t>(g_model.trainerData.channelsStart + MAX_TRAINER_CHANNELS, MAX_OUTPUT_CHANNELS)
new StaticText(this, grid.getLabelSlot(true), STR_CHANNELRANGE, 0, new StaticText(this, grid.getLabelSlot(true), STR_CHANNELRANGE, 0,
COLOR_THEME_PRIMARY1); COLOR_THEME_PRIMARY1);
channelStart = new NumberEdit( channelStart = new NumberEdit(
this, grid.getFieldSlot(2, 0), 1, this, grid.getFieldSlot(2, 0), PPMCH_START_MIN, PPMCH_START_MAX,
MAX_OUTPUT_CHANNELS - 8 + g_model.trainerData.channelsCount + 1,
GET_DEFAULT(1 + g_model.trainerData.channelsStart)); GET_DEFAULT(1 + g_model.trainerData.channelsStart));
channelEnd = channelEnd = new NumberEdit(
new NumberEdit(this, grid.getFieldSlot(2, 1), this, grid.getFieldSlot(2, 1), PPMCH_END_MIN, PPMCH_END_MAX,
g_model.trainerData.channelsStart + 1, GET_DEFAULT((g_model.trainerData.channelsStart +
min<int8_t>(MAX_TRAINER_CHANNELS, DEF_TRAINER_CHANNELS +
g_model.trainerData.channelsStart + g_model.trainerData.channelsCount)));
MAX_TRAINER_CHANNELS_M8),
GET_DEFAULT(g_model.trainerData.channelsStart + 8 +
g_model.trainerData.channelsCount));
channelStart->setPrefix(STR_CH); channelStart->setPrefix(STR_CH);
channelEnd->setPrefix(STR_CH); channelEnd->setPrefix(STR_CH);
channelStart->setSetValueHandler([=](int32_t newValue) { channelStart->setSetValueHandler([=](int32_t newValue) {
g_model.trainerData.channelsStart = newValue - 1; g_model.trainerData.channelsStart = newValue - 1;
SET_DIRTY(); SET_DIRTY();
channelEnd->setMin(g_model.trainerData.channelsStart + 1); channelEnd->setMin(PPMCH_END_MIN);
channelEnd->setMax(min<int8_t>( channelEnd->setMax(PPMCH_END_MAX);
MAX_TRAINER_CHANNELS,
g_model.trainerData.channelsStart + MAX_TRAINER_CHANNELS_M8));
channelEnd->invalidate(); channelEnd->invalidate();
}); });
channelEnd->setSetValueHandler([=](int32_t newValue) { channelEnd->setSetValueHandler([=](int32_t newValue) {
g_model.trainerData.channelsCount = g_model.trainerData.channelsCount =
newValue - g_model.trainerData.channelsStart - 8; newValue - g_model.trainerData.channelsStart -
DEF_TRAINER_CHANNELS;
SET_DIRTY(); SET_DIRTY();
channelStart->setMax(MAX_TRAINER_CHANNELS - 8 + channelStart->setMax(PPMCH_START_MAX);
g_model.trainerData.channelsCount + 1);
}); });
grid.nextLine(); grid.nextLine();