Merge pull request #9578 from mikeller/add_custom_box_names

Added custom (switch) box naming.
This commit is contained in:
Michael Keller 2020-03-13 13:16:07 +13:00 committed by GitHub
commit d9fedb5024
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 52 additions and 6 deletions

View File

@ -1612,6 +1612,14 @@ const clivalue_t valueTable[] = {
// PG_POSITION
{ "position_alt_source", VAR_INT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_POSITION_ALT_SOURCE }, PG_POSITION, offsetof(positionConfig_t, altSource) },
// PG_MODE_ACTIVATION_CONFIG
#if defined(USE_CUSTOM_BOX_NAMES)
{ "box_user_1_name", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_BOX_USER_NAME_LENGTH, STRING_FLAGS_NONE }, PG_MODE_ACTIVATION_CONFIG, offsetof(modeActivationConfig_t, box_user_1_name) },
{ "box_user_2_name", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_BOX_USER_NAME_LENGTH, STRING_FLAGS_NONE }, PG_MODE_ACTIVATION_CONFIG, offsetof(modeActivationConfig_t, box_user_2_name) },
{ "box_user_3_name", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_BOX_USER_NAME_LENGTH, STRING_FLAGS_NONE }, PG_MODE_ACTIVATION_CONFIG, offsetof(modeActivationConfig_t, box_user_3_name) },
{ "box_user_4_name", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_BOX_USER_NAME_LENGTH, STRING_FLAGS_NONE }, PG_MODE_ACTIVATION_CONFIG, offsetof(modeActivationConfig_t, box_user_4_name) },
#endif
};
const uint16_t valueTableEntryCount = ARRAYLEN(valueTable);

View File

@ -27,8 +27,6 @@
#define MAX_NAME_LENGTH 16u
#define MAX_PROFILE_NAME_LENGTH 8u
typedef enum {
CONFIGURATION_STATE_DEFAULTS_BARE = 0,
CONFIGURATION_STATE_DEFAULTS_CUSTOM,

View File

@ -54,6 +54,17 @@ static uint8_t activeLinkedMacArray[MAX_MODE_ACTIVATION_CONDITION_COUNT];
PG_REGISTER_ARRAY(modeActivationCondition_t, MAX_MODE_ACTIVATION_CONDITION_COUNT, modeActivationConditions, PG_MODE_ACTIVATION_PROFILE, 2);
#if defined(USE_CUSTOM_BOX_NAMES)
PG_REGISTER_WITH_RESET_TEMPLATE(modeActivationConfig_t, modeActivationConfig, PG_MODE_ACTIVATION_CONFIG, 0);
PG_RESET_TEMPLATE(modeActivationConfig_t, modeActivationConfig,
.box_user_1_name = { 0 },
.box_user_2_name = { 0 },
.box_user_3_name = { 0 },
.box_user_4_name = { 0 },
);
#endif
bool IS_RC_MODE_ACTIVE(boxId_e boxId)
{
return bitArrayGet(&rcModeActivationMask, boxId);

View File

@ -115,6 +115,20 @@ typedef struct modeActivationCondition_s {
PG_DECLARE_ARRAY(modeActivationCondition_t, MAX_MODE_ACTIVATION_CONDITION_COUNT, modeActivationConditions);
#if defined(USE_CUSTOM_BOX_NAMES)
#define MAX_BOX_USER_NAME_LENGTH 16
typedef struct modeActivationConfig_s {
char box_user_1_name[MAX_BOX_USER_NAME_LENGTH];
char box_user_2_name[MAX_BOX_USER_NAME_LENGTH];
char box_user_3_name[MAX_BOX_USER_NAME_LENGTH];
char box_user_4_name[MAX_BOX_USER_NAME_LENGTH];
} modeActivationConfig_t;
PG_DECLARE(modeActivationConfig_t, modeActivationConfig);
#endif
typedef struct modeActivationProfile_s {
modeActivationCondition_t modeActivationConditions[MAX_MODE_ACTIVATION_CONDITION_COUNT];
} modeActivationProfile_t;

View File

@ -131,7 +131,20 @@ static bool activeBoxIdGet(boxId_e boxId)
void serializeBoxNameFn(sbuf_t *dst, const box_t *box)
{
sbufWriteString(dst, box->boxName);
#if defined(USE_CUSTOM_BOX_NAMES)
if (box->boxId == BOXUSER1 && strlen(modeActivationConfig()->box_user_1_name) > 0) {
sbufWriteString(dst, modeActivationConfig()->box_user_1_name);
} else if (box->boxId == BOXUSER2 && strlen(modeActivationConfig()->box_user_2_name) > 0) {
sbufWriteString(dst, modeActivationConfig()->box_user_2_name);
} else if (box->boxId == BOXUSER3 && strlen(modeActivationConfig()->box_user_3_name) > 0) {
sbufWriteString(dst, modeActivationConfig()->box_user_3_name);
} else if (box->boxId == BOXUSER4 && strlen(modeActivationConfig()->box_user_4_name) > 0) {
sbufWriteString(dst, modeActivationConfig()->box_user_4_name);
} else
#endif
{
sbufWriteString(dst, box->boxName);
}
sbufWriteU8(dst, ';');
}

View File

@ -96,7 +96,7 @@
// betaflight specific parameter group ids start at 500
#define PG_BETAFLIGHT_START 500
#define PG_MODE_ACTIVATION_OPERATOR_CONFIG 500
//#define PG_MODE_ACTIVATION_OPERATOR_CONFIG 500 removed
#define PG_OSD_CONFIG 501
#define PG_BEEPER_CONFIG 502
#define PG_BEEPER_DEV_CONFIG 503
@ -149,7 +149,8 @@
#define PG_SDIO_PIN_CONFIG 550
#define PG_PULLUP_CONFIG 551
#define PG_PULLDOWN_CONFIG 552
#define PG_BETAFLIGHT_END 552
#define PG_MODE_ACTIVATION_CONFIG 553
#define PG_BETAFLIGHT_END 553
// OSD configuration (subject to change)

View File

@ -34,6 +34,6 @@
PG_REGISTER_WITH_RESET_TEMPLATE(pinioBoxConfig_t, pinioBoxConfig, PG_PINIOBOX_CONFIG, 1);
PG_RESET_TEMPLATE(pinioBoxConfig_t, pinioBoxConfig,
{ PERMANENT_ID_NONE, PERMANENT_ID_NONE, PERMANENT_ID_NONE, PERMANENT_ID_NONE }
{ PERMANENT_ID_NONE, PERMANENT_ID_NONE, PERMANENT_ID_NONE, PERMANENT_ID_NONE },
);
#endif

View File

@ -366,4 +366,5 @@
#define USE_PROFILE_NAMES
#define USE_SERIALRX_SRXL2 // Spektrum SRXL2 protocol
#define USE_INTERPOLATED_SP
#define USE_CUSTOM_BOX_NAMES
#endif