comparison Discovery/Src/tMenuCvOptionText.c @ 1071:b4a79464caf7 Icon_Integration

Dynamic menu creation for CV views: Because of the increasing features of the OSTC the maintenance of the the menus becomes difficult. Some are not available because of HW version or connected sensors. To keep the "legacy" menus stable the functionality of the cv options page has been increased. Based on enabled cv views and connected sensors the page will be filled dynamically. The page items allow quick acces to the view related options. For the first implementation the views: compass, timer, sensor O2 and sensor CO2 are supported.
author Ideenmodellierer
date Thu, 19 Feb 2026 13:28:37 +0100
parents
children 734f84b72b30
comparison
equal deleted inserted replaced
1070:4499227a2db8 1071:b4a79464caf7
1 ///////////////////////////////////////////////////////////////////////////////
2 /// -*- coding: UTF-8 -*-
3 ///
4 /// \file Discovery/Src/tMenuCvOptionText.c
5 /// \brief File providing functions for generation of text lines
6 /// \author heinrichs weikamp gmbh
7 /// \date 03-Feb-2026
8 ///
9 /// \details
10 ///
11 /// $Id$
12 ///////////////////////////////////////////////////////////////////////////////
13 /// \par Copyright (c) 2014-2025 Heinrichs Weikamp gmbh
14 ///
15 /// This program is free software: you can redistribute it and/or modify
16 /// it under the terms of the GNU General Public License as published by
17 /// the Free Software Foundation, either version 3 of the License, or
18 /// (at your option) any later version.
19 ///
20 /// This program is distributed in the hope that it will be useful,
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 /// GNU General Public License for more details.
24 ///
25 /// You should have received a copy of the GNU General Public License
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
27 //////////////////////////////////////////////////////////////////////////////
28
29 /* Includes ------------------------------------------------------------------*/
30 #include "tMenuCvOptionText.h"
31 #include "tMenuEditCvOption.h"
32 #include "tMenu.h"
33 #include "tHome.h" // for enum CUSTOMVIEWS and init_t7_compass()
34 #include "t3.h"
35 #include "t7.h"
36
37 /* Private function prototypes -----------------------------------------------*/
38
39 /* Exported functions --------------------------------------------------------*/
40
41
42 static refreshFunc_t refreshFctPointerTable[MAXLINES]; /* function pointer for refresh */
43 static uint8_t activeLines = 0; /* number of active lines */
44
45 refreshFunc_t* tMCvOptText_GetTable()
46 {
47 return refreshFctPointerTable;
48 }
49 uint8_t tMCvOptText_GetTableItemCnt()
50 {
51 return activeLines;
52 }
53
54 uint8_t tMCvOptText_refreshCompass(char* pText)
55 {
56 uint8_t textPointer = 0;
57 pText[textPointer++] = TXT_2BYTE;
58 pText[textPointer++] = TXT2BYTE_Compass;
59 pText[textPointer++] = '\t';
60
61 if(settingsGetPointer()->compassBearing != 0)
62 {
63 textPointer += snprintf(&pText[textPointer], 20, "(%03u`)", settingsGetPointer()->compassBearing % 360);
64 }
65 pText[textPointer] = 0;
66 return strlen(pText);
67 }
68
69 uint8_t tMCvOptText_refreshTimer(char* pText)
70 {
71 SSettings *settings = settingsGetPointer();
72 snprintf(pText, 21, "%c%c\t%u:%02u \016\016[m:ss]\017", TXT_2BYTE, TXT2BYTE_Timer, settings->timerDurationS / 60, settings->timerDurationS % 60);
73 return strlen(pText);
74 }
75
76 uint8_t tMCvOptText_refreshO2(char* pText)
77 {
78 char sensorStatusColor[3];
79 uint8_t textPointer = 0;
80 SSettings *pSettings = settingsGetPointer();
81
82
83 pText[textPointer++] = TXT_2BYTE;
84 pText[textPointer++] = TXT2BYTE_Sensor;
85
86 textPointer += snprintf(&pText[textPointer],20,"O2 %c%c",TXT_2BYTE,TXT2BYTE_Sensor);
87
88 if((stateUsed->lifeData.ppO2Sensor_bar[0] != 0) || (stateUsed->lifeData.ppO2Sensor_bar[1] != 0) || (stateUsed->lifeData.ppO2Sensor_bar[2] != 0))
89 {
90 pText[textPointer++] = '\t';
91 sensorStatusColor[0] = '\020';
92 sensorStatusColor[1] = '\020';
93 sensorStatusColor[2] = '\020';
94
95 /* Warning */
96 if(stateUsed->warnings.sensorOutOfBounds) sensorStatusColor[0] = '\024';
97 if(stateUsed->warnings.sensorOutOfBounds) sensorStatusColor[1] = '\024';
98 if(stateUsed->warnings.sensorOutOfBounds) sensorStatusColor[2] = '\024';
99 /* Grey out */
100 if(stateUsed->diveSettings.ppo2sensors_deactivated & 1) sensorStatusColor[0] = '\031';
101 if(stateUsed->diveSettings.ppo2sensors_deactivated & 2) sensorStatusColor[1] = '\031';
102 if(stateUsed->diveSettings.ppo2sensors_deactivated & 4) sensorStatusColor[2] = '\031';
103
104 if((pSettings->ext_sensor_map[0] == SENSOR_ANALOG) || (pSettings->ext_sensor_map[0] == SENSOR_DIGO2M) || (pSettings->ext_sensor_map[0] == SENSOR_SENTINELM))
105 {
106 textPointer += snprintf(&pText[textPointer],20,"%c%01.1f \020\007",sensorStatusColor[0], stateUsed->lifeData.ppO2Sensor_bar[0]);
107 }
108 if((pSettings->ext_sensor_map[1] == SENSOR_ANALOG) || (pSettings->ext_sensor_map[1] == SENSOR_DIGO2M) || (pSettings->ext_sensor_map[1] == SENSOR_SENTINELM))
109 {
110 textPointer += snprintf(&pText[textPointer],20,"%c%01.1f \020\007",sensorStatusColor[1], stateUsed->lifeData.ppO2Sensor_bar[1]);
111 }
112 if((pSettings->ext_sensor_map[2] == SENSOR_ANALOG) || (pSettings->ext_sensor_map[2] == SENSOR_DIGO2M) || (pSettings->ext_sensor_map[2] == SENSOR_SENTINELM))
113 {
114 textPointer += snprintf(&pText[textPointer],20,"%c%01.1f",sensorStatusColor[2], stateUsed->lifeData.ppO2Sensor_bar[2]);
115 }
116 }
117 pText[textPointer++] = '\020';
118 pText[textPointer] = 0;
119 return strlen(pText);
120 }
121
122 uint8_t tMCvOptText_refreshCO2(char* pText)
123 {
124 char sensorStatusColor;
125 uint8_t textPointer = 0;
126 SSettings *pSettings = settingsGetPointer();
127
128
129 pText[textPointer++] = TXT_2BYTE;
130 pText[textPointer++] = TXT2BYTE_Sensor;
131
132 textPointer += snprintf(&pText[textPointer],20,"CO2 %c%c",TXT_2BYTE,TXT2BYTE_Sensor);
133
134
135 pText[textPointer++] = '\t';
136 sensorStatusColor = '\020';
137
138 /* Warning */
139 if(stateUsed->warnings.co2High) sensorStatusColor = '\024';
140 /* Grey out */
141 if(pSettings->co2_sensor_active == 0) sensorStatusColor = '\031';
142
143 textPointer += snprintf(&pText[textPointer],20,"%c%ld \020\007",sensorStatusColor, stateUsed->lifeData.CO2_data.CO2_ppm);
144
145 pText[textPointer++] = '\020';
146 pText[textPointer] = 0;
147 return strlen(pText);
148 }
149
150
151 uint8_t tMCvOptText_BuildDynamicContentList()
152 {
153 uint8_t cvOptIndex = 0;
154 uint8_t CvOptAvailable = 0;
155 uint8_t index = 0;
156 uint8_t SensorActive[SENSOR_END];
157 SSettings *settings = settingsGetPointer();
158
159 memset(SensorActive, 0, sizeof(SensorActive));
160
161
162 for (index = 0; index < EXT_INTERFACE_SENSOR_CNT; index++)
163 {
164 switch(settings->ext_sensor_map[index])
165 {
166 case SENSOR_ANALOG: SensorActive[SENSOR_ANALOG] = 1;
167 break;
168 case SENSOR_SENTINEL:
169 case SENSOR_DIGO2M: SensorActive[SENSOR_DIGO2] = 1;
170 break;
171 case SENSOR_CO2: SensorActive[SENSOR_CO2] = 1;
172 break;
173 #if defined ENABLE_GNSS_INTERNAL || defined ENABLE_GNSS_EXTERN
174 case SENSOR_GNSS: SensorActive[SENSOR_GNSS] = 1;
175 break;
176 #endif
177 default:
178 break;
179 }
180 }
181
182 do
183 {
184 CvOptAvailable = 0;
185 switch(cvOptIndex)
186 {
187 case CVOPT_Compass: if((!t3_customview_disabled(CVIEW_T3_Compass)) || (!t3_customview_disabled(CVIEW_T3_Navigation)) || (!t7_customview_disabled(CVIEW_Compass)))
188 {
189 refreshFctPointerTable[activeLines] = tMCvOptText_refreshCompass;
190 CvOptAvailable = 1;
191 }
192 break;
193 case CVOPT_Timer: if(!t7_customview_disabled(CVIEW_Timer))
194 {
195 refreshFctPointerTable[activeLines] = tMCvOptText_refreshTimer;
196 CvOptAvailable = 1;
197 }
198 break;
199 case CVOPT_O2_Sensor: if((SensorActive[SENSOR_ANALOG]) || (SensorActive[SENSOR_DIGO2]))
200 {
201 refreshFctPointerTable[activeLines] = tMCvOptText_refreshO2;
202 CvOptAvailable = 1;
203 }
204 break;
205 case CVOPT_CO2_Sensor: if(SensorActive[SENSOR_CO2])
206 {
207 refreshFctPointerTable[activeLines] = tMCvOptText_refreshCO2;
208 CvOptAvailable = 1;
209 }
210 break;
211 default:
212 break;
213 }
214 if(CvOptAvailable)
215 {
216 tMCvOption_SetOpenFnct(cvOptIndex,activeLines);
217 activeLines++;
218 }
219 cvOptIndex++;
220 } while((activeLines < MAXLINES) && (cvOptIndex != CVOPT_END));
221
222 for(index = activeLines; index < MAXLINES; index++) /* delete pointers not in use */
223 {
224 tMCvOption_SetOpenFnct(CVOPT_END, index);
225 }
226
227 return activeLines;
228 }
229
230
231 /* Private functions ---------------------------------------------------------*/