# HG changeset patch # User ideenmodellierer # Date 1566229187 -7200 # Node ID fca370f847f84013c29a6858ce30d26576e8e662 # Parent 77cdfbdaca8ced9014fe7b9351691cbe29832901 Added parameter for number of sectors to be defined diff -r 77cdfbdaca8c -r fca370f847f8 Discovery/Inc/motion.h --- a/Discovery/Inc/motion.h Tue Aug 13 21:13:54 2019 +0200 +++ b/Discovery/Inc/motion.h Mon Aug 19 17:39:47 2019 +0200 @@ -10,6 +10,7 @@ /* exported data types */ +#define CUSTOMER_DEFINED_VIEWS (100u) /* value will cause the function to detect the numer of selected views */ typedef enum { @@ -39,7 +40,7 @@ } SSector; void InitMotionDetection(void); -void DefinePitchSectors(float centerAngle); +void DefinePitchSectors(float centerAngle, uint8_t numOfSectors); detectionState_t detectPitch(float currentPitch); detectionState_t detectSectorButtonEvent(float curPitch); diff -r 77cdfbdaca8c -r fca370f847f8 Discovery/Src/base.c --- a/Discovery/Src/base.c Tue Aug 13 21:13:54 2019 +0200 +++ b/Discovery/Src/base.c Mon Aug 19 17:39:47 2019 +0200 @@ -904,7 +904,7 @@ tHome_change_customview_button_pressed(action); if((settingsGetPointer()->MotionDetection == MOTION_DETECT_SECTOR) && (action == ACTION_BUTTON_ENTER)) /* Button pressed while sector detection is active => calibrate to current pitch value */ { - DefinePitchSectors(stateRealGetPointer()->lifeData.compass_pitch); + DefinePitchSectors(stateRealGetPointer()->lifeData.compass_pitch,CUSTOMER_DEFINED_VIEWS); } } else if (status.page == PageSurface) diff -r 77cdfbdaca8c -r fca370f847f8 Discovery/Src/motion.c --- a/Discovery/Src/motion.c Tue Aug 13 21:13:54 2019 +0200 +++ b/Discovery/Src/motion.c Mon Aug 19 17:39:47 2019 +0200 @@ -11,6 +11,7 @@ #include "motion.h" #include "data_central.h" #include "t7.h" +#include "settings.h" #define STABLE_STATE_COUNT 2 /* number of count to declare a state as stable (at the moment based on 100ms) */ #define STABLE_STATE_TIMEOUT 5 /* Detection shall be aborted if a movement state is stable for more than 500ms */ @@ -24,6 +25,7 @@ #define SECTOR_BORDER 400.0 /* Define a value which is out of limit to avoid not wanted key events */ #define SECTOR_FILTER 10 /* Define speed for calculated angle to follow real value */ +#define SECTOR_MAX 10 /* maximum number of sectors */ static detectionState_t detectionState = DETECT_NOTHING; @@ -61,11 +63,22 @@ return sector; } -void DefinePitchSectors(float centerPitch) +void DefinePitchSectors(float centerPitch,uint8_t numOfSectors) { uint8_t index; - sectorCount = t7_GetEnabled_customviews(); + if(numOfSectors == CUSTOMER_DEFINED_VIEWS) + { + sectorCount = t7_GetEnabled_customviews(); + if(sectorCount > 5) + { + sectorCount = 5; /* more views are hard to manually control */ + } + } + else + { + sectorCount = numOfSectors; + } sectorSize = SECTOR_WINDOW / sectorCount; PitchSector[0].upperlimit = centerPitch + (SECTOR_WINDOW / 2); @@ -91,7 +104,17 @@ curSector = 0; sectorSize = 0; sectorCount = 0; - DefinePitchSectors(0); + + switch(settingsGetPointer()->MotionDetection) + { + case MOTION_DETECT_SECTOR: DefinePitchSectors(0,CUSTOMER_DEFINED_VIEWS); + break; + case MOTION_DETECT_MOVE: DefinePitchSectors(0,SECTOR_MAX); + break; + default: + break; + } + } /* Map the current pitch value to a sector and create button event in case the sector is left */