diff --git a/CHANGELOG b/CHANGELOG index 31329092..f3c63dc1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -21,6 +21,7 @@ * AS5x47 encoder support: https://github.com/vedderb/bldc/pull/511 * Disable BMS limit options. * Added PT1000 temperature sensor support. +* APP ADC button bitfield and CC disable support. === FW 5.03 === * Fixed inductance measurement bug. diff --git a/applications/app_adc.c b/applications/app_adc.c index 218d0a8c..14f3e0d0 100644 --- a/applications/app_adc.c +++ b/applications/app_adc.c @@ -259,11 +259,11 @@ static THD_FUNCTION(adc_thread, arg) { bool rev_button = false; if (use_rx_tx_as_buttons) { cc_button = !palReadPad(HW_UART_TX_PORT, HW_UART_TX_PIN); - if (config.cc_button_inverted) { + if ((config.buttons >> 1) & 1) { cc_button = !cc_button; } rev_button = !palReadPad(HW_UART_RX_PORT, HW_UART_RX_PIN); - if (config.rev_button_inverted) { + if ((config.buttons >> 2) & 1) { rev_button = !rev_button; } } else { @@ -274,29 +274,33 @@ static THD_FUNCTION(adc_thread, arg) { config.ctrl_type == ADC_CTRL_TYPE_DUTY_REV_BUTTON || config.ctrl_type == ADC_CTRL_TYPE_PID_REV_BUTTON) { rev_button = !palReadPad(HW_ICU_GPIO, HW_ICU_PIN); - if (config.rev_button_inverted) { + if ((config.buttons >> 2) & 1) { rev_button = !rev_button; } } else { cc_button = !palReadPad(HW_ICU_GPIO, HW_ICU_PIN); - if (config.cc_button_inverted) { + if ((config.buttons >> 1) & 1) { cc_button = !cc_button; } } } // Override button values, when used from LISP - if(buttons_detached){ + if (buttons_detached) { cc_button = cc_override; rev_button = rev_override; - if (config.cc_button_inverted) { + if ((config.buttons >> 1) & 1) { cc_button = !cc_button; } - if (config.cc_button_inverted) { - cc_button = !cc_button; + if ((config.buttons >> 2) & 1) { + rev_button = !rev_button; } } + if (!((config.buttons >> 0) & 1)) { + cc_button = false; + } + // All pins and buttons are still decoded for debugging, even // when output is disabled. if (app_is_output_disabled()) { diff --git a/applications/appconf_default.h b/applications/appconf_default.h index 2554e5ab..77012010 100755 --- a/applications/appconf_default.h +++ b/applications/appconf_default.h @@ -176,6 +176,9 @@ #ifndef APPCONF_ADC_SAFE_START #define APPCONF_ADC_SAFE_START true #endif +#ifndef APPCONF_ADC_BUTTONS +#define APPCONF_ADC_BUTTONS 0 +#endif #ifndef APPCONF_ADC_CC_BUTTON_INVERTED #define APPCONF_ADC_CC_BUTTON_INVERTED false #endif diff --git a/conf_general.h b/conf_general.h index a6d552b6..f369171f 100755 --- a/conf_general.h +++ b/conf_general.h @@ -24,7 +24,7 @@ #define FW_VERSION_MAJOR 6 #define FW_VERSION_MINOR 00 // Set to 0 for building a release and iterate during beta test builds -#define FW_TEST_VERSION_NUMBER 61 +#define FW_TEST_VERSION_NUMBER 62 #include "datatypes.h" diff --git a/confgenerator.c b/confgenerator.c index e4c635b8..60e31e1b 100644 --- a/confgenerator.c +++ b/confgenerator.c @@ -255,8 +255,7 @@ int32_t confgenerator_serialize_appconf(uint8_t *buffer, const app_configuration buffer_append_float16(buffer, conf->app_adc_conf.voltage2_end, 1000, &ind); buffer[ind++] = conf->app_adc_conf.use_filter; buffer[ind++] = conf->app_adc_conf.safe_start; - buffer[ind++] = conf->app_adc_conf.cc_button_inverted; - buffer[ind++] = conf->app_adc_conf.rev_button_inverted; + buffer[ind++] = conf->app_adc_conf.buttons; buffer[ind++] = conf->app_adc_conf.voltage_inverted; buffer[ind++] = conf->app_adc_conf.voltage2_inverted; buffer_append_float32_auto(buffer, conf->app_adc_conf.throttle_exp, &ind); @@ -650,8 +649,7 @@ bool confgenerator_deserialize_appconf(const uint8_t *buffer, app_configuration conf->app_adc_conf.voltage2_end = buffer_get_float16(buffer, 1000, &ind); conf->app_adc_conf.use_filter = buffer[ind++]; conf->app_adc_conf.safe_start = buffer[ind++]; - conf->app_adc_conf.cc_button_inverted = buffer[ind++]; - conf->app_adc_conf.rev_button_inverted = buffer[ind++]; + conf->app_adc_conf.buttons = buffer[ind++]; conf->app_adc_conf.voltage_inverted = buffer[ind++]; conf->app_adc_conf.voltage2_inverted = buffer[ind++]; conf->app_adc_conf.throttle_exp = buffer_get_float32_auto(buffer, &ind); @@ -1029,8 +1027,7 @@ void confgenerator_set_defaults_appconf(app_configuration *conf) { conf->app_adc_conf.voltage2_end = APPCONF_ADC_VOLTAGE2_END; conf->app_adc_conf.use_filter = APPCONF_ADC_USE_FILTER; conf->app_adc_conf.safe_start = APPCONF_ADC_SAFE_START; - conf->app_adc_conf.cc_button_inverted = APPCONF_ADC_CC_BUTTON_INVERTED; - conf->app_adc_conf.rev_button_inverted = APPCONF_ADC_REV_BUTTON_INVERTED; + conf->app_adc_conf.buttons = APPCONF_ADC_BUTTONS; conf->app_adc_conf.voltage_inverted = APPCONF_ADC_VOLTAGE_INVERTED; conf->app_adc_conf.voltage2_inverted = APPCONF_ADC_VOLTAGE2_INVERTED; conf->app_adc_conf.throttle_exp = APPCONF_ADC_THROTTLE_EXP; diff --git a/confgenerator.h b/confgenerator.h index a7414d69..7d98d7a5 100644 --- a/confgenerator.h +++ b/confgenerator.h @@ -9,7 +9,7 @@ // Constants #define MCCONF_SIGNATURE 1990552441 -#define APPCONF_SIGNATURE 3494444161 +#define APPCONF_SIGNATURE 372136320 // Functions int32_t confgenerator_serialize_mcconf(uint8_t *buffer, const mc_configuration *conf); diff --git a/datatypes.h b/datatypes.h index c3f9b735..a5616dc1 100644 --- a/datatypes.h +++ b/datatypes.h @@ -644,8 +644,7 @@ typedef struct { float voltage2_end; bool use_filter; SAFE_START_MODE safe_start; - bool cc_button_inverted; - bool rev_button_inverted; + uint8_t buttons; bool voltage_inverted; bool voltage2_inverted; float throttle_exp;