Mercurial > public > ostc4
changeset 368:50ea68c7a153 MotionDetection
Added menu item for motion detection. There are several possibility to use motion detection for user action input. To select of the a new menu entry has been added to the Sys2 =>Custom View Menu (Variables in german)
author | ideenmodellierer |
---|---|
date | Tue, 13 Aug 2019 21:10:46 +0200 |
parents | e309f78f89a5 |
children | 210bffc496a3 |
files | Common/Inc/settings.h Discovery/Inc/base.h Discovery/Inc/tStructure.h Discovery/Inc/text_multilanguage.h Discovery/Src/base.c Discovery/Src/settings.c Discovery/Src/tMenuEditSystem.c Discovery/Src/text_multilanguage.c |
diffstat | 8 files changed, 129 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/Common/Inc/settings.h Sat Jul 20 21:42:45 2019 +0200 +++ b/Common/Inc/settings.h Tue Aug 13 21:10:46 2019 +0200 @@ -216,6 +216,8 @@ uint8_t FlipDisplay; /* new in 0xFFFF0019 */ uint32_t cv_configuration; + /* new in 0xFFFF001A */ + uint8_t MotionDetection; } SSettings;
--- a/Discovery/Inc/base.h Sat Jul 20 21:42:45 2019 +0200 +++ b/Discovery/Inc/base.h Tue Aug 13 21:10:46 2019 +0200 @@ -86,8 +86,8 @@ ACTION_BUTTON_NEXT, ACTION_BUTTON_ENTER, ACTION_BUTTON_ENTER_FINAL, - ACTION_SHAKE_POS, - ACTION_SHAKE_NEG, + ACTION_PITCH_POS, + ACTION_PITCH_NEG, ACTION_END } SAction;
--- a/Discovery/Inc/tStructure.h Sat Jul 20 21:42:45 2019 +0200 +++ b/Discovery/Inc/tStructure.h Tue Aug 13 21:10:46 2019 +0200 @@ -284,8 +284,9 @@ #define StMSYS4_CViewTimeout _MB(2,8,4,1,0) #define StMSYS4_CViewStandard _MB(2,8,4,2,0) #define StMSYS4_CornerTimeout _MB(2,8,4,3,0) -#define StMSYS4_CornerStandard _MB(2,8,4,4,0) +#define StMSYS4_CornerStandard _MB(2,8,4,4,0) #define StMSYS4_ExtraDisplay _MB(2,8,4,5,0) +#define StMSYS4_MotionCtrl _MB(2,8,4,6,0) #define StMSYS5_Info _MB(2,8,5,1,0)
--- a/Discovery/Inc/text_multilanguage.h Sat Jul 20 21:42:45 2019 +0200 +++ b/Discovery/Inc/text_multilanguage.h Tue Aug 13 21:10:46 2019 +0200 @@ -274,6 +274,11 @@ TXT2BYTE_ExtraDecoGame, TXT2BYTE_ExtraNone, /* */ + TXT2BYTE_MotionCtrl, + TXT2BYTE_MoCtrlNone, + TXT2BYTE_MoCtrlPitch, + TXT2BYTE_MoCtrlSector, + /* */ TXT2BYTE_DecoDataLost, TXT2BYTE_Info, TXT2BYTE_Korrekturwerte,
--- a/Discovery/Src/base.c Sat Jul 20 21:42:45 2019 +0200 +++ b/Discovery/Src/base.c Tue Aug 13 21:10:46 2019 +0200 @@ -351,7 +351,7 @@ uint8_t lastsecond = 0xFF; #endif - detectionState_t shakestate; + detectionState_t pitchstate; set_globalState( StBoot0 ); LastButtonPressed = 0; @@ -457,6 +457,7 @@ setDebugMode(); openInfo( StIDEBUG ); } + InitMotionDetection(); TIM_init(); /* start cylic 100ms task */ @@ -487,14 +488,24 @@ DoDisplayRefresh = 0; RefreshDisplay(); - shakestate = detectShake(stateRealGetPointer()->lifeData.compass_pitch); - if(DETECT_NEG_SHAKE == shakestate) + switch(settingsGetPointer()->MotionDetection) + { + case MOTION_DETECT_MOVE: pitchstate = detectPitch(stateRealGetPointer()->lifeData.compass_pitch); + break; + case MOTION_DETECT_SECTOR: pitchstate = detectSectorButtonEvent(stateRealGetPointer()->lifeData.compass_pitch); + break; + default: + pitchstate = DETECT_NOTHING; + break; + } + + if(DETECT_NEG_PITCH == pitchstate) { - StoreButtonAction((uint8_t)ACTION_SHAKE_NEG); + StoreButtonAction((uint8_t)ACTION_PITCH_NEG); } - if(DETECT_POS_SHAKE == shakestate) + if(DETECT_POS_PITCH == pitchstate) { - StoreButtonAction((uint8_t)ACTION_SHAKE_POS); + StoreButtonAction((uint8_t)ACTION_PITCH_POS); } // Enable this to make the simulator write a logbook entry @@ -885,11 +896,17 @@ set_globalState(StD); } else tHome_change_field_button_pressed(); - } else if ((action == ACTION_BUTTON_ENTER) || (action == ACTION_SHAKE_NEG) || (action == ACTION_SHAKE_POS)) + } else if ((action == ACTION_BUTTON_ENTER) || (action == ACTION_PITCH_NEG) || (action == ACTION_PITCH_POS)) { if ((status.page == PageDive) && (status.line == 0)) + { tHome_change_customview_button_pressed(action); + if((settingsGetPointer()->MotionDetection == MOTION_DETECT_SECTOR) && (action == ACTION_BUTTON_ENTER)) /* Button pressed while sector detection is active => calibrate to current pitch value */ + { + DefinePitchSectors(stateRealGetPointer()->lifeData.compass_pitch); + } + } else if (status.page == PageSurface) tHome_change_customview_button_pressed(action); else
--- a/Discovery/Src/settings.c Sat Jul 20 21:42:45 2019 +0200 +++ b/Discovery/Src/settings.c Tue Aug 13 21:10:46 2019 +0200 @@ -82,7 +82,7 @@ * There might even be entries with fixed values that have no range */ const SSettings SettingsStandard = { - .header = 0xFFFF0019, + .header = 0xFFFF001A, .warning_blink_dsec = 8 * 2, .lastDiveLogId = 0, .logFlashNextSampleStartAddress = 0, @@ -307,6 +307,7 @@ .FactoryButtonBalance[2] = 3, .FlipDisplay = 0, .cv_configuration = 0xFFFFFFFF, + .MotionDetection = 0, }; /* Private function prototypes -----------------------------------------------*/ @@ -353,6 +354,7 @@ pSettings->scooterControl = 0; + /* Pointing to the old header data => set new data depending on what had been added since last version */ switch(pSettings->header) { case 0xFFFF0000: @@ -450,6 +452,9 @@ case 0xFFFF0018: pSettings->cv_configuration = 0xFFFFFFFF; // no break + case 0xFFFF0019: + pSettings->MotionDetection = 0; + // no break default: pSettings->header = pStandard->header; break; // no break before!! @@ -1347,6 +1352,11 @@ Settings.FlipDisplay = 0; corrections++; } + if(Settings.MotionDetection > 2) /* At the moment only two detection functions available */ + { + Settings.MotionDetection = 0; + corrections++; + } if(corrections > 255) return 255; @@ -1399,7 +1409,7 @@ return ((firmware_FirmwareData.versionSecond & 0x03) << 6) + ((firmware_FirmwareData.versionThird & 0x1F) << 1) + (firmware_FirmwareData.versionBeta & 0x01); } -SSettings* settingsGetPointer(void) +inline SSettings* settingsGetPointer(void) { return &Settings; }
--- a/Discovery/Src/tMenuEditSystem.c Sat Jul 20 21:42:45 2019 +0200 +++ b/Discovery/Src/tMenuEditSystem.c Tue Aug 13 21:10:46 2019 +0200 @@ -36,9 +36,9 @@ #include "settings.h" // for getLicence() #include "tHome.h" // for enum CUSTOMVIEWS and init_t7_compass() #include "tMenuEdit.h" +#include "Motion.h" /* Private variables ---------------------------------------------------------*/ - uint8_t infoPage = 0; /* Private function prototypes -----------------------------------------------*/ @@ -77,6 +77,7 @@ uint8_t OnAction_CornerTimeout (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_CornerStandard(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_ExtraDisplay (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); +uint8_t OnAction_MotionCtrl (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_Exit (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_Confirm (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); @@ -732,9 +733,10 @@ write_field_button(StMSYS4_CViewStandard, 400, 700, ME_Y_LINE2, &FontT48, ""); write_field_button(StMSYS4_CornerTimeout, 400, 700, ME_Y_LINE3, &FontT48, ""); - write_field_button(StMSYS4_CornerStandard, 400, 700, ME_Y_LINE4, &FontT48, ""); + write_field_button(StMSYS4_CornerStandard, 400, 700, ME_Y_LINE4, &FontT48, ""); write_field_button(StMSYS4_ExtraDisplay, 400, 700, ME_Y_LINE5, &FontT48, ""); + write_field_button(StMSYS4_MotionCtrl, 400, 700, ME_Y_LINE6, &FontT48, ""); setEvent(StMSYS4_CViewTimeout, (uint32_t)OnAction_CViewTimeout); setEvent(StMSYS4_CViewStandard, (uint32_t)OnAction_CViewStandard); @@ -743,6 +745,7 @@ setEvent(StMSYS4_CornerStandard, (uint32_t)OnAction_CornerStandard); setEvent(StMSYS4_ExtraDisplay, (uint32_t)OnAction_ExtraDisplay); + setEvent(StMSYS4_MotionCtrl, (uint32_t)OnAction_MotionCtrl); } @@ -904,6 +907,31 @@ text[6] = 0; write_label_var( 30, 700, ME_Y_LINE5, &FontT48, text); + + /* MotionCtrl */ + text[0] = TXT_2BYTE; + text[1] = TXT2BYTE_MotionCtrl; + text[2] = ' '; + text[3] = ' '; + text[4] = TXT_2BYTE; + switch(settingsGetPointer()->MotionDetection) + { + case MOTION_DETECT_OFF: + text[5] = TXT2BYTE_MoCtrlNone; + break; + case MOTION_DETECT_MOVE: + text[5] = TXT2BYTE_MoCtrlPitch; + break; + case MOTION_DETECT_SECTOR: + text[5] = TXT2BYTE_MoCtrlSector; + break; + default: + snprintf(&text[4],2,"%u",settingsGetPointer()->MotionDetection); + break; + } + text[6] = 0; + write_label_var( 30, 700, ME_Y_LINE6, &FontT48, text); + write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); } @@ -1042,6 +1070,28 @@ } +uint8_t OnAction_MotionCtrl (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) +{ + uint8_t newValue; + switch(settingsGetPointer()->MotionDetection) + { + case 0: + newValue = 1; + break; + case 1: + newValue = 2; + break; + case 2: + newValue = 0; + break; + default: + newValue = 0; + break; + } + settingsGetPointer()->MotionDetection = newValue; + return UNSPECIFIC_RETURN; +} + void openEdit_Information(void) { char text[70];
--- a/Discovery/Src/text_multilanguage.c Sat Jul 20 21:42:45 2019 +0200 +++ b/Discovery/Src/text_multilanguage.c Tue Aug 13 21:10:46 2019 +0200 @@ -1262,6 +1262,32 @@ static uint8_t text_IT_ExtraNone[] = "no"; static uint8_t text_ES_ExtraNone[] = "ninguno"; +/* Menu SYS2 - Strings for Motion Control Selection */ +static uint8_t text_EN_MotionCtrl[] = "Motion Control"; +static uint8_t text_DE_MotionCtrl[] = "Bew. Steuerung"; +static uint8_t text_FR_MotionCtrl[] = "Motion Control"; +static uint8_t text_IT_MotionCtrl[] = "Motion Control"; +static uint8_t text_ES_MotionCtrl[] = "Motion Control"; + +static uint8_t text_EN_MoCtrlNone[] = "Off"; +static uint8_t text_DE_MoCtrlNone[] = "Aus"; +static uint8_t text_FR_MoCtrlNone[] = "Off"; +static uint8_t text_IT_MoCtrlNone[] = "Off"; +static uint8_t text_ES_MoCtrlNone[] = "Off"; + +static uint8_t text_EN_MoCtrlPitch[] = "Pitch move"; +static uint8_t text_DE_MoCtrlPitch[] = "Nickbewegung"; +static uint8_t text_FR_MoCtrlPitch[] = "Pitch move"; +static uint8_t text_IT_MoCtrlPitch[] = "Pitch move"; +static uint8_t text_ES_MoCtrlPitch[] = "Pitch move"; + +static uint8_t text_EN_MoCtrlSector[] = "Sector"; +static uint8_t text_DE_MoCtrlSector[] = "Sektoren"; +static uint8_t text_FR_MoCtrlSector[] = "Sector"; +static uint8_t text_IT_MoCtrlSector[] = "Sector"; +static uint8_t text_ES_MoCtrlSector[] = "Sector"; + + // Menu SYS2 Reset RTE and Firmware Update During Bluetooth Connection static uint8_t text_EN_DecoDataLost[] = "Decompression data will be lost"; static uint8_t text_DE_DecoDataLost[] = "Dekompressionsdaten verloren!"; @@ -1716,6 +1742,10 @@ {(uint8_t)TXT2BYTE_ExtraBigFont, {text_EN_ExtraBigFont, text_DE_ExtraBigFont, text_FR_ExtraBigFont, text_IT_ExtraBigFont, text_ES_ExtraBigFont}}, {(uint8_t)TXT2BYTE_ExtraDecoGame, {text_EN_ExtraDecoGame, text_DE_ExtraDecoGame, text_FR_ExtraDecoGame, text_IT_ExtraDecoGame, text_ES_ExtraDecoGame}}, {(uint8_t)TXT2BYTE_ExtraNone, {text_EN_ExtraNone, text_DE_ExtraNone, text_FR_ExtraNone, text_IT_ExtraNone, text_ES_ExtraNone}}, + {(uint8_t)TXT2BYTE_MotionCtrl, {text_EN_MotionCtrl, text_DE_MotionCtrl, text_FR_MotionCtrl, text_IT_MotionCtrl, text_ES_MotionCtrl}}, + {(uint8_t)TXT2BYTE_MoCtrlNone, {text_EN_MoCtrlNone, text_DE_MoCtrlNone, text_FR_MoCtrlNone, text_IT_MoCtrlNone, text_ES_MoCtrlNone}}, + {(uint8_t)TXT2BYTE_MoCtrlPitch, {text_EN_MoCtrlPitch, text_DE_MoCtrlPitch, text_FR_MoCtrlPitch, text_IT_MoCtrlPitch, text_ES_MoCtrlPitch}}, + {(uint8_t)TXT2BYTE_MoCtrlSector, {text_EN_MoCtrlSector, text_DE_MoCtrlSector, text_FR_MoCtrlSector, text_IT_MoCtrlSector, text_ES_MoCtrlSector}}, {(uint8_t)TXT2BYTE_DecoDataLost, {text_EN_DecoDataLost, text_DE_DecoDataLost, text_FR_DecoDataLost, text_IT_DecoDataLost, text_ES_DecoDataLost}}, {(uint8_t)TXT2BYTE_Info, {text_EN_Info, text_DE_Info, text_FR_Info, text_IT_Info, text_ES_Info}}, {(uint8_t)TXT2BYTE_Korrekturwerte, {text_EN_Korrekturwerte, text_DE_Korrekturwerte, text_FR_Korrekturwerte, text_IT_Korrekturwerte, text_ES_Korrekturwerte}},