Mercurial > public > ostc4
annotate Discovery/Src/tInfoSensor.c @ 752:4f19336a3f21
Dev Bugfix: Alignment problem in lifedata structure:
Since the introduction of the 64 bit DigO2 sensor ID the potential risk of a misalignment is present in the lifedata structure. E.g. If a new 8bit variable is added in front of the data structure containing the 64bit value. To avoid this in future the sensor data structure which may contain the 64bit value has been moved to the top of the structure (first element)
author | Ideenmodellierer |
---|---|
date | Tue, 07 Mar 2023 19:51:30 +0100 |
parents | e33d661d1743 |
children | c31237d20491 |
rev | line source |
---|---|
717 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tInfoCompass.c | |
5 /// \brief there is only compass_DX_f, compass_DY_f, compass_DZ_f output during this mode | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 23-Feb-2015 | |
8 /// | |
9 /// \details | |
10 /// | |
11 /// $Id$ | |
12 /////////////////////////////////////////////////////////////////////////////// | |
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh | |
14 /// | |
15 /// This program is free software: you can redistribute it and/or modify | |
16 /// it under the terms of the GNU General Public License as published by | |
17 /// the Free Software Foundation, either version 3 of the License, or | |
18 /// (at your option) any later version. | |
19 /// | |
20 /// This program is distributed in the hope that it will be useful, | |
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 /// GNU General Public License for more details. | |
24 /// | |
25 /// You should have received a copy of the GNU General Public License | |
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. | |
27 ////////////////////////////////////////////////////////////////////////////// | |
28 | |
29 /* Includes ------------------------------------------------------------------*/ | |
30 | |
31 #include "gfx_engine.h" | |
32 #include "gfx_fonts.h" | |
33 #include "tHome.h" | |
34 #include "tInfo.h" | |
35 #include "tInfoSensor.h" | |
36 #include "tMenuEdit.h" | |
37 | |
38 #include <string.h> | |
39 #include <inttypes.h> | |
40 | |
41 extern void openEdit_O2Sensors(void); | |
42 | |
43 /* Private variables ---------------------------------------------------------*/ | |
44 | |
45 /* Exported functions --------------------------------------------------------*/ | |
46 void openInfo_Sensor(void) | |
47 { | |
48 set_globalState(StISENINFO); | |
49 setBackMenu((uint32_t)openEdit_O2Sensors,0,6); | |
50 } | |
51 | |
52 | |
53 | |
54 uint64_t mod64(uint64_t a, uint64_t b) | |
55 { | |
56 uint64_t div; | |
57 div=(a/10); | |
58 b=(10*div); | |
59 return (a-b); | |
60 } | |
61 | |
62 void uint64ToString(uint64_t value, char* pbuf) | |
63 { | |
64 char tmpBuf[32]; | |
65 uint8_t index = 31; | |
66 | |
67 tmpBuf[index--] = 0; /* zero termination */ | |
68 while((index != 0) && (value != 0)) | |
69 { | |
70 tmpBuf[index--] = '0' + (value % 10);// mod64(worker64,10); | |
71 value /= 10; | |
72 } | |
73 strcpy(pbuf,&tmpBuf[index+1]); | |
74 } | |
75 | |
76 // =============================================================================== | |
77 // refreshInfo_Compass | |
78 /// @brief there is only compass_DX_f, compass_DY_f, compass_DZ_f output during this mode | |
79 /// the accel is not called during this process | |
80 // =============================================================================== | |
81 void refreshInfo_Sensor(GFX_DrawCfgScreen s) | |
82 { | |
83 SSensorDataDiveO2* pDiveO2Data; | |
84 char text[31]; | |
85 uint8_t strIndex = 0; | |
86 | |
724
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
87 float pressure = 0.0; |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
88 |
717 | 89 text[0] = '\001'; |
90 text[1] = TXT_Sensor; | |
91 text[2] = ' '; | |
92 text[3] = TXT_Information; | |
93 text[4] = 0; | |
94 tInfo_write_content_simple( 30, 340, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware); | |
95 | |
96 | |
97 pDiveO2Data = (SSensorDataDiveO2*)stateRealGetPointer()->lifeData.extIf_sensor_data; | |
98 | |
99 strIndex = snprintf(text,32,"ID: "); | |
100 if(pDiveO2Data->sensorId != 0) | |
101 { | |
102 uint64ToString(pDiveO2Data->sensorId,&text[strIndex]); | |
103 } | |
104 tInfo_write_content_simple( 30, 340, ME_Y_LINE1, &FontT48, text, CLUT_Font020); | |
105 snprintf(text,32,"%c: %02.1f",TXT_Temperature , (float)pDiveO2Data->temperature / 1000.0); | |
106 tInfo_write_content_simple( 30, 340, ME_Y_LINE2, &FontT48, text, CLUT_Font020); | |
724
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
107 |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
108 #ifdef ENABLE_EXTERNAL_PRESSURE |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
109 pressure = (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[2]); |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
110 #else |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
111 pressure = (float)pDiveO2Data->pressure / 1000.0; |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
112 #endif |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
113 snprintf(text,32,"Druck: %02.1f (%02.1f)", (float)pDiveO2Data->pressure / 1000.0, pressure *1000.0); |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
114 |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
115 tInfo_write_content_simple( 30, 340, ME_Y_LINE3, &FontT48, text, CLUT_Font020); |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
116 snprintf(text,32,"Feuchtigkeit: %02.1f", (float)pDiveO2Data->humidity / 1000.0); |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
117 tInfo_write_content_simple( 30, 340, ME_Y_LINE4, &FontT48, text, CLUT_Font020); |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
118 snprintf(text,32,"Status: 0x%lx", pDiveO2Data->status); |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
119 tInfo_write_content_simple( 30, 340, ME_Y_LINE5, &FontT48, text, CLUT_Font020); |
732 | 120 #ifdef ENABLE_EXTERNAL_PRESSURE |
724
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
121 snprintf(text,32,"Norm ppO2: %02.3f (%02.1f)", (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0] / (pressure / 1000.0)),(float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0])); |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
122 tInfo_write_content_simple( 30, 340, ME_Y_LINE6, &FontT48, text, CLUT_Font020); |
732 | 123 #endif |
717 | 124 } |
125 | |
126 void sendActionToInfoSensor(uint8_t sendAction) | |
127 { | |
128 | |
129 switch(sendAction) | |
130 { | |
131 | |
132 case ACTION_BUTTON_BACK: | |
133 exitMenuEdit_to_BackMenu(); | |
134 break; | |
135 | |
136 case ACTION_BUTTON_ENTER: | |
137 case ACTION_BUTTON_NEXT: | |
138 case ACTION_TIMEOUT: | |
139 case ACTION_MODE_CHANGE: | |
140 case ACTION_IDLE_TICK: | |
141 case ACTION_IDLE_SECOND: | |
142 default: | |
143 break; | |
144 } | |
145 } | |
146 |