Mercurial > public > ostc4
comparison Discovery/Src/t7.c @ 369:210bffc496a3 MotionDetection
Added a function to count the active custom views.
| author | ideenmodellierer |
|---|---|
| date | Tue, 13 Aug 2019 21:12:17 +0200 |
| parents | e309f78f89a5 |
| children | 75eedde05ff6 |
comparison
equal
deleted
inserted
replaced
| 368:50ea68c7a153 | 369:210bffc496a3 |
|---|---|
| 36 #include "math.h" | 36 #include "math.h" |
| 37 #include "tHome.h" | 37 #include "tHome.h" |
| 38 #include "simulation.h" | 38 #include "simulation.h" |
| 39 #include "timer.h" | 39 #include "timer.h" |
| 40 #include "unit.h" | 40 #include "unit.h" |
| 41 #include "motion.h" | |
| 41 | 42 |
| 42 /* Private function prototypes -----------------------------------------------*/ | 43 /* Private function prototypes -----------------------------------------------*/ |
| 43 | 44 |
| 44 void t7_refresh_surface(void); | 45 void t7_refresh_surface(void); |
| 45 void t7_refresh_surface_debugmode(void); | 46 void t7_refresh_surface_debugmode(void); |
| 565 /* custom view primary OR debug if automatic return is off */ | 566 /* custom view primary OR debug if automatic return is off */ |
| 566 if((settingsGetPointer()->tX_customViewTimeout == 0) && (settingsGetPointer()->showDebugInfo)) | 567 if((settingsGetPointer()->tX_customViewTimeout == 0) && (settingsGetPointer()->showDebugInfo)) |
| 567 selection_customview = CVIEW_noneOrDebug; | 568 selection_customview = CVIEW_noneOrDebug; |
| 568 else | 569 else |
| 569 selection_customview = settingsGetPointer()->tX_customViewPrimary; | 570 selection_customview = settingsGetPointer()->tX_customViewPrimary; |
| 571 | |
| 572 InitMotionDetection(); | |
| 570 } | 573 } |
| 571 | 574 |
| 572 if(status.page == PageSurface) | 575 if(status.page == PageSurface) |
| 573 set_globalState(StD); | 576 set_globalState(StD); |
| 574 | 577 |
| 595 { | 598 { |
| 596 if(last_mode != MODE_SURFACE) | 599 if(last_mode != MODE_SURFACE) |
| 597 { | 600 { |
| 598 last_mode = MODE_SURFACE; | 601 last_mode = MODE_SURFACE; |
| 599 selection_customview = customviewsSurface[0]; | 602 selection_customview = customviewsSurface[0]; |
| 603 InitMotionDetection(); | |
| 600 } | 604 } |
| 601 if(status.page == PageDive) | 605 if(status.page == PageDive) |
| 602 set_globalState(StS); | 606 set_globalState(StS); |
| 603 | 607 |
| 604 if(settingsGetPointer()->showDebugInfo) | 608 if(settingsGetPointer()->showDebugInfo) |
| 1477 { | 1481 { |
| 1478 if(stateUsed->mode == MODE_DIVE) | 1482 if(stateUsed->mode == MODE_DIVE) |
| 1479 selection_customview = settingsGetPointer()->tX_customViewPrimary; | 1483 selection_customview = settingsGetPointer()->tX_customViewPrimary; |
| 1480 } | 1484 } |
| 1481 | 1485 |
| 1486 uint8_t t7_GetEnabled_customviews() | |
| 1487 { | |
| 1488 uint8_t *pViews; | |
| 1489 uint8_t increment = 1; | |
| 1490 | |
| 1491 uint8_t enabledViewCnt = 0; | |
| 1492 uint32_t cv_config = settingsGetPointer()->cv_configuration; | |
| 1493 | |
| 1494 if(stateUsed->mode == MODE_DIVE) | |
| 1495 pViews = customviewsDive; | |
| 1496 else | |
| 1497 pViews = customviewsSurface; | |
| 1498 | |
| 1499 while((*pViews != CVIEW_END)) | |
| 1500 { | |
| 1501 increment = 1; | |
| 1502 /* check if view is enabled */ | |
| 1503 for(int i=0;i<6;i++) | |
| 1504 { | |
| 1505 if((*pViews == cv_changelist[i]) && !CHECK_BIT_THOME(cv_config, (1 << cv_changelist[i]))) | |
| 1506 { | |
| 1507 increment = 0; | |
| 1508 break; | |
| 1509 } | |
| 1510 } | |
| 1511 if (((*pViews == CVIEW_sensors) || (*pViews == CVIEW_sensors_mV)) && | |
| 1512 ((stateUsed->diveSettings.ppo2sensors_deactivated) || (stateUsed->diveSettings.ccrOption == 0))) | |
| 1513 { | |
| 1514 increment = 0; | |
| 1515 } | |
| 1516 | |
| 1517 pViews++; | |
| 1518 enabledViewCnt += increment; | |
| 1519 } | |
| 1520 return enabledViewCnt; | |
| 1521 } | |
| 1522 | |
| 1482 void t7_change_customview(uint8_t action) | 1523 void t7_change_customview(uint8_t action) |
| 1483 { | 1524 { |
| 1484 uint8_t *pViews; | 1525 uint8_t *pViews; |
| 1485 uint8_t *pStartView,*pCurView, *pLastView; | 1526 uint8_t *pStartView,*pCurView, *pLastView; |
| 1486 _Bool cv_disabled = 0; | 1527 _Bool cv_disabled = 0; |
| 1501 pViews++; | 1542 pViews++; |
| 1502 } | 1543 } |
| 1503 pLastView = pViews; | 1544 pLastView = pViews; |
| 1504 pViews = pCurView; | 1545 pViews = pCurView; |
| 1505 | 1546 |
| 1506 if((action == ACTION_BUTTON_ENTER) || (action == ACTION_SHAKE_POS)) | 1547 if((action == ACTION_BUTTON_ENTER) || (action == ACTION_PITCH_POS)) |
| 1507 { | 1548 { |
| 1508 if(*pViews < CVIEW_END) | 1549 if(*pViews < CVIEW_END) |
| 1509 pViews++; | 1550 pViews++; |
| 1510 | 1551 |
| 1511 if(*pViews == CVIEW_END) | 1552 if(*pViews == CVIEW_END) |
| 1543 cv_disabled = 1; | 1584 cv_disabled = 1; |
| 1544 } | 1585 } |
| 1545 | 1586 |
| 1546 if(cv_disabled) /* view is disabled => jump to next view */ | 1587 if(cv_disabled) /* view is disabled => jump to next view */ |
| 1547 { | 1588 { |
| 1548 if((action == ACTION_BUTTON_ENTER) || (action == ACTION_SHAKE_POS)) | 1589 if((action == ACTION_BUTTON_ENTER) || (action == ACTION_PITCH_POS)) |
| 1549 { | 1590 { |
| 1550 pViews++; | 1591 pViews++; |
| 1551 if(*pViews == CVIEW_END) | 1592 if(*pViews == CVIEW_END) |
| 1552 { | 1593 { |
| 1553 pViews = pStartView; | 1594 pViews = pStartView; |
