comparison Discovery/Src/tInfoSensor.c @ 717:88f73b05d45c

Added new info page for extended sensor data: The new source file may be used to create a information page individual for every smart sensor type. The DiveO2 sensor is the first supported sensor
author Ideenmodellierer
date Sun, 20 Nov 2022 20:46:10 +0100
parents
children f285424f04d9
comparison
equal deleted inserted replaced
716:74cfd91199bd 717:88f73b05d45c
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
87 text[0] = '\001';
88 text[1] = TXT_Sensor;
89 text[2] = ' ';
90 text[3] = TXT_Information;
91 text[4] = 0;
92 tInfo_write_content_simple( 30, 340, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware);
93
94
95 pDiveO2Data = (SSensorDataDiveO2*)stateRealGetPointer()->lifeData.extIf_sensor_data;
96
97 strIndex = snprintf(text,32,"ID: ");
98 if(pDiveO2Data->sensorId != 0)
99 {
100 uint64ToString(pDiveO2Data->sensorId,&text[strIndex]);
101 }
102 tInfo_write_content_simple( 30, 340, ME_Y_LINE1, &FontT48, text, CLUT_Font020);
103 snprintf(text,32,"%c: %02.1f",TXT_Temperature , (float)pDiveO2Data->temperature / 1000.0);
104 tInfo_write_content_simple( 30, 340, ME_Y_LINE2, &FontT48, text, CLUT_Font020);
105 }
106
107 void sendActionToInfoSensor(uint8_t sendAction)
108 {
109
110 switch(sendAction)
111 {
112
113 case ACTION_BUTTON_BACK:
114 exitMenuEdit_to_BackMenu();
115 break;
116
117 case ACTION_BUTTON_ENTER:
118 case ACTION_BUTTON_NEXT:
119 case ACTION_TIMEOUT:
120 case ACTION_MODE_CHANGE:
121 case ACTION_IDLE_TICK:
122 case ACTION_IDLE_SECOND:
123 default:
124 break;
125 }
126 }
127