comparison Discovery/Src/t7.c @ 225:2bb1db22b5f5 div-fixes-3

cleanup: random set of cleanups A random set of cleanups, as found during code reading, and looking around fixing issues. Contains all kinds of things: typo's in comment, typo in variable name, removal of unused code, making things static where possible. Does not contain any functional changes. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Mon, 01 Apr 2019 15:50:41 +0200
parents 9b4b3decd9ba
children 3949781096d4
comparison
equal deleted inserted replaced
224:ceecabfddb57 225:2bb1db22b5f5
54 void t7_compass(uint16_t ActualHeading, uint16_t UserSetHeading); 54 void t7_compass(uint16_t ActualHeading, uint16_t UserSetHeading);
55 void t7_SummaryOfLeftCorner(void); 55 void t7_SummaryOfLeftCorner(void);
56 void t7_debug(void); 56 void t7_debug(void);
57 57
58 void t7_miniLiveLogProfile(void); 58 void t7_miniLiveLogProfile(void);
59 //void t7_clock(void);
60 void t7_logo_OSTC(void); 59 void t7_logo_OSTC(void);
61 static void t7_colorscheme_mod(char *text); 60 static void t7_colorscheme_mod(char *text);
62 61
63 uint8_t t7_test_customview_warnings(void); 62 uint8_t t7_test_customview_warnings(void);
64 void t7_show_customview_warnings(void); 63 void t7_show_customview_warnings(void);
547 546
548 547
549 void t7_refresh(void) 548 void t7_refresh(void)
550 { 549 {
551 static uint8_t last_mode = MODE_SURFACE; 550 static uint8_t last_mode = MODE_SURFACE;
552
553 // uint32_t oldScreen;//, oldPlugin;
554 SStateList status; 551 SStateList status;
555 get_globalStateList(&status); 552 get_globalStateList(&status);
556 553
557 t7screen.FBStartAdress = getFrame(22); 554 t7screen.FBStartAdress = getFrame(22);
558 555
1129 else 1126 else
1130 t7_refresh_customview(); 1127 t7_refresh_customview();
1131 draw_frame(0,0, CLUT_pluginboxSurface, CLUT_Font020); 1128 draw_frame(0,0, CLUT_pluginboxSurface, CLUT_Font020);
1132 } 1129 }
1133 1130
1134
1135 void t7_refresh_surface_debugmode_wireless_info(void) 1131 void t7_refresh_surface_debugmode_wireless_info(void)
1136 { 1132 {
1137 char text[400]; 1133 char text[400];
1138 uint8_t colorDataLost = 0; 1134 uint8_t colorDataLost = 0;
1139 int txtPointer = 0; 1135 int txtPointer = 0;
1481 { 1477 {
1482 if(stateUsed->mode == MODE_DIVE) 1478 if(stateUsed->mode == MODE_DIVE)
1483 selection_customview = settingsGetPointer()->tX_customViewPrimary; 1479 selection_customview = settingsGetPointer()->tX_customViewPrimary;
1484 } 1480 }
1485 1481
1486
1487 // for CVIEW_END is none_or_debug
1488 void t7_change_customview(void) 1482 void t7_change_customview(void)
1489 { 1483 {
1490 const uint8_t *pViews; 1484 const uint8_t *pViews;
1491 _Bool cv_disabled = 0; 1485 _Bool cv_disabled = 0;
1492 1486
2656 *p = '\027'; 2650 *p = '\027';
2657 p++; 2651 p++;
2658 } 2652 }
2659 } 2653 }
2660 2654
2661
2662 void draw_frame(_Bool PluginBoxHeader, _Bool LinesOnTheSides, uint8_t colorBox, uint8_t colorLinesOnTheSide) 2655 void draw_frame(_Bool PluginBoxHeader, _Bool LinesOnTheSides, uint8_t colorBox, uint8_t colorLinesOnTheSide)
2663 { 2656 {
2664 point_t LeftLow, WidthHeight; 2657 point_t LeftLow, WidthHeight;
2665 point_t start, stop; 2658 point_t start, stop;
2666 2659
3120 text[textpointer++] = 0; 3113 text[textpointer++] = 0;
3121 t7_colorscheme_mod(text); 3114 t7_colorscheme_mod(text);
3122 GFX_write_string(&FontT42, &t7cY0free, text, 1); 3115 GFX_write_string(&FontT42, &t7cY0free, text, 1);
3123 } 3116 }
3124 3117
3125
3126
3127
3128 /*
3129 point_t start, change, stop;
3130 float value;
3131 uint16_t front;
3132 uint8_t color;
3133
3134
3135 start.y = t7cH.WindowY0 - 5;
3136 start.x = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET;
3137 stop.x = start.x + CUSTOMBOX_SPACE_INSIDE;
3138
3139
3140 for(int i=0;i<16;i++)
3141 {
3142 stop.y = start.y;
3143 change.y = start.y;
3144
3145 value = pState->lifeData.tissue_nitrogen_bar[i] - 0.7512f;
3146 value *= 20;
3147
3148 if(value < 0)
3149 front = 0;
3150 else
3151 if(value > CUSTOMBOX_SPACE_INSIDE)
3152 front = CUSTOMBOX_SPACE_INSIDE;
3153 else
3154 front = (uint16_t)value;
3155
3156 change.x = start.x + front;
3157 if(change.x != start.x)
3158 GFX_draw_thick_line(1,&t7screen, start, change, CLUT_Font020);
3159 if(change.x != stop.x)
3160 GFX_draw_thick_line(1,&t7screen, change, stop, CLUT_Font021);
3161
3162 start.y -= 3;
3163 }
3164
3165 // He
3166 start.y -= 28 + 14;
3167 for(int i=0;i<16;i++)
3168 {
3169 stop.y = start.y;
3170 change.y = start.y;
3171
3172 value = pState->lifeData.tissue_helium_bar[i];
3173 value *= 20;
3174
3175 if(value < 0)
3176 front = 0;
3177 else
3178 if(value > CUSTOMBOX_SPACE_INSIDE)
3179 front = CUSTOMBOX_SPACE_INSIDE;
3180 else
3181 front = (uint16_t)value;
3182
3183 change.x = start.x + front;
3184 if(change.x != start.x)
3185 GFX_draw_thick_line(1,&t7screen, start, change, CLUT_Font020);
3186 if(change.x != stop.x)
3187 GFX_draw_thick_line(1,&t7screen, change, stop, CLUT_Font021);
3188
3189 start.y -= 3;
3190 }
3191
3192 // CNS == Oxygen
3193 start.y -= 28 + 14;
3194
3195 value = pState->lifeData.cns;
3196 value *= (CUSTOMBOX_SPACE_INSIDE/2);
3197 value /= 100;
3198
3199 if(value < 0)
3200 front = 0;
3201 else
3202 if(value > CUSTOMBOX_SPACE_INSIDE)
3203 front = CUSTOMBOX_SPACE_INSIDE;
3204 else
3205 front = (uint16_t)value;
3206
3207 if(pState->lifeData.cns < 95)
3208 color = CLUT_Font020;
3209 else
3210 if(pState->lifeData.cns < 100)
3211 color = CLUT_WarningYellow;
3212 else
3213 color = CLUT_WarningRed;
3214
3215 for(int i=0;i<16;i++)
3216 {
3217 stop.y = start.y;
3218 change.y = start.y;
3219
3220 change.x = start.x + front;
3221 if(change.x != start.x)
3222 GFX_draw_thick_line(1,&t7screen, start, change, color);
3223 if(change.x != stop.x)
3224 GFX_draw_thick_line(1,&t7screen, change, stop, CLUT_Font021);
3225
3226 start.y -= 3;
3227 }
3228
3229 // where is the onload/offload limit for N2 and He
3230 decom_get_inert_gases(pState->lifeData.pressure_ambient_bar, &pState->lifeData.actualGas, &percent_N2, &percent_He);
3231 partial_pressure_N2 = (pState->lifeData.pressure_ambient_bar - WATER_VAPOUR_PRESSURE) * percent_N2;
3232 partial_pressure_He = (pState->lifeData.pressure_ambient_bar - WATER_VAPOUR_PRESSURE) * percent_He;
3233
3234 if((percent_N2 > 0) && (partial_pressure_N2 > (0.8f + 0.5f)))
3235 {
3236 start.y = t7cH.WindowY0 + 1 - 5;
3237 stop.y = start.y - (3 * 15) - 1;
3238
3239 value = partial_pressure_N2;
3240 value *= 20;
3241
3242 if(value < 0)
3243 front = 3;
3244 else
3245 if(value + 5 > CUSTOMBOX_SPACE_INSIDE)
3246 front = CUSTOMBOX_SPACE_INSIDE - 3;
3247 else
3248 front = (uint16_t)value;
3249
3250 start.x = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET + front;
3251 stop.x = start.x;
3252 GFX_draw_thick_line(2,&t7screen, start, stop, CLUT_EverythingOkayGreen);
3253 }
3254
3255 if((percent_He > 0) && (partial_pressure_He > 0.5f))
3256 {
3257 start.y = t7cH.WindowY0 + 1 - 5 - 3*16 - 28 - 14;
3258 stop.y = start.y - (3 * 15) - 1;
3259
3260 value = partial_pressure_He;
3261 value *= 20;
3262
3263 if(value < 0)
3264 front = 3;
3265 else
3266 if(value + 5 > CUSTOMBOX_SPACE_INSIDE)
3267 front = CUSTOMBOX_SPACE_INSIDE - 3;
3268 else
3269 front = (uint16_t)value;
3270
3271 start.x = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET + front;
3272 stop.x = start.x;
3273 GFX_draw_thick_line(2,&t7screen, start, stop, CLUT_EverythingOkayGreen);
3274 }
3275
3276 start.y = t7cH.WindowY0 + 1 - 5 - 6*16 - 2*28 - 2*14;
3277 stop.y = start.y - (3 * 15) - 1;
3278
3279 start.x = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET + CUSTOMBOX_SPACE_INSIDE/2;
3280 stop.x = start.x;
3281 GFX_draw_thick_line(2, &t7screen, start, stop, CLUT_WarningRed);
3282 */
3283
3284 /*
3285 void t7_clock(void)
3286 {
3287 point_t start, stop;
3288
3289
3290 for(uint16_t i=0;i<360;i+=30)
3291 {
3292 start = t7_compass_circle(1,i);
3293 stop = t7_compass_circle(2,i);
3294 start.x += 280; // standard center is 400, 250
3295 stop.x += 280;
3296 GFX_draw_thick_line(5,&t7screen, start, stop, CLUT_CompassSubTick);
3297
3298 start.x = 400+280;
3299 start.y = 250;
3300 stop = t7_compass_circle(2,58);
3301 stop.x += 280;
3302 GFX_draw_thick_line(3,&t7screen, start, stop, CLUT_CompassNorthTick);
3303 stop = t7_compass_circle(0,302);
3304 stop.x += 280;
3305 GFX_draw_thick_line(3,&t7screen, start, stop, CLUT_CompassNorthTick);
3306 }
3307 }
3308 */
3309
3310 //static float testCC = 180;
3311 void t7_compass(uint16_t ActualHeading, uint16_t UserSetHeading) 3118 void t7_compass(uint16_t ActualHeading, uint16_t UserSetHeading)
3312 { 3119 {
3313
3314 /*
3315 static uint16_t lastHeading = 0;
3316 float differenceCompass, resultKalman;
3317
3318 if(testCC > lastHeading)
3319 differenceCompass = testCC - lastHeading;
3320 else
3321 differenceCompass = lastHeading - testCC;
3322
3323 resultKalman = Kalman_getAngle(differenceCompass, 2, 0.1);
3324 if(testCC > lastHeading)
3325 ActualHeading = lastHeading + resultKalman;
3326 else
3327 ActualHeading = lastHeading - resultKalman;
3328
3329 lastHeading = ActualHeading;
3330 */
3331 uint16_t ActualHeadingRose; 3120 uint16_t ActualHeadingRose;
3332 uint16_t LeftBorderHeading, LineHeading; 3121 uint16_t LeftBorderHeading, LineHeading;
3333 uint32_t offsetPicture; 3122 uint32_t offsetPicture;
3334 point_t start, stop, center; 3123 point_t start, stop, center;
3335 static int32_t LastHeading = 0; 3124 static int32_t LastHeading = 0;
3373 newHeading -= 360; 3162 newHeading -= 360;
3374 3163
3375 LastHeading = newHeading; 3164 LastHeading = newHeading;
3376 ActualHeading = newHeading; 3165 ActualHeading = newHeading;
3377 ActualHeadingRose = ActualHeading; 3166 ActualHeadingRose = ActualHeading;
3378 /* 3167
3379 if (ActualHeading < 90)
3380 ActualHeading += 360;
3381
3382 if(ActualHeading > LastHeading)
3383 {
3384 if((ActualHeading - LastHeading) < 25)
3385 ActualHeading = LastHeading + 1;
3386 }
3387 else
3388 if(ActualHeading < LastHeading)
3389 {
3390 if((LastHeading - ActualHeading) < 25)
3391 ActualHeading = LastHeading - 1;
3392 }
3393 */
3394 if(pSettings->FlipDisplay) 3168 if(pSettings->FlipDisplay)
3395 { 3169 {
3396 ActualHeadingRose = 360 - ActualHeadingRose; 3170 ActualHeadingRose = 360 - ActualHeadingRose;
3397 if (ActualHeadingRose < 170) ActualHeadingRose += 360; 3171 if (ActualHeadingRose < 170) ActualHeadingRose += 360;
3398 } 3172 }