annotate Discovery/Src/tInfoSensor.c @ 827:ffb1036c27c2 Evo_2_23

Moved CO2 Menu from Xtra to Hardware: The first CO2 sensor menu implementation was placed within the Xtra menu. In the new version the CO2 options may be accessed using the sensor overview menu of the Hardware page. With this change it is no longer necessary to take care for compile switches in the menus because the menu will only be shown if a CO2 sensor is detected.
author Ideenmodellierer
date Sun, 05 Nov 2023 20:19:08 +0100
parents a370741a743b
children 17d9d6eddd8d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
717
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
1 ///////////////////////////////////////////////////////////////////////////////
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
2 /// -*- coding: UTF-8 -*-
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
3 ///
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
4 /// \file Discovery/Src/tInfoCompass.c
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
5 /// \brief there is only compass_DX_f, compass_DY_f, compass_DZ_f output during this mode
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
6 /// \author heinrichs weikamp gmbh
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
7 /// \date 23-Feb-2015
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
8 ///
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
9 /// \details
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
10 ///
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
11 /// $Id$
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
12 ///////////////////////////////////////////////////////////////////////////////
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
14 ///
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
15 /// This program is free software: you can redistribute it and/or modify
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
16 /// it under the terms of the GNU General Public License as published by
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
17 /// the Free Software Foundation, either version 3 of the License, or
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
18 /// (at your option) any later version.
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
19 ///
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
20 /// This program is distributed in the hope that it will be useful,
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
23 /// GNU General Public License for more details.
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
24 ///
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
25 /// You should have received a copy of the GNU General Public License
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
27 //////////////////////////////////////////////////////////////////////////////
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
28
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
29 /* Includes ------------------------------------------------------------------*/
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
30
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
31 #include "gfx_engine.h"
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
32 #include "gfx_fonts.h"
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
33 #include "tHome.h"
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
34 #include "tInfo.h"
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
35 #include "tInfoSensor.h"
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
36 #include "tMenuEdit.h"
827
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
37 #include "data_exchange_main.h"
717
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
38
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
39 #include <string.h>
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
40 #include <inttypes.h>
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
41
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
42 extern void openEdit_O2Sensors(void);
783
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
43 uint8_t OnAction_Sensor (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
717
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
44
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
45 /* Private variables ---------------------------------------------------------*/
783
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
46 static uint8_t activeSensorId = 0;
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
47 static uint8_t sensorActive = 0;
717
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
48 /* Exported functions --------------------------------------------------------*/
783
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
49 void openInfo_Sensor(uint8_t sensorId)
717
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
50 {
783
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
51 SSettings *pSettings = settingsGetPointer();
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
52 activeSensorId = sensorId;
717
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
53 set_globalState(StISENINFO);
783
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
54 switch (activeSensorId)
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
55 {
786
19ab6f3ed52a Cleanup sensor data interface:
Ideenmodellierer
parents: 783
diff changeset
56 case 2: setBackMenu((uint32_t)openEdit_O2Sensors,0,3);
783
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
57 break;
786
19ab6f3ed52a Cleanup sensor data interface:
Ideenmodellierer
parents: 783
diff changeset
58 case 1: setBackMenu((uint32_t)openEdit_O2Sensors,0,2);
783
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
59 break;
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
60 default:
786
19ab6f3ed52a Cleanup sensor data interface:
Ideenmodellierer
parents: 783
diff changeset
61 case 0: setBackMenu((uint32_t)openEdit_O2Sensors,0,1);
783
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
62 break;
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
63 }
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
64
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
65 sensorActive = 1;
786
19ab6f3ed52a Cleanup sensor data interface:
Ideenmodellierer
parents: 783
diff changeset
66 if(pSettings->ppo2sensors_deactivated & (1 << (activeSensorId)))
783
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
67 {
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
68 sensorActive = 0;
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
69 }
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
70 }
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
71
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
72
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
73 uint8_t OnAction_Sensor(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
74 {
786
19ab6f3ed52a Cleanup sensor data interface:
Ideenmodellierer
parents: 783
diff changeset
75 if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId)))
783
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
76 {
786
19ab6f3ed52a Cleanup sensor data interface:
Ideenmodellierer
parents: 783
diff changeset
77 settingsGetPointer()->ppo2sensors_deactivated &= ~(1 << (activeSensorId));
783
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
78 tMenuEdit_set_on_off(editId, 1);
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
79 }
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
80 else
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
81 {
786
19ab6f3ed52a Cleanup sensor data interface:
Ideenmodellierer
parents: 783
diff changeset
82 settingsGetPointer()->ppo2sensors_deactivated |= (1 << (activeSensorId));
783
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
83 tMenuEdit_set_on_off(editId, 0);
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
84 }
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
85 return UPDATE_DIVESETTINGS;
717
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
86 }
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
87
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
88
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
89
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
90 uint64_t mod64(uint64_t a, uint64_t b)
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
91 {
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
92 uint64_t div;
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
93 div=(a/10);
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
94 b=(10*div);
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
95 return (a-b);
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
96 }
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
97
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
98 void uint64ToString(uint64_t value, char* pbuf)
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
99 {
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
100 char tmpBuf[32];
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
101 uint8_t index = 31;
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
102
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
103 tmpBuf[index--] = 0; /* zero termination */
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
104 while((index != 0) && (value != 0))
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
105 {
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
106 tmpBuf[index--] = '0' + (value % 10);// mod64(worker64,10);
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
107 value /= 10;
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
108 }
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
109 strcpy(pbuf,&tmpBuf[index+1]);
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
110 }
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
111
783
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
112 void tInfo_write_buttonTextline_simple(uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode)
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
113 {
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
114 char localtext[32];
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
115
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
116 if(left2ByteCode)
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
117 {
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
118 localtext[0] = TXT_2BYTE;
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
119 localtext[1] = left2ByteCode;
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
120 localtext[2] = 0;
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
121 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
122 }
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
123
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
124 if(middle2ByteCode)
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
125 {
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
126 localtext[0] = '\001';
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
127 localtext[1] = TXT_2BYTE;
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
128 localtext[2] = middle2ByteCode;
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
129 localtext[3] = 0;
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
130 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
131 }
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
132
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
133 if(right2ByteCode)
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
134 {
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
135 localtext[0] = '\002';
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
136 localtext[1] = TXT_2BYTE;
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
137 localtext[2] = right2ByteCode;
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
138 localtext[3] = 0;
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
139 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
140 }
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
141 }
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
142
827
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
143 static void refreshInfo_SensorO2(GFX_DrawCfgScreen s)
717
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
144 {
783
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
145 const SDiveState *pStateReal = stateRealGetPointer();
717
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
146 SSensorDataDiveO2* pDiveO2Data;
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
147 char text[31];
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
148 uint8_t strIndex = 0;
783
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
149 char *textPointer = text;
717
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
150
724
f285424f04d9 Development feature: external pressure sensor
Ideenmodellierer
parents: 717
diff changeset
151 float pressure = 0.0;
f285424f04d9 Development feature: external pressure sensor
Ideenmodellierer
parents: 717
diff changeset
152
827
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
153 pDiveO2Data = (SSensorDataDiveO2*)pStateReal->lifeData.extIf_sensor_data[activeSensorId];
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
154 strIndex = snprintf(text,32,"ID: ");
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
155 if(pDiveO2Data->sensorId != 0)
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
156 {
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
157 uint64ToString(pDiveO2Data->sensorId,&text[strIndex]);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
158 }
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
159 tInfo_write_content_simple( 30, 770, ME_Y_LINE1, &FontT48, text, CLUT_Font020);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
160 snprintf(text,32,"%c: %02.1f",TXT_Temperature , (float)pDiveO2Data->temperature / 1000.0);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
161 tInfo_write_content_simple( 30, 770, ME_Y_LINE2, &FontT48, text, CLUT_Font020);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
162
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
163 #ifdef ENABLE_EXTERNAL_PRESSURE
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
164 pressure = (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[2]);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
165 #else
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
166 pressure = (float)pDiveO2Data->pressure / 1000.0;
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
167 #endif
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
168 snprintf(text,32,"Druck: %02.1f (%02.1f)", (float)pDiveO2Data->pressure / 1000.0, pressure *1000.0);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
169
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
170 tInfo_write_content_simple( 30, 770, ME_Y_LINE3, &FontT48, text, CLUT_Font020);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
171 snprintf(text,32,"Feuchtigkeit: %02.1f", (float)pDiveO2Data->humidity / 1000.0);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
172 tInfo_write_content_simple( 30, 770, ME_Y_LINE4, &FontT48, text, CLUT_Font020);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
173 snprintf(text,32,"Status: 0x%lx", pDiveO2Data->status);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
174 tInfo_write_content_simple( 30, 770, ME_Y_LINE5, &FontT48, text, CLUT_Font020);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
175 #ifdef ENABLE_EXTERNAL_PRESSURE
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
176 snprintf(text,32,"Norm ppO2: %02.3f (%02.1f)", (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0] / (pressure / 1000.0)),(float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0]));
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
177 tInfo_write_content_simple( 30, 770, ME_Y_LINE6, &FontT48, text, CLUT_Font020);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
178 #endif
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
179
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
180 if(sensorActive)
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
181 {
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
182 *textPointer++ = '\005';
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
183 }
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
184 else
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
185 {
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
186 *textPointer++ = '\006';
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
187 }
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
188 *textPointer++ = ' ';
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
189 *textPointer++ = TXT_2BYTE;
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
190 *textPointer++ = TXT2BYTE_Sensor;
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
191 *textPointer++ = ' ';
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
192 *textPointer++ = TXT_2BYTE;
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
193 *textPointer++ = TXT2BYTE_O2IFDigital;
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
194 *textPointer++ = '1' + activeSensorId;
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
195
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
196 snprintf(textPointer, 20,": %01.2f, %01.1f mV", pStateReal->lifeData.ppO2Sensor_bar[activeSensorId], pStateReal->lifeData.sensorVoltage_mV[activeSensorId]);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
197
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
198 tInfo_write_content_simple( 30, 770, ME_Y_LINE6, &FontT48, text, CLUT_Font020);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
199
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
200 tInfo_write_buttonTextline_simple(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,0);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
201 }
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
202
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
203 static void refreshInfo_SensorCo2(GFX_DrawCfgScreen s)
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
204 {
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
205 const SDiveState *pStateReal = stateRealGetPointer();
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
206 char text[31];
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
207 char *textPointer = text;
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
208
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
209 snprintf(text,32,"CO2: %ld ppm",pStateReal->lifeData.CO2_data.CO2_ppm);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
210 tInfo_write_content_simple( 30, 770, ME_Y_LINE1, &FontT48, text, CLUT_Font020);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
211
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
212
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
213 snprintf(text,32,"Signal: %d",pStateReal->lifeData.CO2_data.signalStrength);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
214 tInfo_write_content_simple( 30, 770, ME_Y_LINE2, &FontT48, text, CLUT_Font020);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
215
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
216 if(sensorActive)
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
217 {
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
218 *textPointer++ = '\005';
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
219 }
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
220 else
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
221 {
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
222 *textPointer++ = '\006';
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
223 }
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
224 *textPointer++ = ' ';
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
225 *textPointer++ = TXT_2BYTE;
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
226 *textPointer++ = TXT2BYTE_Sensor;
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
227 *textPointer++ = ' ';
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
228 *textPointer++ = 'C';
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
229 *textPointer++ = 'o';
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
230 *textPointer++ = '1' + activeSensorId;
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
231
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
232 snprintf(textPointer, 20,": %ld ppm", pStateReal->lifeData.CO2_data.CO2_ppm);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
233
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
234 tInfo_write_content_simple( 30, 770, ME_Y_LINE6, &FontT48, text, CLUT_Font020);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
235
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
236 tInfo_write_buttonTextline_simple(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_O2Calib);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
237 }
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
238 // ===============================================================================
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
239 void refreshInfo_Sensor(GFX_DrawCfgScreen s)
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
240 {
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
241 const SDiveState *pStateReal = stateRealGetPointer();
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
242
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
243 char text[31];
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
244
717
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
245 text[0] = '\001';
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
246 text[1] = TXT_Sensor;
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
247 text[2] = ' ';
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
248 text[3] = TXT_Information;
783
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
249 text[4] = ' ';
786
19ab6f3ed52a Cleanup sensor data interface:
Ideenmodellierer
parents: 783
diff changeset
250 text[5] = '1' + activeSensorId;
783
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
251 text[6] = 0;
826
a370741a743b Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents: 786
diff changeset
252 tInfo_write_content_simple( 30, 770, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware);
717
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
253
827
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
254 switch(pStateReal->lifeData.extIf_sensor_map[activeSensorId])
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
255 {
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
256 default:
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
257 case SENSOR_DIGO2M: refreshInfo_SensorO2(s);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
258 break;
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
259 case SENSOR_CO2M: refreshInfo_SensorCo2(s);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
260 break;
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
261 }
717
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
262 }
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
263
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
264 void sendActionToInfoSensor(uint8_t sendAction)
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
265 {
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
266 switch(sendAction)
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
267 {
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
268 case ACTION_BUTTON_BACK:
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
269 exitMenuEdit_to_BackMenu();
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
270 break;
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
271
786
19ab6f3ed52a Cleanup sensor data interface:
Ideenmodellierer
parents: 783
diff changeset
272 case ACTION_BUTTON_ENTER: if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId)))
783
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
273 {
827
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
274 if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M)
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
275 {
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
276 settingsGetPointer()->co2_sensor_active = 1;
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
277 }
786
19ab6f3ed52a Cleanup sensor data interface:
Ideenmodellierer
parents: 783
diff changeset
278 settingsGetPointer()->ppo2sensors_deactivated &= ~(uint8_t)(1 << (activeSensorId));
783
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
279 sensorActive = 1;
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
280 }
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
281 else
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
282 {
827
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
283 if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M)
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
284 {
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
285 settingsGetPointer()->co2_sensor_active = 0;
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
286 }
786
19ab6f3ed52a Cleanup sensor data interface:
Ideenmodellierer
parents: 783
diff changeset
287 settingsGetPointer()->ppo2sensors_deactivated |= (uint8_t)(1 << (activeSensorId));
783
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
288 sensorActive = 0;
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
289 }
c31237d20491 Update digital O2 sensor information:
Ideenmodellierer
parents: 732
diff changeset
290 break;
827
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
291 case ACTION_BUTTON_NEXT: if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M)
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
292 {
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
293 DataEX_setExtInterface_Cmd(EXT_INTERFACE_CO2_CALIB);
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
294 }
ffb1036c27c2 Moved CO2 Menu from Xtra to Hardware:
Ideenmodellierer
parents: 826
diff changeset
295 break;
717
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
296 case ACTION_TIMEOUT:
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
297 case ACTION_MODE_CHANGE:
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
298 case ACTION_IDLE_TICK:
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
299 case ACTION_IDLE_SECOND:
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
300 default:
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
301 break;
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
302 }
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
303 }
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
304