annotate Discovery/Src/show_logbook.c @ 38:5f11787b4f42

include in ostc4 repository
author heinrichsweikamp
date Sat, 28 Apr 2018 11:52:34 +0200
parents
children 4276d56eb37c cc8e24374b83
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 GFX_DrawCfgScreen tLOGscreen;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 GFX_DrawCfgScreen tLOGbackground;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 void print_gas_name(char* output,uint8_t lengh,uint8_t oxygen,uint8_t helium);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 int16_t get_colour(int16_t color);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 /* Overview */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 void show_logbook_logbook_show_log_page1(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 /* Temperature */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 void show_logbook_logbook_show_log_page2(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 /* Gas List */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 void show_logbook_logbook_show_log_page3(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 /* ppO2 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 void show_logbook_logbook_show_log_page4(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 inline uint32_t MinU32LOG(uint32_t a, uint32_t b)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 return ((a<b)?a:b);
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 uint32_t MaxU32LOG(uint32_t a, uint32_t b)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 return((a>b)?a:b);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 void write_label_(GFX_DrawCfgScreen *screenInput, SWindowGimpStyle win, const tFont *Font, uint8_t color, const char *text)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 GFX_DrawCfgWindow hgfx;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 if( win.right > 799)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 win.right = 799;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 if(win.top > 479)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 win.top = 479;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 hgfx.Image = screenInput;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 hgfx.WindowNumberOfTextLines = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 hgfx.WindowLineSpacing = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 hgfx.WindowTab = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 hgfx.WindowX0 = win.left;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 hgfx.WindowX1 = win.right;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 hgfx.WindowY1 = 479 - win.top;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 if(hgfx.WindowY1 < Font->height)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 hgfx.WindowY0 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 hgfx.WindowY0 = hgfx.WindowY1 - Font->height;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 GFX_write_label(Font, &hgfx, text, color);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 * @brief GFX write label. / print coordinate system & depth graph
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 * @author Peter Ryser
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 * @version V0.0.1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 * @date 07-July-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 * @param hgfx:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 * @param window: WindowGimpStyle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 * @param mode: different modes depending witch page uses the function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 * @param dataLength:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 * @param depthdata:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 * @param colordata: 1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 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)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 SLogbookHeader logbookHeader;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 SWindowGimpStyle wintemp = *window;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 SWindowGimpStyle winsmal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 logbook_getHeader(StepBackwards, &logbookHeader);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 int divetime = logbookHeader.diveTimeMinutes;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 int maxDepth = logbookHeader.maxDepth/100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 int16_t saveBottom = wintemp.bottom;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 int16_t saveTop = 0 - wintemp.top;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 //*** Horisontal (depth) ***************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 //--- calc depth lines and labels --
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 int vscale = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 int vstep = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 vstep = maxDepth / 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 vscale = vstep * 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 if(vscale < maxDepth)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 vstep += 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 vscale += 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 if(vscale <
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 for(int i=1; i <= 20; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 vscale = i * 25;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 vstep = i * 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 if( vscale > maxDepth)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 //--- print depth labels ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 winsmal.left = wintemp.left - 48;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 winsmal.top = wintemp.top - 3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 winsmal.right = wintemp.left -1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 winsmal.bottom = winsmal.top + 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 write_label_(hgfx, winsmal,&FontT24,CLUT_GasSensor1,"[m]");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 winsmal.left = wintemp.left - 48;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 char msg[3];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 float deltaline = ((float)(wintemp.bottom - wintemp.top))/5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 for(int i = 1; i<=5; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 winsmal.top = wintemp.top + deltaline * i - 14;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 winsmal.bottom = winsmal.top + 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 winsmal.right = wintemp.left - 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 snprintf(msg,5,"%i",i * vstep);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 write_label_(hgfx, winsmal,&FontT24,CLUT_GasSensor1,msg);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 //vertical (Time) *******************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 //--- calc time lines and labels --
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 int timestep = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 int lines = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 for(int i=1; i <= 60; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 timestep = i * 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 lines = divetime/timestep;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 if(lines < 7)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 //*** print coordinate system grit ***
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 int winwidth = wintemp.right - wintemp.left;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 float vdeltaline = ((float)(winwidth * timestep))/divetime;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 GFX_draw_Grid( &tLOGbackground,wintemp, 0, vdeltaline, 5,0, CLUT_LogbookGrid);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 //--- print time labels ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 winsmal.left = wintemp.left;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 winsmal.top = wintemp.top - 40;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 winsmal.right = winsmal.left + 60;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 winsmal.bottom = winsmal.top + 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 for(int i = 1; i<=lines; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 winsmal.left= wintemp.left + vdeltaline * i - 15;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 winsmal.right = winsmal.left + 30;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 snprintf(msg,5,"%3i",i * timestep);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 write_label_(hgfx, winsmal,&FontT24,CLUT_GasSensor1,msg);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 winsmal.left = wintemp.left;// - 9;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 winsmal.top = wintemp.top - 40;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 winsmal.right = winsmal.left + 60;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 write_label_(hgfx, winsmal,&FontT24,CLUT_GasSensor1,"min");;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 //--- print depth graph ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 //adapt window
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 int winhight = wintemp.bottom - wintemp.top;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 int newhight = (winhight * maxDepth)/vscale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 wintemp.bottom = wintemp.top + newhight;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 //wintemp.fontcolor = LOGBOOK_GRAPH_DEPTH;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 int datamax = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 for(int i=0;i<dataLength;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 if(depthdata[i]>datamax)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 datamax = depthdata[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 if(decostopdata)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 if(dataLength <= 1000)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 uint8_t colortemp[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 for(int i = 0; i<dataLength; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 if(decostopdata[i] > depthdata[i])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 colortemp[i] = CLUT_WarningRed;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 colortemp[i] = CLUT_NiceGreen;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235 GFX_graph_print(hgfx,&wintemp,saveTop,1,0,datamax, decostopdata,dataLength, NULL, colortemp);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 GFX_graph_print(hgfx,&wintemp,saveTop,1,0,datamax, decostopdata,dataLength, CLUT_NiceGreen, NULL);
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 switch(mode)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 case 0:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 GFX_graph_print(hgfx,&wintemp,0,1,0,datamax, depthdata,dataLength,CLUT_GasSensor1, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 case 1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 GFX_graph_print(hgfx,&wintemp,saveBottom,1,0,datamax, depthdata,dataLength,CLUT_GasSensor0,colordata);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 case 2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 if(*colordata)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 GFX_graph_print(hgfx,&wintemp,0,1,0,datamax, depthdata,dataLength,CLUT_GasSensor0,colordata);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 GFX_graph_print(hgfx,&wintemp,0,1,0,datamax, depthdata,dataLength,CLUT_GasSensor1, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 * @brief scaleAdapt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 * @author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 * @version V0.0.1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 * @date 29-Nov-2016
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 * @param ...
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 * @retval *OutputStepOfScale, *OutputMaxValueOnScale, *OutputTop, *OutputBottom
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271 * fit to multiples of 1�C (data format is 1/10�C)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274 void scaleAdapt( int InputTop, int InputBottom,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 int16_t *OutputMinValue, int16_t *OutputMaxValue, int *OutputTop, int *OutputBottom,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 uint16_t *OutputStepOfScale, int16_t *OutputMaxValueOnScale)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 // uint16_t oldScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 uint16_t newScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 // uint16_t diff_newScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 // int16_t oldMaxOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 int16_t newMaxOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 // int16_t diff_newMaxOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 _Bool negativeMaxValue = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 // float oldRange;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 float newRange;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 float sizeOfScreen;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 // float InputTopValue;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 // float InputBottomValue;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 float screenToRangeRatio;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 float diffOutMaxToMaxOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 float diffOutMinToMaxOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 int positonOutputMaxValue;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 int positonOutputMinValue;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 // scale
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 // oldScale = *OutputStepOfScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 newScale = *OutputStepOfScale + 9;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 newScale /= 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 newScale *= 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 // diff_newScale = newScale - *OutputStepOfScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 // oldRange = 5 * oldScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 newRange = 5 * newScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 *OutputStepOfScale = newScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 // MaxValueOnScale
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 // oldMaxOnScale = *OutputMaxValueOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312 if(OutputMaxValueOnScale < 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 negativeMaxValue = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 newMaxOnScale = 0 - *OutputMaxValueOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 negativeMaxValue = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 newMaxOnScale = *OutputMaxValueOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 newMaxOnScale += 9;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 newMaxOnScale /= 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324 newMaxOnScale *= 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 if(negativeMaxValue)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 // diff_newMaxOnScale = newMaxOnScale + *OutputMaxValueOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 *OutputMaxValueOnScale = 0 - newMaxOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 // diff_newMaxOnScale = newMaxOnScale - *OutputMaxValueOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 *OutputMaxValueOnScale = newMaxOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 // new coordinates
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 sizeOfScreen = 1 + InputBottom - InputTop;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339 // InputTopValue = *OutputMaxValueOnScale;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 // InputBottomValue = InputTopValue + (6 * *OutputStepOfScale);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 screenToRangeRatio = sizeOfScreen / newRange;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 diffOutMaxToMaxOnScale = abs(*OutputMaxValueOnScale) - abs(*OutputMaxValue);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 // diffOutMinToMax = abs(*OutputMinValue - *OutputMaxValue);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 diffOutMinToMaxOnScale = abs(*OutputMaxValueOnScale - *OutputMinValue);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 positonOutputMaxValue = (int)(diffOutMaxToMaxOnScale * screenToRangeRatio);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 positonOutputMaxValue += *OutputTop;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 positonOutputMinValue = (int)(diffOutMinToMaxOnScale * screenToRangeRatio);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350 positonOutputMinValue += *OutputTop;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 // positonOutputMinValue = (int)(diffOutMinToMax * screenToRangeRatio);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 // positonOutputMinValue += positonOutputMaxValue;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 *OutputTop = positonOutputMaxValue;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354 *OutputBottom = positonOutputMinValue;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 * @brief scaleHelper
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361 * @author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 * @version V0.0.1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 * @date 13-Oct-2016
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 * @param hgfx:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 * pixel 50 oben
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370 * pixel 439 unten
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 * pixel 390 gesamt h�he
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 * for temperature, input is �C * 10
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376 void scaleHelper( uint16_t InputDataLength, int16_t *InputDataArray, int InputTop, int InputBottom,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 int16_t *OutputMinValue, int16_t *OutputMaxValue, int *OutputTop, int *OutputBottom,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 uint16_t *OutputStepOfScale, int16_t *OutputMaxValueOnScale)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 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
381 int32_t datamax = INT16_MIN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 uint16_t deltaMinMax = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 // uint16_t deltaMinMaxUsed = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 // uint16_t digits = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 // uint16_t scaler = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 uint32_t step = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387 const int sizeOfScreen = InputBottom - InputTop;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388 float pixel2range = 1.0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390 // min, max, deltaMinMax, OutputMinValue, OutputMaxValue
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 for(uint16_t i = 0; i < InputDataLength; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 if(InputDataArray[i] > datamax)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 datamax = InputDataArray[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396 if(InputDataArray[i] < datamin)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 datamin = InputDataArray[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400 deltaMinMax = (uint16_t)(datamax - datamin);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 *OutputMinValue = (int16_t)datamin;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 *OutputMaxValue = (int16_t)datamax;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 // step
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 step = deltaMinMax / 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 while(deltaMinMax > (step * 5))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 step += 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 pixel2range = ((float)sizeOfScreen) / (step * 5);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413 *OutputStepOfScale = (uint16_t)step;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414 *OutputMaxValueOnScale = *OutputMaxValue;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 *OutputTop = InputTop;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416 *OutputBottom = ((int)(pixel2range * deltaMinMax)) + *OutputTop;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421 * @brief show_logbook_logbook_show_log_page1 /
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422 * @author Peter Ryser
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423 * @version V0.0.1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424 * @date 07-July-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
426 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
427 * @param hgfx:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
428 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
430 void show_logbook_logbook_show_log_page1(GFX_DrawCfgScreen *hgfx,uint8_t StepBackwards)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
432 SWindowGimpStyle wintemp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
433 SWindowGimpStyle winsmal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
434 wintemp.left = 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
435 wintemp.right = 799 - wintemp.left;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
436 wintemp.top = 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
437 wintemp.bottom = 479 - 40;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439 SLogbookHeader logbookHeader;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
440 logbook_getHeader(StepBackwards ,&logbookHeader);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442 uint16_t depthdata[1000] = { 0 };
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
443 uint8_t gasdata[1000] = { 0 };
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444 int16_t tempdata[1000] = { 0 };
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446 uint16_t dataLength = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447 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
448
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 //Print Date
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450 uint8_t year = logbookHeader.dateYear;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451 uint8_t month = logbookHeader.dateMonth;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452 uint8_t day = logbookHeader.dateDay;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453 char text[40];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454 snprintf(text, 20, "20%02i-%02i-%02i", year, month, day);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
455 Gfx_write_label_var(hgfx, 30, 150,10, &FontT42,CLUT_GasSensor1,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457 // Print logbook number with offset
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458 if(settingsGetPointer()->logbookOffset)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460 int32_t logNumber;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461 logNumber = settingsGetPointer()->logbookOffset - StepBackwards;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462 if(logNumber < 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463 logNumber = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
464 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
465 if(logNumber > 9999)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
466 logNumber = 9999;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
468 snprintf(text,20,"#%i",logNumber);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
469 Gfx_write_label_var(hgfx, 300, 590,10, &FontT42,CLUT_GasSensor1,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
471
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472 //Print time
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
473 uint8_t hour = logbookHeader.timeHour;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474 uint8_t minute = logbookHeader.timeMinute;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 snprintf(text,20,"%02i:%02i",hour,minute);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476 Gfx_write_label_var(hgfx, 600, 749,10, &FontT42,CLUT_GasSensor1,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478 //Print Dive Mode (OC/CCR/...)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479 switch(logbookHeader.diveMode)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481 case DIVEMODE_OC:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
482 snprintf(text,20,"open circuit");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
483 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
484 case DIVEMODE_CCR:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485 snprintf(text,20,"closed circuit");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
486 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
487 case DIVEMODE_Gauge:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
488 snprintf(text,20,"Gauge");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490 case DIVEMODE_Apnea:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491 snprintf(text,20,"Apnea");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494 Gfx_write_label_var(hgfx, 30, 250,60, &FontT42,CLUT_GasSensor4,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496 // Decomodel
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497 if(logbookHeader.diveMode <= DIVEMODE_CCR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
498 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499 switch(logbookHeader.decoModel)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
500 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501 case GF_MODE:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502 snprintf(text,20,"\002GF%u/%u",logbookHeader.gfLow_or_Vpm_conservatism,logbookHeader.gfHigh);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
504 case VPM_MODE:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505 snprintf(text,20,"\002VPM +%u",logbookHeader.gfLow_or_Vpm_conservatism);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508 Gfx_write_label_var(hgfx, 600, 729,60, &FontT42,CLUT_GasSensor1,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
510
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
511 //Write Dive Time
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
512 int minutes = logbookHeader.diveTimeMinutes;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513 int seconds = logbookHeader.diveTimeSeconds;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514 int hours = minutes/60;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515 minutes -= hours * 60;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
516 snprintf(text,20,"%02i:%02i:%02i",hours,minutes,seconds);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
517 Gfx_write_label_var(hgfx, 30, 250,360, &FontT42,CLUT_GasSensor1,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
518 Gfx_write_label_var(hgfx, 200, 250,360, &FontT42,CLUT_GasSensor4,"s");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
519
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
520 // Max Depth
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
521 int maxdepth =logbookHeader.maxDepth/100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
522 int maxdepth_dcm = logbookHeader.maxDepth/10 - maxdepth * 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
523 int top = 150;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
524 if(settingsGetPointer()->nonMetricalSystem)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
525 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
526 float maxDepthFeet = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
527 maxDepthFeet = unit_depth_float(((float)logbookHeader.maxDepth)/100);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
528 snprintf(text,20,"%.0f",maxDepthFeet);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
529 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
530 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
531 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
532 snprintf(text,20,"%i.%i",maxdepth,maxdepth_dcm);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
533 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
534 Gfx_write_label_var(hgfx, 30, 250,top, &FontT42,CLUT_GasSensor1,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
535 winsmal.left = 30;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
536 winsmal.top = top -3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
537 winsmal.bottom = winsmal.top + FontT42.height;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
538 winsmal.right = winsmal.left + 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
539 if(maxdepth < 10)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
540 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
541 winsmal.left = 137;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
542 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
543 else if(maxdepth < 100)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
544 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
545 winsmal.left = 151;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
546 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
547 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
548 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
549 winsmal.left = 147;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
550 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
551 write_label_(hgfx, winsmal,&FontT24,CLUT_GasSensor4,"max");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
552 snprintf(text,3,"%c%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
553 , unit_depth_char1()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
554 , unit_depth_char2()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
555 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
556 Gfx_write_label_var(hgfx, winsmal.left - 37, 250,top, &FontT42,CLUT_GasSensor4,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
557
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
558 // Average Depth
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
559 int avrdepth =logbookHeader.averageDepth_mbar/100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
560 int avrdepth_dcm = logbookHeader.averageDepth_mbar/10 - avrdepth * 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
561 top = 200;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
562 if(settingsGetPointer()->nonMetricalSystem)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
563 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
564 float avgDepthFeet = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
565 avgDepthFeet = unit_depth_float(((float)logbookHeader.averageDepth_mbar)/100);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
566 snprintf(text,20,"%.0f",avgDepthFeet);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
567 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
568 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
569 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
570 snprintf(text,20,"%i.%i",avrdepth,avrdepth_dcm);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
571 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
572 Gfx_write_label_var(hgfx, 30, 250,top, &FontT42,CLUT_GasSensor1,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
573 winsmal.left = 30;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
574 winsmal.top = top -3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
575 winsmal.bottom = winsmal.top + FontT42.height;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
576 winsmal.right = winsmal.left + 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
577 if(avrdepth < 10)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
578 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
579 winsmal.left = 137 ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
580 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
581 else if(avrdepth < 100)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
582 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
583 winsmal.left = 151;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
584 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
585 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
586 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
587 winsmal.left = 147;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
588 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
589 write_label_(hgfx, winsmal,&FontT24,CLUT_GasSensor4,"avg");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
590 snprintf(text,3,"%c%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
591 , unit_depth_char1()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
592 , unit_depth_char2()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
593 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
594 Gfx_write_label_var(hgfx, winsmal.left - 37, 250,top, &FontT42,CLUT_GasSensor4,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
595 // Temperature
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
596 top+= 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
597 float temp_Temperature;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
598 uint16_t start;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
599 temp_Temperature = ((float)logbookHeader.minTemp)/10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
600 snprintf(text,20,"%.1f",unit_temperature_float(temp_Temperature));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
601 Gfx_write_label_var(hgfx, 30, 250,top, &FontT42,CLUT_GasSensor1,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
602
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
603 if(settingsGetPointer()->nonMetricalSystem)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
604 start = 121;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
605 else if((logbookHeader.minTemp >= 0) && (logbookHeader.minTemp < 10))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
606 start = 100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
607 else if((logbookHeader.minTemp >= -10) && (logbookHeader.minTemp < 100))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
608 start = 114;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
609 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
610 start = 121;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
611
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
612 text[0] = '\140';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
613 if(settingsGetPointer()->nonMetricalSystem)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
614 text[1] = 'F';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
615 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
616 text[1] = 'C';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
617 text[2] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
618
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
619 Gfx_write_label_var(hgfx, start, 300,top, &FontT42,CLUT_GasSensor4,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
620
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
621 // CNS
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
622 snprintf(text,20,"CNS: %i %%",logbookHeader.maxCNS);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
623 Gfx_write_label_var(hgfx, 30, 250,750, &FontT42,CLUT_GasSensor1,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
624
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
625 // Surface Pressure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
626 // snprintf(text,20,"\001%i\016\016 mbar",logbookHeader.surfacePressure_mbar);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
627 // Gfx_write_label_var(hgfx,300,500,750, &FontT42,CLUT_GasSensor1,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
628 // snprintf(text,40,"%i\016\016 mbar\017 (%i\016\016 m\017)",logbookHeader.surfacePressure_mbar, unit_SeaLevelRelation_integer(logbookHeader.surfacePressure_mbar));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
629 snprintf(text,40,"%i\016\016 mbar\017",logbookHeader.surfacePressure_mbar);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
630 Gfx_write_label_var(hgfx,320,600,750, &FontT42,CLUT_GasSensor1,text);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
631
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
632
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
633 //--- print coordinate system & depth graph with gaschanges ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
634 wintemp.left = 330;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
635 wintemp.top = 160;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
636 wintemp.bottom -= 40;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
637 show_logbook_draw_depth_graph(hgfx, StepBackwards, &wintemp, 1, dataLength, depthdata, gasdata, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
638 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
639
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
640
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
641 void show_logbook_logbook_show_log_page2(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
642 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
643 //*** Page2: Depth and Temperature ****
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
644
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
645 SWindowGimpStyle wintemp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
646 SWindowGimpStyle winsmal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
647 wintemp.left = 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
648 wintemp.right = 799 - wintemp.left;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
649 wintemp.top = 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
650 wintemp.bottom = 479 - 40;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
651
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
652 SLogbookHeader logbookHeader;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
653
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
654 logbook_getHeader(StepBackwards,&logbookHeader);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
655 uint16_t dataLength = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
656 uint16_t depthdata[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
657 uint8_t gasdata[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
658 int16_t tempdata[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
659 uint16_t decoDepthdata[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
660 uint16_t *pDecoDepthData = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
661
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
662 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
663
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
664 for(int i = 0; i<dataLength; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
665 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
666 if(decoDepthdata[i] >= 300)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
667 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
668 pDecoDepthData = decoDepthdata;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
669 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
670 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
671 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
672 //--- print coordinate system & depth graph ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
673 show_logbook_draw_depth_graph(hgfx, StepBackwards, &wintemp, 0, dataLength, depthdata, gasdata, pDecoDepthData);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
674
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
675 //*** Temperature *************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
676
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
677 //--- print temperature labels ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
678 // input maxtmpline, tmpstep, deltaline
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
679
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
680 winsmal.left = wintemp.right +6;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
681 winsmal.top = wintemp.top - 3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
682 winsmal.right = wintemp.right + 30;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
683 winsmal.bottom = winsmal.top + 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
684
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
685 write_label_(hgfx, winsmal,&FontT24,CLUT_LogbookTemperature,"[C]");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
686
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
687
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
688 int16_t minVal = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
689 int16_t maxVal = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
690 int newTop = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
691 int newBottom = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
692 uint16_t step = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
693 int16_t maxValTop = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
694
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
695 scaleHelper(dataLength, tempdata, wintemp.top, wintemp.bottom,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
696 &minVal, &maxVal, &newTop, &newBottom,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
697 &step, &maxValTop); // newTop is wintemp.top
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
698
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
699 scaleAdapt( wintemp.top, wintemp.bottom,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
700 &minVal, &maxVal, &newTop, &newBottom,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
701 &step, &maxValTop);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
702
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
703 // temperature in 1/10 �C
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
704 int deltaline = (1 + wintemp.bottom - wintemp.top)/5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
705 char msg[3];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
706 int tmp = maxValTop;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
707 for(int i = 1; i<=5; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
708 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
709 tmp -= step;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
710 //if(tmp < 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
711 //break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
712 winsmal.top = wintemp.top + deltaline * i - 14;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
713 winsmal.bottom = winsmal.top + 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
714 if((tmp >= 0) && (tmp < 100))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
715 snprintf(msg,2,"%1i",tmp);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
716 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
717 snprintf(msg,3,"%2i",tmp);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
718 write_label_(hgfx, winsmal,&FontT24,CLUT_LogbookTemperature,msg);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
719 }
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 //--- print temperature graph ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
723 // input tempdata[i], maxtmpline, mintmpline, maxTmp, minTmp, deltaline, wintemp.top, dataLength, datamax,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
724
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
725 //adapt window
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
726 wintemp.bottom = newBottom;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
727 wintemp.top = newTop;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
728 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
729 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
730
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
731
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
732 void show_logbook_logbook_show_log_page2_original(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
733 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
734 //*** Page2: Depth and Temperature ****
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
735
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
736 SWindowGimpStyle wintemp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
737 SWindowGimpStyle winsmal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
738 wintemp.left = 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
739 wintemp.right = 799 - wintemp.left;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
740 wintemp.top = 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
741 wintemp.bottom = 479 - 40;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
742
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
743 SLogbookHeader logbookHeader;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
744
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
745 logbook_getHeader(StepBackwards,&logbookHeader);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
746 uint16_t dataLength = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
747 uint16_t depthdata[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
748 uint8_t gasdata[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
749 int16_t tempdata[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
750 uint16_t decoDepthdata[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
751 uint16_t *pDecoDepthData = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
752
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
753 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
754
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
755 /* test
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
756 for(int i = 0; i<dataLength/2; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
757 decoDepthdata[i] = 300;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
758
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
759 for(int i = dataLength/2; i<dataLength; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
760 decoDepthdata[i] = 1200;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
761 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
762 for(int i = 0; i<dataLength; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
763 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
764 if(decoDepthdata[i] >= 300)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
765 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
766 pDecoDepthData = decoDepthdata;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
767 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
768 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
769 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
770 //--- print coordinate system & depth graph ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
771 show_logbook_draw_depth_graph(hgfx, StepBackwards, &wintemp, 0, dataLength, depthdata, gasdata, pDecoDepthData);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
772
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
773 //*** Temperature *************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
774
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
775
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
776 int16_t datamax = -1000; // �C * 10
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
777 int16_t datamin = +1000;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
778 for(int i = 0; i < dataLength;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
779 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
780 if(tempdata[i]>datamax)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
781 datamax = tempdata[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
782 if(tempdata[i]< datamin)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
783 datamin = tempdata[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
784 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
785 float maxTmp = ((float)datamax) /10.f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
786 float minTmp = ((float)datamin) /10.f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
787 int deltaTmp = maxTmp - minTmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
788 int tmpstep = 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
789
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
790 // 5 different scales: 1�C, 2�C, 4�C, 5�C, 10�C
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
791 // with 6 lines == 5 steps
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
792 if((deltaTmp) <=5)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
793 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
794 tmpstep = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
795 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
796 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
797 if(deltaTmp <= (5*2))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
798 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
799 tmpstep = 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
800 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
801 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
802 if(deltaTmp <= (5 * 4))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
803 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
804 tmpstep = 4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
805 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
806 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
807 if(deltaTmp <= (5 * 5))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
808 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
809 tmpstep = 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
810 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
811 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
812 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
813 tmpstep = 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
814 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
815 // int steps = deltaTmp/tmpstep;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
816
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
817
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
818 // int steps = deltaTmp/5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
819 // int tmpstep = 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
820 // if(steps > 4)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
821 // tmpstep = 10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
822
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
823 int maxtmpline = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
824 int mintmpline = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
825 if(minTmp < 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
826 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
827 if(minTmp >= -5)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
828 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
829 mintmpline = -5;
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 else if(minTmp >= -10)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
833 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
834 mintmpline = -10;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
835 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
836 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
837 mintmpline = -15;
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 if(maxTmp > 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
841 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
842 while(maxtmpline < maxTmp)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
843 maxtmpline += tmpstep;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
844 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
845
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
846 if(tmpstep < 5)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
847 maxtmpline = MaxU32LOG(maxtmpline, 10);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
848 else if(tmpstep == 5)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
849 maxtmpline = MaxU32LOG(maxtmpline, 25);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
850 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
851 maxtmpline = 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
852
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
853 maxtmpline += mintmpline;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
854
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
855 //--- print temperature labels ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
856 // input maxtmpline, tmpstep, deltaline
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
857
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
858 winsmal.left = wintemp.right +6;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
859 winsmal.top = wintemp.top - 3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
860 winsmal.right = wintemp.right + 30;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
861 winsmal.bottom = winsmal.top + 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
862
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
863 write_label_(hgfx, winsmal,&FontT24,CLUT_LogbookTemperature,"[C]");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
864
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
865 int deltaline = (wintemp.bottom - wintemp.top)/5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
866 char msg[3];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
867 int tmp = maxtmpline;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
868 for(int i = 1; i<=5; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
869 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
870 tmp -= tmpstep;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
871 //if(tmp < 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
872 //break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
873 winsmal.top = wintemp.top + deltaline * i - 14;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
874 winsmal.bottom = winsmal.top + 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
875 snprintf(msg,3,"%2i",tmp);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
876 write_label_(hgfx, winsmal,&FontT24,CLUT_LogbookTemperature,msg);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
877 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
878
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
879
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
880 //--- print temperature graph ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
881 // input tempdata[i], maxtmpline, mintmpline, maxTmp, minTmp, deltaline, wintemp.top, dataLength, datamax,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
882
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
883 //adapt window
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
884 float ftmp =((maxtmpline - minTmp) * deltaline) /tmpstep + wintemp.top;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
885 wintemp.bottom = ftmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
886 if((ftmp - (int)ftmp) >= 0.5f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
887 wintemp.bottom++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
888
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
889 ftmp = ((maxtmpline - maxTmp) * deltaline) /tmpstep + wintemp.top;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
890 wintemp.top = ftmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
891 if((ftmp - (int)ftmp) >= 0.5f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
892 wintemp.top++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
893
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
894 if(wintemp.top <= wintemp.bottom)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
895 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
896 for(int i = 0; i < dataLength;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
897 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
898 tempdata[i] -= mintmpline;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
899 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
900 datamax -= mintmpline;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
901 // hw 160518
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
902 // es wird nur das Fenster (wintemp.top, wintemp.bottom) verwendet in dem Daten sind
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
903 // daher muss datamin angegeben werden
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
904 // der Gesamtbereich ist uninteressant
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
905 // Bsp Temperatur von 8�C bis 5�C
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
906 // Y-Achse ist 10�C (oben) bis 0�C (unten)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
907 // aber wintemp.top ist 127
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
908 // und wintemp.bottom ist 243
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
909 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, (uint16_t *)tempdata,dataLength,CLUT_LogbookTemperature, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
910 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
911 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
912
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
913
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
914 void build_logbook_test(uint8_t page, uint8_t StepBackwards)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
915 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
916 uint32_t lastScreen,lastBackground;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
917
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
918 lastScreen = tLOGscreen.FBStartAdress;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
919 lastBackground = tLOGbackground.FBStartAdress;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
920
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
921 tLOGscreen.FBStartAdress = getFrame(16);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
922 tLOGscreen.ImageHeight = 480;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
923 tLOGscreen.ImageWidth = 800;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
924 tLOGscreen.LayerIndex = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
925
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
926 tLOGbackground.FBStartAdress = getFrame(17);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
927 tLOGbackground.ImageHeight = 480;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
928 tLOGbackground.ImageWidth = 800;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
929 tLOGbackground.LayerIndex = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
930 switch(page)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
931 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
932 case 1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
933 show_logbook_logbook_show_log_page1(&tLOGscreen,StepBackwards);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
934 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
935 case 2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
936 show_logbook_logbook_show_log_page2(&tLOGscreen,StepBackwards);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
937 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
938 case 3:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
939 show_logbook_logbook_show_log_page3(&tLOGscreen,StepBackwards);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
940 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
941 case 4:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
942 show_logbook_logbook_show_log_page4(&tLOGscreen,StepBackwards);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
943 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
944 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
945
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
946 releaseFrame(16,lastScreen);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
947 releaseFrame(17,lastBackground);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
948 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
949
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
950
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
951 void show_logbook_test(_Bool firstPage, uint8_t StepBackwards)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
952 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
953 static uint8_t page = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
954 if(firstPage)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
955 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
956 page = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
957 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
958 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
959 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
960 page++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
961 if(page > 4)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
962 page = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
963 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
964
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
965 build_logbook_test(page,StepBackwards);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
966 // GFX_ResetLayer(TOP_LAYER);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
967 // GFX_ResetLayer(BACKGRD_LAYER);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
968
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
969 set_globalState(StILOGSHOW);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
970 GFX_SetFramesTopBottom(tLOGscreen.FBStartAdress, tLOGbackground.FBStartAdress,480);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
971 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
972
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
973
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
974 void show_logbook_exit(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
975 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
976 releaseFrame(16,tLOGscreen.FBStartAdress);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
977 releaseFrame(17,tLOGbackground.FBStartAdress);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
978 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
979
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
980
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
981 void show_logbook_logbook_show_log_page3(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
982 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
983 SWindowGimpStyle wintemp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
984 SWindowGimpStyle winsmal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
985 wintemp.left = 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
986 wintemp.right = 799 - wintemp.left;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
987 wintemp.top = 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
988 wintemp.bottom = 479 - 40;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
989
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
990 SLogbookHeader logbookHeader;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
991
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
992 logbook_getHeader(StepBackwards, &logbookHeader);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
993 uint16_t dataLength = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
994 uint16_t depthdata[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
995 uint8_t gasdata[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
996 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
997
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
998 //--- print coordinate system & depth graph with gaschanges ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
999 show_logbook_draw_depth_graph(hgfx, StepBackwards, &wintemp, 1, dataLength, depthdata, gasdata, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1000
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1001 //--- print gas list ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1002 winsmal.left = wintemp.right - 190;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1003 winsmal.right = winsmal.left + 150;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1004
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1005 char msg[15];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1006 char gas_name[15];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1007 int j = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1008 for(int i = 4;i >= 0;i--)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1009 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1010 if(logbookHeader.gasordil[i].note.ub.active > 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1011 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1012 j++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1013 winsmal.top = wintemp.bottom - 5 - j * 26 ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1014 winsmal.bottom = winsmal.top + 21 ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1015 uint8_t color = get_colour(i);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1016
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1017 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
1018 snprintf(msg,15,"G%i: %s",i + 1, gas_name);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1019 //msg[10] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1020 write_label_(hgfx, winsmal,&FontT24,color,msg);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1021 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1022 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1023
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1024 //--- define buttons ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1025 /*if(*ghost_char_logfile_oxydata)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1026 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
1027 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1028 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
1029 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1030 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1031
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1032 void show_logbook_logbook_show_log_page4(GFX_DrawCfgScreen *hgfx, uint8_t StepBackwards)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1033 { SWindowGimpStyle wintemp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1034 SWindowGimpStyle winsmal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1035 wintemp.left = 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1036 wintemp.right = 799 - wintemp.left;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1037 wintemp.top = 50;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1038 wintemp.bottom = 479 - 40;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1039 uint8_t color = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1040 SLogbookHeader logbookHeader;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1041
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1042 logbook_getHeader(StepBackwards, &logbookHeader);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1043 uint16_t dataLength = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1044 uint16_t depthdata[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1045 uint8_t gasdata[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1046 uint16_t ppO2data[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1047 uint16_t sensor2[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1048 uint16_t sensor3[1000];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1049 uint16_t *setpoint = ppO2data;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1050 uint16_t *sensor1 = ppO2data;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1051
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1052
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1053 if(logbookHeader.diveMode != DIVEMODE_CCR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1054 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
1055 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1056 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1057 if(logbookHeader.CCRmode == CCRMODE_FixedSetpoint)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1058 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
1059 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1060 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
1061 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1062
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1063
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1064 //--- print coordinate system & depth graph with bailout---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1065 show_logbook_draw_depth_graph(hgfx, StepBackwards, &wintemp, 0, dataLength, depthdata, gasdata, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1066
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1067
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1068
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1069 //*** Desciption at bottom of page ***************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1070 winsmal.top = wintemp.bottom +2 ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1071 winsmal.bottom = winsmal.top + 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1072
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1073
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1074 /*if(strcmp( (char*)ghost_char_logfile_text_oc_ccr,"ccr/bailout") == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1075 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1076 winsmal.left = wintemp.left + 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1077 winsmal.right = winsmal.left + 55;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1078
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1079 oled_write(OVERLAY, &winsmal,"CCR -",false,true);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1080
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1081 winsmal.left = winsmal.right;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1082 winsmal.right = winsmal.left + 90;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1083 //winsmal.fontcolor = oled_get_colour(15);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1084 oled_write(OVERLAY, &winsmal,"bailout",false,true);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1085 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1086 else*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1087 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1088 winsmal.left = wintemp.left + 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1089 winsmal.right = winsmal.left + 55;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1090 color = CLUT_GasSensor1;//LOGBOOK_GRAPH_DEPTH;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1091
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1092 write_label_(hgfx, winsmal,&FontT24,color,"depth");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1093
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1094 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1095 winsmal.left = 799 - 67;//wintemp.right -67;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1096 winsmal.right = winsmal.left;// + 45;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1097
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1098 color = CLUT_LogbookTemperature;//LOGBOOK_GRAPH_DEPTH;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1099 if(logbookHeader.diveMode != DIVEMODE_CCR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1100 write_label_(hgfx, winsmal,&FontT24,color,"\002PP O2");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1101 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1102 if(logbookHeader.CCRmode != CCRMODE_Sensors)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1103 write_label_(hgfx, winsmal,&FontT24,color,"\002SETPOINT");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1104 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1105 write_label_(hgfx, winsmal,&FontT24,color,"\002SENSORS");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1106
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1107 //*** PP O2 ****************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1108 //calc lines and labels
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1109 int datamax = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1110 int datamin = 10000;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1111 for(int i=1;i<dataLength;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1112 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1113 if(ppO2data[i]>datamax)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1114 datamax = ppO2data[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1115 if(ppO2data[i]<datamin)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1116 datamin = ppO2data[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1117 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1118 if((logbookHeader.diveMode == DIVEMODE_CCR) && (logbookHeader.CCRmode == CCRMODE_Sensors))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1119 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1120 for(int i=1;i<dataLength;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1121 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1122 if(sensor2[i]>datamax)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1123 datamax = sensor2[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1124 if(sensor2[i]<datamin)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1125 datamin = sensor2[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1126 if(sensor3[i]>datamax)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1127 datamax = sensor3[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1128 if(sensor3[i]<datamin)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1129 datamin = sensor3[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1130 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1131 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1132 float maxoxy = ((float)datamax)/100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1133 float minoxy = ((float)datamin)/100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1134 float oxystep = 0.5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1135 float maxoxyline = 2.5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1136
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1137 //--- print PP O2 labels ----
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1138 winsmal.left = wintemp.right + 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1139 winsmal.top = wintemp.top ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1140 winsmal.right = wintemp.right + 30;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1141 winsmal.bottom = winsmal.top + 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1142 //winsmal.font = ft_tiny + ft_SLIM;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1143 color = CLUT_LogbookTemperature;// = LOGBOOK_GRAPH_TEMP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1144
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1145 write_label_(hgfx, winsmal,&FontT24,color,"bar");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1146
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1147 int deltaline = (wintemp.bottom - wintemp.top)/5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1148 char msg[4];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1149 float oxy = maxoxyline;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1150 for(int i = 1; i<=5; i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1151 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1152 oxy -= oxystep;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1153 if(oxy < 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1154 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1155 winsmal.top = wintemp.top + deltaline * i - 8;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1156 winsmal.bottom = winsmal.top + 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1157 snprintf(msg,4,"%1.1f",oxy);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1158 write_label_(hgfx, winsmal,&FontT24,color,msg);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1159 //oled_write(OVERLAY, &winsmal,msg,false,true);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1160 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1161
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1162 //--- print PP O2 graph ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1163 //Adapt window
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1164 float ftmp = ((maxoxyline - minoxy) * deltaline) /oxystep + wintemp.top;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1165 wintemp.bottom = ftmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1166 if((ftmp - (int)ftmp) >= 0.5f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1167 wintemp.bottom++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1168
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1169 ftmp = wintemp.top + ((maxoxyline - maxoxy) * deltaline) /oxystep;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1170 wintemp.top = ftmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1171 if((ftmp - (int)ftmp) >= 0.5f)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1172 wintemp.top++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1173 wintemp.top = MaxU32LOG(wintemp.top ,0);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1174 if(wintemp.top < wintemp.bottom)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1175 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1176 if((logbookHeader.diveMode == DIVEMODE_CCR) && (logbookHeader.CCRmode == CCRMODE_Sensors))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1177 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1178 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, ppO2data,dataLength,CLUT_LogbookTemperature, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1179 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, sensor2,dataLength,CLUT_LogbookTemperature, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1180 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, sensor3,dataLength,CLUT_LogbookTemperature, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1181 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1182 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1183 GFX_graph_print(hgfx,&wintemp,0,1,datamax,datamin, ppO2data,dataLength,CLUT_LogbookTemperature, NULL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1184 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1185 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1186 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1187 point_t startPoint, stopPoint;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1188 startPoint.x = wintemp.left;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1189 stopPoint.x = wintemp.right;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1190 stopPoint.y = startPoint.y = 479 - wintemp.top;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1191 GFX_draw_colorline(hgfx, startPoint, stopPoint, CLUT_LogbookTemperature);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1192 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1193
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1194 //--- define buttons ---
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1195 //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
1196 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1197
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1198 void print_gas_name(char* output,uint8_t length,uint8_t oxygen,uint8_t helium)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1199 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1200 if(helium == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1201 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1202 if(oxygen == 21)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1203 snprintf(output, length, "Air");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1204 else if(oxygen == 100)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1205 snprintf(output, length, "Oxy");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1206 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1207 snprintf(output, length, "NX%i",oxygen);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1208 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1209 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1210 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1211 if((oxygen + helium) == 100)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1212 snprintf(output, length, "HX%i",oxygen);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1213 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1214 snprintf(output, length, "TMX%i/%i", oxygen, helium);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1215 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1216
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1217 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1218
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1219 int16_t get_colour(int16_t color)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1220 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1221 return CLUT_GasSensor1 + color;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1222 }