1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 13:25:30 +03:00

Added custom (switch) box naming.

This commit is contained in:
mikeller 2020-03-12 06:56:24 +13:00
parent acdccd5a16
commit f3ec114a2a
8 changed files with 52 additions and 6 deletions

View file

@ -1612,6 +1612,14 @@ const clivalue_t valueTable[] = {
// PG_POSITION // PG_POSITION
{ "position_alt_source", VAR_INT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_POSITION_ALT_SOURCE }, PG_POSITION, offsetof(positionConfig_t, altSource) }, { "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); const uint16_t valueTableEntryCount = ARRAYLEN(valueTable);

View file

@ -27,8 +27,6 @@
#define MAX_NAME_LENGTH 16u #define MAX_NAME_LENGTH 16u
#define MAX_PROFILE_NAME_LENGTH 8u
typedef enum { typedef enum {
CONFIGURATION_STATE_DEFAULTS_BARE = 0, CONFIGURATION_STATE_DEFAULTS_BARE = 0,
CONFIGURATION_STATE_DEFAULTS_CUSTOM, 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); 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) bool IS_RC_MODE_ACTIVE(boxId_e boxId)
{ {
return bitArrayGet(&rcModeActivationMask, 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); 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 { typedef struct modeActivationProfile_s {
modeActivationCondition_t modeActivationConditions[MAX_MODE_ACTIVATION_CONDITION_COUNT]; modeActivationCondition_t modeActivationConditions[MAX_MODE_ACTIVATION_CONDITION_COUNT];
} modeActivationProfile_t; } modeActivationProfile_t;

View file

@ -130,8 +130,21 @@ static bool activeBoxIdGet(boxId_e boxId)
} }
void serializeBoxNameFn(sbuf_t *dst, const box_t *box) void serializeBoxNameFn(sbuf_t *dst, const box_t *box)
{
#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); sbufWriteString(dst, box->boxName);
}
sbufWriteU8(dst, ';'); sbufWriteU8(dst, ';');
} }

View file

@ -96,7 +96,7 @@
// betaflight specific parameter group ids start at 500 // betaflight specific parameter group ids start at 500
#define PG_BETAFLIGHT_START 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_OSD_CONFIG 501
#define PG_BEEPER_CONFIG 502 #define PG_BEEPER_CONFIG 502
#define PG_BEEPER_DEV_CONFIG 503 #define PG_BEEPER_DEV_CONFIG 503
@ -149,7 +149,8 @@
#define PG_SDIO_PIN_CONFIG 550 #define PG_SDIO_PIN_CONFIG 550
#define PG_PULLUP_CONFIG 551 #define PG_PULLUP_CONFIG 551
#define PG_PULLDOWN_CONFIG 552 #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) // OSD configuration (subject to change)

View file

@ -34,6 +34,6 @@
PG_REGISTER_WITH_RESET_TEMPLATE(pinioBoxConfig_t, pinioBoxConfig, PG_PINIOBOX_CONFIG, 1); PG_REGISTER_WITH_RESET_TEMPLATE(pinioBoxConfig_t, pinioBoxConfig, PG_PINIOBOX_CONFIG, 1);
PG_RESET_TEMPLATE(pinioBoxConfig_t, pinioBoxConfig, 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 #endif

View file

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