diff --git a/src/main/config/config.c b/src/main/config/config.c index 4aeafee01..1d51b693b 100755 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -98,7 +98,7 @@ void mixerUseConfigs(servoParam_t *servoConfToUse, flight3DConfig_t *flight3DCon master_t masterConfig; // master config struct with data independent from profiles profile_t *currentProfile; // profile config struct -static const uint8_t EEPROM_CONF_VERSION = 77; +static const uint8_t EEPROM_CONF_VERSION = 78; static void resetAccelerometerTrims(flightDynamicsTrims_t *accelerometerTrims) { diff --git a/src/main/config/config.h b/src/main/config/config.h index ec700aa20..e2a7fedd6 100644 --- a/src/main/config/config.h +++ b/src/main/config/config.h @@ -34,8 +34,9 @@ typedef enum { FEATURE_RX_PARALLEL_PWM = 1 << 13, FEATURE_RX_MSP = 1 << 14, FEATURE_RSSI_ADC = 1 << 15, - FEATURE_LED_STRIP = 1 << 16 -} AvailableFeatures; + FEATURE_LED_STRIP = 1 << 16, + FEATURE_DISPLAY = 1 << 17 +} features_e; bool feature(uint32_t mask); void featureSet(uint32_t mask); diff --git a/src/main/io/display.c b/src/main/io/display.c index f4fbb0df4..ee7c1fbef 100644 --- a/src/main/io/display.c +++ b/src/main/io/display.c @@ -54,23 +54,33 @@ uint32_t nextPageAt = 0; char lineBuffer[SCREEN_CHARACTER_COLUMN_COUNT]; typedef enum { + PAGE_ARMED, PAGE_BATTERY, PAGE_SENSORS } pageId_e; const char* pageTitles[] = { + "ARMED", "BATTERY", "SENSORS" }; #define PAGE_COUNT (PAGE_SENSORS + 1) +const uint8_t cyclePageIds[] = { + PAGE_BATTERY, + PAGE_SENSORS +}; + +#define CYCLE_PAGE_ID_COUNT (sizeof(cyclePageIds) / sizeof(cyclePageIds[0])) + static const char* tickerCharacters = "|/-\\"; #define TICKER_CHARACTER_COUNT (sizeof(tickerCharacters) / sizeof(char)) typedef struct pageState_s { bool pageChanging; pageId_e pageId; + uint8_t cycleIndex; } pageState_t; static pageState_t pageState; @@ -131,6 +141,10 @@ void handlePageChange(void) showTitle(); } +void showArmedPage(void) +{ +} + void showBatteryPage(void) { tfp_sprintf(lineBuffer, "volts: %d.%d, cells: %d", vbat / 10, vbat % 10, batteryCellCount); @@ -170,6 +184,7 @@ void showSensorsPage(void) void updateDisplay(void) { uint32_t now = micros(); + static uint8_t previousArmedState = 0; bool updateNow = (int32_t)(now - nextDisplayUpdateAt) >= 0L; if (!updateNow) { @@ -178,20 +193,35 @@ void updateDisplay(void) nextDisplayUpdateAt = now + DISPLAY_UPDATE_FREQUENCY; - if (ARMING_FLAG(ARMED)) { - return; + bool armedState = ARMING_FLAG(ARMED) ? true : false; + bool armedStateChanged = armedState != previousArmedState; + previousArmedState = armedState; + + if (armedState) { + if (!armedStateChanged) { + return; + } + pageState.pageId = PAGE_ARMED; + pageState.pageChanging = true; + } else { + if (armedStateChanged) { + nextPageAt = now; + pageState.cycleIndex = CYCLE_PAGE_ID_COUNT; + } + pageState.pageChanging = (int32_t)(now - nextPageAt) >= 0L; + if (pageState.pageChanging) { + nextPageAt = now + PAGE_CYCLE_FREQUENCY; + pageState.cycleIndex++; + pageState.cycleIndex = pageState.cycleIndex % CYCLE_PAGE_ID_COUNT; + pageState.pageId = cyclePageIds[pageState.cycleIndex]; + } } - pageState.pageChanging = (int32_t)(now - nextPageAt) >= 0L; - if (pageState.pageChanging) { - nextPageAt = now + PAGE_CYCLE_FREQUENCY; - pageState.pageId++; - pageState.pageId = pageState.pageId % PAGE_COUNT; + if (pageState.pageChanging) { handlePageChange(); } - switch(pageState.pageId) { case PAGE_BATTERY: showBatteryPage(); @@ -199,9 +229,13 @@ void updateDisplay(void) case PAGE_SENSORS: showSensorsPage(); break; + case PAGE_ARMED: + showArmedPage(); + break; + } + if (!armedState) { + updateTicker(); } - - updateTicker(); } diff --git a/src/main/io/serial_cli.c b/src/main/io/serial_cli.c index a3a496a61..aaa2e4ca3 100644 --- a/src/main/io/serial_cli.c +++ b/src/main/io/serial_cli.c @@ -99,7 +99,7 @@ uint8_t cliMode = 0; static char cliBuffer[48]; static uint32_t bufferIndex = 0; -// sync this with MultiType enum from mw.h +// sync this with mutiType_e static const char * const mixerNames[] = { "TRI", "QUADP", "QUADX", "BI", "GIMBAL", "Y6", "HEX6", @@ -109,15 +109,15 @@ static const char * const mixerNames[] = { "CUSTOM", NULL }; -// sync this with AvailableFeatures enum from board.h +// sync this with features_e static const char * const featureNames[] = { "RX_PPM", "VBAT", "INFLIGHT_ACC_CAL", "RX_SERIAL", "MOTOR_STOP", "SERVO_TILT", "SOFTSERIAL", "GPS", "FAILSAFE", "SONAR", "TELEMETRY", "CURRENT_METER", "3D", "RX_PARALLEL_PWM", - "RX_MSP", "RSSI_ADC", "LED_STRIP", NULL + "RX_MSP", "RSSI_ADC", "LED_STRIP", "DISPLAY", NULL }; -// sync this with AvailableSensors enum from board.h +// sync this with sensors_e static const char * const sensorNames[] = { "GYRO", "ACC", "BARO", "MAG", "SONAR", "GPS", "GPS+MAG", NULL }; diff --git a/src/main/main.c b/src/main/main.c index 8965325ae..2785afd6c 100755 --- a/src/main/main.c +++ b/src/main/main.c @@ -139,7 +139,9 @@ void init(void) initBoardAlignment(&masterConfig.boardAlignment); #ifdef DISPLAY - displayInit(); + if (feature(FEATURE_DISPLAY)) { + displayInit(); + } #endif // We have these sensors; SENSORS_SET defined in board.h depending on hardware platform diff --git a/src/main/mw.c b/src/main/mw.c index c439a0d4b..df311033e 100755 --- a/src/main/mw.c +++ b/src/main/mw.c @@ -434,7 +434,9 @@ void executePeriodicTasks(void) #endif #ifdef DISPLAY case UPDATE_DISPLAY_TASK: - updateDisplay(); + if (feature(FEATURE_DISPLAY)) { + updateDisplay(); + } break; #endif } diff --git a/src/main/sensors/sensors.h b/src/main/sensors/sensors.h index f893f531b..81d82a9f8 100644 --- a/src/main/sensors/sensors.h +++ b/src/main/sensors/sensors.h @@ -29,7 +29,7 @@ typedef enum { SENSOR_SONAR = 1 << 4, SENSOR_GPS = 1 << 5, SENSOR_GPSMAG = 1 << 6, -} AvailableSensors; +} sensors_e; typedef enum { ALIGN_DEFAULT = 0, // driver-provided alignment