Mercurial > public > ostc4
annotate Discovery/Src/tMenuGas.c @ 1067:a7ed4eb3142b Icon_Integration
Exit to Correct Menu when Exiting from 'Reset Menu' Submenus.
Write Progress and Success Messages when Flashing the Bootloader.
Only Show 'Flash Bootloader' if the Available Bootloader is Different from the Existing One.
(mikeller)
| author | heinrichsweikamp |
|---|---|
| date | Tue, 17 Feb 2026 09:49:37 +0100 |
| parents | eceb5cb2a8e3 |
| children |
| 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 */ | |
| 1066 | 225 #ifdef ENABLE_ADVANCED_GAS |
| 38 | 226 if(ltr) |
| 227 color[2] = '\020'; | |
| 1066 | 228 #endif |
| 38 | 229 /* bar */ |
| 230 | |
| 231 if(mod < depthUp) | |
| 232 { | |
| 233 color[0] = '\025'; | |
| 234 color[1] = '\025'; | |
| 235 } | |
| 236 if(typeDeco && !depthUp) | |
| 237 { | |
| 238 color[1] = '\025'; | |
| 239 } | |
| 240 } | |
| 241 | |
| 242 /* output */ | |
| 243 /* MOD */ | |
| 244 textPointer += snprintf(&text[textPointer], 14,\ | |
| 245 "*" | |
| 246 " " | |
| 247 "\034" | |
| 248 "%c" | |
| 249 "%3u" | |
| 250 "\016\016" | |
| 1061 | 251 "%c%c" |
| 38 | 252 "\017", |
| 253 color[0], | |
| 254 unit_depth_integer(mod), | |
| 255 unit_depth_char1(), | |
| 256 unit_depth_char2() | |
| 257 ); | |
| 258 | |
| 259 /* deco */ | |
| 260 if(typeDeco) | |
| 261 { | |
| 262 textPointer += snprintf(&text[textPointer], 14,\ | |
| 263 "%c" | |
| 264 "%3u" | |
| 265 "\016\016" | |
| 1061 | 266 "%c%c" |
| 38 | 267 "\017", |
| 268 color[1], | |
| 269 unit_depth_integer(depthUp), | |
| 270 unit_depth_char1(), | |
| 271 unit_depth_char2() | |
| 272 ); | |
| 273 } | |
| 274 else | |
| 275 { | |
| 276 text[textPointer++] = '\x7F'; | |
| 277 text[textPointer++] = '\x7F'; | |
| 278 text[textPointer++] = 3*25 + 20; | |
| 279 } | |
| 280 /* liter */ | |
| 1061 | 281 #ifdef ENABLE_ADVANCED_GAS |
| 282 if(ltr != 0) | |
| 283 { | |
| 284 textPointer += snprintf(&text[textPointer], 12,\ | |
| 285 "%c" | |
| 286 "\007\007%2u" | |
| 287 "\016\016" | |
| 288 "ltr" | |
| 289 "\017" | |
| 290 , color[2],ltr | |
| 291 ); | |
| 292 } | |
| 293 else | |
| 294 { | |
| 295 text[textPointer++] = '\007'; | |
| 296 text[textPointer++] = '\007'; | |
| 297 text[textPointer++] = '\007'; | |
| 298 } | |
| 38 | 299 /* bar */ |
| 1061 | 300 if(bar != 0) |
| 301 { | |
| 302 textPointer += snprintf(&text[textPointer], 12,\ | |
| 303 "%c" | |
| 304 "\007%3u" | |
| 305 "\016\016" | |
| 306 "bar" | |
| 307 "\017", | |
| 308 color[3], bar); | |
| 309 } | |
| 310 #endif | |
| 38 | 311 text[textPointer++] = '\035'; |
| 312 text[textPointer++] = '\n'; | |
| 313 text[textPointer++] = '\r'; | |
| 314 text[textPointer] = 0; | |
| 315 } | |
| 316 } | |
| 317 } | |
| 318 | |
| 319 /* special gas number #6 in dive mode*/ | |
|
647
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
320 if(((line == 0) || (line == 6))) |
| 38 | 321 { |
|
647
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
322 if(actual_menu_content != MENU_SURFACE) |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
323 { |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
324 text[textPointer++] = '\020'; |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
325 text[textPointer++] = TXT_2BYTE; |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
326 if(start == NUM_OFFSET_DILUENT) |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
327 text[textPointer++] = TXT2BYTE_SpecialDiveGasMenuCCR; |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
328 else |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
329 text[textPointer++] = TXT2BYTE_SpecialDiveGasMenu; |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
330 text[textPointer++] = '\n'; |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
331 text[textPointer++] = '\r'; |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
332 text[textPointer++] = 0; |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
333 } |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
334 else /* switch to bailout selection in surface mode */ |
| 662 | 335 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
|
336 { |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
337 text[textPointer++] = '\024'; |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
338 if(gasMode == CCGAS_STANDARD) |
|
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 textPointer += snprintf(&text[textPointer], 14,"Bailout\n"); |
|
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 else |
|
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 textPointer += snprintf(&text[textPointer], 14,"Diluent\n"); |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
345 } |
|
15f6f0b5786c
Integrated selection of bailout in the diluent selection page:
Ideenmodellierer
parents:
528
diff
changeset
|
346 } |
| 38 | 347 } |
| 348 } | |
| 349 | |
| 350 | |
| 351 /* Private functions ---------------------------------------------------------*/ | |
| 352 | |
| 353 /* write_gas() is used in t7.c | |
| 354 */ | |
| 355 uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium) | |
| 356 { | |
| 357 uint8_t length; | |
| 358 | |
| 359 if((oxygen == 21) && (helium == 0)) | |
| 360 { | |
| 361 strcpy(text,"Air"); | |
| 362 length = 3; | |
| 363 } | |
| 364 else if(oxygen == 100) | |
| 365 { | |
| 366 strcpy(text,"Oxy"); | |
| 367 length = 3; | |
| 368 } | |
| 369 else if(helium == 0) | |
| 370 { | |
| 371 length = snprintf(text, 7,"NX%u",oxygen); | |
| 372 } | |
| 373 else if((oxygen + helium) == 100) | |
| 374 { | |
| 375 length = snprintf(text, 7,"HX%u",oxygen); | |
| 376 } | |
| 377 else | |
| 378 { | |
| 379 length = snprintf(text, 7,"%u/%u",oxygen,helium); | |
| 380 } | |
| 381 | |
| 382 if(length > 6) | |
| 383 { | |
| 384 strcpy(text,"error"); | |
| 385 length = 5; | |
| 386 } | |
| 387 | |
| 388 return length; | |
| 389 } |
