annotate code_part1/OSTC_code_c_part2/p2_main.c @ 644:420e62cd88ad

point to correct diluent location
author heinrichsweikamp
date Wed, 03 Oct 2012 13:12:02 +0200
parents cb055a7d75f3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
167
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
1 // ********************************************************************
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
2 // ** main code for simulation / tests without full simulation code **
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
3 // ** This is NOT a part of the OSTC **
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
4 // ********************************************************************
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
5
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
6 //////////////////////////////////////////////////////////////////////////////
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
7 // OSTC - diving computer code
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
8 // Copyright (C) 2008 HeinrichsWeikamp GbR
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
9 //
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
10 // This program is free software: you can redistribute it and/or modify
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
11 // it under the terms of the GNU General Public License as published by
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
13 // (at your option) any later version.
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
14 //
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
15 // This program is distributed in the hope that it will be useful,
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
18 // GNU General Public License for more details.
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
19 //
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
20 // You should have received a copy of the GNU General Public License
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
21 // along with this program. If not, see <http://www.gnu.org/licenses/>.
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
22 //
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
23 //////////////////////////////////////////////////////////////////////////////
167
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
24 // History:
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
25 // 12/25/10 v110: [jDG] split in three files (deco.c, main.c, definitions.h)
167
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
26 // 01/24/11 : [jDG] make it link with oled+wordprocessor display functions
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
27
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
28 #include <stdlib.h>
167
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
29 #include <stdio.h>
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
30
167
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
31 //////////////////////////////////////////////////////////////////////////////
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
32 // Compile with:
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
33 // p2_deco.c
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
34 // p2_environment.asm
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
35 // To have a linkable application, downloadable on the OSTC.
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
36 //////////////////////////////////////////////////////////////////////////////
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
37
167
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
38 #define TEST_MAIN 1
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
39 #include "p2_definitions.h"
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
40 #include "../OSTC_code_c_part2/shared_definitions.h"
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
41
167
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
42 //////////////////////////////////////////////////////////////////////////////
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
43 //
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
44
167
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
45 static void print_stops(void)
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
46 {
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
47 //TODO: print decompression stops using aa_wordprocessor...
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
48 PLED_ClearScreen();
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
49 win_top = 0;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
50 win_leftx2 = 0;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
51 win_font = 0;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
52 win_invert = 0;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
53 PLED_standard_color();
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
54
167
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
55 sprintf(letter, "TTS: %d", char_O_ascenttime);
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
56 aa_wordprocessor();
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
57
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
58 //TODO: Wait click (to continue)
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
59 }
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
60
167
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
61 //////////////////////////////////////////////////////////////////////////////
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
62 #pragma code main = 0x9000
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
63 void main(void)
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
64 {
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
65 static unsigned int i;
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
66 static unsigned int debug_temp;
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
67
167
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
68 char_I_deco_model = 0;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
69 deco_clear_CNS_fraction();
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
70
167
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
71 char_I_N2_ratio = 79; //38;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
72 char_I_He_ratio = 0; //50;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
73 char_I_deco_distance = 10; // 10 = 1 meter
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
74 char_I_depth_last_deco = 3; // values below 3 (meter) are ignored
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
75
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
76 char_I_const_ppO2 = 0;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
77 char_I_deco_ppO2_change = 0; // [dm] 10 = 1 meter
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
78 char_I_deco_ppO2 = 0;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
79
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
80 char_I_deco_gas_change1 = 20; // [m] 1 = 1 meter
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
81 char_I_deco_N2_ratio1 = 50;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
82 char_I_deco_He_ratio1 = 0;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
83
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
84 char_I_deco_gas_change2 = 6; // [m] 1 = 1 meter
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
85 char_I_deco_N2_ratio2 = 0;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
86 char_I_deco_He_ratio2 = 0;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
87
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
88 char_I_deco_gas_change3 = 0; // [m] 1 = 1 meter
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
89 char_I_deco_gas_change4 = 0; // [m] 1 = 1 meter
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
90 char_I_deco_gas_change5 = 0; // [m] 1 = 1 meter
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
91
167
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
92 //char_I_actual_ppO2; // 0x507
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
93 char_I_GF_High_percentage = 100; // 0x514 new in v.102
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
94 char_I_GF_Low_percentage = 100; // 0x515 new in v.102
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
95
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
96 char_I_saturation_multiplier = 110;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
97 char_I_desaturation_multiplier = 90;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
98
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
99 //---- Starts at zero meter ----------------------------------------------
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
100 int_I_pres_respiration = 1000;//980;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
101 int_I_pres_surface = 1000;//980;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
102 deco_clear_tissue();
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
103
167
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
104 //---- Calculate 29min at 45m --------------------------------------------
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
105 char_I_step_is_1min = 1;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
106 int_I_pres_respiration = 4500 + int_I_pres_surface;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
107
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
108 for (i=0;i<29;i++)
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
109 deco_calc_hauptroutine();
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
110
167
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
111 // Wait for one full computation
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
112 char_I_step_is_1min = 0;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
113 char_O_deco_status = 255;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
114 while (char_O_deco_status)
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
115 deco_calc_hauptroutine();
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
116 print_stops();
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
117
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
118 // And a second one
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
119 while (char_O_deco_status)
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
120 deco_calc_hauptroutine();
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
121 print_stops();
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
122
167
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
123 //---- 3000 seconds at 90m -----------------------------------------------
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
124 int_I_pres_respiration = 10000;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
125 for (i=0;i<1500;i++)
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
126 deco_calc_hauptroutine();
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
127
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
128 while(char_O_deco_status != 0)
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
129 deco_calc_hauptroutine();
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
130 print_stops();
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
131
167
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
132 //---- 300 seconds at 29m ------------------------------------------------
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
133 int_I_pres_respiration = 3000;
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
134 for (i=0;i<150;i++)
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
135 deco_calc_hauptroutine();
116
14a074e1a375 Split C code, and use direct linking.
JeanDo
parents:
diff changeset
136
167
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
137 while(char_O_deco_status != 0)
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
138 deco_calc_hauptroutine();
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
139 print_stops();
cb055a7d75f3 + Use overlay local vars.
JeanDo
parents: 116
diff changeset
140 }