Mercurial > public > ostc4
changeset 361:b111fc4250e9 MotionDetection
Pass action to customer vie update function.
By intoducing shakes the reason for calling an update may not only be the middle button. To be able to handle positiv and negativ shake events the action is now provided to the update function
author | Ideenmodellierer |
---|---|
date | Tue, 11 Jun 2019 05:30:09 +0200 |
parents | fc5e9fdcb156 |
children | 7b8c87a39c0e |
files | Discovery/Inc/base.h Discovery/Inc/t7.h Discovery/Inc/tHome.h Discovery/Src/base.c Discovery/Src/t7.c Discovery/Src/tHome.c |
diffstat | 6 files changed, 74 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/Discovery/Inc/base.h Fri May 24 22:01:46 2019 +0200 +++ b/Discovery/Inc/base.h Tue Jun 11 05:30:09 2019 +0200 @@ -86,6 +86,8 @@ ACTION_BUTTON_NEXT, ACTION_BUTTON_ENTER, ACTION_BUTTON_ENTER_FINAL, + ACTION_SHAKE_POS, + ACTION_SHAKE_NEG, ACTION_END } SAction;
--- a/Discovery/Inc/t7.h Fri May 24 22:01:46 2019 +0200 +++ b/Discovery/Inc/t7.h Tue Jun 11 05:30:09 2019 +0200 @@ -40,7 +40,7 @@ void t7_refresh_customview_old(void); void t7_change_field(void); -void t7_change_customview(void); +void t7_change_customview(uint8_t action); void t7_set_field_to_primary(void); void t7_set_customview_to_primary(void);
--- a/Discovery/Inc/tHome.h Fri May 24 22:01:46 2019 +0200 +++ b/Discovery/Inc/tHome.h Tue Jun 11 05:30:09 2019 +0200 @@ -116,7 +116,7 @@ void tHome_sleepmode_fun(void); void set_globalState_tHome(void); void tHome_change_field_button_pressed(void); -void tHome_change_customview_button_pressed(void); +void tHome_change_customview_button_pressed(uint8_t action); void tHome_findNextStop(const uint16_t *list, uint8_t *depthOut, uint16_t *lengthOut); void tHomeDiveMenuControl(uint8_t sendAction);
--- a/Discovery/Src/base.c Fri May 24 22:01:46 2019 +0200 +++ b/Discovery/Src/base.c Tue Jun 11 05:30:09 2019 +0200 @@ -238,6 +238,7 @@ static void TIM_DEMO_init(void); #endif + //#include "lodepng.h" //#include <stdlib.h> // for malloc and free @@ -519,7 +520,11 @@ if(DETECT_NEG_SHAKE == detectShake(stateRealGetPointer()->lifeData.compass_pitch)) { - StoreButtonAction((uint8_t)ACTION_BUTTON_ENTER); + StoreButtonAction((uint8_t)ACTION_SHAKE_NEG); + } + if(DETECT_POS_SHAKE == detectShake(stateRealGetPointer()->lifeData.compass_pitch)) + { + StoreButtonAction((uint8_t)ACTION_SHAKE_POS); } // Enable this to make the simulator write a logbook entry @@ -910,14 +915,16 @@ set_globalState(StD); } else tHome_change_field_button_pressed(); - } else if (action == ACTION_BUTTON_ENTER) { - if ((status.page == PageDive) && (status.line == 0)) - tHome_change_customview_button_pressed(); - else if (status.page == PageSurface) - tHome_change_customview_button_pressed(); - else - tHomeDiveMenuControl(action); - } + } else if ((action == ACTION_BUTTON_ENTER) || (action == ACTION_SHAKE_NEG) || (action == ACTION_SHAKE_POS)) + { + + if ((status.page == PageDive) && (status.line == 0)) + tHome_change_customview_button_pressed(action); + else if (status.page == PageSurface) + tHome_change_customview_button_pressed(action); + else + tHomeDiveMenuControl(action); + } break; case BaseMenu:
--- a/Discovery/Src/t7.c Fri May 24 22:01:46 2019 +0200 +++ b/Discovery/Src/t7.c Tue Jun 11 05:30:09 2019 +0200 @@ -1479,9 +1479,10 @@ selection_customview = settingsGetPointer()->tX_customViewPrimary; } -void t7_change_customview(void) +void t7_change_customview(uint8_t action) { const uint8_t *pViews; + uint8_t *pStartView,*pCurView, *pLastView; _Bool cv_disabled = 0; if(stateUsed->mode == MODE_DIVE) @@ -1489,21 +1490,37 @@ else pViews = customviewsSurface; - while((*pViews != CVIEW_END) && (*pViews != selection_customview)) - {pViews++;} - - if(*pViews < CVIEW_END) - pViews++; - - - if(*pViews == CVIEW_END) + 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_SHAKE_POS)) { - if(stateUsed->mode == MODE_DIVE) - pViews = customviewsDive; - else - pViews = customviewsSurface; + if(*pViews < CVIEW_END) + pViews++; + + if(*pViews == CVIEW_END) + { + pViews = pStartView; + } } - + else + { + pViews--; + if(pViews = pStartView) + { + pViews = pLastView - 1; + } + } if(stateUsed->mode == MODE_DIVE) { do @@ -1524,16 +1541,24 @@ cv_disabled = 1; } - if(cv_disabled) + if(cv_disabled) /* view is disabled => jump to next view */ { - if(*pViews < CVIEW_END) - { - pViews++; - } - else - { - pViews = customviewsDive; - } + if((action == ACTION_BUTTON_ENTER) || (action == ACTION_SHAKE_POS)) + { + pViews++; + if(*pViews == CVIEW_END) + { + pViews = pStartView; + } + } + else + { + pViews--; + if(pViews == pStartView) + { + pViews = pLastView - 1; + } + } } } while(cv_disabled); } @@ -1570,11 +1595,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) {
--- a/Discovery/Src/tHome.c Fri May 24 22:01:46 2019 +0200 +++ b/Discovery/Src/tHome.c Tue Jun 11 05:30:09 2019 +0200 @@ -42,6 +42,7 @@ #include "tMenuEditGasOC.h" // for openEdit_DiveSelectBetterGas() #include "tMenuEditSetpoint.h" // for openEdit_DiveSelectBetterSetpoint() #include "simulation.h" +#include "motion.h" /* Private types -------------------------------------------------------------*/ @@ -330,11 +331,11 @@ } -void tHome_change_customview_button_pressed(void) +void tHome_change_customview_button_pressed(uint8_t action) { tHome_tick_count_cview = 0; if(settingsGetPointer()->design == 7) - t7_change_customview(); + t7_change_customview(action); else if(settingsGetPointer()->design == 3) t3_change_customview();