annotate Discovery/Src/tMenuEditSetpoint.c @ 194:f23b9055436f div-fixes-cleanup-1

cleanup: more trivial cleanup (logbook.c/h) Kick out unused code, commented code. Corrected some comments, and most relevant: make things static where we can. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Tue, 19 Mar 2019 11:42:00 +0100
parents 255eedad4155
children d539ed9aa5b8
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/tMenuEditSetpoint.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 /// \brief
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 19-Dec-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 "tMenuEditSetpoint.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31
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 "gfx_fonts.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 #include "tMenuEdit.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 #include "unit.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 /* Private types -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 typedef struct
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 uint8_t spID;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 SSetpointLine * pSetpointLine;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 } SEditSetpointPage;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 SEditSetpointPage editSetpointPage;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 /* Private function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 void openEdit_DiveSetpointSelect(uint8_t line);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 void openEdit_DiveSetpointSelect_Subroutine(uint8_t line);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 /* Announced function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 uint8_t OnAction_SP_Setpoint (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 uint8_t OnAction_SP_Depth (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 uint8_t On (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 //uint8_t OnAction_SP_First (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 //uint8_t OnAction_SP_Active (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 //uint8_t OnAction_SP_DM_Select (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 uint8_t OnAction_SP_DM_Sensor1 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 uint8_t OnAction_SP_DM_Sensor2 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 uint8_t OnAction_SP_DM_Sensor3 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 void openEdit_Setpoint(uint8_t line)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 uint8_t useSensorSubMenu = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 /* dive mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 if(actual_menu_content != MENU_SURFACE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 uint8_t setpointCbar, actualGasID;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 SDiveState *pState;
130
b7689d9e888a Minor changes to improved code quality and to eliminate warnings
Ideenmodellierer
parents: 38
diff changeset
75 setpointCbar = 100;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 if(actual_menu_content == MENU_DIVE_REAL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 pState = stateRealGetPointerWrite();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 pState = stateSimGetPointerWrite();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 // actualGasID
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 if(pState->diveSettings.diveMode != DIVEMODE_CCR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 actualGasID = pState->lifeData.lastDiluent_GasIdInSettings;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 if((actualGasID <= NUM_OFFSET_DILUENT) || (actualGasID > NUM_GASES + NUM_OFFSET_DILUENT))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 actualGasID = NUM_OFFSET_DILUENT + 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 actualGasID = pState->lifeData.actualGas.GasIdInSettings;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 // setpointCbar, CCR_Mode and sensor menu
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 if(line < 6)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 setpointCbar = pState->diveSettings.setpoint[line].setpoint_cbar;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 pState->diveSettings.CCR_Mode = CCRMODE_FixedSetpoint;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 // BetterSetpoint warning only once
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 if(actualBetterSetpointId() == line)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 uint8_t depth;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 depth = pState->diveSettings.setpoint[line].depth_meter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 // BetterSetpoint warning only once -> clear active
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 for(int i=0; i<=NUM_GASES; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 pState->diveSettings.setpoint[i].note.ub.first = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 if(pState->diveSettings.setpoint[i].depth_meter <= depth)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 pState->diveSettings.setpoint[i].note.ub.active = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 pState->diveSettings.setpoint[line].note.ub.first = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 if(pState->diveSettings.CCR_Mode != CCRMODE_Sensors)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 /* setpoint_cbar will be written by updateSetpointStateUsed() in main.c loop */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 setpointCbar = 255;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 pState->diveSettings.CCR_Mode = CCRMODE_Sensors;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 useSensorSubMenu = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 setActualGas_DM(&pState->lifeData,actualGasID,setpointCbar);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 if(pState->diveSettings.diveMode != DIVEMODE_CCR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 pState->diveSettings.diveMode = DIVEMODE_CCR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 unblock_diluent_page();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 clear_warning_fallback();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 if(!useSensorSubMenu)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 exitMenuEdit_to_Home();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 else // entire sub menu during dive to select sensors active
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 set_globalState_Menu_Line(line);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 resetMenuEdit(CLUT_MenuPageGasSP);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 char text[3];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 uint8_t sensorActive[3];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 text[0] = '\001';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 text[1] = TXT_o2Sensors;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 text[2] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 write_topline(text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 write_label_var( 96, 340, ME_Y_LINE1, &FontT48, "Sensor 1");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 write_label_var( 96, 340, ME_Y_LINE2, &FontT48, "Sensor 2");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 write_label_var( 96, 340, ME_Y_LINE3, &FontT48, "Sensor 3");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 sensorActive[0] = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 sensorActive[1] = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 sensorActive[2] = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 if(pState->diveSettings.ppo2sensors_deactivated & 1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 sensorActive[0] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 if(pState->diveSettings.ppo2sensors_deactivated & 2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 sensorActive[1] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 if(pState->diveSettings.ppo2sensors_deactivated & 4)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 sensorActive[2] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 write_field_on_off(StMSP_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, "", sensorActive[0]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 write_field_on_off(StMSP_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", sensorActive[1]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 write_field_on_off(StMSP_Sensor3, 30, 95, ME_Y_LINE3, &FontT48, "", sensorActive[2]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 setEvent(StMSP_Sensor1, (uint32_t)OnAction_SP_DM_Sensor1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 setEvent(StMSP_Sensor2, (uint32_t)OnAction_SP_DM_Sensor2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 setEvent(StMSP_Sensor3, (uint32_t)OnAction_SP_DM_Sensor3);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 /* surface mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 uint8_t spId, setpoint_cbar, sp_high, depthDeco, first;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 // uint8_t active,
166
255eedad4155 cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents: 130
diff changeset
183 char text[70];
255eedad4155 cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents: 130
diff changeset
184 uint8_t textPointer;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 uint16_t y_line;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 set_globalState_Menu_Line(line);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 resetMenuEdit(CLUT_MenuPageGasSP);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 spId = line;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 editSetpointPage.spID = spId;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 SSettings *data = settingsGetPointer();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 editSetpointPage.pSetpointLine = data->setpoint;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 setpoint_cbar = editSetpointPage.pSetpointLine[spId].setpoint_cbar;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 depthDeco = editSetpointPage.pSetpointLine[spId].depth_meter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 //active = editSetpointPage.pSetpointLine[spId].note.ub.active;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 first = editSetpointPage.pSetpointLine[spId].note.ub.first;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 sp_high = setpoint_cbar / 100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 strcpy(text, "\001" "Setpoint #0 X");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 text[11] += spId;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 text[13] = TXT_Setpoint_Edit;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 write_topline(text);
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 y_line = ME_Y_LINE_BASE + (line * ME_Y_LINE_STEP);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 textPointer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 text[textPointer++] = 'S';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 text[textPointer++] = 'P';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 text[textPointer++] = '0' + spId;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 text[textPointer++] = ' ';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 text[textPointer++] = ' ';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 if(first == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 strcpy(&text[textPointer++],"\177");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 textPointer += snprintf(&text[textPointer], 60,\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 "* "
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 " "
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 " bar"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 "\034"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 " "
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 " "
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 " "
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 "meter"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235 "\017"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 "\035"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 "\n\r"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 write_label_var( 20, 800, y_line, &FontT48, text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 write_field_udigit(StMSP_ppo2_setting, 160, 800, y_line, &FontT48, "#.## ###", (uint32_t)sp_high, (uint32_t)(setpoint_cbar - (100 * sp_high)), depthDeco, 0);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 setEvent(StMSP_ppo2_setting, (uint32_t)OnAction_SP_Setpoint);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 startEdit();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 uint8_t OnAction_SP_Setpoint(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 int8_t digitContentNew;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 uint32_t new_integer_part, new_fractional_part, new_cbar, newDepth;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 if(action == ACTION_BUTTON_ENTER)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 return digitContent;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 if(action == ACTION_BUTTON_ENTER_FINAL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 evaluateNewString(editId, &new_integer_part, &new_fractional_part, &newDepth, 0);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 new_cbar = (new_integer_part * 100) + new_fractional_part;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 if(new_cbar < 50)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 new_cbar = 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 if(new_cbar > 160)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 new_cbar = 160;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 new_integer_part = new_cbar / 100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 new_fractional_part = new_cbar - (new_integer_part * 100);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 editSetpointPage.pSetpointLine[editSetpointPage.spID].setpoint_cbar = new_cbar;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 if(newDepth > 255)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 newDepth = 255;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 editSetpointPage.pSetpointLine[editSetpointPage.spID].depth_meter = newDepth;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 return UPDATE_AND_EXIT_TO_MENU;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 if(action == ACTION_BUTTON_NEXT)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 digitContentNew = digitContent + 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 if((blockNumber == 0) && (digitContentNew > '1'))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 digitContentNew = '0';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 if(digitContentNew > '9')
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286 digitContentNew = '0';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 return digitContentNew;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 if(action == ACTION_BUTTON_BACK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 digitContentNew = digitContent - 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 if((blockNumber == 0) && (digitContentNew > '1'))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 digitContentNew = '1';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 if(digitContentNew < '0')
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 digitContentNew = '9';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 return digitContentNew;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 return EXIT_TO_MENU;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 uint8_t OnAction_SP_Depth(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 uint8_t digitContentNew;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 uint32_t newDepth;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 if(action == ACTION_BUTTON_ENTER)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 return digitContent;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312 if(action == ACTION_BUTTON_ENTER_FINAL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 evaluateNewString(editId, &newDepth, 0, 0, 0);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 if(newDepth > 255)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 newDepth = 255;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 editSetpointPage.pSetpointLine[editSetpointPage.spID].depth_meter = newDepth;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 tMenuEdit_newInput(editId, newDepth, 0, 0, 0);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 return UPDATE_DIVESETTINGS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 if(action == ACTION_BUTTON_NEXT)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 digitContentNew = digitContent + 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 if(digitContentNew > '9')
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 digitContentNew = '0';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 return digitContentNew;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 if(action == ACTION_BUTTON_BACK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 digitContentNew = digitContent - 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 if(digitContentNew < '0')
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 digitContentNew = '9';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 return digitContentNew;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 return UNSPECIFIC_RETURN;
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 void openEdit_DiveSelectBetterSetpoint(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 uint8_t spId;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 SDiveState *pState;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 uint8_t depth;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 spId = actualBetterSetpointId();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 if(actual_menu_content == MENU_DIVE_REAL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350 pState = stateRealGetPointerWrite();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 pState = stateSimGetPointerWrite();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354 depth = pState->diveSettings.setpoint[spId].depth_meter;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356 // BetterSetpoint warning only once -> clear active
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357 for(int i=0; i<=NUM_GASES; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 pState->diveSettings.setpoint[i].note.ub.first = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 if(pState->diveSettings.setpoint[i].depth_meter <= depth)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361 pState->diveSettings.setpoint[i].note.ub.active = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 // new setpoint
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 pState->diveSettings.setpoint[spId].note.ub.first = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367 // change in lifeData
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 setActualGas_DM(&pState->lifeData, pState->lifeData.actualGas.GasIdInSettings, pState->diveSettings.setpoint[spId].setpoint_cbar);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 uint8_t OnAction_SP_DM_Sensor1 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 SDiveState * pDiveState = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375 if(actual_menu_content == MENU_DIVE_REAL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376 pDiveState = stateRealGetPointerWrite();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 pDiveState = stateSimGetPointerWrite();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 if(pDiveState->diveSettings.ppo2sensors_deactivated & 1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 pDiveState->diveSettings.ppo2sensors_deactivated &= 4+2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 tMenuEdit_set_on_off(editId, 1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387 pDiveState->diveSettings.ppo2sensors_deactivated |= 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388 tMenuEdit_set_on_off(editId, 0);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 return UNSPECIFIC_RETURN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 uint8_t OnAction_SP_DM_Sensor2 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396 SDiveState * pDiveState = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 if(actual_menu_content == MENU_DIVE_REAL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 pDiveState = stateRealGetPointerWrite();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401 pDiveState = stateSimGetPointerWrite();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 if(pDiveState->diveSettings.ppo2sensors_deactivated & 2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 pDiveState->diveSettings.ppo2sensors_deactivated &= 4+1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 tMenuEdit_set_on_off(editId, 1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410 pDiveState->diveSettings.ppo2sensors_deactivated |= 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 tMenuEdit_set_on_off(editId, 0);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414 return UNSPECIFIC_RETURN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417 uint8_t OnAction_SP_DM_Sensor3 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419 SDiveState * pDiveState = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421 if(actual_menu_content == MENU_DIVE_REAL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422 pDiveState = stateRealGetPointerWrite();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424 pDiveState = stateSimGetPointerWrite();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
426 if(pDiveState->diveSettings.ppo2sensors_deactivated & 4)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
427 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
428 pDiveState->diveSettings.ppo2sensors_deactivated &= 2+1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429 tMenuEdit_set_on_off(editId, 1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
430 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
432 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
433 pDiveState->diveSettings.ppo2sensors_deactivated |= 4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
434 tMenuEdit_set_on_off(editId, 0);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
435 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
436 return UNSPECIFIC_RETURN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
437 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439 /* Private functions ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
440
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442 uint8_t OnAction_SP_Active(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
443 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444 uint8_t active, first;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446 first = editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.first;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448 if(first)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 return UNSPECIFIC_RETURN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451 active = editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.active;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453 if(active)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
455 active = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456 editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.active = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460 active = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461 editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.active = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463 tMenuEdit_set_on_off(editId, active);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
464
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
465 return UPDATE_DIVESETTINGS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
466 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
468 uint8_t OnAction_SP_First(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
469 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470 uint8_t active, first, i;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
471 SDiveState * pStateReal = stateRealGetPointerWrite();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
473 first = editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.first;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 if(first)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476 return UNSPECIFIC_RETURN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478 for(i=0;i<NUM_GASES;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479 editSetpointPage.pSetpointLine[i].note.ub.first = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481 editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.first = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
482
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
483 active = editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.active;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
484 if(active == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
486 editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.active = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
487 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
488
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489 tMenuEdit_set_on_off(editId, 1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491 return UPDATE_DIVESETTINGS;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494 uint8_t OnAction_SP_DM_Select(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496 SDiveState * pDiveState = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
498 if(editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.active == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499 editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.active = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
500
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501 for(int i=0;i<NUM_GASES;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502 editSetpointPage.pSetpointLine[i].note.ub.first = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
504 editSetpointPage.pSetpointLine[editSetpointPage.spID].note.ub.first = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506 if(actual_menu_content == MENU_DIVE_REAL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507 pDiveState = stateRealGetPointerWrite();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509 pDiveState = stateSimGetPointerWrite();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
510
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
511 setActualGas_DM(&pDiveState->lifeData, pDiveState->lifeData.actualGas.GasIdInSettings, editSetpointPage.pSetpointLine[editSetpointPage.spID].setpoint_cbar);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
512
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513 return EXIT_TO_HOME;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515 */