changeset 592:f52bc70e380f

MotionCtrl - Sectorview Map sectors directly to custom views: In previous version detection of sector changes lead to a button event which triggered the change of the shown custom view. As result the views shown were depending on the angle which is present while entering focus state. The new implementation maps the primary view to the center sector and assigns the other enabled views around the center => views will always appear at the same angle value.
author Ideenmodellierer
date Sun, 03 Jan 2021 14:43:16 +0100
parents 0172431fbad9
children 3a6f922b73ea
files Discovery/Inc/t3.h Discovery/Inc/t7.h Discovery/Src/motion.c Discovery/Src/t3.c Discovery/Src/t7.c
diffstat 5 files changed, 140 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Inc/t3.h	Wed Jan 06 22:02:49 2021 +0100
+++ b/Discovery/Inc/t3.h	Sun Jan 03 14:43:16 2021 +0100
@@ -35,6 +35,7 @@
 /* Exported functions --------------------------------------------------------*/
 void t3_init(void);
 void t3_refresh(void);
+void t3_select_customview(uint8_t selectedCustomview);
 uint8_t t3_change_customview(uint8_t action);
 uint8_t t3_GetEnabled_customviews(void);
 uint8_t t3_getCustomView(void);
--- a/Discovery/Inc/t7.h	Wed Jan 06 22:02:49 2021 +0100
+++ b/Discovery/Inc/t7.h	Sun Jan 03 14:43:16 2021 +0100
@@ -60,7 +60,7 @@
 void t7_refresh_customview_old(void);
 
 void t7_change_field(void);
-void t7_change_customview(uint8_t action);
+uint8_t t7_change_customview(uint8_t action);
 void t7_select_customview(uint8_t selectedCustomview);
 
 void t7_set_field_to_primary(void);
--- a/Discovery/Src/motion.c	Wed Jan 06 22:02:49 2021 +0100
+++ b/Discovery/Src/motion.c	Sun Jan 03 14:43:16 2021 +0100
@@ -14,6 +14,7 @@
 #include "t7.h"
 #include "t3.h"
 #include "settings.h"
+#include "base.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 */
@@ -26,6 +27,7 @@
 
 #define SECTOR_MAX					24		/* maximum number of sectors */
 #define SECTOR_SCROLL				7		/* number of sectors used for scroll detection */
+#define SECTOR_MAX_CNT				5		/* max number of views used for sector control */
 
 #define MOTION_DELTA_STABLE			0
 #define MOTION_DELTA_JITTER			1
@@ -46,6 +48,7 @@
 
 static uint8_t focusCnt = 0;
 static uint8_t inFocus = 0;
+static uint8_t sectorMap[SECTOR_MAX_CNT];
 
 void resetMotionDeltaHistory()
 {
@@ -172,9 +175,9 @@
 		{
 			sectorDetection.count =  t7_GetEnabled_customviews();
 		}
-		if(sectorDetection.count > 5)
+		if(sectorDetection.count > SECTOR_MAX_CNT)
 		{
-			sectorDetection.count = 5;	/* more views are hard to manually control */
+			sectorDetection.count = SECTOR_MAX_CNT;	/* more views are hard to manually control */
 		}
 	}
 	else
@@ -207,6 +210,63 @@
 
 }
 
+
+uint8_t GetCVForSector(uint8_t selSector)
+{
+	if(selSector < sectorDetection.count)
+	{
+		return sectorMap[selSector];
+	}
+	else
+	{
+		return 0;
+	}
+}
+void MapCVToSector()
+{
+	uint8_t centerView = 0;
+
+	memset(sectorMap, 0, sizeof(sectorMap));
+
+	switch(sectorDetection.count)
+	{
+		case 1: centerView = 0; break;
+		case 2: centerView = 0; break;
+		case 3: centerView = 1; break;
+		case 4: centerView = 1; break;
+		case 5: centerView = 2; break;
+		default: centerView = sectorDetection.count / 2 - 1;
+			break;
+	}
+	if(settingsGetPointer()->design == 3)		/* Big font view ? */
+	{
+		sectorMap[centerView] = settingsGetPointer()->tX_customViewPrimaryBF;
+	}
+	else
+	{
+		sectorMap[centerView] = settingsGetPointer()->tX_customViewPrimary;
+	}
+
+	centerView++;
+	while(sectorMap[centerView] == 0)
+	{
+		if(settingsGetPointer()->design == 3)		/* Big font view ? */
+		{
+			sectorMap[centerView] = t3_change_customview(ACTION_BUTTON_ENTER);
+		}
+		else
+		{
+			sectorMap[centerView] = t7_change_customview(ACTION_BUTTON_ENTER);
+		}
+		centerView++;
+		if(centerView == sectorDetection.count)
+		{
+			centerView = 0;
+		}
+	}
+
+}
+
 void InitMotionDetection(void)
 {
 	sectorDetection.target = 0;
@@ -217,6 +277,7 @@
 	switch(settingsGetPointer()->MotionDetection)
 	{
 		case MOTION_DETECT_SECTOR: DefinePitchSectors(settingsGetPointer()->viewPitch,CUSTOMER_DEFINED_VIEWS);
+									MapCVToSector();
 			break;
 		case MOTION_DETECT_MOVE: DefinePitchSectors(settingsGetPointer()->viewPitch,SECTOR_MAX);
 			break;
@@ -232,31 +293,20 @@
 /* Map the current pitch value to a sector and create button event in case the sector is left */
 detectionState_t detectSectorButtonEvent(float curPitch)
 {
-	static uint8_t lastTargetSector = 0;
 	uint8_t newTargetSector;
-	uint8_t PitchEvent = DETECT_NOTHING;
 
-/* only change sector if reading is stable */
 	newTargetSector = GetSectorForPitch(stateRealGetPointer()->lifeData.compass_pitch);
-	if(lastTargetSector == newTargetSector)
-	{
-		sectorDetection.target = newTargetSector;
-	}
-	lastTargetSector = newTargetSector;
-	if(sectorDetection.target != sectorDetection.current)
+
+	if(settingsGetPointer()->design == 3)		/* Big font view ? */
 	{
-		 if(sectorDetection.target > sectorDetection.current)
-		 {
-			 sectorDetection.current++;
-			PitchEvent = DETECT_POS_PITCH;
-		 }
-		 else
-		 {
-			 sectorDetection.current--;
-			 PitchEvent = DETECT_NEG_PITCH;
-		 }
+		t3_select_customview(GetCVForSector(newTargetSector));
 	}
-	return PitchEvent;
+	else
+	{
+		t7_select_customview(GetCVForSector(newTargetSector));
+	}
+
+	return DETECT_NOTHING;
 }
 
 /* Check if pitch is not in center position and trigger a button action if needed */
--- a/Discovery/Src/t3.c	Wed Jan 06 22:02:49 2021 +0100
+++ b/Discovery/Src/t3.c	Sun Jan 03 14:43:16 2021 +0100
@@ -38,6 +38,11 @@
 #include "unit.h"
 #include "motion.h"
 
+#include "logbook_miniLive.h"
+
+
+#define CV_PROFILE_WIDTH		(700U)
+
 //* Imported function prototypes ---------------------------------------------*/
 extern uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium);
 
@@ -75,6 +80,7 @@
 	CVIEW_T3_DepthData,
 	CVIEW_noneOrDebug,
 	CVIEW_T3_DecoTTS,
+	CVIEW_T3_Profile,
     CVIEW_T3_END
 };
 
@@ -165,6 +171,59 @@
     t3c2.WindowTab = 600;
 }
 
+void t3_select_customview(uint8_t selectedCustomview)
+{
+	if(selectedCustomview < CVIEW_T3_END)
+	{
+		t3_selection_customview = selectedCustomview;
+	}
+}
+
+void t3_miniLiveLogProfile(void)
+{
+    SWindowGimpStyle wintemp;
+    uint16_t datalength = 0;
+    uint16_t* pReplayData;
+    uint16_t max_depth = 0;
+
+    point_t start, stop;
+
+	SSettings* pSettings;
+	pSettings = settingsGetPointer();
+
+    wintemp.left = t3c1.WindowX0;
+    wintemp.right = t3c1.WindowX0 + CV_PROFILE_WIDTH;
+   	wintemp.top = 480 - BigFontSeperationTopBottom + 5;
+   	wintemp.bottom = t3c1.WindowY1 = 479 - 5;
+
+    start.x = CV_PROFILE_WIDTH + 2;
+    start.y = wintemp.top;
+    stop.x = start.x;
+    stop.y = wintemp.bottom;
+
+   	GFX_draw_line(&t3screen, start, stop, CLUT_Font020);
+
+   	if(getReplayOffset() != 0xFFFF)
+   	{
+		getReplayInfo(&pReplayData, &datalength, &max_depth);
+   	}
+
+   	if(max_depth < (uint16_t)(stateUsed->lifeData.max_depth_meter * 100))
+	{
+		max_depth = (uint16_t)(stateUsed->lifeData.max_depth_meter * 100);
+	}
+	if(datalength != 0)
+	{
+		GFX_graph_print(&t3screen, &wintemp, 0,1,0, max_depth, pReplayData, datalength, CLUT_Font031, NULL);
+	}
+	else
+	{
+		datalength = 750;
+	}
+
+    GFX_graph_print(&t3screen, &wintemp, 0,1,0, max_depth, getMiniLiveReplayPointerToData(), datalength, CLUT_Font030, NULL);
+}
+
 
 void t3_refresh(void)
 {
@@ -955,6 +1014,11 @@
         t3_basics_compass(tXscreen, center, heading, stateUsed->diveSettings.compassHeading);
         break;
 
+    case CVIEW_T3_Profile:
+        snprintf(text,100,"\032\f\001%c%c",TXT_2BYTE,TXT2BYTE_Profile);
+        GFX_write_string(&FontT42,tXc1,text,0);
+        t3_miniLiveLogProfile();
+    	break;
     case CVIEW_T3_DecoTTS:
     case CVIEW_T3_Decostop:
     default:
--- a/Discovery/Src/t7.c	Wed Jan 06 22:02:49 2021 +0100
+++ b/Discovery/Src/t7.c	Sun Jan 03 14:43:16 2021 +0100
@@ -1601,7 +1601,7 @@
     return cv_disabled;
 }
 
-void t7_change_customview(uint8_t action)
+uint8_t t7_change_customview(uint8_t action)
 {
     uint8_t *pViews;
     uint8_t *pStartView,*pCurView, *pLastView;
@@ -1660,6 +1660,7 @@
     } while(cv_disabled);
 
     selection_customview = *pViews;
+    return *pViews;
 }
 
 void t7_select_customview(uint8_t selectedCustomview)