comparison Discovery/Src/t3.c @ 599:5a8f9126e4cb

Bugfix T3 skip deactivated views: I previous version the OSTC hangs if only conditional views (like decoplan which is only displayed in case of deco time) are switched. Rootcause was that the select function could never switch to another view because no visible view was available. To avoid this use case a fallback option has been added. In case no other view is available, the current view will be kept. In case no view at all (even no conditional view) is available then a switch to the "None" view will be done independend if it is enabled or not. T3_Profile: Added functionalty to show max depth and divetime of a profile provided by the replay block.
author Ideenmodellierer
date Mon, 04 Jan 2021 21:48:31 +0100
parents f52bc70e380f
children 7ef2d310287d
comparison
equal deleted inserted replaced
598:0a3836643173 599:5a8f9126e4cb
35 #include "math.h" 35 #include "math.h"
36 #include "tHome.h" 36 #include "tHome.h"
37 #include "timer.h" 37 #include "timer.h"
38 #include "unit.h" 38 #include "unit.h"
39 #include "motion.h" 39 #include "motion.h"
40
41 #include "logbook_miniLive.h" 40 #include "logbook_miniLive.h"
42 41
43 42
44 #define CV_PROFILE_WIDTH (700U) 43 #define CV_PROFILE_WIDTH (600U)
45 44
46 //* Imported function prototypes ---------------------------------------------*/ 45 //* Imported function prototypes ---------------------------------------------*/
47 extern uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium); 46 extern uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium);
48 47
49 /* Exported variables --------------------------------------------------------*/ 48 /* Exported variables --------------------------------------------------------*/
78 CVIEW_T3_GasList, 77 CVIEW_T3_GasList,
79 CVIEW_T3_Navigation, 78 CVIEW_T3_Navigation,
80 CVIEW_T3_DepthData, 79 CVIEW_T3_DepthData,
81 CVIEW_noneOrDebug, 80 CVIEW_noneOrDebug,
82 CVIEW_T3_DecoTTS, 81 CVIEW_T3_DecoTTS,
82 #ifdef ENABLE_T3_PROFILE_VIEW
83 CVIEW_T3_Profile, 83 CVIEW_T3_Profile,
84 #endif
84 CVIEW_T3_END 85 CVIEW_T3_END
85 }; 86 };
86 87
87 /* Private function prototypes -----------------------------------------------*/ 88 /* Private function prototypes -----------------------------------------------*/
88 void t3_refresh_divemode(void); 89 void t3_refresh_divemode(void);
182 void t3_miniLiveLogProfile(void) 183 void t3_miniLiveLogProfile(void)
183 { 184 {
184 SWindowGimpStyle wintemp; 185 SWindowGimpStyle wintemp;
185 uint16_t datalength = 0; 186 uint16_t datalength = 0;
186 uint16_t* pReplayData; 187 uint16_t* pReplayData;
187 uint16_t max_depth = 0; 188 uint16_t max_depth = 10;
188 189 char text[TEXTSIZE];
189 point_t start, stop; 190 point_t start, stop;
190 191 uint8_t doNotDrawLifeData = 0;
191 SSettings* pSettings; 192
192 pSettings = settingsGetPointer(); 193 uint16_t diveMinutes = 0;
193 194
194 wintemp.left = t3c1.WindowX0; 195 wintemp.left = t3c1.WindowX0;
195 wintemp.right = t3c1.WindowX0 + CV_PROFILE_WIDTH; 196 wintemp.right = t3c1.WindowX0 + CV_PROFILE_WIDTH;
196 wintemp.top = 480 - BigFontSeperationTopBottom + 5; 197 wintemp.top = 480 - BigFontSeperationTopBottom + 5;
197 wintemp.bottom = t3c1.WindowY1 = 479 - 5; 198 wintemp.bottom = 479 - 5;
198 199
199 start.x = CV_PROFILE_WIDTH + 2; 200 start.x = CV_PROFILE_WIDTH + 2;
200 start.y = wintemp.top; 201 start.y = t3c1.WindowY0;
201 stop.x = start.x; 202 stop.x = start.x;
202 stop.y = wintemp.bottom; 203 stop.y = t3c1.WindowY1;
203 204
204 GFX_draw_line(&t3screen, start, stop, CLUT_Font020); 205 GFX_draw_line(&t3screen, start, stop, CLUT_Font020);
205 206
206 if(getReplayOffset() != 0xFFFF) 207 if(getReplayOffset() != 0xFFFF)
207 { 208 {
208 getReplayInfo(&pReplayData, &datalength, &max_depth); 209 getReplayInfo(&pReplayData, &datalength, &max_depth, &diveMinutes);
209 } 210 }
210 211
211 if(max_depth < (uint16_t)(stateUsed->lifeData.max_depth_meter * 100)) 212 if(max_depth < (uint16_t)(stateUsed->lifeData.max_depth_meter * 100))
212 { 213 {
213 max_depth = (uint16_t)(stateUsed->lifeData.max_depth_meter * 100); 214 max_depth = (uint16_t)(stateUsed->lifeData.max_depth_meter * 100);
216 { 217 {
217 GFX_graph_print(&t3screen, &wintemp, 0,1,0, max_depth, pReplayData, datalength, CLUT_Font031, NULL); 218 GFX_graph_print(&t3screen, &wintemp, 0,1,0, max_depth, pReplayData, datalength, CLUT_Font031, NULL);
218 } 219 }
219 else 220 else
220 { 221 {
221 datalength = 750; 222 datalength = getMiniLiveReplayLength();
223 if(datalength < CV_PROFILE_WIDTH)
224 {
225 if(datalength < 3) /* wait for some data entries to start graph */
226 {
227 doNotDrawLifeData = 1;
228 }
229 datalength = CV_PROFILE_WIDTH;
230 }
231 diveMinutes = 0; /* do not show divetime because it is already shown in the upper field */
222 } 232 }
223 233
224 GFX_graph_print(&t3screen, &wintemp, 0,1,0, max_depth, getMiniLiveReplayPointerToData(), datalength, CLUT_Font030, NULL); 234
235 if(diveMinutes != 0)
236 {
237 snprintf(text,TEXTSIZE,"\002%dmin",diveMinutes);
238 GFX_write_string(&FontT42,&t3c1,text,1);
239 }
240
241 snprintf(text,TEXTSIZE,"\002%01.1fm", max_depth / 100.0);
242 GFX_write_string(&FontT42,&t3c1,text,0);
243
244 if(!doNotDrawLifeData)
245 {
246 GFX_graph_print(&t3screen, &wintemp, 0,1,0, max_depth, getMiniLiveReplayPointerToData(), datalength, CLUT_Font030, NULL);
247 }
225 } 248 }
226 249
227 250
228 void t3_refresh(void) 251 void t3_refresh(void)
229 { 252 {
263 void t3_set_customview_to_primary(void) 286 void t3_set_customview_to_primary(void)
264 { 287 {
265 if(stateUsed->mode == MODE_DIVE) 288 if(stateUsed->mode == MODE_DIVE)
266 { 289 {
267 t3_selection_customview = settingsGetPointer()->tX_customViewPrimaryBF; 290 t3_selection_customview = settingsGetPointer()->tX_customViewPrimaryBF;
291 t3_change_customview(ACTION_END);
268 } 292 }
269 } 293 }
270 294
271 /* Private functions ---------------------------------------------------------*/ 295 /* Private functions ---------------------------------------------------------*/
272 296
1013 GFX_write_string(&FontT105,tXc1,text,0); 1037 GFX_write_string(&FontT105,tXc1,text,0);
1014 t3_basics_compass(tXscreen, center, heading, stateUsed->diveSettings.compassHeading); 1038 t3_basics_compass(tXscreen, center, heading, stateUsed->diveSettings.compassHeading);
1015 break; 1039 break;
1016 1040
1017 case CVIEW_T3_Profile: 1041 case CVIEW_T3_Profile:
1018 snprintf(text,100,"\032\f\001%c%c",TXT_2BYTE,TXT2BYTE_Profile); 1042 snprintf(text,100,"\032\f\002%c%c",TXT_2BYTE,TXT2BYTE_Profile);
1019 GFX_write_string(&FontT42,tXc1,text,0); 1043 GFX_write_string(&FontT42,tXc1,text,0);
1020 t3_miniLiveLogProfile(); 1044 t3_miniLiveLogProfile();
1021 break; 1045 break;
1022 case CVIEW_T3_DecoTTS: 1046 case CVIEW_T3_DecoTTS:
1023 case CVIEW_T3_Decostop: 1047 case CVIEW_T3_Decostop:
1511 else 1535 else
1512 pDecoinfo = &stateUsed->decolistVPM; 1536 pDecoinfo = &stateUsed->decolistVPM;
1513 1537
1514 uint8_t curViewIdx = 0xff; 1538 uint8_t curViewIdx = 0xff;
1515 uint8_t index = 0; 1539 uint8_t index = 0;
1540 uint8_t indexOverrun = 0;
1516 uint8_t lastViewIdx = 0; 1541 uint8_t lastViewIdx = 0;
1517 uint8_t iterate = 0; /* set to 1 if a view has to be skipped */ 1542 uint8_t iterate = 0; /* set to 1 if a view has to be skipped */
1543 uint8_t useFallback = 0; /* is set if the current view is disabled */
1544 uint8_t fallbackSelection = CVIEW_noneOrDebug; /* show "None" view per default */
1518 1545
1519 /* set pointer to currently selected view and count number of entries */ 1546 /* set pointer to currently selected view and count number of entries */
1520 while((tX_customviews[index] != CVIEW_T3_END)) 1547 while((tX_customviews[index] != CVIEW_T3_END))
1521 { 1548 {
1522 if (tX_customviews[index] == *tX_selection_customview) 1549 if (tX_customviews[index] == *tX_selection_customview)
1526 index++; 1553 index++;
1527 } 1554 }
1528 if(curViewIdx == 0xff) /* called with unknown view */ 1555 if(curViewIdx == 0xff) /* called with unknown view */
1529 { 1556 {
1530 curViewIdx = 0; 1557 curViewIdx = 0;
1531 *tX_selection_customview = tX_customviews[index]; 1558 *tX_selection_customview = CVIEW_noneOrDebug; /* show "None" view per default */
1532 } 1559 }
1533 lastViewIdx = index; 1560 lastViewIdx = index;
1534 index = curViewIdx; 1561 index = curViewIdx;
1535 do 1562 do
1536 { 1563 {
1545 index++; 1572 index++;
1546 } 1573 }
1547 if(tX_customviews[index] == CVIEW_T3_END) 1574 if(tX_customviews[index] == CVIEW_T3_END)
1548 { 1575 {
1549 index = 0; 1576 index = 0;
1577 indexOverrun = 1;
1550 } 1578 }
1551 break; 1579 break;
1552 case ACTION_PITCH_NEG: 1580 case ACTION_PITCH_NEG:
1553 if(index == 0) 1581 if(index == 0)
1554 { 1582 {
1555 index = lastViewIdx - 1; 1583 index = lastViewIdx - 1;
1584 indexOverrun = 1;
1556 } 1585 }
1557 else 1586 else
1558 { 1587 {
1559 index--; 1588 index--;
1560 } 1589 }
1564 } 1593 }
1565 1594
1566 if(t3_customview_disabled(tX_customviews[index])) 1595 if(t3_customview_disabled(tX_customviews[index]))
1567 { 1596 {
1568 iterate = 1; 1597 iterate = 1;
1598 if(*tX_selection_customview == tX_customviews[index])
1599 {
1600 useFallback = 1; /* the provided view is disabled => use fallback */
1601 }
1569 } 1602 }
1570 if((tX_customviews[index] == CVIEW_T3_TTS) && !pDecoinfo->output_time_to_surface_seconds) /* Skip TTS if value is 0 */ 1603 else /* special case which are enabled but not to be displayed at the moment */
1571 { 1604 {
1572 iterate = 1; 1605 if(settingsGetPointer()->MotionDetection != MOTION_DETECT_SECTOR) /* no hiding in case of active sector view option (fixed mapping would change during dive) */
1573 } 1606 {
1574 if((tX_customviews[index] == CVIEW_T3_Decostop) && ((!pDecoinfo->output_ndl_seconds) && (!pDecoinfo->output_time_to_surface_seconds) && (timer_Safetystop_GetCountDown() == 0))) /* Skip Deco if NDL is not set */ 1607 if((tX_customviews[index] == CVIEW_T3_TTS) && !pDecoinfo->output_time_to_surface_seconds) /* Skip TTS if value is 0 */
1575 { 1608 {
1576 iterate = 1; 1609 iterate = 1;
1577 } 1610 fallbackSelection = CVIEW_T3_TTS;
1578 if((iterate) && (action == ACTION_END)) 1611 }
1612 if((tX_customviews[index] == CVIEW_T3_Decostop) && ((!pDecoinfo->output_ndl_seconds) && (!pDecoinfo->output_time_to_surface_seconds) && (timer_Safetystop_GetCountDown() == 0))) /* Skip Deco if NDL is not set */
1613 {
1614 iterate = 1;
1615 fallbackSelection = CVIEW_T3_Decostop;
1616 }
1617 }
1618 }
1619 if((iterate) && (action == ACTION_END)) /* ACTION_END is used to check the enable state of the provided view. If it is enable the function will return without change */
1579 { 1620 {
1580 action = ACTION_BUTTON_ENTER; 1621 action = ACTION_BUTTON_ENTER;
1581 } 1622 }
1582 }while (iterate == 1); 1623 }while ((iterate == 1) && (!((indexOverrun == 1) && (*tX_selection_customview == tX_customviews[index])))); /* no other available view found => use fallback */
1583 1624
1584 *tX_selection_customview = tX_customviews[index]; 1625 if(*tX_selection_customview == tX_customviews[index])
1626 {
1627 if(useFallback)
1628 {
1629 *tX_selection_customview = fallbackSelection; /* no active view found => keep actual view or change to fallback if actual view is deactivated */
1630 }
1631 }
1632 else
1633 {
1634 *tX_selection_customview = tX_customviews[index];
1635 }
1585 } 1636 }
1586 1637
1587 1638
1588 void t3_basics_colorscheme_mod(char *text) 1639 void t3_basics_colorscheme_mod(char *text)
1589 { 1640 {