annotate Discovery/Src/tMenuGas.c @ 426:514e6269256f ImprovmentNVM_2

Added function to analyse the sampel ringbuffer: The function will show 0 for used sectors, 4 for the sector currently in use and 5 for empty sectors. This allows identification of log sample index position and identification of a buffer corruption (more than 2 sectors have state 4) The repair function writes dummy bytes to the end of the active buffer with the lower sector number. This decision is based on the fact that corruption results typically in a reset of index to buffer start address. After repair the writing will be continued using the hugher buffer marked as used.
author ideenmodellierer
date Sat, 15 Feb 2020 20:50:58 +0100
parents 3f09b283d993
children a9c195be907e
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
344
3f09b283d993 Removed not used wireless menu items
ideenmodellierer
parents: 38
diff changeset
77 uint8_t gasId, oxygen, helium, depthUp, active, first, typeDeco;
38
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 //bar = stateUsed->lifeData.bottle_bar[gasId];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 if(active)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 if(actual_menu_content == MENU_SURFACE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 strcpy(&text[textPointer++],"\020");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 fPpO2ofGasAtThisDepth = (stateUsed->lifeData.pressure_ambient_bar - WATER_VAPOUR_PRESSURE) * pGasLine[gasId].oxygen_percentage / 100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 if(fPpO2ofGasAtThisDepth > fPpO2limitHigh)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 strcpy(&text[textPointer++],"\025");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 strcpy(&text[textPointer++],"\020");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 strcpy(&text[textPointer++],"\021");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 textPointer += write_gas(&text[textPointer], oxygen, helium);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 strcpy(&text[textPointer++],"\t");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 if(gasMode == OCGAS_BAILOUT_INACTIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 textPointer += snprintf(&text[textPointer], 59,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 "\024"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 " Bailout"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 "\021"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 "\034"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 " %3u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 " %c%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 "\035"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 "\n\r",
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 unit_depth_integer(mod),
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 unit_depth_char1(),
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 unit_depth_char2()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 textPointer += snprintf(&text[textPointer], 57,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 "\024"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 " Bailout"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 "\021"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 "\034"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 " %3u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 "m"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 " %2u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 "ltr"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 " %3u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 "bar"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 "\035"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 "\n\r",
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 mod, ltr, bar
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 );
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 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 if(first == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 strcpy(&text[textPointer++],"\177");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 /* color active / inactive for gas changes */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 char color[5] = {'\021','\021','\021','\021','\021'};
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 if(active)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 /* mod */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 color[0] = '\023';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 /* deco */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 if(typeDeco && depthUp)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 color[1] = '\020';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 /* ltr */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 if(ltr)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 color[2] = '\020';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 /* bar */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 if(mod < depthUp)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 color[0] = '\025';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 color[1] = '\025';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 if(typeDeco && !depthUp)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 color[1] = '\025';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 /* output */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 /* MOD */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 textPointer += snprintf(&text[textPointer], 14,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 "*"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 " "
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 "\034"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 "%3u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 " %c%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 "\017",
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 color[0],
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 unit_depth_integer(mod),
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 unit_depth_char1(),
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 unit_depth_char2()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 /* deco */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 if(typeDeco)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 textPointer += snprintf(&text[textPointer], 14,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 "%3u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 " %c%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 "\017",
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 color[1],
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 unit_depth_integer(depthUp),
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 unit_depth_char1(),
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 unit_depth_char2()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 text[textPointer++] = '\x7F';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 text[textPointer++] = '\x7F';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274 text[textPointer++] = 3*25 + 20;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 /* liter */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 textPointer += snprintf(&text[textPointer], 12,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 " %2u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 "ltr"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 , color[2],ltr
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 /* bar */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 textPointer += snprintf(&text[textPointer], 12,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 "%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 " %3u"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 "bar"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 "\017",
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 color[3], bar
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 text[textPointer++] = '\035';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 text[textPointer++] = '\n';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 text[textPointer++] = '\r';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 text[textPointer] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 }
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 /* special gas number #6 in dive mode*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 if(((line == 0) || (line == 6)) && (actual_menu_content != MENU_SURFACE))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 text[textPointer++] = '\020';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 text[textPointer++] = TXT_2BYTE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 if(start == NUM_OFFSET_DILUENT)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312 text[textPointer++] = TXT2BYTE_SpecialDiveGasMenuCCR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 text[textPointer++] = TXT2BYTE_SpecialDiveGasMenu;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 text[textPointer++] = '\n';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 text[textPointer++] = '\r';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 text[textPointer++] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 /* Private functions ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324 /* write_gas() is used in t7.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 uint8_t length;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 if((oxygen == 21) && (helium == 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 strcpy(text,"Air");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 length = 3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 else if(oxygen == 100)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 strcpy(text,"Oxy");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 length = 3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 else if(helium == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 length = snprintf(text, 7,"NX%u",oxygen);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 else if((oxygen + helium) == 100)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 length = snprintf(text, 7,"HX%u",oxygen);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350 length = snprintf(text, 7,"%u/%u",oxygen,helium);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 if(length > 6)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355 strcpy(text,"error");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356 length = 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 return length;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 }