comparison Discovery/Src/tMenuSetpoint.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 1b995079c045
children b7cd0c5c8e43
comparison
equal deleted inserted replaced
787:aeb72882f30a 788:4abfb8a2a435
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. 26 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
27 ////////////////////////////////////////////////////////////////////////////// 27 //////////////////////////////////////////////////////////////////////////////
28 28
29 /* Includes ------------------------------------------------------------------*/ 29 /* Includes ------------------------------------------------------------------*/
30 #include "tMenu.h" 30 #include "tMenu.h"
31 #include "tMenuEditSetpoint.h"
31 #include "tMenuSetpoint.h" 32 #include "tMenuSetpoint.h"
32 #include "unit.h" 33 #include "unit.h"
33 34
34 /* Private function prototypes -----------------------------------------------*/ 35 /* Private function prototypes -----------------------------------------------*/
35 36
36 /* Exported functions --------------------------------------------------------*/ 37 /* Exported functions --------------------------------------------------------*/
37 38
38 uint32_t tMSP_refresh(uint8_t line, 39 uint32_t tMSP_refresh(char *text, uint16_t *tab, char *subtext)
39 char *text,
40 uint16_t *tab,
41 char *subtext)
42 { 40 {
41 SSettings *settings = settingsGetPointer();
42
43 const SSetpointLine * pSetpointLine; 43 const SSetpointLine * pSetpointLine;
44 44
45 uint8_t textPointer, setpoint_cbar, sp_high, depthUp, first; // active 45 uint8_t textPointer, setpoint_cbar, depthUp, first;
46 46
47 if(actual_menu_content == MENU_SURFACE) 47 if(actual_menu_content == MENU_SURFACE)
48 pSetpointLine = settingsGetPointer()->setpoint; 48 pSetpointLine = settings->setpoint;
49 else 49 else
50 pSetpointLine = stateUsed->diveSettings.setpoint; 50 pSetpointLine = stateUsed->diveSettings.setpoint;
51 51
52 textPointer = 0; 52 textPointer = 0;
53 *tab = 130; 53 *tab = 130;
55 55
56 if((actual_menu_content == MENU_SURFACE) || (stateUsed->diveSettings.diveMode != DIVEMODE_PSCR)) /* do not show setpoints in PSCR mode */ 56 if((actual_menu_content == MENU_SURFACE) || (stateUsed->diveSettings.diveMode != DIVEMODE_PSCR)) /* do not show setpoints in PSCR mode */
57 { 57 {
58 for(int spId=1;spId<=NUM_GASES;spId++) 58 for(int spId=1;spId<=NUM_GASES;spId++)
59 { 59 {
60 if(line && (line != spId)) 60 if (settings->autoSetpoint) {
61 { 61 if (actual_menu_content == MENU_SURFACE && spId == 5) {
62 first = pSetpointLine[spId].note.ub.first; 62 textPointer += snprintf(&text[textPointer], 40, "\020%c%c\016\016%c%c\017 %c%c\002%c\n\r", TXT_2BYTE, TXT2BYTE_SetpointShort, TXT_2BYTE, TXT2BYTE_SetpointLow, TXT_2BYTE, TXT2BYTE_SetpointDelayed, settings->delaySetpointLow ? '\005' : '\006');
63 if(first == 0) 63 continue;
64 { 64 } else if (spId > SETPOINT_INDEX_AUTO_DECO) {
65 strcpy(&text[textPointer], 65 textPointer += snprintf(&text[textPointer], 3, "\n\r");
66 "\t"
67 "\177"
68 "*"
69 "\n\r"
70 );
71 textPointer += 5;
72 }
73 else
74 {
75 strcpy(&text[textPointer],"\n\r");
76 textPointer += 2;
77 }
78 }
79 else
80 {
81 setpoint_cbar = pSetpointLine[spId].setpoint_cbar;
82 depthUp = pSetpointLine[spId].depth_meter;
83 //active = pSetpointLine[spId].note.ub.active;
84 first = pSetpointLine[spId].note.ub.first;
85 66
86 strcpy(&text[textPointer],"\020"); // if(active) always active 67 continue;
87 textPointer += 1; 68 }
69 }
88 70
89 sp_high = setpoint_cbar / 100; 71 setpoint_cbar = pSetpointLine[spId].setpoint_cbar;
72 depthUp = pSetpointLine[spId].depth_meter;
73 first = pSetpointLine[spId].note.ub.first;
90 74
91 text[textPointer++] = 'S'; 75 if (settings->autoSetpoint && spId == SETPOINT_INDEX_AUTO_DECO && !pSetpointLine[spId].note.ub.active) {
92 text[textPointer++] = 'P'; 76 strcpy(&text[textPointer++],"\031");
93 text[textPointer++] = '0' + spId; 77 } else {
94 text[textPointer++] = '\t'; 78 strcpy(&text[textPointer++],"\020");
79 }
95 80
96 if((first == 0) || (actual_menu_content != MENU_SURFACE)) 81 uint8_t setpointBar = setpoint_cbar / 100;
97 strcpy(&text[textPointer++],"\177");
98 82
99 char color = '\031'; 83 textPointer += snprintf(&text[textPointer], 4, "%c%c", TXT_2BYTE, TXT2BYTE_SetpointShort);
100 if(depthUp) 84 textPointer += printSetpointName(&text[textPointer], spId, settings, true);
101 color = '\020'; 85 text[textPointer++] = '\t';
102 86
103 textPointer += snprintf(&text[textPointer], 57, 87 if (first == 0 || actual_menu_content != MENU_SURFACE) {
104 "* " 88 strcpy(&text[textPointer++],"\177");
105 "%u.%02u" 89 }
106 "\016\016" 90
107 " bar" 91 textPointer += snprintf(&text[textPointer], 40, "* %u.%02u\016\016 bar\017\034 \016\016 \017", setpointBar, setpoint_cbar - (100 * setpointBar));
108 "\017" 92 if (!settings->autoSetpoint || spId < SETPOINT_INDEX_AUTO_DECO) {
109 "\034" 93 char color = '\031';
110 " " 94 if(depthUp)
111 "\016\016" 95 color = '\020';
112 " " 96
113 "\017" 97 textPointer += snprintf(&text[textPointer], 40, "%c%3u\016\016 %c%c\017\035\n\r", color, unit_depth_integer(depthUp), unit_depth_char1(), unit_depth_char2());
114 "%c" 98 } else {
115 "%3u" 99 textPointer += snprintf(&text[textPointer], 3, "\n\r");
116 "\016\016" 100 }
117 " %c%c"
118 "\017"
119 "\035"
120 "\n\r",
121 sp_high, setpoint_cbar - (100 * sp_high),
122 color,
123 unit_depth_integer(depthUp),
124 unit_depth_char1(),
125 unit_depth_char2()
126 );
127 }
128 } 101 }
129 } 102 }
130 if((actual_menu_content != MENU_SURFACE) /*&& (line == 0)*/) 103 if (actual_menu_content != MENU_SURFACE) {
131 {
132 text[textPointer++] = '\020'; 104 text[textPointer++] = '\020';
133 text[textPointer++] = TXT_2BYTE; 105 text[textPointer++] = TXT_2BYTE;
134 text[textPointer++] = TXT2BYTE_UseSensor; 106 text[textPointer++] = TXT2BYTE_UseSensor;
135 text[textPointer++] = '\n'; 107 text[textPointer++] = '\n';
136 text[textPointer++] = '\r'; 108 text[textPointer++] = '\r';
137 109
138 110
139 if(stateUsed->diveSettings.diveMode == DIVEMODE_PSCR) 111 if(stateUsed->diveSettings.diveMode == DIVEMODE_PSCR)
140 { 112 {
141 textPointer += snprintf(&text[textPointer], 20,"\020%c", TXT_SimPpo2); 113 textPointer += snprintf(&text[textPointer], 20,"\020%c", TXT_SimPpo2);
142 } 114 }
143 text[textPointer++] = 0; 115 text[textPointer++] = 0;
144 } 116 }
145 else 117 else
146 { 118 {
147 text[textPointer++] = '\020'; 119 text[textPointer++] = '\020';
148 text[textPointer++] = TXT_2BYTE; 120 text[textPointer++] = TXT_2BYTE;
149 text[textPointer++] = TXT2BYTE_AutomaticSP; 121 text[textPointer++] = TXT2BYTE_AutomaticSP;
150 text[textPointer++] = '\002'; 122 text[textPointer++] = '\002';
151 if(settingsGetPointer()->autoSetpoint) 123 if (settings->autoSetpoint)
152 text[textPointer++] = '\005'; 124 text[textPointer++] = '\005';
153 else 125 else
154 text[textPointer++] = '\006'; 126 text[textPointer++] = '\006';
155 text[textPointer++] = 0; 127 text[textPointer++] = 0;
156 } 128 }