annotate Discovery/Src/tMenuGas.c @ 288:ba229a012ac7 div-fixes-6

cleanup: no useless checks for simulator state and some more in the style of commit 74a8296a2318. And in addition more cleanup like removing commented and unused code, and making things static. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Mon, 29 Apr 2019 19:43:05 +0200
parents 5f11787b4f42
children 3f09b283d993
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 ///////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 /// -*- coding: UTF-8 -*-
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 /// \file Discovery/Src/tMenuGas.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 /// \brief Main Template file for Menu Page Gas, OC only at the moment
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 /// \author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 /// \date 30-April-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 /// \details
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 /// $Id$
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ///////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 /// This program is free software: you can redistribute it and/or modify
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 /// it under the terms of the GNU General Public License as published by
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 /// the Free Software Foundation, either version 3 of the License, or
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 /// (at your option) any later version.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 /// This program is distributed in the hope that it will be useful,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 /// GNU General Public License for more details.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 /// You should have received a copy of the GNU General Public License
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 //////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 #include "tMenu.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 #include "tMenuGas.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 #include "check_warning.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 #include "decom.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 #include "unit.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 #define OCGAS_STANDARD (0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 #define OCGAS_BAILOUT_INACTIVE (1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 #define OCGAS_BAILOUT_ACTIVE (2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 #define CCGAS_STANDARD (0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 /* Private function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 void tMG_refresh(uint8_t line, char *text, uint16_t *tab, char *subtext, uint8_t start, uint8_t gasMode);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 uint32_t tMOG_refresh(uint8_t line, char *text, uint16_t *tab, char *subtext)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 uint8_t gas_mode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 if((actual_menu_content == MENU_SURFACE) || (stateUsed->diveSettings.ccrOption == 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 gas_mode = OCGAS_STANDARD;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 if (stateUsed->diveSettings.diveMode == DIVEMODE_CCR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 gas_mode = OCGAS_BAILOUT_INACTIVE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 gas_mode = OCGAS_BAILOUT_ACTIVE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 tMG_refresh(line, text, tab, subtext, 0, gas_mode);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 return StMOG;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 uint32_t tMCG_refresh(uint8_t line, char *text, uint16_t *tab, char *subtext)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 tMG_refresh(line, text, tab, subtext, NUM_OFFSET_DILUENT, CCGAS_STANDARD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 return StMCG;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 void tMG_refresh(uint8_t line, char *text, uint16_t *tab, char *subtext, uint8_t start, uint8_t gasMode)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 const SGasLine * pGasLine;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 uint8_t gasId, oxygen, helium, depthUp, active, first, typeDeco, wirelessId;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 float fPpO2limitHigh = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 float fPpO2ofGasAtThisDepth = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 //uint8_t senderCode, depthDown,;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 //uint16_t bar;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 uint16_t textPointer, mod, ltr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 if(actual_menu_content == MENU_SURFACE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 pGasLine = settingsGetPointer()->gas;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 pGasLine = stateUsed->diveSettings.gas;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 if(actualLeftMaxDepth(stateUsed))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 fPpO2limitHigh = (float)(settingsGetPointer()->ppO2_max_deco) / 100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 fPpO2limitHigh = (float)(settingsGetPointer()->ppO2_max_std) / 100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 textPointer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 *tab = 158;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 if((line == 0) && (actual_menu_content == MENU_SURFACE))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 strcpy(subtext,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 "\022"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 // " Travel Deco MOD Bottle"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 " First MOD Deco Bottle"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 gasId = start;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 for(int count=1;count<=NUM_GASES;count++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 gasId++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 if(line && (line != count))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 first = pGasLine[gasId].note.ub.first;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 if(first == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 strcpy(&text[textPointer],
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 "\t"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 "\177"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 "*"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 "\n\r"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 textPointer += 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 strcpy(&text[textPointer],"\n\r");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 textPointer += 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 oxygen = pGasLine[gasId].oxygen_percentage;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 helium = pGasLine[gasId].helium_percentage;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 depthUp = pGasLine[gasId].depth_meter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 //depthDown = pGasLine[gasId].depth_meter_travel;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 //senderCode = pGasLine[gasId].note.ub.senderCode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 active = pGasLine[gasId].note.ub.active;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 first = pGasLine[gasId].note.ub.first;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 typeDeco = pGasLine[gasId].note.ub.deco;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 mod = calc_MOD(gasId);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 ltr = pGasLine[gasId].bottle_size_liter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 wirelessId = pGasLine[gasId].bottle_wireless_id;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 //bar = stateUsed->lifeData.bottle_bar[gasId];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 if(active)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 if(actual_menu_content == MENU_SURFACE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 strcpy(&text[textPointer++],"\020");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 fPpO2ofGasAtThisDepth = (stateUsed->lifeData.pressure_ambient_bar - WATER_VAPOUR_PRESSURE) * pGasLine[gasId].oxygen_percentage / 100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 if(fPpO2ofGasAtThisDepth > fPpO2limitHigh)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 strcpy(&text[textPointer++],"\025");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 strcpy(&text[textPointer++],"\020");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 strcpy(&text[textPointer++],"\021");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 textPointer += write_gas(&text[textPointer], oxygen, helium);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 strcpy(&text[textPointer++],"\t");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 if(gasMode == OCGAS_BAILOUT_INACTIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 textPointer += snprintf(&text[textPointer], 59,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 "\024"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 " Bailout"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 "\021"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 "\034"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 " %3u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 " %c%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 "\035"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 "\n\r",
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 unit_depth_integer(mod),
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 unit_depth_char1(),
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 unit_depth_char2()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 textPointer += snprintf(&text[textPointer], 57,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 "\024"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 " Bailout"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 "\021"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 "\034"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 " %3u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 "m"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 " %2u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 "ltr"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 " %3u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 "bar"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 "\035"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 "\n\r",
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 mod, ltr, bar
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 if(first == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 strcpy(&text[textPointer++],"\177");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 /* color active / inactive for gas changes */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 char color[5] = {'\021','\021','\021','\021','\021'};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 if(active)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 /* mod */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 color[0] = '\023';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 /* deco */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 if(typeDeco && depthUp)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 color[1] = '\020';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 /* ltr */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 if(ltr)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 color[2] = '\020';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 /* bar */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 if(wirelessId)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 color[3] = '\020';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 /* wireless */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 if(wirelessId)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 color[4] = '\020';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 /* ltr, bar */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 if(mod < depthUp)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 color[0] = '\025';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 color[1] = '\025';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 if(typeDeco && !depthUp)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 color[1] = '\025';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 /* output */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 /* MOD */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 textPointer += snprintf(&text[textPointer], 14,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 "*"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 " "
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 "\034"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 "%3u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 " %c%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 "\017",
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 color[0],
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 unit_depth_integer(mod),
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 unit_depth_char1(),
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 unit_depth_char2()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 /* deco */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 if(typeDeco)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 textPointer += snprintf(&text[textPointer], 14,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 "%3u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 " %c%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 "\017",
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271 color[1],
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 unit_depth_integer(depthUp),
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 unit_depth_char1(),
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274 unit_depth_char2()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 text[textPointer++] = '\x7F';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 text[textPointer++] = '\x7F';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281 text[textPointer++] = 3*25 + 20;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 /* liter */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 textPointer += snprintf(&text[textPointer], 12,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 " %2u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 "ltr"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 , color[2],ltr
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 /* bar */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 textPointer += snprintf(&text[textPointer], 12,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 " %3u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 "bar"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 "\017",
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 color[3], bar
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 /* wireless */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 if(wirelessId)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 textPointer += snprintf(&text[textPointer], 8,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 " *"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312 "%u",
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 color[4], (wirelessId%0x0F)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 text[textPointer++] = '\035';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 text[textPointer++] = '\n';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 text[textPointer++] = '\r';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 text[textPointer] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 /* special gas number #6 in dive mode*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 if(((line == 0) || (line == 6)) && (actual_menu_content != MENU_SURFACE))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 text[textPointer++] = '\020';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 text[textPointer++] = TXT_2BYTE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 if(start == NUM_OFFSET_DILUENT)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 text[textPointer++] = TXT2BYTE_SpecialDiveGasMenuCCR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 text[textPointer++] = TXT2BYTE_SpecialDiveGasMenu;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 text[textPointer++] = '\n';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 text[textPointer++] = '\r';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 text[textPointer++] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 /* Private functions ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 /* write_gas() is used in t7.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 uint8_t length;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 if((oxygen == 21) && (helium == 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 strcpy(text,"Air");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 length = 3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354 else if(oxygen == 100)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356 strcpy(text,"Oxy");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357 length = 3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 else if(helium == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361 length = snprintf(text, 7,"NX%u",oxygen);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 else if((oxygen + helium) == 100)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 length = snprintf(text, 7,"HX%u",oxygen);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 length = snprintf(text, 7,"%u/%u",oxygen,helium);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 if(length > 6)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374 strcpy(text,"error");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375 length = 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 return length;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 }