comparison Discovery/Src/t7.c @ 788:4abfb8a2a435

Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
author heinrichsweikamp
date Tue, 04 Jul 2023 14:39:06 +0200
parents 74253a41cf80
children 1e3c12d772eb
comparison
equal deleted inserted replaced
787:aeb72882f30a 788:4abfb8a2a435
1760 i++; 1760 i++;
1761 return i; 1761 return i;
1762 } 1762 }
1763 1763
1764 1764
1765 static bool setpointIsActive(SSettings *settings, unsigned setpointIndex)
1766 {
1767 if (settings->autoSetpoint && setpointIndex == SETPOINT_INDEX_AUTO_DECO) {
1768 return settings->setpoint[setpointIndex].note.ub.active;
1769 }
1770
1771 return true;
1772 }
1773
1774
1765 static void t7_CcrSummary(SSettings *settings) 1775 static void t7_CcrSummary(SSettings *settings)
1766 { 1776 {
1767 unsigned numLines = 1; // CCR Mode 1777 unsigned numLines = 1; // CCR Mode
1768 1778
1769 SGasLine *diluentsToShow[MAX_NUM_SUMMARY_LINES - 1] = { NULL }; 1779 SGasLine *diluentsToShow[MAX_NUM_SUMMARY_LINES - 1] = { NULL };
1788 1798
1789 bool showManualSetpoints = false; 1799 bool showManualSetpoints = false;
1790 unsigned offset; 1800 unsigned offset;
1791 SSetpointLine *setpointsToShow[MAX_NUM_SUMMARY_LINES - 1] = { NULL }; 1801 SSetpointLine *setpointsToShow[MAX_NUM_SUMMARY_LINES - 1] = { NULL };
1792 if (settings->CCR_Mode == CCRMODE_FixedSetpoint || settings->fallbackToFixedSetpoint) { 1802 if (settings->CCR_Mode == CCRMODE_FixedSetpoint || settings->fallbackToFixedSetpoint) {
1793 // Add setpoint at start of dive
1794 offset = numLines; 1803 offset = numLines;
1795 i = 1; 1804 if (settings->autoSetpoint) {
1796 while (i <= NUM_GASES) { 1805 setpointsToShow[numLines++ - offset] = &settings->setpoint[SETPOINT_INDEX_AUTO_LOW];
1797 if (settings->setpoint[i].note.ub.active && settings->setpoint[i].note.ub.first) { 1806 setpointsToShow[numLines++ - offset] = &settings->setpoint[SETPOINT_INDEX_AUTO_HIGH];
1798 setpointsToShow[numLines - offset] = &settings->setpoint[i]; 1807 if (setpointIsActive(settings, SETPOINT_INDEX_AUTO_DECO)) {
1799 numLines++; 1808 setpointsToShow[numLines++ - offset] = &settings->setpoint[SETPOINT_INDEX_AUTO_DECO];
1800
1801 break;
1802 } 1809 }
1803 1810 } else {
1804 i++; 1811 // Add setpoint at start of dive
1805 }
1806
1807 if (settings->autoSetpoint) {
1808 i = 1; 1812 i = 1;
1809 while (i <= NUM_GASES && numLines < MAX_NUM_SUMMARY_LINES) { 1813 while (i <= NUM_GASES) {
1810 if (settings->setpoint[i].note.ub.active && !settings->setpoint[i].note.ub.first && settings->setpoint[i].depth_meter) { 1814 if (setpointIsActive(settings, i) && settings->setpoint[i].note.ub.first) {
1811 setpointsToShow[numLines - offset] = &settings->setpoint[i]; 1815 setpointsToShow[numLines - offset] = &settings->setpoint[i];
1812 numLines++; 1816 numLines++;
1817
1818 break;
1813 } 1819 }
1814 1820
1815 i++; 1821 i++;
1816 } 1822 }
1817 } else { 1823
1818 showManualSetpoints = true; 1824 showManualSetpoints = true;
1819 } 1825 }
1820 } 1826 }
1821 1827
1822 // Add remaining active diluents 1828 // Add remaining active diluents
1840 if (setpointsToShow[0]) { 1846 if (setpointsToShow[0]) {
1841 offset--; 1847 offset--;
1842 } 1848 }
1843 i = 2; 1849 i = 2;
1844 while (i <= NUM_GASES && numLines < MAX_NUM_SUMMARY_LINES) { 1850 while (i <= NUM_GASES && numLines < MAX_NUM_SUMMARY_LINES) {
1845 if (settings->setpoint[i].note.ub.active && !settings->setpoint[i].note.ub.first) { 1851 if (setpointIsActive(settings, i) && !settings->setpoint[i].note.ub.first) {
1846 setpointsToShow[numLines - offset] = &settings->setpoint[i]; 1852 setpointsToShow[numLines - offset] = &settings->setpoint[i];
1847 numLines++; 1853 numLines++;
1848 } 1854 }
1849 1855
1850 i++; 1856 i++;
1877 1883
1878 i = 0; 1884 i = 0;
1879 while (setpointsToShow[i] != NULL && i < MAX_NUM_SUMMARY_LINES - 1) { 1885 while (setpointsToShow[i] != NULL && i < MAX_NUM_SUMMARY_LINES - 1) {
1880 heading[headingIndex++] = '\n'; 1886 heading[headingIndex++] = '\n';
1881 heading[headingIndex++] = '\r'; 1887 heading[headingIndex++] = '\r';
1882 if (i == 0) { 1888 if (settings->autoSetpoint) {
1889 heading[headingIndex++] = TXT_2BYTE;
1890 heading[headingIndex++] = TXT2BYTE_SetpointShort;
1891 headingIndex += printSetpointName(&heading[headingIndex], i + 1, settings, true);
1892 } else if (i == 0) {
1883 heading[headingIndex++] = TXT_2BYTE; 1893 heading[headingIndex++] = TXT_2BYTE;
1884 heading[headingIndex++] = TXT2BYTE_Setpoint; 1894 heading[headingIndex++] = TXT2BYTE_Setpoint;
1885 } 1895 }
1886 1896
1887 data[dataIndex++] = '\n'; 1897 data[dataIndex++] = '\n';
1888 data[dataIndex++] = '\r'; 1898 data[dataIndex++] = '\r';
1889 data[dataIndex++] = '\t'; 1899 data[dataIndex++] = '\t';
1890 dataIndex += snprintf(&data[dataIndex], 10, "\020%01.2f", setpointsToShow[i]->setpoint_cbar / 100.0); 1900 dataIndex += snprintf(&data[dataIndex], 10, "\020%01.2f", setpointsToShow[i]->setpoint_cbar / 100.0);
1891 if (settings->autoSetpoint) { 1901 if (setpointsToShow[i]->depth_meter && !(settings->autoSetpoint && i + 1 == SETPOINT_INDEX_AUTO_DECO)) {
1892 dataIndex += snprintf(&data[dataIndex], 10, "\016\016 %um\017", setpointsToShow[i]->depth_meter); 1902 bool setpointDelayed = settings->autoSetpoint && i + 1 == SETPOINT_INDEX_AUTO_LOW && settings->delaySetpointLow;
1903 dataIndex += snprintf(&data[dataIndex], 10, "\016\016 %um%s\017", setpointsToShow[i]->depth_meter, setpointDelayed ? "(d)" : "");
1893 } 1904 }
1894 1905
1895 i++; 1906 i++;
1896 } 1907 }
1897 1908
2446 2457
2447 case CVIEW_Decolist: 2458 case CVIEW_Decolist:
2448 snprintf(text,100,"\032\f\001 %c%c", TXT_2BYTE, TXT2BYTE_Decolist); 2459 snprintf(text,100,"\032\f\001 %c%c", TXT_2BYTE, TXT2BYTE_Decolist);
2449 GFX_write_string(&FontT42,&t7cH,text,0); 2460 GFX_write_string(&FontT42,&t7cH,text,0);
2450 2461
2451 const SDecoinfo * pDecoinfo;
2452 uint8_t depthNext, depthLast, depthSecond, depthInc; 2462 uint8_t depthNext, depthLast, depthSecond, depthInc;
2453
2454 if(stateUsed->diveSettings.deco_type.ub.standard == GF_MODE)
2455 pDecoinfo = &stateUsed->decolistBuehlmann;
2456 else
2457 pDecoinfo = &stateUsed->decolistVPM;
2458 2463
2459 depthLast = (uint8_t)(stateUsed->diveSettings.last_stop_depth_bar * 10); 2464 depthLast = (uint8_t)(stateUsed->diveSettings.last_stop_depth_bar * 10);
2460 depthSecond = (uint8_t)(stateUsed->diveSettings.input_second_to_last_stop_depth_bar * 10); 2465 depthSecond = (uint8_t)(stateUsed->diveSettings.input_second_to_last_stop_depth_bar * 10);
2461 depthInc = (uint8_t)(stateUsed->diveSettings.input_next_stop_increment_depth_bar * 10); 2466 depthInc = (uint8_t)(stateUsed->diveSettings.input_next_stop_increment_depth_bar * 10);
2462 2467
2465 depthLast = (uint8_t)unit_depth_integer(depthLast); 2470 depthLast = (uint8_t)unit_depth_integer(depthLast);
2466 depthSecond = (uint8_t)unit_depth_integer(depthSecond); 2471 depthSecond = (uint8_t)unit_depth_integer(depthSecond);
2467 depthInc = (uint8_t)unit_depth_integer(depthInc); 2472 depthInc = (uint8_t)unit_depth_integer(depthInc);
2468 } 2473 }
2469 2474
2475 const SDecoinfo * pDecoinfo = getDecoInfo();
2470 for(start=DECOINFO_STRUCT_MAX_STOPS-1; start>0; start--) 2476 for(start=DECOINFO_STRUCT_MAX_STOPS-1; start>0; start--)
2471 if(pDecoinfo->output_stop_length_seconds[start]) break; 2477 if(pDecoinfo->output_stop_length_seconds[start]) break;
2472 start -= 6; 2478 start -= 6;
2473 if(start < 0) start = 0; 2479 if(start < 0) start = 0;
2474 2480
2536 uint8_t oxygen_percentage = 0; 2542 uint8_t oxygen_percentage = 0;
2537 SDivetime Divetime = {0,0,0, 0}; 2543 SDivetime Divetime = {0,0,0, 0};
2538 SDivetime SafetyStopTime = {0,0,0,0}; 2544 SDivetime SafetyStopTime = {0,0,0,0};
2539 SDivetime TimeoutTime = {0,0,0,0}; 2545 SDivetime TimeoutTime = {0,0,0,0};
2540 uint8_t customview_warnings = 0; 2546 uint8_t customview_warnings = 0;
2541 const SDecoinfo * pDecoinfo;
2542 2547
2543 SSettings* pSettings; 2548 SSettings* pSettings;
2544 pSettings = settingsGetPointer(); 2549 pSettings = settingsGetPointer();
2545 2550
2546 Divetime.Total = stateUsed->lifeData.dive_time_seconds_without_surface_time; 2551 Divetime.Total = stateUsed->lifeData.dive_time_seconds_without_surface_time;
2557 TimeoutTime.Total = 0; 2562 TimeoutTime.Total = 0;
2558 } 2563 }
2559 TimeoutTime.Minutes = TimeoutTime.Total / 60; 2564 TimeoutTime.Minutes = TimeoutTime.Total / 60;
2560 TimeoutTime.Seconds = TimeoutTime.Total - (TimeoutTime.Minutes * 60); 2565 TimeoutTime.Seconds = TimeoutTime.Total - (TimeoutTime.Minutes * 60);
2561 2566
2562 if(stateUsed->diveSettings.deco_type.ub.standard == GF_MODE) 2567 const SDecoinfo * pDecoinfo = getDecoInfo();
2563 pDecoinfo = &stateUsed->decolistBuehlmann;
2564 else
2565 pDecoinfo = &stateUsed->decolistVPM;
2566
2567 if(pDecoinfo->output_time_to_surface_seconds) 2568 if(pDecoinfo->output_time_to_surface_seconds)
2568 { 2569 {
2569 tHome_findNextStop(pDecoinfo->output_stop_length_seconds, &nextstopDepthMeter, &nextstopLengthSeconds); 2570 tHome_findNextStop(pDecoinfo->output_stop_length_seconds, &nextstopDepthMeter, &nextstopLengthSeconds);
2570 } 2571 }
2571 else 2572 else