annotate Discovery/Src/show_logbook.c @ 224:ceecabfddb57 div-fixes-3

Bugfix, deco: fix 2 (small) problems with calculated ceiling This fixes 1 trivial, and 1 not really trivial bug in the calculation of the ceiling. When simulating a bounce dive to 80m, things become clear (tried this on a CCR dive, fixed setpoint 1.2bar, about 15 minutes of bottom time). Closely watch the behavior of the ceiling data. At some point during the ascent, the ceiling begins to decrease in 10cm steps. Then suddenly (while still ascending), the ceiling increases again with 1m, does not change for some time, and then suddenly steps 1.1m less deep. While not very relevant to real deco diving, it is simply wrong. The reason for this is subtle. The algorithm used to find the ceiling is a sort of linear search, stepping down a meter, overshoot the depth, and search back in 10cm steps. It seems some numerical instability. Fixing this, was a bit more computational intensive search by stepping up down in equal steps of 10cm. But, I'm pretty sure that things can be speeded up here, as a ceiling does not change fast, so it should be not that difficult to limit the search space, or use a binary search algorithm instead. The trivial second problem fixed, is that the ceiling ends at the surface and not at 1m depth. This small issue became visible after changing the step down size above. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Sun, 31 Mar 2019 19:35:51 +0200
parents f11f0bf6ef2d
children 5a633dece17a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 ///////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 /// -*- coding: UTF-8 -*-
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 /// \file Discovery/Src/show_logbook.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 /// \brief show_logbook_logbook_show_log_page1 /
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 /// \author Heinrichs Weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 /// \date 07-July-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 /// \details
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 /// $Id$
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ///////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 /// This program is free software: you can redistribute it and/or modify
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 /// it under the terms of the GNU General Public License as published by
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 /// the Free Software Foundation, either version 3 of the License, or
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 /// (at your option) any later version.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 /// This program is distributed in the hope that it will be useful,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 /// GNU General Public License for more details.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 /// You should have received a copy of the GNU General Public License
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 //////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 #include "base.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 #include "logbook.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 #include "gfx_colors.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 #include "gfx_engine.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 #include "gfx_fonts.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 #include "show_logbook.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 #include "unit.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 #include <stdint.h>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 #include <stdio.h>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 #include <stdlib.h> // for abs()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42
186
f11f0bf6ef2d cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents: 166
diff changeset
43 static GFX_DrawCfgScreen tLOGscreen;
f11f0bf6ef2d cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents: 166
diff changeset
44 static GFX_DrawCfgScreen tLOGbackground;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46
186
f11f0bf6ef2d cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents: 166
diff changeset
47 static void print_gas_name(char* output,uint8_t lengh,uint8_t oxygen,uint8_t helium);
f11f0bf6ef2d cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents: 166
diff changeset
48 static int16_t get_colour(int16_t color);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 /* Overview */
186
f11f0bf6ef2d cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents: 166
diff changeset
51 static void show_logbook_logbook_show_log_page1(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 /* Temperature */
186
f11f0bf6ef2d cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents: 166
diff changeset
53 static void show_logbook_logbook_show_log_page2(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 /* Gas List */
186
f11f0bf6ef2d cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents: 166
diff changeset
55 static void show_logbook_logbook_show_log_page3(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 /* ppO2 */
186
f11f0bf6ef2d cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents: 166
diff changeset
57 static void show_logbook_logbook_show_log_page4(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58
186
f11f0bf6ef2d cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents: 166
diff changeset
59 static inline uint32_t MaxU32LOG(uint32_t a, uint32_t b)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 return((a>b)?a:b);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 * @brief GFX write label. / print coordinate system & depth graph
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 * @author Peter Ryser
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 * @version V0.0.1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 * @date 07-July-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 * @param hgfx:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 * @param window: WindowGimpStyle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 * @param mode: different modes depending witch page uses the function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 * @param dataLength:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 * @param depthdata:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 * @param colordata: 1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 */
186
f11f0bf6ef2d cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents: 166
diff changeset
80 static void show_logbook_draw_depth_graph(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards, SWindowGimpStyle* window, short mode, uint16_t dataLength, uint16_t* depthdata, uint8_t * colordata, uint16_t * decostopdata)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 SLogbookHeader logbookHeader;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 SWindowGimpStyle wintemp = *window;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 SWindowGimpStyle winsmal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 logbook_getHeader(StepBackwards, &logbookHeader);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 int divetime = logbookHeader.diveTimeMinutes;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 int maxDepth = logbookHeader.maxDepth/100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 int16_t saveBottom = wintemp.bottom;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 int16_t saveTop = 0 - wintemp.top;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 //*** Horisontal (depth) ***************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 //--- calc depth lines and labels --
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 int vscale = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 int vstep = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 vstep = maxDepth / 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 vscale = vstep * 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 if(vscale < maxDepth)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 vstep += 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 vscale += 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 if(vscale <
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 for(int i=1; i <= 20; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 vscale = i * 25;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 vstep = i * 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 if( vscale > maxDepth)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 //--- print depth labels ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 winsmal.left = wintemp.left - 48;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 winsmal.top = wintemp.top - 3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 winsmal.right = wintemp.left -1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 winsmal.bottom = winsmal.top + 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
121 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,CLUT_GasSensor1,"[m]");
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
122
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
123 // winsmal.left = wintemp.left - 48;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 char msg[3];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 float deltaline = ((float)(wintemp.bottom - wintemp.top))/5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 for(int i = 1; i<=5; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 winsmal.top = wintemp.top + deltaline * i - 14;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 winsmal.bottom = winsmal.top + 16;
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
130
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
131 // winsmal.right = wintemp.left - 2;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 snprintf(msg,5,"%i",i * vstep);
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
133 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,CLUT_GasSensor1,msg);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 //vertical (Time) *******************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 //--- calc time lines and labels --
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 int timestep = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 int lines = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 for(int i=1; i <= 60; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 timestep = i * 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 lines = divetime/timestep;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 if(lines < 7)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 //*** print coordinate system grit ***
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 int winwidth = wintemp.right - wintemp.left;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 float vdeltaline = ((float)(winwidth * timestep))/divetime;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 GFX_draw_Grid( &tLOGbackground,wintemp, 0, vdeltaline, 5,0, CLUT_LogbookGrid);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 //--- print time labels ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 winsmal.left = wintemp.left;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 winsmal.top = wintemp.top - 40;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 winsmal.right = winsmal.left + 60;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 winsmal.bottom = winsmal.top + 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
161 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,CLUT_GasSensor1,"min");
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 for(int i = 1; i<=lines; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 winsmal.left= wintemp.left + vdeltaline * i - 15;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 winsmal.right = winsmal.left + 30;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 snprintf(msg,5,"%3i",i * timestep);
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
167 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,CLUT_GasSensor1,msg);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 winsmal.left = wintemp.left;// - 9;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 winsmal.top = wintemp.top - 40;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 winsmal.right = winsmal.left + 60;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 //--- print depth graph ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 //adapt window
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 int winhight = wintemp.bottom - wintemp.top;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 int newhight = (winhight * maxDepth)/vscale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 wintemp.bottom = wintemp.top + newhight;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 //wintemp.fontcolor = LOGBOOK_GRAPH_DEPTH;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 int datamax = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 for(int i=0;i<dataLength;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 if(depthdata[i]>datamax)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 datamax = depthdata[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 if(decostopdata)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 if(dataLength <= 1000)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 uint8_t colortemp[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 for(int i = 0; i<dataLength; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 if(decostopdata[i] > depthdata[i])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 colortemp[i] = CLUT_WarningRed;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 colortemp[i] = CLUT_NiceGreen;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 }
166
255eedad4155 cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents: 150
diff changeset
204 GFX_graph_print(hgfx,&wintemp,saveTop,1,0,datamax, decostopdata,dataLength, 0, colortemp);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 GFX_graph_print(hgfx,&wintemp,saveTop,1,0,datamax, decostopdata,dataLength, CLUT_NiceGreen, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
210 if(settingsGetPointer()->FlipDisplay)
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
211 {
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
212 winsmal.right = 800 - wintemp.left;
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
213 winsmal.left = 800 - wintemp.right;
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
214 winsmal.bottom = wintemp.bottom;
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
215 winsmal.top = wintemp.top;
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
216 }
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
217 else
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
218 {
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
219 winsmal.right = wintemp.right;
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
220 winsmal.left = wintemp.left;
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
221 winsmal.bottom = wintemp.bottom;
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
222 winsmal.top = wintemp.top;
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
223 }
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
224
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 switch(mode)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 case 0:
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
228 GFX_graph_print(hgfx,&winsmal,0,1,0,datamax, depthdata,dataLength,CLUT_GasSensor1, NULL);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 case 1:
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
231 GFX_graph_print(hgfx,&winsmal,saveBottom,1,0,datamax, depthdata,dataLength,CLUT_GasSensor0,colordata);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 case 2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 if(*colordata)
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
235 GFX_graph_print(hgfx,&winsmal,0,1,0,datamax, depthdata,dataLength,CLUT_GasSensor0,colordata);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 else
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
237 GFX_graph_print(hgfx,&winsmal,0,1,0,datamax, depthdata,dataLength,CLUT_GasSensor1, NULL);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 * @brief scaleAdapt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 * @author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 * @version V0.0.1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 * @date 29-Nov-2016
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 * @param ...
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 * @retval *OutputStepOfScale, *OutputMaxValueOnScale, *OutputTop, *OutputBottom
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 * fit to multiples of 1�C (data format is 1/10�C)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256
186
f11f0bf6ef2d cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents: 166
diff changeset
257 static void scaleAdapt( int InputTop, int InputBottom,
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 int16_t *OutputMinValue, int16_t *OutputMaxValue, int *OutputTop, int *OutputBottom,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 uint16_t *OutputStepOfScale, int16_t *OutputMaxValueOnScale)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 // uint16_t oldScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 uint16_t newScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 // uint16_t diff_newScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 // int16_t oldMaxOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 int16_t newMaxOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 // int16_t diff_newMaxOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 _Bool negativeMaxValue = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 // float oldRange;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271 float newRange;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 float sizeOfScreen;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274 // float InputTopValue;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 // float InputBottomValue;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 float screenToRangeRatio;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 float diffOutMaxToMaxOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 float diffOutMinToMaxOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 int positonOutputMaxValue;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 int positonOutputMinValue;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 // scale
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 // oldScale = *OutputStepOfScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 newScale = *OutputStepOfScale + 9;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286 newScale /= 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 newScale *= 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 // diff_newScale = newScale - *OutputStepOfScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 // oldRange = 5 * oldScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 newRange = 5 * newScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 *OutputStepOfScale = newScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 // MaxValueOnScale
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 // oldMaxOnScale = *OutputMaxValueOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 if(OutputMaxValueOnScale < 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 negativeMaxValue = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 newMaxOnScale = 0 - *OutputMaxValueOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 negativeMaxValue = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 newMaxOnScale = *OutputMaxValueOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 newMaxOnScale += 9;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 newMaxOnScale /= 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 newMaxOnScale *= 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 if(negativeMaxValue)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 // diff_newMaxOnScale = newMaxOnScale + *OutputMaxValueOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 *OutputMaxValueOnScale = 0 - newMaxOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 // diff_newMaxOnScale = newMaxOnScale - *OutputMaxValueOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 *OutputMaxValueOnScale = newMaxOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 // new coordinates
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 sizeOfScreen = 1 + InputBottom - InputTop;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 // InputTopValue = *OutputMaxValueOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 // InputBottomValue = InputTopValue + (6 * *OutputStepOfScale);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 screenToRangeRatio = sizeOfScreen / newRange;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 diffOutMaxToMaxOnScale = abs(*OutputMaxValueOnScale) - abs(*OutputMaxValue);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 // diffOutMinToMax = abs(*OutputMinValue - *OutputMaxValue);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 diffOutMinToMaxOnScale = abs(*OutputMaxValueOnScale - *OutputMinValue);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 positonOutputMaxValue = (int)(diffOutMaxToMaxOnScale * screenToRangeRatio);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 positonOutputMaxValue += *OutputTop;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 positonOutputMinValue = (int)(diffOutMinToMaxOnScale * screenToRangeRatio);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 positonOutputMinValue += *OutputTop;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 // positonOutputMinValue = (int)(diffOutMinToMax * screenToRangeRatio);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 // positonOutputMinValue += positonOutputMaxValue;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 *OutputTop = positonOutputMaxValue;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 *OutputBottom = positonOutputMinValue;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 * @brief scaleHelper
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 * @author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 * @version V0.0.1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 * @date 13-Oct-2016
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 * @param hgfx:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 * pixel 50 oben
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 * pixel 439 unten
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354 * pixel 390 gesamt h�he
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356 * for temperature, input is �C * 10
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358
186
f11f0bf6ef2d cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents: 166
diff changeset
359 static void scaleHelper( uint16_t InputDataLength, int16_t *InputDataArray, int InputTop, int InputBottom,
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 int16_t *OutputMinValue, int16_t *OutputMaxValue, int *OutputTop, int *OutputBottom,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361 uint16_t *OutputStepOfScale, int16_t *OutputMaxValueOnScale)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 int32_t datamin = INT16_MAX; // 32 bit for delta calculation ( delta is unsigned -> value can be 2x INT16_MAX)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 int32_t datamax = INT16_MIN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 uint16_t deltaMinMax = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 // uint16_t deltaMinMaxUsed = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367 // uint16_t digits = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 // uint16_t scaler = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 uint32_t step = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370 const int sizeOfScreen = InputBottom - InputTop;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 float pixel2range = 1.0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 // min, max, deltaMinMax, OutputMinValue, OutputMaxValue
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374 for(uint16_t i = 0; i < InputDataLength; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376 if(InputDataArray[i] > datamax)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 datamax = InputDataArray[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 if(InputDataArray[i] < datamin)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 datamin = InputDataArray[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 deltaMinMax = (uint16_t)(datamax - datamin);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 *OutputMinValue = (int16_t)datamin;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 *OutputMaxValue = (int16_t)datamax;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388 // step
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389 step = deltaMinMax / 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390 while(deltaMinMax > (step * 5))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 step += 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 pixel2range = ((float)sizeOfScreen) / (step * 5);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396 *OutputStepOfScale = (uint16_t)step;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 *OutputMaxValueOnScale = *OutputMaxValue;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 *OutputTop = InputTop;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 *OutputBottom = ((int)(pixel2range * deltaMinMax)) + *OutputTop;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404 * @brief show_logbook_logbook_show_log_page1 /
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 * @author Peter Ryser
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 * @version V0.0.1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 * @date 07-July-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410 * @param hgfx:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412 */
186
f11f0bf6ef2d cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents: 166
diff changeset
413 static void show_logbook_logbook_show_log_page1(GFX_DrawCfgScreen *hgfx,uint8_t StepBackwards)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 SWindowGimpStyle wintemp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416 SWindowGimpStyle winsmal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417 wintemp.left = 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418 wintemp.right = 799 - wintemp.left;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419 wintemp.top = 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 wintemp.bottom = 479 - 40;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422 SLogbookHeader logbookHeader;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423 logbook_getHeader(StepBackwards ,&logbookHeader);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425 uint16_t depthdata[1000] = { 0 };
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
426 uint8_t gasdata[1000] = { 0 };
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
427 int16_t tempdata[1000] = { 0 };
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
428
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429 uint16_t dataLength = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
430 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata,gasdata, tempdata, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
432 //Print Date
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
433 uint8_t year = logbookHeader.dateYear;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
434 uint8_t month = logbookHeader.dateMonth;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
435 uint8_t day = logbookHeader.dateDay;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
436 char text[40];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
437 snprintf(text, 20, "20%02i-%02i-%02i", year, month, day);
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
438
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
439 Gfx_write_label_var(hgfx, 30, 250,10, &FontT42,CLUT_GasSensor1,text);
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
440
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442 // Print logbook number with offset
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
443 if(settingsGetPointer()->logbookOffset)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445 int32_t logNumber;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446 logNumber = settingsGetPointer()->logbookOffset - StepBackwards;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447 if(logNumber < 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448 logNumber = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450 if(logNumber > 9999)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451 logNumber = 9999;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453 snprintf(text,20,"#%i",logNumber);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454 Gfx_write_label_var(hgfx, 300, 590,10, &FontT42,CLUT_GasSensor1,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
455 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457 //Print time
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458 uint8_t hour = logbookHeader.timeHour;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459 uint8_t minute = logbookHeader.timeMinute;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460 snprintf(text,20,"%02i:%02i",hour,minute);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461 Gfx_write_label_var(hgfx, 600, 749,10, &FontT42,CLUT_GasSensor1,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463 //Print Dive Mode (OC/CCR/...)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
464 switch(logbookHeader.diveMode)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
465 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
466 case DIVEMODE_OC:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467 snprintf(text,20,"open circuit");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
468 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
469 case DIVEMODE_CCR:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470 snprintf(text,20,"closed circuit");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
471 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472 case DIVEMODE_Gauge:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
473 snprintf(text,20,"Gauge");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 case DIVEMODE_Apnea:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476 snprintf(text,20,"Apnea");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479 Gfx_write_label_var(hgfx, 30, 250,60, &FontT42,CLUT_GasSensor4,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481 // Decomodel
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
482 if(logbookHeader.diveMode <= DIVEMODE_CCR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
483 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
484 switch(logbookHeader.decoModel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
486 case GF_MODE:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
487 snprintf(text,20,"\002GF%u/%u",logbookHeader.gfLow_or_Vpm_conservatism,logbookHeader.gfHigh);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
488 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489 case VPM_MODE:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490 snprintf(text,20,"\002VPM +%u",logbookHeader.gfLow_or_Vpm_conservatism);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493 Gfx_write_label_var(hgfx, 600, 729,60, &FontT42,CLUT_GasSensor1,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496 //Write Dive Time
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497 int minutes = logbookHeader.diveTimeMinutes;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
498 int seconds = logbookHeader.diveTimeSeconds;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499 int hours = minutes/60;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
500 minutes -= hours * 60;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501 snprintf(text,20,"%02i:%02i:%02i",hours,minutes,seconds);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502 Gfx_write_label_var(hgfx, 30, 250,360, &FontT42,CLUT_GasSensor1,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503 Gfx_write_label_var(hgfx, 200, 250,360, &FontT42,CLUT_GasSensor4,"s");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
504
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505 // Max Depth
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506 int maxdepth =logbookHeader.maxDepth/100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507 int maxdepth_dcm = logbookHeader.maxDepth/10 - maxdepth * 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508 int top = 150;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509 if(settingsGetPointer()->nonMetricalSystem)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
510 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
511 float maxDepthFeet = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
512 maxDepthFeet = unit_depth_float(((float)logbookHeader.maxDepth)/100);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513 snprintf(text,20,"%.0f",maxDepthFeet);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
516 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
517 snprintf(text,20,"%i.%i",maxdepth,maxdepth_dcm);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
518 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
519 Gfx_write_label_var(hgfx, 30, 250,top, &FontT42,CLUT_GasSensor1,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
520 winsmal.left = 30;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
521 winsmal.top = top -3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
522 winsmal.bottom = winsmal.top + FontT42.height;
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
523
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
524 if(maxdepth < 10)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
525 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
526 winsmal.left = 137;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
527 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
528 else if(maxdepth < 100)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
529 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
530 winsmal.left = 151;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
531 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
532 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
533 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
534 winsmal.left = 147;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
535 }
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
536 winsmal.right = winsmal.left + 50;
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
537
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
538 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,top, &FontT24,CLUT_GasSensor4,"max");
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
539 snprintf(text,3,"%c%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
540 , unit_depth_char1()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
541 , unit_depth_char2()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
542 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
543 Gfx_write_label_var(hgfx, winsmal.left - 37, 250,top, &FontT42,CLUT_GasSensor4,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
544
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
545 // Average Depth
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
546 int avrdepth =logbookHeader.averageDepth_mbar/100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
547 int avrdepth_dcm = logbookHeader.averageDepth_mbar/10 - avrdepth * 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
548 top = 200;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
549 if(settingsGetPointer()->nonMetricalSystem)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
550 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
551 float avgDepthFeet = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
552 avgDepthFeet = unit_depth_float(((float)logbookHeader.averageDepth_mbar)/100);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
553 snprintf(text,20,"%.0f",avgDepthFeet);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
554 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
555 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
556 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
557 snprintf(text,20,"%i.%i",avrdepth,avrdepth_dcm);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
558 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
559 Gfx_write_label_var(hgfx, 30, 250,top, &FontT42,CLUT_GasSensor1,text);
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
560
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
561 winsmal.left = 30;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
562 winsmal.top = top -3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
563 winsmal.bottom = winsmal.top + FontT42.height;
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
564
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
565 /* put avg behind previous string */
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
566 if(avrdepth < 10)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
567 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
568 winsmal.left = 137 ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
569 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
570 else if(avrdepth < 100)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
571 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
572 winsmal.left = 151;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
573 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
574 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
575 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
576 winsmal.left = 147;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
577 }
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
578 winsmal.right = winsmal.left + 50;
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
579
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
580 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,CLUT_GasSensor4,"avg");
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
581 snprintf(text,3,"%c%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
582 , unit_depth_char1()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
583 , unit_depth_char2()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
584 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
585 Gfx_write_label_var(hgfx, winsmal.left - 37, 250,top, &FontT42,CLUT_GasSensor4,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
586 // Temperature
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
587 top+= 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
588 float temp_Temperature;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
589 uint16_t start;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
590 temp_Temperature = ((float)logbookHeader.minTemp)/10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
591 snprintf(text,20,"%.1f",unit_temperature_float(temp_Temperature));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
592 Gfx_write_label_var(hgfx, 30, 250,top, &FontT42,CLUT_GasSensor1,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
593
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
594 if(settingsGetPointer()->nonMetricalSystem)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
595 start = 121;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
596 else if((logbookHeader.minTemp >= 0) && (logbookHeader.minTemp < 10))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
597 start = 100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
598 else if((logbookHeader.minTemp >= -10) && (logbookHeader.minTemp < 100))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
599 start = 114;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
600 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
601 start = 121;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
602
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
603 text[0] = '\140';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
604 if(settingsGetPointer()->nonMetricalSystem)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
605 text[1] = 'F';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
606 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
607 text[1] = 'C';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
608 text[2] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
609
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
610 Gfx_write_label_var(hgfx, start, 300,top, &FontT42,CLUT_GasSensor4,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
611
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
612 // CNS
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
613 snprintf(text,20,"CNS: %i %%",logbookHeader.maxCNS);
150
097d7146b779 Place CNS and pressure within the screen (avoid clipping)
Ideenmodellierer
parents: 115
diff changeset
614 Gfx_write_label_var(hgfx, 30, 250,440, &FontT42,CLUT_GasSensor1,text);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
615
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
616 // Surface Pressure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
617 // snprintf(text,20,"\001%i\016\016 mbar",logbookHeader.surfacePressure_mbar);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
618 // Gfx_write_label_var(hgfx,300,500,750, &FontT42,CLUT_GasSensor1,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
619 // snprintf(text,40,"%i\016\016 mbar\017 (%i\016\016 m\017)",logbookHeader.surfacePressure_mbar, unit_SeaLevelRelation_integer(logbookHeader.surfacePressure_mbar));
102
4276d56eb37c hPa instead of mbar, enabled Spanish language
heinrichsweikamp
parents: 38
diff changeset
620 snprintf(text,40,"%i\016\016 hPa\017",logbookHeader.surfacePressure_mbar);
150
097d7146b779 Place CNS and pressure within the screen (avoid clipping)
Ideenmodellierer
parents: 115
diff changeset
621 Gfx_write_label_var(hgfx,320,600,440, &FontT42,CLUT_GasSensor1,text);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
622
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
623
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
624 //--- print coordinate system & depth graph with gaschanges ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
625 wintemp.left = 330;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
626 wintemp.top = 160;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
627 wintemp.bottom -= 40;
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
628
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
629 show_logbook_draw_depth_graph(hgfx, StepBackwards, &wintemp, 1, dataLength, depthdata, gasdata, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
630 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
631
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
632
186
f11f0bf6ef2d cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents: 166
diff changeset
633 static void show_logbook_logbook_show_log_page2(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
634 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
635 //*** Page2: Depth and Temperature ****
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
636
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
637 SWindowGimpStyle wintemp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
638 SWindowGimpStyle winsmal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
639 wintemp.left = 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
640 wintemp.right = 799 - wintemp.left;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
641 wintemp.top = 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
642 wintemp.bottom = 479 - 40;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
643
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
644 SLogbookHeader logbookHeader;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
645
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
646 logbook_getHeader(StepBackwards,&logbookHeader);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
647 uint16_t dataLength = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
648 uint16_t depthdata[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
649 uint8_t gasdata[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
650 int16_t tempdata[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
651 uint16_t decoDepthdata[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
652 uint16_t *pDecoDepthData = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
653
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
654 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata,gasdata, tempdata, NULL, NULL, NULL, NULL, NULL, NULL, NULL, decoDepthdata);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
655
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
656 for(int i = 0; i<dataLength; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
657 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
658 if(decoDepthdata[i] >= 300)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
659 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
660 pDecoDepthData = decoDepthdata;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
661 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
662 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
663 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
664 //--- print coordinate system & depth graph ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
665 show_logbook_draw_depth_graph(hgfx, StepBackwards, &wintemp, 0, dataLength, depthdata, gasdata, pDecoDepthData);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
666
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
667 //*** Temperature *************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
668
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
669 //--- print temperature labels ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
670 // input maxtmpline, tmpstep, deltaline
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
671
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
672 winsmal.left = wintemp.right +6;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
673 winsmal.top = wintemp.top - 3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
674 winsmal.right = wintemp.right + 30;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
675 winsmal.bottom = winsmal.top + 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
676
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
677 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,CLUT_LogbookTemperature,"[C]");
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
678
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
679 int16_t minVal = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
680 int16_t maxVal = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
681 int newTop = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
682 int newBottom = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
683 uint16_t step = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
684 int16_t maxValTop = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
685
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
686 scaleHelper(dataLength, tempdata, wintemp.top, wintemp.bottom,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
687 &minVal, &maxVal, &newTop, &newBottom,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
688 &step, &maxValTop); // newTop is wintemp.top
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
689
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
690 scaleAdapt( wintemp.top, wintemp.bottom,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
691 &minVal, &maxVal, &newTop, &newBottom,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
692 &step, &maxValTop);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
693
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
694 // temperature in 1/10 �C
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
695 int deltaline = (1 + wintemp.bottom - wintemp.top)/5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
696 char msg[3];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
697 int tmp = maxValTop;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
698 for(int i = 1; i<=5; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
699 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
700 tmp -= step;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
701 //if(tmp < 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
702 //break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
703 winsmal.top = wintemp.top + deltaline * i - 14;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
704 winsmal.bottom = winsmal.top + 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
705 if((tmp >= 0) && (tmp < 100))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
706 snprintf(msg,2,"%1i",tmp);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
707 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
708 snprintf(msg,3,"%2i",tmp);
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
709 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,CLUT_LogbookTemperature,msg);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
710 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
711
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
712
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
713 //--- print temperature graph ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
714 // input tempdata[i], maxtmpline, mintmpline, maxTmp, minTmp, deltaline, wintemp.top, dataLength, datamax,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
715
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
716 //adapt window
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
717 wintemp.bottom = newBottom;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
718 wintemp.top = newTop;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
719 GFX_graph_print(hgfx,&wintemp,0,1,maxVal,minVal, (uint16_t *)tempdata,dataLength,CLUT_LogbookTemperature, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
720 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
721
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
722
186
f11f0bf6ef2d cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents: 166
diff changeset
723 static void build_logbook_test(uint8_t page, uint8_t StepBackwards)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
724 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
725 uint32_t lastScreen,lastBackground;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
726
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
727 lastScreen = tLOGscreen.FBStartAdress;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
728 lastBackground = tLOGbackground.FBStartAdress;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
729
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
730 tLOGscreen.FBStartAdress = getFrame(16);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
731 tLOGscreen.ImageHeight = 480;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
732 tLOGscreen.ImageWidth = 800;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
733 tLOGscreen.LayerIndex = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
734
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
735 tLOGbackground.FBStartAdress = getFrame(17);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
736 tLOGbackground.ImageHeight = 480;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
737 tLOGbackground.ImageWidth = 800;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
738 tLOGbackground.LayerIndex = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
739 switch(page)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
740 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
741 case 1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
742 show_logbook_logbook_show_log_page1(&tLOGscreen,StepBackwards);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
743 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
744 case 2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
745 show_logbook_logbook_show_log_page2(&tLOGscreen,StepBackwards);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
746 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
747 case 3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
748 show_logbook_logbook_show_log_page3(&tLOGscreen,StepBackwards);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
749 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
750 case 4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
751 show_logbook_logbook_show_log_page4(&tLOGscreen,StepBackwards);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
752 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
753 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
754
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
755 releaseFrame(16,lastScreen);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
756 releaseFrame(17,lastBackground);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
757 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
758
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
759
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
760 void show_logbook_test(_Bool firstPage, uint8_t StepBackwards)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
761 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
762 static uint8_t page = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
763 if(firstPage)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
764 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
765 page = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
766 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
767 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
768 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
769 page++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
770 if(page > 4)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
771 page = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
772 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
773
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
774 build_logbook_test(page,StepBackwards);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
775 // GFX_ResetLayer(TOP_LAYER);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
776 // GFX_ResetLayer(BACKGRD_LAYER);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
777
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
778 set_globalState(StILOGSHOW);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
779 GFX_SetFramesTopBottom(tLOGscreen.FBStartAdress, tLOGbackground.FBStartAdress,480);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
780 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
781
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
782
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
783 void show_logbook_exit(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
784 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
785 releaseFrame(16,tLOGscreen.FBStartAdress);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
786 releaseFrame(17,tLOGbackground.FBStartAdress);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
787 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
788
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
789
186
f11f0bf6ef2d cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents: 166
diff changeset
790 static void show_logbook_logbook_show_log_page3(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
791 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
792 SWindowGimpStyle wintemp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
793 SWindowGimpStyle winsmal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
794 wintemp.left = 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
795 wintemp.right = 799 - wintemp.left;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
796 wintemp.top = 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
797 wintemp.bottom = 479 - 40;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
798
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
799 SLogbookHeader logbookHeader;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
800
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
801 logbook_getHeader(StepBackwards, &logbookHeader);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
802 uint16_t dataLength = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
803 uint16_t depthdata[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
804 uint8_t gasdata[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
805 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata,gasdata, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
806
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
807 //--- print coordinate system & depth graph with gaschanges ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
808 show_logbook_draw_depth_graph(hgfx, StepBackwards, &wintemp, 1, dataLength, depthdata, gasdata, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
809
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
810 //--- print gas list ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
811 winsmal.left = wintemp.right - 190;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
812 winsmal.right = winsmal.left + 150;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
813
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
814 char msg[15];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
815 char gas_name[15];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
816 int j = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
817 for(int i = 4;i >= 0;i--)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
818 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
819 if(logbookHeader.gasordil[i].note.ub.active > 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
820 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
821 j++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
822 winsmal.top = wintemp.bottom - 5 - j * 26 ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
823 winsmal.bottom = winsmal.top + 21 ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
824 uint8_t color = get_colour(i);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
825
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
826 print_gas_name(gas_name,15,logbookHeader.gasordil[i].oxygen_percentage,logbookHeader.gasordil[i].helium_percentage);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
827 snprintf(msg,15,"G%i: %s",i + 1, gas_name);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
828 //msg[10] = 0;
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
829 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,msg);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
830 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
831 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
832
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
833 //--- define buttons ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
834 /*if(*ghost_char_logfile_oxydata)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
835 button_start_single_action(surf1_menu_logbook_current_page, surf1_menu_logbook_show_log_page4, surf1_menu_logbook_show_log_next);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
836 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
837 button_start_single_action(surf1_menu_logbook_current_page, surf1_menu_logbook_show_log_page1, surf1_menu_logbook_show_log_next);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
838 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
839 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
840
186
f11f0bf6ef2d cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents: 166
diff changeset
841 static void show_logbook_logbook_show_log_page4(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
842 { SWindowGimpStyle wintemp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
843 SWindowGimpStyle winsmal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
844 wintemp.left = 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
845 wintemp.right = 799 - wintemp.left;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
846 wintemp.top = 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
847 wintemp.bottom = 479 - 40;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
848 uint8_t color = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
849 SLogbookHeader logbookHeader;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
850
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
851 logbook_getHeader(StepBackwards, &logbookHeader);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
852 uint16_t dataLength = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
853 uint16_t depthdata[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
854 uint8_t gasdata[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
855 uint16_t ppO2data[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
856 uint16_t sensor2[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
857 uint16_t sensor3[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
858 uint16_t *setpoint = ppO2data;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
859 uint16_t *sensor1 = ppO2data;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
860
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
861
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
862 if(logbookHeader.diveMode != DIVEMODE_CCR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
863 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata,gasdata, NULL, ppO2data, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
864 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
865 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
866 if(logbookHeader.CCRmode == CCRMODE_FixedSetpoint)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
867 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata, gasdata, NULL, NULL, setpoint, NULL, NULL, NULL, NULL, NULL, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
868 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
869 dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata, gasdata, NULL, NULL, NULL, sensor1, sensor2, sensor3, NULL, NULL, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
870 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
871
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
872
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
873 //--- print coordinate system & depth graph with bailout---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
874 show_logbook_draw_depth_graph(hgfx, StepBackwards, &wintemp, 0, dataLength, depthdata, gasdata, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
875
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
876
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
877
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
878 //*** Desciption at bottom of page ***************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
879 winsmal.top = wintemp.bottom +2 ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
880 winsmal.bottom = winsmal.top + 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
881
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
882
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
883 /*if(strcmp( (char*)ghost_char_logfile_text_oc_ccr,"ccr/bailout") == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
884 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
885 winsmal.left = wintemp.left + 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
886 winsmal.right = winsmal.left + 55;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
887
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
888 oled_write(OVERLAY, &winsmal,"CCR -",false,true);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
889
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
890 winsmal.left = winsmal.right;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
891 winsmal.right = winsmal.left + 90;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
892 //winsmal.fontcolor = oled_get_colour(15);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
893 oled_write(OVERLAY, &winsmal,"bailout",false,true);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
894 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
895 else*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
896 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
897 winsmal.left = wintemp.left + 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
898 winsmal.right = winsmal.left + 55;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
899 color = CLUT_GasSensor1;//LOGBOOK_GRAPH_DEPTH;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
900
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
901 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,"depth");
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
902
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
903 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
904 winsmal.left = 799 - 67;//wintemp.right -67;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
905 winsmal.right = winsmal.left;// + 45;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
906
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
907 color = CLUT_LogbookTemperature;//LOGBOOK_GRAPH_DEPTH;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
908 if(logbookHeader.diveMode != DIVEMODE_CCR)
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
909 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,"\002PP O2");
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
910 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
911 if(logbookHeader.CCRmode != CCRMODE_Sensors)
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
912 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,"\002SETPOINT");
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
913 else
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
914 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,"\002SENSORS");
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
915
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
916 //*** PP O2 ****************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
917 //calc lines and labels
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
918 int datamax = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
919 int datamin = 10000;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
920 for(int i=1;i<dataLength;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
921 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
922 if(ppO2data[i]>datamax)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
923 datamax = ppO2data[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
924 if(ppO2data[i]<datamin)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
925 datamin = ppO2data[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
926 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
927 if((logbookHeader.diveMode == DIVEMODE_CCR) && (logbookHeader.CCRmode == CCRMODE_Sensors))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
928 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
929 for(int i=1;i<dataLength;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
930 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
931 if(sensor2[i]>datamax)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
932 datamax = sensor2[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
933 if(sensor2[i]<datamin)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
934 datamin = sensor2[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
935 if(sensor3[i]>datamax)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
936 datamax = sensor3[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
937 if(sensor3[i]<datamin)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
938 datamin = sensor3[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
939 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
940 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
941 float maxoxy = ((float)datamax)/100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
942 float minoxy = ((float)datamin)/100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
943 float oxystep = 0.5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
944 float maxoxyline = 2.5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
945
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
946 //--- print PP O2 labels ----
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
947 winsmal.left = wintemp.right + 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
948 winsmal.top = wintemp.top ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
949 winsmal.right = wintemp.right + 30;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
950 winsmal.bottom = winsmal.top + 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
951 //winsmal.font = ft_tiny + ft_SLIM;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
952 color = CLUT_LogbookTemperature;// = LOGBOOK_GRAPH_TEMP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
953
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
954 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,"bar");
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
955
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
956 int deltaline = (wintemp.bottom - wintemp.top)/5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
957 char msg[4];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
958 float oxy = maxoxyline;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
959 for(int i = 1; i<=5; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
960 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
961 oxy -= oxystep;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
962 if(oxy < 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
963 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
964 winsmal.top = wintemp.top + deltaline * i - 8;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
965 winsmal.bottom = winsmal.top + 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
966 snprintf(msg,4,"%1.1f",oxy);
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
967 Gfx_write_label_var(hgfx, winsmal.left, winsmal.right,winsmal.top, &FontT24,color,msg);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
968 //oled_write(OVERLAY, &winsmal,msg,false,true);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
969 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
970
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
971 //--- print PP O2 graph ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
972 //Adapt window
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
973 float ftmp = ((maxoxyline - minoxy) * deltaline) /oxystep + wintemp.top;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
974 wintemp.bottom = ftmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
975 if((ftmp - (int)ftmp) >= 0.5f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
976 wintemp.bottom++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
977
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
978 ftmp = wintemp.top + ((maxoxyline - maxoxy) * deltaline) /oxystep;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
979 wintemp.top = ftmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
980 if((ftmp - (int)ftmp) >= 0.5f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
981 wintemp.top++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
982 wintemp.top = MaxU32LOG(wintemp.top ,0);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
983 if(wintemp.top < wintemp.bottom)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
984 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
985 if((logbookHeader.diveMode == DIVEMODE_CCR) && (logbookHeader.CCRmode == CCRMODE_Sensors))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
986 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
987 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, ppO2data,dataLength,CLUT_LogbookTemperature, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
988 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, sensor2,dataLength,CLUT_LogbookTemperature, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
989 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, sensor3,dataLength,CLUT_LogbookTemperature, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
990 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
991 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
992 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, ppO2data,dataLength,CLUT_LogbookTemperature, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
993 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
994 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
995 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
996 point_t startPoint, stopPoint;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
997 startPoint.x = wintemp.left;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
998 stopPoint.x = wintemp.right;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
999 stopPoint.y = startPoint.y = 479 - wintemp.top;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1000 GFX_draw_colorline(hgfx, startPoint, stopPoint, CLUT_LogbookTemperature);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1001 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1002
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1003 //--- define buttons ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1004 //button_start_single_action(surf1_menu_logbook_current_page, surf1_menu_logbook_show_log_page1, surf1_menu_logbook_show_log_next);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1005 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1006
186
f11f0bf6ef2d cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents: 166
diff changeset
1007 static void print_gas_name(char* output,uint8_t length,uint8_t oxygen,uint8_t helium)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1008 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1009 if(helium == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1010 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1011 if(oxygen == 21)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1012 snprintf(output, length, "Air");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1013 else if(oxygen == 100)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1014 snprintf(output, length, "Oxy");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1015 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1016 snprintf(output, length, "NX%i",oxygen);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1017 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1018 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1019 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1020 if((oxygen + helium) == 100)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1021 snprintf(output, length, "HX%i",oxygen);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1022 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1023 snprintf(output, length, "TMX%i/%i", oxygen, helium);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1024 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1025
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1026 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1027
186
f11f0bf6ef2d cleanup: remove obsolete code, make static, etc.
Jan Mulder <jlmulder@xs4all.nl>
parents: 166
diff changeset
1028 static int16_t get_colour(int16_t color)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1029 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1030 return CLUT_GasSensor1 + color;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1031 }