Mercurial > public > ostc4
diff Discovery/Src/t7.c @ 387:0dbb74be972f
Merged in Ideenmodellierer/ostc4/MotionDetection (pull request #34)
MotionDetection
author | heinrichsweikamp <bitbucket@heinrichsweikamp.com> |
---|---|
date | Sun, 24 Nov 2019 15:46:58 +0000 |
parents | 14fd5f35cb50 |
children | b57f497726f7 |
line wrap: on
line diff
--- a/Discovery/Src/t7.c Sun Nov 24 16:08:29 2019 +0100 +++ b/Discovery/Src/t7.c Sun Nov 24 15:46:58 2019 +0000 @@ -38,6 +38,7 @@ #include "simulation.h" #include "timer.h" #include "unit.h" +#include "motion.h" /* Private function prototypes -----------------------------------------------*/ @@ -570,6 +571,8 @@ selection_customview = CVIEW_noneOrDebug; else selection_customview = settingsGetPointer()->tX_customViewPrimary; + + InitMotionDetection(); } if(status.page == PageSurface) @@ -600,6 +603,7 @@ { last_mode = MODE_SURFACE; selection_customview = customviewsSurface[0]; + InitMotionDetection(); } if(status.page == PageDive) set_globalState(StS); @@ -1440,64 +1444,144 @@ selection_customview = settingsGetPointer()->tX_customViewPrimary; } -void t7_change_customview(void) +uint8_t t7_GetEnabled_customviews() { - const uint8_t *pViews; + int8_t i; + uint8_t *pViews; + uint8_t increment = 1; + + uint8_t enabledViewCnt = 0; + uint32_t cv_config = settingsGetPointer()->cv_configuration; + + if(stateUsed->mode == MODE_DIVE) + pViews = (uint8_t*)customviewsDive; + else + pViews = (uint8_t*)customviewsSurface; + + while((*pViews != CVIEW_END)) + { + increment = 1; + /* check if view is enabled */ + i=0; + do + { + if(*pViews == cv_changelist[i]) + { + if(!CHECK_BIT_THOME(cv_config, cv_changelist[i])) + { + increment = 0; + } + break; + } + i++; + } while(cv_changelist[i] != CVIEW_END); + if(cv_changelist[i] == CVIEW_END) + { + increment = 0; + } + if (((*pViews == CVIEW_sensors) || (*pViews == CVIEW_sensors_mV)) && + ((stateUsed->diveSettings.ppo2sensors_deactivated) || (stateUsed->diveSettings.ccrOption == 0))) + { + increment = 0; + } + + pViews++; + enabledViewCnt += increment; + } + return enabledViewCnt; +} + +void t7_change_customview(uint8_t action) +{ + int8_t i; + uint8_t *pViews; + uint8_t *pStartView,*pCurView, *pLastView; _Bool cv_disabled = 0; if(stateUsed->mode == MODE_DIVE) - pViews = customviewsDive; + pViews = (uint8_t*)customviewsDive; else - pViews = customviewsSurface; - - while((*pViews != CVIEW_END) && (*pViews != selection_customview)) - {pViews++;} - - if(*pViews < CVIEW_END) - pViews++; - - - if(*pViews == CVIEW_END) + pViews = (uint8_t*)customviewsSurface; + + pStartView = pViews; + /* set pointer to currently selected view and count number of entries */ + while((*pViews != CVIEW_END)) + { + if (*pViews == selection_customview) + { + pCurView = pViews; + } + pViews++; + } + pLastView = pViews; + pViews = pCurView; + + if((action == ACTION_BUTTON_ENTER) || (action == ACTION_PITCH_POS)) { - if(stateUsed->mode == MODE_DIVE) - pViews = customviewsDive; - else - pViews = customviewsSurface; + if(*pViews < CVIEW_END) + pViews++; + + if(*pViews == CVIEW_END) + { + pViews = pStartView; + } } - - if(stateUsed->mode == MODE_DIVE) + else { - do + if(pViews == pStartView) + { + pViews = pLastView - 1; + } + else + { + pViews--; + } + } + + do + { + cv_disabled = 0; + i=0; + while(cv_changelist[i] != CVIEW_END) { - cv_disabled = 0; - for(int i=0;i<6;i++) - { - if((*pViews == cv_changelist[i]) && !CHECK_BIT_THOME(settingsGetPointer()->cv_configuration, cv_changelist[i])) - { - cv_disabled = 1; - break; - } - } - - if ((*pViews == CVIEW_sensors || *pViews == CVIEW_sensors_mV) && - stateUsed->diveSettings.ppo2sensors_deactivated) - { - cv_disabled = 1; - } - - if(cv_disabled) - { - if(*pViews < CVIEW_END) - { - pViews++; - } - else - { - pViews = customviewsDive; - } - } - } while(cv_disabled); - } + if((*pViews == cv_changelist[i]) && !CHECK_BIT_THOME(settingsGetPointer()->cv_configuration, cv_changelist[i])) + { + cv_disabled = 1; + break; + } + i++; + } + + if (((*pViews == CVIEW_sensors) || (*pViews == CVIEW_sensors_mV)) && + ((stateUsed->diveSettings.ppo2sensors_deactivated) || (stateUsed->diveSettings.ccrOption == 0))) + { + cv_disabled = 1; + } + + if(cv_disabled) /* view is disabled => jump to next view */ + { + if((action == ACTION_BUTTON_ENTER) || (action == ACTION_PITCH_POS)) + { + pViews++; + if(*pViews == CVIEW_END) + { + pViews = pStartView; + } + } + else + { + if(pViews == pStartView) + { + pViews = pLastView - 1; + } + else + { + pViews--; + } + } + } + } while(cv_disabled); + selection_customview = *pViews; } @@ -1531,11 +1615,11 @@ pSettings = settingsGetPointer(); if((selection_customview == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0)) - t7_change_customview(); + t7_change_customview(ACTION_BUTTON_ENTER); if((selection_customview == CVIEW_sensors_mV) &&(stateUsed->diveSettings.ccrOption == 0)) - t7_change_customview(); + t7_change_customview(ACTION_BUTTON_ENTER); if((selection_customview == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0)) - t7_change_customview(); + t7_change_customview(ACTION_BUTTON_ENTER); switch(selection_customview) {