Mercurial > public > ostc4
comparison Discovery/Src/base.c @ 549:469e93f8633e
Only execute motion detection functions if features is enabled:
Added compile switch around function and, in case the switch is on, an additional check if the features is activated by the settings.
Added function to add an additional level of brightness to the backlight:
The new interface allows to increase the brightness of the display on top of the normal setting. This may be used to indicate focus state to the user if motion detection is enabled
author | Ideenmodellierer |
---|---|
date | Sun, 08 Nov 2020 18:36:02 +0100 |
parents | ffd01ead2c80 |
children | e581425c7e3e |
comparison
equal
deleted
inserted
replaced
548:e7e44986684a | 549:469e93f8633e |
---|---|
197 */ | 197 */ |
198 | 198 |
199 /* Includes ------------------------------------------------------------------*/ | 199 /* Includes ------------------------------------------------------------------*/ |
200 #include "stdio.h" | 200 #include "stdio.h" |
201 #include <string.h> // for memcopy | 201 #include <string.h> // for memcopy |
202 #include <math.h> | |
202 #include "configuration.h" | 203 #include "configuration.h" |
203 | 204 |
204 #include "stm32f4xx_hal.h" | 205 #include "stm32f4xx_hal.h" |
205 #include "ostc.h" | 206 #include "ostc.h" |
206 #include "base.h" | 207 #include "base.h" |
262 static TIM_HandleTypeDef TimBacklightHandle; | 263 static TIM_HandleTypeDef TimBacklightHandle; |
263 #ifdef DEMOMODE | 264 #ifdef DEMOMODE |
264 TIM_HandleTypeDef TimDemoHandle; /* used in stm32f4xx_it.c too */ | 265 TIM_HandleTypeDef TimDemoHandle; /* used in stm32f4xx_it.c too */ |
265 #endif | 266 #endif |
266 | 267 |
268 | |
269 static uint8_t blBoost = 0; | |
267 static uint8_t RequestModeChange = 0; | 270 static uint8_t RequestModeChange = 0; |
268 | 271 |
269 static uint8_t LastButtonPressed; | 272 static uint8_t LastButtonPressed; |
270 static uint32_t LastButtonPressedTick; | 273 static uint32_t LastButtonPressedTick; |
271 static uint32_t BaseTick100ms; /* Tick at last 100ms cycle */ | 274 static uint32_t BaseTick100ms; /* Tick at last 100ms cycle */ |
498 DoDisplayRefresh = 0; | 501 DoDisplayRefresh = 0; |
499 RefreshDisplay(); | 502 RefreshDisplay(); |
500 | 503 |
501 TimeoutControl(); /* exit menus if needed */ | 504 TimeoutControl(); /* exit menus if needed */ |
502 | 505 |
503 if(stateUsed->mode == MODE_DIVE) /* handle motion events in divemode only */ | 506 #ifdef ENABLE_MOTION_CONTROL |
507 if((stateUsed->mode == MODE_DIVE) && (settingsGetPointer()->MotionDetection != MOTION_DETECT_OFF)) /* handle motion events in divemode only */ | |
504 { | 508 { |
505 switch(settingsGetPointer()->MotionDetection) | 509 evaluateMotionDelta(stateUsed->lifeData.compass_roll, stateUsed->lifeData.compass_pitch, stateUsed->lifeData.compass_heading); |
506 { | 510 checkViewport(stateUsed->lifeData.compass_roll, stateUsed->lifeData.compass_pitch, stateUsed->lifeData.compass_heading); |
507 case MOTION_DETECT_MOVE: pitchstate = detectPitch(stateRealGetPointer()->lifeData.compass_pitch); | 511 |
508 break; | 512 if(viewInFocus()) |
509 case MOTION_DETECT_SECTOR: pitchstate = detectSectorButtonEvent(stateRealGetPointer()->lifeData.compass_pitch); | 513 { |
510 break; | 514 set_Backlight_Boost(settingsGetPointer()->viewPortMode & 0x03); |
511 case MOTION_DETECT_SCROLL: pitchstate = detectScrollButtonEvent(stateRealGetPointer()->lifeData.compass_pitch); | 515 switch(settingsGetPointer()->MotionDetection) |
512 break; | 516 { |
513 default: | 517 case MOTION_DETECT_MOVE: pitchstate = detectPitch(stateRealGetPointer()->lifeData.compass_pitch); |
514 pitchstate = DETECT_NOTHING; | 518 break; |
515 break; | 519 case MOTION_DETECT_SECTOR: pitchstate = detectSectorButtonEvent(stateRealGetPointer()->lifeData.compass_pitch); |
516 } | 520 break; |
517 if(DETECT_NEG_PITCH == pitchstate) | 521 case MOTION_DETECT_SCROLL: pitchstate = detectScrollButtonEvent(stateRealGetPointer()->lifeData.compass_pitch); |
518 { | 522 break; |
519 StoreButtonAction((uint8_t)ACTION_PITCH_NEG); | 523 default: |
520 } | 524 pitchstate = DETECT_NOTHING; |
521 if(DETECT_POS_PITCH == pitchstate) | 525 break; |
522 { | 526 } |
523 StoreButtonAction((uint8_t)ACTION_PITCH_POS); | 527 if(DETECT_NEG_PITCH == pitchstate) |
524 } | 528 { |
529 StoreButtonAction((uint8_t)ACTION_PITCH_NEG); | |
530 } | |
531 if(DETECT_POS_PITCH == pitchstate) | |
532 { | |
533 StoreButtonAction((uint8_t)ACTION_PITCH_POS); | |
534 } | |
535 } | |
536 else | |
537 { | |
538 set_Backlight_Boost(0); | |
539 } | |
525 } | 540 } |
526 | 541 #endif |
527 | 542 |
528 #ifdef SIM_WRITES_LOGBOOK | 543 #ifdef SIM_WRITES_LOGBOOK |
529 if(stateUsed == stateSimGetPointer()) | 544 if(stateUsed == stateSimGetPointer()) |
530 logbook_InitAndWrite(stateUsed); | 545 logbook_InitAndWrite(stateUsed); |
531 #endif | 546 #endif |
784 { | 799 { |
785 | 800 |
786 if ((status.page == PageDive) && (status.line == 0)) | 801 if ((status.page == PageDive) && (status.line == 0)) |
787 { | 802 { |
788 tHome_change_customview_button_pressed(action); | 803 tHome_change_customview_button_pressed(action); |
789 if((settingsGetPointer()->MotionDetection != MOTION_DETECT_OFF) && (action == ACTION_BUTTON_ENTER)) /* Button pressed while motion detection is active => calibrate to current pitch value */ | |
790 { | |
791 DefinePitchSectors(stateRealGetPointer()->lifeData.compass_pitch,CUSTOMER_KEEP_LAST_SECTORS); | |
792 } | |
793 } | 804 } |
794 else if (status.page == PageSurface) | 805 else if (status.page == PageSurface) |
795 tHome_change_customview_button_pressed(action); | 806 tHome_change_customview_button_pressed(action); |
796 else | 807 else |
797 tHomeDiveMenuControl(action); | 808 tHomeDiveMenuControl(action); |
1141 SSettings *pSettings = settingsGetPointer(); | 1152 SSettings *pSettings = settingsGetPointer(); |
1142 /* 300 - 4000 */ | 1153 /* 300 - 4000 */ |
1143 /* important levelAmbient 300 - 1200 */ | 1154 /* important levelAmbient 300 - 1200 */ |
1144 levelAmbient = 10 * pStateReal->lifeData.ambient_light_level; | 1155 levelAmbient = 10 * pStateReal->lifeData.ambient_light_level; |
1145 | 1156 |
1146 switch( pSettings->brightness) | 1157 switch( pSettings->brightness + blBoost) |
1147 { | 1158 { |
1148 case 0: /* Cave */ | 1159 case 0: /* Cave */ |
1149 levelMax = 3000;/* max 25 % (x2) */ | 1160 levelMax = 3000;/* max 25 % (x2) */ |
1150 levelMin = 1500; | 1161 levelMin = 1500; |
1151 break; | 1162 break; |
1239 HAL_TIM_PWM_ConfigChannel(&TimBacklightHandle, &sConfig, TIM_BACKLIGHT_CHANNEL); | 1250 HAL_TIM_PWM_ConfigChannel(&TimBacklightHandle, &sConfig, TIM_BACKLIGHT_CHANNEL); |
1240 HAL_TIM_PWM_Start(&TimBacklightHandle, TIM_BACKLIGHT_CHANNEL); | 1251 HAL_TIM_PWM_Start(&TimBacklightHandle, TIM_BACKLIGHT_CHANNEL); |
1241 } | 1252 } |
1242 #endif | 1253 #endif |
1243 | 1254 |
1255 | |
1256 void set_Backlight_Boost(uint8_t level) | |
1257 { | |
1258 if(level < 3) | |
1259 { | |
1260 blBoost = level; | |
1261 } | |
1262 } | |
1244 | 1263 |
1245 static void EXTILine_Buttons_Config(void) | 1264 static void EXTILine_Buttons_Config(void) |
1246 { | 1265 { |
1247 GPIO_InitTypeDef GPIO_InitStructure; | 1266 GPIO_InitTypeDef GPIO_InitStructure; |
1248 | 1267 |