comparison 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
comparison
equal deleted inserted replaced
358:c6a084d1433f 387:0dbb74be972f
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);
568 /* custom view primary OR debug if automatic return is off */ 569 /* custom view primary OR debug if automatic return is off */
569 if((settingsGetPointer()->tX_customViewTimeout == 0) && (settingsGetPointer()->showDebugInfo)) 570 if((settingsGetPointer()->tX_customViewTimeout == 0) && (settingsGetPointer()->showDebugInfo))
570 selection_customview = CVIEW_noneOrDebug; 571 selection_customview = CVIEW_noneOrDebug;
571 else 572 else
572 selection_customview = settingsGetPointer()->tX_customViewPrimary; 573 selection_customview = settingsGetPointer()->tX_customViewPrimary;
574
575 InitMotionDetection();
573 } 576 }
574 577
575 if(status.page == PageSurface) 578 if(status.page == PageSurface)
576 set_globalState(StD); 579 set_globalState(StD);
577 580
598 { 601 {
599 if(last_mode != MODE_SURFACE) 602 if(last_mode != MODE_SURFACE)
600 { 603 {
601 last_mode = MODE_SURFACE; 604 last_mode = MODE_SURFACE;
602 selection_customview = customviewsSurface[0]; 605 selection_customview = customviewsSurface[0];
606 InitMotionDetection();
603 } 607 }
604 if(status.page == PageDive) 608 if(status.page == PageDive)
605 set_globalState(StS); 609 set_globalState(StS);
606 610
607 if(settingsGetPointer()->showDebugInfo) 611 if(settingsGetPointer()->showDebugInfo)
1438 { 1442 {
1439 if(stateUsed->mode == MODE_DIVE) 1443 if(stateUsed->mode == MODE_DIVE)
1440 selection_customview = settingsGetPointer()->tX_customViewPrimary; 1444 selection_customview = settingsGetPointer()->tX_customViewPrimary;
1441 } 1445 }
1442 1446
1443 void t7_change_customview(void) 1447 uint8_t t7_GetEnabled_customviews()
1444 { 1448 {
1445 const uint8_t *pViews; 1449 int8_t i;
1450 uint8_t *pViews;
1451 uint8_t increment = 1;
1452
1453 uint8_t enabledViewCnt = 0;
1454 uint32_t cv_config = settingsGetPointer()->cv_configuration;
1455
1456 if(stateUsed->mode == MODE_DIVE)
1457 pViews = (uint8_t*)customviewsDive;
1458 else
1459 pViews = (uint8_t*)customviewsSurface;
1460
1461 while((*pViews != CVIEW_END))
1462 {
1463 increment = 1;
1464 /* check if view is enabled */
1465 i=0;
1466 do
1467 {
1468 if(*pViews == cv_changelist[i])
1469 {
1470 if(!CHECK_BIT_THOME(cv_config, cv_changelist[i]))
1471 {
1472 increment = 0;
1473 }
1474 break;
1475 }
1476 i++;
1477 } while(cv_changelist[i] != CVIEW_END);
1478 if(cv_changelist[i] == CVIEW_END)
1479 {
1480 increment = 0;
1481 }
1482 if (((*pViews == CVIEW_sensors) || (*pViews == CVIEW_sensors_mV)) &&
1483 ((stateUsed->diveSettings.ppo2sensors_deactivated) || (stateUsed->diveSettings.ccrOption == 0)))
1484 {
1485 increment = 0;
1486 }
1487
1488 pViews++;
1489 enabledViewCnt += increment;
1490 }
1491 return enabledViewCnt;
1492 }
1493
1494 void t7_change_customview(uint8_t action)
1495 {
1496 int8_t i;
1497 uint8_t *pViews;
1498 uint8_t *pStartView,*pCurView, *pLastView;
1446 _Bool cv_disabled = 0; 1499 _Bool cv_disabled = 0;
1447 1500
1448 if(stateUsed->mode == MODE_DIVE) 1501 if(stateUsed->mode == MODE_DIVE)
1449 pViews = customviewsDive; 1502 pViews = (uint8_t*)customviewsDive;
1450 else 1503 else
1451 pViews = customviewsSurface; 1504 pViews = (uint8_t*)customviewsSurface;
1452 1505
1453 while((*pViews != CVIEW_END) && (*pViews != selection_customview)) 1506 pStartView = pViews;
1454 {pViews++;} 1507 /* set pointer to currently selected view and count number of entries */
1455 1508 while((*pViews != CVIEW_END))
1456 if(*pViews < CVIEW_END) 1509 {
1457 pViews++; 1510 if (*pViews == selection_customview)
1458 1511 {
1459 1512 pCurView = pViews;
1460 if(*pViews == CVIEW_END) 1513 }
1461 { 1514 pViews++;
1462 if(stateUsed->mode == MODE_DIVE) 1515 }
1463 pViews = customviewsDive; 1516 pLastView = pViews;
1464 else 1517 pViews = pCurView;
1465 pViews = customviewsSurface; 1518
1466 } 1519 if((action == ACTION_BUTTON_ENTER) || (action == ACTION_PITCH_POS))
1467 1520 {
1468 if(stateUsed->mode == MODE_DIVE) 1521 if(*pViews < CVIEW_END)
1469 { 1522 pViews++;
1470 do 1523
1471 { 1524 if(*pViews == CVIEW_END)
1472 cv_disabled = 0; 1525 {
1473 for(int i=0;i<6;i++) 1526 pViews = pStartView;
1474 { 1527 }
1475 if((*pViews == cv_changelist[i]) && !CHECK_BIT_THOME(settingsGetPointer()->cv_configuration, cv_changelist[i])) 1528 }
1476 { 1529 else
1477 cv_disabled = 1; 1530 {
1478 break; 1531 if(pViews == pStartView)
1479 } 1532 {
1480 } 1533 pViews = pLastView - 1;
1481 1534 }
1482 if ((*pViews == CVIEW_sensors || *pViews == CVIEW_sensors_mV) && 1535 else
1483 stateUsed->diveSettings.ppo2sensors_deactivated) 1536 {
1484 { 1537 pViews--;
1485 cv_disabled = 1; 1538 }
1486 } 1539 }
1487 1540
1488 if(cv_disabled) 1541 do
1489 { 1542 {
1490 if(*pViews < CVIEW_END) 1543 cv_disabled = 0;
1491 { 1544 i=0;
1492 pViews++; 1545 while(cv_changelist[i] != CVIEW_END)
1493 } 1546 {
1494 else 1547 if((*pViews == cv_changelist[i]) && !CHECK_BIT_THOME(settingsGetPointer()->cv_configuration, cv_changelist[i]))
1495 { 1548 {
1496 pViews = customviewsDive; 1549 cv_disabled = 1;
1497 } 1550 break;
1498 } 1551 }
1499 } while(cv_disabled); 1552 i++;
1500 } 1553 }
1554
1555 if (((*pViews == CVIEW_sensors) || (*pViews == CVIEW_sensors_mV)) &&
1556 ((stateUsed->diveSettings.ppo2sensors_deactivated) || (stateUsed->diveSettings.ccrOption == 0)))
1557 {
1558 cv_disabled = 1;
1559 }
1560
1561 if(cv_disabled) /* view is disabled => jump to next view */
1562 {
1563 if((action == ACTION_BUTTON_ENTER) || (action == ACTION_PITCH_POS))
1564 {
1565 pViews++;
1566 if(*pViews == CVIEW_END)
1567 {
1568 pViews = pStartView;
1569 }
1570 }
1571 else
1572 {
1573 if(pViews == pStartView)
1574 {
1575 pViews = pLastView - 1;
1576 }
1577 else
1578 {
1579 pViews--;
1580 }
1581 }
1582 }
1583 } while(cv_disabled);
1584
1501 selection_customview = *pViews; 1585 selection_customview = *pViews;
1502 } 1586 }
1503 1587
1504 1588
1505 uint8_t t7_get_length_of_customtext(void) 1589 uint8_t t7_get_length_of_customtext(void)
1529 1613
1530 SSettings* pSettings; 1614 SSettings* pSettings;
1531 pSettings = settingsGetPointer(); 1615 pSettings = settingsGetPointer();
1532 1616
1533 if((selection_customview == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0)) 1617 if((selection_customview == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0))
1534 t7_change_customview(); 1618 t7_change_customview(ACTION_BUTTON_ENTER);
1535 if((selection_customview == CVIEW_sensors_mV) &&(stateUsed->diveSettings.ccrOption == 0)) 1619 if((selection_customview == CVIEW_sensors_mV) &&(stateUsed->diveSettings.ccrOption == 0))
1536 t7_change_customview(); 1620 t7_change_customview(ACTION_BUTTON_ENTER);
1537 if((selection_customview == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0)) 1621 if((selection_customview == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0))
1538 t7_change_customview(); 1622 t7_change_customview(ACTION_BUTTON_ENTER);
1539 1623
1540 switch(selection_customview) 1624 switch(selection_customview)
1541 { 1625 {
1542 case CVIEW_noneOrDebug: 1626 case CVIEW_noneOrDebug:
1543 if(settingsGetPointer()->showDebugInfo) 1627 if(settingsGetPointer()->showDebugInfo)