From 4a2ef89ea81160849554aa5a443c79b147ef7a40 Mon Sep 17 00:00:00 2001 From: jflyper Date: Fri, 21 Jul 2017 20:38:22 +0900 Subject: [PATCH] Revert left stick constraints and introduce context --- src/main/cms/cms.c | 12 ++++++------ src/main/cms/cms.h | 2 ++ src/main/fc/rc_controls.c | 8 ++++++++ src/test/unit/rc_controls_unittest.cc | 1 + 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/cms/cms.c b/src/main/cms/cms.c index 00fe8d2d3b..6590dfe880 100644 --- a/src/main/cms/cms.c +++ b/src/main/cms/cms.c @@ -130,7 +130,7 @@ static displayPort_t *cmsDisplayPortSelectNext(void) #define RIGHT_MENU_COLUMN(p) ((p)->cols - 8) #define MAX_MENU_ITEMS(p) ((p)->rows - 2) -static bool cmsInMenu = false; +bool cmsInMenu = false; typedef struct cmsCtx_s { const CMS_Menu *menu; // menu for this context @@ -913,19 +913,19 @@ void cmsUpdate(uint32_t currentTimeUs) if (IS_MID(THROTTLE) && IS_LO(YAW) && IS_HI(PITCH) && !ARMING_FLAG(ARMED)) { key = KEY_MENU; } - else if (IS_MID(THROTTLE) && IS_MID(YAW) && IS_MID(ROLL) && IS_HI(PITCH)) { + else if (IS_HI(PITCH)) { key = KEY_UP; } - else if (IS_MID(THROTTLE) && IS_MID(YAW) && IS_MID(ROLL) && IS_LO(PITCH)) { + else if (IS_LO(PITCH)) { key = KEY_DOWN; } - else if (IS_MID(THROTTLE) && IS_MID(YAW) && IS_LO(ROLL) && IS_MID(PITCH)) { + else if (IS_LO(ROLL)) { key = KEY_LEFT; } - else if (IS_MID(THROTTLE) && IS_MID(YAW) && IS_HI(ROLL) && IS_MID(PITCH)) { + else if (IS_HI(ROLL)) { key = KEY_RIGHT; } - else if ((IS_HI(YAW) || IS_LO(YAW)) && IS_MID(THROTTLE) && IS_MID(ROLL) && IS_MID(PITCH)) + else if (IS_HI(YAW) || IS_LO(YAW)) { key = KEY_ESC; } diff --git a/src/main/cms/cms.h b/src/main/cms/cms.h index 6667c3d3cb..aeafdda0e7 100644 --- a/src/main/cms/cms.h +++ b/src/main/cms/cms.h @@ -4,6 +4,8 @@ #include "common/time.h" +extern bool cmsInMenu; + // Device management bool cmsDisplayPortRegister(displayPort_t *pDisplay); diff --git a/src/main/fc/rc_controls.c b/src/main/fc/rc_controls.c index 5a7bec6ab1..72f8a6de81 100644 --- a/src/main/fc/rc_controls.c +++ b/src/main/fc/rc_controls.c @@ -34,6 +34,8 @@ #include "config/parameter_group.h" #include "config/parameter_group_ids.h" +#include "cms/cms.h" + #include "drivers/camera_control.h" #include "fc/config.h" @@ -124,6 +126,12 @@ void processRcStickPositions(throttleStatus_e throttleStatus) uint8_t stTmp = 0; int i; +#ifdef CMS + if (cmsInMenu) { + return; + } +#endif + // ------------------ STICKS COMMAND HANDLER -------------------- // checking sticks positions for (i = 0; i < 4; i++) { diff --git a/src/test/unit/rc_controls_unittest.cc b/src/test/unit/rc_controls_unittest.cc index edd846db68..1e85421cdc 100644 --- a/src/test/unit/rc_controls_unittest.cc +++ b/src/test/unit/rc_controls_unittest.cc @@ -695,6 +695,7 @@ void baroSetCalibrationCycles(uint16_t) {} void blackboxLogEvent(FlightLogEvent, flightLogEventData_t *) {} +bool cmsInMenu = false; uint8_t armingFlags = 0; int16_t heading; uint8_t stateFlags = 0;