Mercurial > public > ostc4
annotate Discovery/Src/tMenuGas.c @ 1064:449e0f8f23d0 Icon_Integration
Code cleanup co2 sensor:
In the very first implementation the co2 sensor was directly switch by the main CPU via command request. Since the sensor map implementation this function was replaced and the old function are no longer needed => have been removed.
| author | Ideenmodellierer |
|---|---|
| date | Mon, 16 Feb 2026 21:11:59 +0100 |
| parents | f501d7c35c8f |
| children | eceb5cb2a8e3 |
| rev | line source |
|---|---|
| 38 | 1 /////////////////////////////////////////////////////////////////////////////// |
| 2 /// -*- coding: UTF-8 -*- | |
| 3 /// | |
| 4 /// \file Discovery/Src/tMenuGas.c | |
| 5 /// \brief Main Template file for Menu Page Gas, OC only at the moment | |
| 6 /// \author heinrichs weikamp gmbh | |
| 7 /// \date 30-April-2014 | |
| 8 /// | |
| 9 /// \details | |
| 10 /// | |
| 11 /// $Id$ | |
| 12 /////////////////////////////////////////////////////////////////////////////// | |
| 13 /// \par Copyright (c) 2014-2018 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 "tMenu.h" | |
| 31 #include "tMenuGas.h" | |
| 32 #include "check_warning.h" | |
| 33 #include "decom.h" | |
| 34 #include "unit.h" | |
|
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
35 #include "configuration.h" |
| 38 | 36 |
| 37 #define OCGAS_STANDARD (0) | |
| 38 #define OCGAS_BAILOUT_INACTIVE (1) | |
| 39 #define OCGAS_BAILOUT_ACTIVE (2) | |
|
647
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
40 #define CCGAS_STANDARD (3) |
| 38 | 41 |
| 42 /* Private function prototypes -----------------------------------------------*/ | |
| 43 uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium); | |
| 44 void tMG_refresh(uint8_t line, char *text, uint16_t *tab, char *subtext, uint8_t start, uint8_t gasMode); | |
| 45 | |
| 46 /* Exported functions --------------------------------------------------------*/ | |
| 47 | |
| 48 uint32_t tMOG_refresh(uint8_t line, char *text, uint16_t *tab, char *subtext) | |
| 49 { | |
| 50 uint8_t gas_mode; | |
| 51 | |
| 52 if((actual_menu_content == MENU_SURFACE) || (stateUsed->diveSettings.ccrOption == 0)) | |
| 53 { | |
| 54 gas_mode = OCGAS_STANDARD; | |
| 55 } | |
| 56 else | |
| 57 { | |
| 662 | 58 if (isLoopMode(stateUsed->diveSettings.diveMode)) |
| 38 | 59 gas_mode = OCGAS_BAILOUT_INACTIVE; |
| 60 else | |
| 61 gas_mode = OCGAS_BAILOUT_ACTIVE; | |
| 62 } | |
| 63 | |
| 64 tMG_refresh(line, text, tab, subtext, 0, gas_mode); | |
| 65 return StMOG; | |
| 66 } | |
| 67 | |
| 68 uint32_t tMCG_refresh(uint8_t line, char *text, uint16_t *tab, char *subtext) | |
| 69 { | |
| 70 tMG_refresh(line, text, tab, subtext, NUM_OFFSET_DILUENT, CCGAS_STANDARD); | |
| 71 return StMCG; | |
| 72 } | |
| 73 | |
| 74 void tMG_refresh(uint8_t line, char *text, uint16_t *tab, char *subtext, uint8_t start, uint8_t gasMode) | |
| 75 { | |
| 76 const SGasLine * pGasLine; | |
| 77 | |
| 344 | 78 uint8_t gasId, oxygen, helium, depthUp, active, first, typeDeco; |
| 38 | 79 float fPpO2limitHigh = 0; |
| 80 float fPpO2ofGasAtThisDepth = 0; | |
| 81 //uint8_t senderCode, depthDown,; | |
| 1061 | 82 #ifdef ENABLE_ADVANCED_GAS |
| 83 uint16_t bar, ltr; | |
| 84 #endif | |
| 85 uint16_t textPointer, mod; | |
| 38 | 86 |
| 87 if(actual_menu_content == MENU_SURFACE) | |
| 88 { | |
| 89 pGasLine = settingsGetPointer()->gas; | |
| 90 } | |
| 91 else | |
| 92 { | |
| 93 pGasLine = stateUsed->diveSettings.gas; | |
| 94 if(actualLeftMaxDepth(stateUsed)) | |
| 95 fPpO2limitHigh = (float)(settingsGetPointer()->ppO2_max_deco) / 100; | |
| 96 else | |
| 97 fPpO2limitHigh = (float)(settingsGetPointer()->ppO2_max_std) / 100; | |
| 98 } | |
| 99 textPointer = 0; | |
| 100 *tab = 158; | |
| 101 | |
| 102 /* | |
| 103 if((line == 0) && (actual_menu_content == MENU_SURFACE)) | |
| 104 { | |
| 105 strcpy(subtext, | |
| 106 "\022" | |
| 107 // " Travel Deco MOD Bottle" | |
| 108 " First MOD Deco Bottle" | |
| 109 ); | |
| 110 } | |
| 111 */ | |
| 112 | |
| 113 gasId = start; | |
| 114 for(int count=1;count<=NUM_GASES;count++) | |
| 115 { | |
| 116 gasId++; | |
| 117 if(line && (line != count)) | |
| 118 { | |
| 119 first = pGasLine[gasId].note.ub.first; | |
| 120 if(first == 0) | |
| 121 { | |
| 122 strcpy(&text[textPointer], | |
| 123 "\t" | |
| 124 "\177" | |
| 125 "*" | |
| 126 "\n\r" | |
| 127 ); | |
| 128 textPointer += 5; | |
| 129 } | |
| 130 else | |
| 131 { | |
| 132 strcpy(&text[textPointer],"\n\r"); | |
| 133 textPointer += 2; | |
| 134 } | |
| 135 } | |
| 136 else | |
| 137 { | |
| 138 oxygen = pGasLine[gasId].oxygen_percentage; | |
| 139 helium = pGasLine[gasId].helium_percentage; | |
| 140 depthUp = pGasLine[gasId].depth_meter; | |
| 141 //depthDown = pGasLine[gasId].depth_meter_travel; | |
| 142 //senderCode = pGasLine[gasId].note.ub.senderCode; | |
| 143 active = pGasLine[gasId].note.ub.active; | |
| 144 first = pGasLine[gasId].note.ub.first; | |
| 145 typeDeco = pGasLine[gasId].note.ub.deco; | |
| 146 mod = calc_MOD(gasId); | |
| 1061 | 147 #ifdef ENABLE_ADVANCED_GAS |
| 38 | 148 ltr = pGasLine[gasId].bottle_size_liter; |
| 1061 | 149 bar = stateUsed->lifeData.bottle_bar[gasId]; |
| 150 #endif | |
| 38 | 151 |
|
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
152 #ifdef ENABLE_UNUSED_GAS_HIDING |
|
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
153 if(pGasLine[gasId].note.ub.off) |
|
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
154 { |
|
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
155 strcpy(&text[textPointer++],"\021"); |
|
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
156 } |
|
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
157 else |
|
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
158 #endif |
| 38 | 159 if(active) |
| 160 { | |
| 161 if(actual_menu_content == MENU_SURFACE) | |
| 162 strcpy(&text[textPointer++],"\020"); | |
| 163 else | |
| 164 { | |
| 165 fPpO2ofGasAtThisDepth = (stateUsed->lifeData.pressure_ambient_bar - WATER_VAPOUR_PRESSURE) * pGasLine[gasId].oxygen_percentage / 100; | |
| 166 if(fPpO2ofGasAtThisDepth > fPpO2limitHigh) | |
| 167 strcpy(&text[textPointer++],"\025"); | |
| 168 else | |
| 169 strcpy(&text[textPointer++],"\020"); | |
| 170 } | |
| 171 } | |
| 172 else | |
|
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
173 { |
|
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
174 strcpy(&text[textPointer++],"\031"); |
|
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
175 } |
| 38 | 176 textPointer += write_gas(&text[textPointer], oxygen, helium); |
| 177 | |
| 178 strcpy(&text[textPointer++],"\t"); | |
| 179 | |
| 180 if(gasMode == OCGAS_BAILOUT_INACTIVE) | |
| 181 { | |
| 182 textPointer += snprintf(&text[textPointer], 59,\ | |
| 1061 | 183 "\024 Bailout\031\034 %3u\016\016%c%c\017" |
| 184 #ifdef ENABLE_ADVANCED_GAS | |
| 185 | |
| 186 #endif | |
| 187 "\035" | |
| 38 | 188 "\n\r", |
| 189 unit_depth_integer(mod), | |
| 190 unit_depth_char1(), | |
| 1061 | 191 unit_depth_char2()); |
| 192 #ifdef ENABLE_ADVANCED_GAS | |
| 193 if( ltr != 0) | |
| 194 { | |
| 195 textPointer += snprintf(&text[textPointer], 20,"\007 %2u\016\016ltr\017",ltr); | |
| 196 } | |
| 197 else | |
| 198 { | |
| 199 text[textPointer++] = '\007'; | |
| 200 text[textPointer++] = '\007'; | |
| 201 text[textPointer++] = '\007'; | |
| 202 } | |
| 203 if( bar != 0) | |
| 204 { | |
| 205 textPointer += snprintf(&text[textPointer], 20,"\007 %2u\016\016bar\017",bar); | |
| 206 } | |
| 207 | |
| 208 #endif | |
| 38 | 209 } |
| 210 else | |
| 211 { | |
| 212 if(first == 0) | |
| 213 strcpy(&text[textPointer++],"\177"); | |
| 214 | |
| 215 /* color active / inactive for gas changes */ | |
|
528
a9c195be907e
Added new option to gas configuration: "Off":
Ideenmodellierer
parents:
344
diff
changeset
|
216 char color[5] = {'\031','\031','\031','\031','\031'}; |
| 38 | 217 if(active) |
| 218 { | |
| 219 /* mod */ | |
| 220 color[0] = '\023'; | |
| 221 /* deco */ | |
| 222 if(typeDeco && depthUp) | |
| 223 color[1] = '\020'; | |
| 224 /* ltr */ | |
| 225 if(ltr) | |
| 226 color[2] = '\020'; | |
| 227 /* bar */ | |
| 228 | |
| 229 if(mod < depthUp) | |
| 230 { | |
| 231 color[0] = '\025'; | |
| 232 color[1] = '\025'; | |
| 233 } | |
| 234 if(typeDeco && !depthUp) | |
| 235 { | |
| 236 color[1] = '\025'; | |
| 237 } | |
| 238 } | |
| 239 | |
| 240 /* output */ | |
| 241 /* MOD */ | |
| 242 textPointer += snprintf(&text[textPointer], 14,\ | |
| 243 "*" | |
| 244 " " | |
| 245 "\034" | |
| 246 "%c" | |
| 247 "%3u" | |
| 248 "\016\016" | |
| 1061 | 249 "%c%c" |
| 38 | 250 "\017", |
| 251 color[0], | |
| 252 unit_depth_integer(mod), | |
| 253 unit_depth_char1(), | |
| 254 unit_depth_char2() | |
| 255 ); | |
| 256 | |
| 257 /* deco */ | |
| 258 if(typeDeco) | |
| 259 { | |
| 260 textPointer += snprintf(&text[textPointer], 14,\ | |
| 261 "%c" | |
| 262 "%3u" | |
| 263 "\016\016" | |
| 1061 | 264 "%c%c" |
| 38 | 265 "\017", |
| 266 color[1], | |
| 267 unit_depth_integer(depthUp), | |
| 268 unit_depth_char1(), | |
| 269 unit_depth_char2() | |
| 270 ); | |
| 271 } | |
| 272 else | |
| 273 { | |
| 274 text[textPointer++] = '\x7F'; | |
| 275 text[textPointer++] = '\x7F'; | |
| 276 text[textPointer++] = 3*25 + 20; | |
| 277 } | |
| 278 /* liter */ | |
| 1061 | 279 #ifdef ENABLE_ADVANCED_GAS |
| 280 if(ltr != 0) | |
| 281 { | |
| 282 textPointer += snprintf(&text[textPointer], 12,\ | |
| 283 "%c" | |
| 284 "\007\007%2u" | |
| 285 "\016\016" | |
| 286 "ltr" | |
| 287 "\017" | |
| 288 , color[2],ltr | |
| 289 ); | |
| 290 } | |
| 291 else | |
| 292 { | |
| 293 text[textPointer++] = '\007'; | |
| 294 text[textPointer++] = '\007'; | |
| 295 text[textPointer++] = '\007'; | |
| 296 } | |
| 38 | 297 /* bar */ |
| 1061 | 298 if(bar != 0) |
| 299 { | |
| 300 textPointer += snprintf(&text[textPointer], 12,\ | |
| 301 "%c" | |
| 302 "\007%3u" | |
| 303 "\016\016" | |
| 304 "bar" | |
| 305 "\017", | |
| 306 color[3], bar); | |
| 307 } | |
| 308 #endif | |
| 38 | 309 text[textPointer++] = '\035'; |
| 310 text[textPointer++] = '\n'; | |
| 311 text[textPointer++] = '\r'; | |
| 312 text[textPointer] = 0; | |
| 313 } | |
| 314 } | |
| 315 } | |
| 316 | |
| 317 /* special gas number #6 in dive mode*/ | |
|
647
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
318 if(((line == 0) || (line == 6))) |
| 38 | 319 { |
|
647
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
320 if(actual_menu_content != MENU_SURFACE) |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
321 { |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
322 text[textPointer++] = '\020'; |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
323 text[textPointer++] = TXT_2BYTE; |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
324 if(start == NUM_OFFSET_DILUENT) |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
325 text[textPointer++] = TXT2BYTE_SpecialDiveGasMenuCCR; |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
326 else |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
327 text[textPointer++] = TXT2BYTE_SpecialDiveGasMenu; |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
328 text[textPointer++] = '\n'; |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
329 text[textPointer++] = '\r'; |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
330 text[textPointer++] = 0; |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
331 } |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
332 else /* switch to bailout selection in surface mode */ |
| 662 | 333 if((isLoopMode(settingsGetPointer()->dive_mode)) || (stateUsed->diveSettings.ccrOption == 1)) |
|
647
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
334 { |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
335 text[textPointer++] = '\024'; |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
336 if(gasMode == CCGAS_STANDARD) |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
337 { |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
338 textPointer += snprintf(&text[textPointer], 14,"Bailout\n"); |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
339 } |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
340 else |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
341 { |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
342 textPointer += snprintf(&text[textPointer], 14,"Diluent\n"); |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
343 } |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
344 } |
| 38 | 345 } |
| 346 } | |
| 347 | |
| 348 | |
| 349 /* Private functions ---------------------------------------------------------*/ | |
| 350 | |
| 351 /* write_gas() is used in t7.c | |
| 352 */ | |
| 353 uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium) | |
| 354 { | |
| 355 uint8_t length; | |
| 356 | |
| 357 if((oxygen == 21) && (helium == 0)) | |
| 358 { | |
| 359 strcpy(text,"Air"); | |
| 360 length = 3; | |
| 361 } | |
| 362 else if(oxygen == 100) | |
| 363 { | |
| 364 strcpy(text,"Oxy"); | |
| 365 length = 3; | |
| 366 } | |
| 367 else if(helium == 0) | |
| 368 { | |
| 369 length = snprintf(text, 7,"NX%u",oxygen); | |
| 370 } | |
| 371 else if((oxygen + helium) == 100) | |
| 372 { | |
| 373 length = snprintf(text, 7,"HX%u",oxygen); | |
| 374 } | |
| 375 else | |
| 376 { | |
| 377 length = snprintf(text, 7,"%u/%u",oxygen,helium); | |
| 378 } | |
| 379 | |
| 380 if(length > 6) | |
| 381 { | |
| 382 strcpy(text,"error"); | |
| 383 length = 5; | |
| 384 } | |
| 385 | |
| 386 return length; | |
| 387 } |
