comparison Discovery/Src/t4_tetris.c @ 177:458f16cda15c

Merged in janlmulder/ostc4/max-depth (pull request #3) Bugfix: make max depth move with current depth Approved-by: heinrichsweikamp <bitbucket@heinrichsweikamp.com>
author heinrichsweikamp <bitbucket@heinrichsweikamp.com>
date Tue, 12 Mar 2019 15:04:19 +0000
parents ecb71521d004
children
comparison
equal deleted inserted replaced
172:c659fda83e44 177:458f16cda15c
43 GFX_DrawCfgScreen t4screen; 43 GFX_DrawCfgScreen t4screen;
44 GFX_DrawCfgWindow t4l1; 44 GFX_DrawCfgWindow t4l1;
45 GFX_DrawCfgWindow t4l2; 45 GFX_DrawCfgWindow t4l2;
46 GFX_DrawCfgWindow t4l3; 46 GFX_DrawCfgWindow t4l3;
47 47
48 extern float depthLastCall[9];
49 extern uint8_t idDepthLastCall;
50 extern float temperatureLastCall[3];
51 extern uint8_t idTemperatureLastCall;
52
53
54 /* Private types -------------------------------------------------------------*/ 48 /* Private types -------------------------------------------------------------*/
55 #define TEXTSIZE 16 49 #define TEXTSIZE 16
56 50
57 const uint16_t t4SeperationLeftRight = 250; 51 const uint16_t t4SeperationLeftRight = 250;
58 const uint16_t t4SeperationTopMid = 315; 52 const uint16_t t4SeperationTopMid = 315;
59 const uint16_t t4SeperationMidBottom = 139; 53 const uint16_t t4SeperationMidBottom = 139;
60 54
61 /* Private function prototypes -----------------------------------------------*/ 55 /* Private function prototypes -----------------------------------------------*/
62 void t4_refresh_divemode(void); 56 void t4_refresh_divemode(void);
63 void t4_refresh_customview(float depth);
64
65 uint8_t t4_test_customview_warnings(void);
66 void t4_show_customview_warnings(void);
67 void t4_battery_low_customview_extra(void);
68 57
69 /* Exported functions --------------------------------------------------------*/ 58 /* Exported functions --------------------------------------------------------*/
70 59
71 void t4_init(void) 60 void t4_init(void)
72 { 61 {
148 stop.x = start.x = t4SeperationLeftRight; 137 stop.x = start.x = t4SeperationLeftRight;
149 GFX_draw_line(&t4screen, start, stop, CLUT_Font020); 138 GFX_draw_line(&t4screen, start, stop, CLUT_Font020);
150 139
151 140
152 // depth 141 // depth
153 float depth = 0; 142 float depth = unit_depth_float(stateUsed->lifeData.depth_meter);
154 float depthThisCall = unit_depth_float(stateUsed->lifeData.depth_meter);
155 if(is_stateUsedSetToSim())
156 {
157 depth = (depthThisCall + depthLastCall[0] + depthLastCall[1] + depthLastCall[2] + depthLastCall[3] + depthLastCall[4] + depthLastCall[5] + depthLastCall[6] + depthLastCall[7] + depthLastCall[8]) / 10.0f;
158
159 idDepthLastCall++;
160 if(idDepthLastCall >= 9)
161 idDepthLastCall = 0;
162 depthLastCall[idDepthLastCall] = depthThisCall;
163 }
164 else
165 {
166 depth = (depthThisCall + depthLastCall[0] + depthLastCall[1] + depthLastCall[2]) / 4.0f;
167
168 idDepthLastCall++;
169 if(idDepthLastCall >= 3)
170 idDepthLastCall = 0;
171 depthLastCall[idDepthLastCall] = depthThisCall;
172 }
173 143
174 if(depth <= 0.3f) 144 if(depth <= 0.3f)
175 depth = 0; 145 depth = 0;
176 146
177 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Depth); 147 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Depth);