annotate Discovery/Src/tInfoSensor.c @ 720:4f70155362d2

Bugfix set date (year): In the previous version the year selection was clipped to a range between 16 and 22. To avoid clipping issues in future the clipping is now done based on the firmware release date as lower limit and release date +10 years as upper limit.
author Ideenmodellierer
date Tue, 03 Jan 2023 19:47:12 +0100
parents 88f73b05d45c
children f285424f04d9
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"
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
37
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
38 #include <string.h>
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
39 #include <inttypes.h>
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
40
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
41 extern void openEdit_O2Sensors(void);
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
42
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
43 /* Private variables ---------------------------------------------------------*/
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 /* Exported functions --------------------------------------------------------*/
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
46 void openInfo_Sensor(void)
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
47 {
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
48 set_globalState(StISENINFO);
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
49 setBackMenu((uint32_t)openEdit_O2Sensors,0,6);
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
50 }
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
51
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
52
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
53
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
54 uint64_t mod64(uint64_t a, uint64_t b)
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
55 {
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
56 uint64_t div;
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
57 div=(a/10);
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
58 b=(10*div);
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
59 return (a-b);
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
60 }
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
61
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
62 void uint64ToString(uint64_t value, char* pbuf)
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
63 {
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
64 char tmpBuf[32];
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
65 uint8_t index = 31;
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
66
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
67 tmpBuf[index--] = 0; /* zero termination */
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
68 while((index != 0) && (value != 0))
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
69 {
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
70 tmpBuf[index--] = '0' + (value % 10);// mod64(worker64,10);
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
71 value /= 10;
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
72 }
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
73 strcpy(pbuf,&tmpBuf[index+1]);
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
74 }
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
75
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
76 // ===============================================================================
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
77 // refreshInfo_Compass
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
78 /// @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
79 /// the accel is not called during this process
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
80 // ===============================================================================
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
81 void refreshInfo_Sensor(GFX_DrawCfgScreen s)
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
82 {
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
83 SSensorDataDiveO2* pDiveO2Data;
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
84 char text[31];
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
85 uint8_t strIndex = 0;
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 text[0] = '\001';
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
88 text[1] = TXT_Sensor;
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
89 text[2] = ' ';
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
90 text[3] = TXT_Information;
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
91 text[4] = 0;
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
92 tInfo_write_content_simple( 30, 340, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware);
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
93
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
94
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
95 pDiveO2Data = (SSensorDataDiveO2*)stateRealGetPointer()->lifeData.extIf_sensor_data;
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 strIndex = snprintf(text,32,"ID: ");
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
98 if(pDiveO2Data->sensorId != 0)
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 uint64ToString(pDiveO2Data->sensorId,&text[strIndex]);
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
101 }
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
102 tInfo_write_content_simple( 30, 340, ME_Y_LINE1, &FontT48, text, CLUT_Font020);
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
103 snprintf(text,32,"%c: %02.1f",TXT_Temperature , (float)pDiveO2Data->temperature / 1000.0);
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
104 tInfo_write_content_simple( 30, 340, ME_Y_LINE2, &FontT48, text, CLUT_Font020);
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
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
107 void sendActionToInfoSensor(uint8_t sendAction)
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
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
110 switch(sendAction)
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
111 {
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
112
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
113 case ACTION_BUTTON_BACK:
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
114 exitMenuEdit_to_BackMenu();
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
115 break;
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
116
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
117 case ACTION_BUTTON_ENTER:
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
118 case ACTION_BUTTON_NEXT:
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
119 case ACTION_TIMEOUT:
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
120 case ACTION_MODE_CHANGE:
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
121 case ACTION_IDLE_TICK:
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
122 case ACTION_IDLE_SECOND:
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
123 default:
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
124 break;
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
125 }
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
126 }
88f73b05d45c Added new info page for extended sensor data:
Ideenmodellierer
parents:
diff changeset
127