Mercurial > public > ostc4
annotate Discovery/Src/tInfoSensor.c @ 826:a370741a743b Evo_2_23
Bugfix Line order of info screen with flip screen active:
In the previous version the order of the line in flipping mode (top to bottom) was 6,5,4,3,2,1 instead of 1,2,3,4,5,6. This effected the compass calibration as well as the sensor info view. The problem was solved by adapting the Y calculation.
In addition the size of the SensorInfo screen was corrected to avoid clipping issues in flipped mode.
author | Ideenmodellierer |
---|---|
date | Wed, 11 Oct 2023 17:49:19 +0200 |
parents | 19ab6f3ed52a |
children | ffb1036c27c2 |
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); | |
783 | 42 uint8_t OnAction_Sensor (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
717 | 43 |
44 /* Private variables ---------------------------------------------------------*/ | |
783 | 45 static uint8_t activeSensorId = 0; |
46 static uint8_t sensorActive = 0; | |
717 | 47 /* Exported functions --------------------------------------------------------*/ |
783 | 48 void openInfo_Sensor(uint8_t sensorId) |
717 | 49 { |
783 | 50 SSettings *pSettings = settingsGetPointer(); |
51 activeSensorId = sensorId; | |
717 | 52 set_globalState(StISENINFO); |
783 | 53 switch (activeSensorId) |
54 { | |
786 | 55 case 2: setBackMenu((uint32_t)openEdit_O2Sensors,0,3); |
783 | 56 break; |
786 | 57 case 1: setBackMenu((uint32_t)openEdit_O2Sensors,0,2); |
783 | 58 break; |
59 default: | |
786 | 60 case 0: setBackMenu((uint32_t)openEdit_O2Sensors,0,1); |
783 | 61 break; |
62 } | |
63 | |
64 sensorActive = 1; | |
786 | 65 if(pSettings->ppo2sensors_deactivated & (1 << (activeSensorId))) |
783 | 66 { |
67 sensorActive = 0; | |
68 } | |
69 } | |
70 | |
71 | |
72 uint8_t OnAction_Sensor(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
73 { | |
786 | 74 if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId))) |
783 | 75 { |
786 | 76 settingsGetPointer()->ppo2sensors_deactivated &= ~(1 << (activeSensorId)); |
783 | 77 tMenuEdit_set_on_off(editId, 1); |
78 } | |
79 else | |
80 { | |
786 | 81 settingsGetPointer()->ppo2sensors_deactivated |= (1 << (activeSensorId)); |
783 | 82 tMenuEdit_set_on_off(editId, 0); |
83 } | |
84 return UPDATE_DIVESETTINGS; | |
717 | 85 } |
86 | |
87 | |
88 | |
89 uint64_t mod64(uint64_t a, uint64_t b) | |
90 { | |
91 uint64_t div; | |
92 div=(a/10); | |
93 b=(10*div); | |
94 return (a-b); | |
95 } | |
96 | |
97 void uint64ToString(uint64_t value, char* pbuf) | |
98 { | |
99 char tmpBuf[32]; | |
100 uint8_t index = 31; | |
101 | |
102 tmpBuf[index--] = 0; /* zero termination */ | |
103 while((index != 0) && (value != 0)) | |
104 { | |
105 tmpBuf[index--] = '0' + (value % 10);// mod64(worker64,10); | |
106 value /= 10; | |
107 } | |
108 strcpy(pbuf,&tmpBuf[index+1]); | |
109 } | |
110 | |
783 | 111 void tInfo_write_buttonTextline_simple(uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode) |
112 { | |
113 char localtext[32]; | |
114 | |
115 if(left2ByteCode) | |
116 { | |
117 localtext[0] = TXT_2BYTE; | |
118 localtext[1] = left2ByteCode; | |
119 localtext[2] = 0; | |
120 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
121 } | |
122 | |
123 if(middle2ByteCode) | |
124 { | |
125 localtext[0] = '\001'; | |
126 localtext[1] = TXT_2BYTE; | |
127 localtext[2] = middle2ByteCode; | |
128 localtext[3] = 0; | |
129 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
130 } | |
131 | |
132 if(right2ByteCode) | |
133 { | |
134 localtext[0] = '\002'; | |
135 localtext[1] = TXT_2BYTE; | |
136 localtext[2] = right2ByteCode; | |
137 localtext[3] = 0; | |
138 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
139 } | |
140 } | |
141 | |
717 | 142 // =============================================================================== |
143 void refreshInfo_Sensor(GFX_DrawCfgScreen s) | |
144 { | |
783 | 145 const SDiveState *pStateReal = stateRealGetPointer(); |
717 | 146 SSensorDataDiveO2* pDiveO2Data; |
147 char text[31]; | |
148 uint8_t strIndex = 0; | |
783 | 149 char *textPointer = text; |
717 | 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 |
717 | 153 text[0] = '\001'; |
154 text[1] = TXT_Sensor; | |
155 text[2] = ' '; | |
156 text[3] = TXT_Information; | |
783 | 157 text[4] = ' '; |
786 | 158 text[5] = '1' + activeSensorId; |
783 | 159 text[6] = 0; |
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
786
diff
changeset
|
160 tInfo_write_content_simple( 30, 770, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware); |
717 | 161 |
786 | 162 pDiveO2Data = (SSensorDataDiveO2*)&stateRealGetPointer()->lifeData.extIf_sensor_data[activeSensorId]; |
717 | 163 |
164 strIndex = snprintf(text,32,"ID: "); | |
165 if(pDiveO2Data->sensorId != 0) | |
166 { | |
167 uint64ToString(pDiveO2Data->sensorId,&text[strIndex]); | |
168 } | |
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
786
diff
changeset
|
169 tInfo_write_content_simple( 30, 770, ME_Y_LINE1, &FontT48, text, CLUT_Font020); |
717 | 170 snprintf(text,32,"%c: %02.1f",TXT_Temperature , (float)pDiveO2Data->temperature / 1000.0); |
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
786
diff
changeset
|
171 tInfo_write_content_simple( 30, 770, ME_Y_LINE2, &FontT48, text, CLUT_Font020); |
724
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
172 |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
173 #ifdef ENABLE_EXTERNAL_PRESSURE |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
174 pressure = (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[2]); |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
175 #else |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
176 pressure = (float)pDiveO2Data->pressure / 1000.0; |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
177 #endif |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
178 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
|
179 |
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
786
diff
changeset
|
180 tInfo_write_content_simple( 30, 770, ME_Y_LINE3, &FontT48, text, CLUT_Font020); |
724
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
181 snprintf(text,32,"Feuchtigkeit: %02.1f", (float)pDiveO2Data->humidity / 1000.0); |
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
786
diff
changeset
|
182 tInfo_write_content_simple( 30, 770, ME_Y_LINE4, &FontT48, text, CLUT_Font020); |
724
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
183 snprintf(text,32,"Status: 0x%lx", pDiveO2Data->status); |
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
786
diff
changeset
|
184 tInfo_write_content_simple( 30, 770, ME_Y_LINE5, &FontT48, text, CLUT_Font020); |
732 | 185 #ifdef ENABLE_EXTERNAL_PRESSURE |
724
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
186 snprintf(text,32,"Norm ppO2: %02.3f (%02.1f)", (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0] / (pressure / 1000.0)),(float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0])); |
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
786
diff
changeset
|
187 tInfo_write_content_simple( 30, 770, ME_Y_LINE6, &FontT48, text, CLUT_Font020); |
732 | 188 #endif |
783 | 189 |
190 if(sensorActive) | |
191 { | |
192 *textPointer++ = '\005'; | |
193 } | |
194 else | |
195 { | |
196 *textPointer++ = '\006'; | |
197 } | |
198 *textPointer++ = ' '; | |
199 *textPointer++ = TXT_2BYTE; | |
200 *textPointer++ = TXT2BYTE_Sensor; | |
201 *textPointer++ = ' '; | |
202 *textPointer++ = TXT_2BYTE; | |
203 *textPointer++ = TXT2BYTE_O2IFDigital; | |
786 | 204 *textPointer++ = '1' + activeSensorId; |
783 | 205 |
786 | 206 snprintf(textPointer, 20,": %01.2f, %01.1f mV", pStateReal->lifeData.ppO2Sensor_bar[activeSensorId], pStateReal->lifeData.sensorVoltage_mV[activeSensorId]); |
783 | 207 |
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
786
diff
changeset
|
208 tInfo_write_content_simple( 30, 770, ME_Y_LINE6, &FontT48, text, CLUT_Font020); |
783 | 209 |
210 tInfo_write_buttonTextline_simple(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,0); | |
717 | 211 } |
212 | |
213 void sendActionToInfoSensor(uint8_t sendAction) | |
214 { | |
215 switch(sendAction) | |
216 { | |
217 case ACTION_BUTTON_BACK: | |
218 exitMenuEdit_to_BackMenu(); | |
219 break; | |
220 | |
786 | 221 case ACTION_BUTTON_ENTER: if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId))) |
783 | 222 { |
786 | 223 settingsGetPointer()->ppo2sensors_deactivated &= ~(uint8_t)(1 << (activeSensorId)); |
783 | 224 sensorActive = 1; |
225 } | |
226 else | |
227 { | |
786 | 228 settingsGetPointer()->ppo2sensors_deactivated |= (uint8_t)(1 << (activeSensorId)); |
783 | 229 sensorActive = 0; |
230 } | |
231 break; | |
717 | 232 case ACTION_BUTTON_NEXT: |
233 case ACTION_TIMEOUT: | |
234 case ACTION_MODE_CHANGE: | |
235 case ACTION_IDLE_TICK: | |
236 case ACTION_IDLE_SECOND: | |
237 default: | |
238 break; | |
239 } | |
240 } | |
241 |