comparison Discovery/Src/tMenuEditCustom.c @ 626:3e1a0e267f38

Added option to select sensitivity of focus detection: Depending on the location the computer is equiped during dive (arm wet/ dry suite, glove...) it is usefull to adapt the sensitivity of the focus detection. Technical it means the radius of the spot in which direction ray is projected may be changed in size. The option has been added to the motion control menu.
author Ideenmodellierer
date Fri, 12 Feb 2021 21:37:50 +0100
parents 028d8f3a9410
children b9d4baa4f6fa
comparison
equal deleted inserted replaced
625:028d8f3a9410 626:3e1a0e267f38
45 45
46 #define CV_PER_PAGE (5u) /* number of cv selections shown at one page */ 46 #define CV_PER_PAGE (5u) /* number of cv selections shown at one page */
47 #define CV_SUBPAGE_MAX (2u) /* max number of customer view selection pages */ 47 #define CV_SUBPAGE_MAX (2u) /* max number of customer view selection pages */
48 #define MAX_BACKLIGHT_BOOST (2u) /* max number of backlight levels which may be increased during focus state */ 48 #define MAX_BACKLIGHT_BOOST (2u) /* max number of backlight levels which may be increased during focus state */
49 49
50 #define MAX_FOCUS_LIMITER (2u) /* max number for reducing the spot used for focus detection */
51
50 static uint8_t customviewsSubpage = 0; 52 static uint8_t customviewsSubpage = 0;
51 static uint8_t customviewsSubpageMax = 0; /* number of pages needed to display all selectable views */ 53 static uint8_t customviewsSubpageMax = 0; /* number of pages needed to display all selectable views */
52 static const uint8_t* pcv_curchangelist; 54 static const uint8_t* pcv_curchangelist;
53 /* Private function prototypes -----------------------------------------------*/ 55 /* Private function prototypes -----------------------------------------------*/
54 void openEdit_Customview(void); 56 void openEdit_Customview(void);
65 uint8_t OnAction_CornerStandard(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 67 uint8_t OnAction_CornerStandard(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
66 uint8_t OnAction_CViewPortCalib(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 68 uint8_t OnAction_CViewPortCalib(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
67 uint8_t OnAction_CViewPortLayout(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 69 uint8_t OnAction_CViewPortLayout(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
68 uint8_t OnAction_CViewPortAmbient(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 70 uint8_t OnAction_CViewPortAmbient(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
69 uint8_t OnAction_CViewPortControl(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 71 uint8_t OnAction_CViewPortControl(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
72 uint8_t OnAction_CViewPortSpot(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
70 /* Exported functions --------------------------------------------------------*/ 73 /* Exported functions --------------------------------------------------------*/
71 74
72 75
73 76
74 77
184 SSettings* pSettings = settingsGetPointer(); 187 SSettings* pSettings = settingsGetPointer();
185 GFX_DrawCfgScreen* pdrawScreen; 188 GFX_DrawCfgScreen* pdrawScreen;
186 point_t lowerleft = {0,0}; 189 point_t lowerleft = {0,0};
187 point_t upperright = {799,479}; 190 point_t upperright = {799,479};
188 float localLimit = 0.1; 191 float localLimit = 0.1;
192 uint8_t spotSize = (pSettings->viewPortMode >> 5) & 0x03;
189 193
190 text[0] = '\001'; 194 text[0] = '\001';
191 text[1] = TXT_2BYTE; 195 text[1] = TXT_2BYTE;
192 text[2] = TXT2BYTE_MotionCtrl; 196 text[2] = TXT2BYTE_MotionCtrl;
193 text[3] = 0; 197 text[3] = 0;
196 text[0] = TXT_2BYTE; 200 text[0] = TXT_2BYTE;
197 text[1] = TXT2BYTE_CalibView; 201 text[1] = TXT2BYTE_CalibView;
198 text[2] = 0; 202 text[2] = 0;
199 write_label_var( 30, 700, ME_Y_LINE2, &FontT48, text); 203 write_label_var( 30, 700, ME_Y_LINE2, &FontT48, text);
200 204
205
206 textIndex = 0;
207 text[textIndex++] = TXT_2BYTE;
208 text[textIndex++] = TXT2BYTE_FocusSpotSize;
209 text[textIndex++] = 0;
210 write_label_var( 30, 340, ME_Y_LINE3, &FontT48, text);
211
212 textIndex = 0;
213 text[textIndex++] = TXT_2BYTE;
214 switch(spotSize)
215 {
216 case 2: text[textIndex++] = TXT2BYTE_Minimum; break;
217 case 1: text[textIndex++] = TXT2BYTE_Normal; break;
218 default:
219 case 0: text[textIndex++] = TXT2BYTE_Maximum; break;
220 }
221 text[textIndex++] = 0;
222 write_label_var( 500, 800, ME_Y_LINE3, &FontT48, text);
223
201 textIndex = 0; 224 textIndex = 0;
202 text[textIndex++] = TXT_2BYTE; 225 text[textIndex++] = TXT_2BYTE;
203 text[textIndex++] = TXT2BYTE_IndicateFrame; 226 text[textIndex++] = TXT2BYTE_IndicateFrame;
204 text[textIndex++] = ' ';
205 text[textIndex++] = '\006' - (settingsGetPointer()->viewPortMode >> 4);
206 text[textIndex++] = 0; 227 text[textIndex++] = 0;
207 write_label_var( 30, 700, ME_Y_LINE3, &FontT48, text); 228 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, text);
229 textIndex = 0;
230 text[textIndex++] = '\006' - ((settingsGetPointer()->viewPortMode >> 4) & 1);
231 text[textIndex++] = 0;
232 write_label_var( 500, 800, ME_Y_LINE4, &FontT48, text);
208 textIndex = 0; 233 textIndex = 0;
209 text[textIndex++] = TXT_2BYTE; 234 text[textIndex++] = TXT_2BYTE;
210 text[textIndex++] = TXT2BYTE_BoostBacklight; 235 text[textIndex++] = TXT2BYTE_BoostBacklight;
211 text[textIndex++] = ' '; 236 text[textIndex++] = 0;
212 snprintf(&text[textIndex],32," %d",(settingsGetPointer()->viewPortMode & 0x3)); 237 write_label_var( 30, 340, ME_Y_LINE5, &FontT48, text);
213 write_label_var( 30, 700, ME_Y_LINE4, &FontT48, text); 238 textIndex = 0;
239 snprintf(&text[textIndex],32,"%d",(settingsGetPointer()->viewPortMode & 0x3));
240 write_label_var( 500, 800, ME_Y_LINE5, &FontT48, text);
214 241
215 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); 242 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
216 243
217 /* test if we are in focus */ 244 /* test if we are in focus */
218 if((pSettings->viewPitch != 0.0) || (pSettings->viewRoll != 0.0) || (pSettings->viewYaw != 0.0)) 245 if((pSettings->viewPitch != 0.0) || (pSettings->viewRoll != 0.0) || (pSettings->viewYaw != 0.0))
221 248
222 /* show "bar graph" indicating the distance to the center point */ 249 /* show "bar graph" indicating the distance to the center point */
223 textIndex = 0; 250 textIndex = 0;
224 text[textIndex++] = '\001'; 251 text[textIndex++] = '\001';
225 252
226 if(distance < localLimit) 253 if(fabs(distance) < localLimit)
227 { 254 {
228 text[textIndex++] = '+'; 255 text[textIndex++] = '+';
229 } 256 }
230 else 257 else
231 { 258 {
232 text[textIndex++] = '-';
233 while (localLimit < 0.6) 259 while (localLimit < 0.6)
234 { 260 {
235 localLimit += 0.1; 261 localLimit += 0.1;
236 text[textIndex++] = '-'; 262 text[textIndex++] = '-';
237 text[textIndex++] = '-'; 263 text[textIndex++] = '-';
238 if(distance < localLimit) 264 if(fabs(distance) < localLimit)
239 { 265 {
240 break; 266 break;
241 } 267 }
242 } 268 }
243 } 269 }
247 /* MotionCtrl */ 273 /* MotionCtrl */
248 textIndex = 0; 274 textIndex = 0;
249 275
250 text[textIndex++] = TXT_2BYTE; 276 text[textIndex++] = TXT_2BYTE;
251 text[textIndex++] = TXT2BYTE_MotionCtrl; 277 text[textIndex++] = TXT2BYTE_MotionCtrl;
252 text[textIndex++] = ' '; 278 text[textIndex++] = 0;
253 text[textIndex++] = ' '; 279 write_label_var( 30, 340, ME_Y_LINE6, &FontT48, text);
280 textIndex = 0;
254 text[textIndex++] = TXT_2BYTE; 281 text[textIndex++] = TXT_2BYTE;
255 switch(settingsGetPointer()->MotionDetection) 282 switch(settingsGetPointer()->MotionDetection)
256 { 283 {
257 case MOTION_DETECT_OFF: 284 case MOTION_DETECT_OFF:
258 text[textIndex++] = TXT2BYTE_MoCtrlNone; 285 text[textIndex++] = TXT2BYTE_MoCtrlNone;
270 snprintf(&text[4],2,"%u",settingsGetPointer()->MotionDetection); 297 snprintf(&text[4],2,"%u",settingsGetPointer()->MotionDetection);
271 textIndex++; 298 textIndex++;
272 break; 299 break;
273 } 300 }
274 text[textIndex] = 0; 301 text[textIndex] = 0;
275 write_label_var( 30, 700, ME_Y_LINE6, &FontT48, text); 302 write_label_var(500, 800, ME_Y_LINE6, &FontT48, text);
276 303
277 if(distance < 0.5) 304
305 if(viewInFocus())
278 { 306 {
279 set_Backlight_Boost(settingsGetPointer()->viewPortMode & 0x03); 307 set_Backlight_Boost(settingsGetPointer()->viewPortMode & 0x03);
280 if(pSettings->viewPortMode >> 4) 308 if((pSettings->viewPortMode >> 4) & 0x01)
281 { 309 {
282 pdrawScreen = getMenuEditScreen(); 310 pdrawScreen = getMenuEditScreen();
283 GFX_draw_box(pdrawScreen,lowerleft,upperright,0,CLUT_NiceGreen); 311 GFX_draw_box(pdrawScreen,lowerleft,upperright,0,CLUT_NiceGreen);
284 } 312 }
285 } 313 }
286 else 314 else
287 { 315 {
288 set_Backlight_Boost(0); 316 set_Backlight_Boost(0);
289 if(pSettings->viewPortMode >> 4) 317 if((pSettings->viewPortMode >> 4) & 0x01)
290 { 318 {
291 pdrawScreen = getMenuEditScreen(); 319 pdrawScreen = getMenuEditScreen();
292 GFX_draw_box(pdrawScreen,lowerleft,upperright,0,CLUT_MenuTopBackground); 320 GFX_draw_box(pdrawScreen,lowerleft,upperright,0,CLUT_MenuTopBackground);
293 } 321 }
294 } 322 }
390 void openEdit_ViewPort(void) 418 void openEdit_ViewPort(void)
391 { 419 {
392 refresh_ViewPort(); 420 refresh_ViewPort();
393 421
394 write_field_button(StMCustom5_CViewPortCalib, 400, 700, ME_Y_LINE2, &FontT48, ""); 422 write_field_button(StMCustom5_CViewPortCalib, 400, 700, ME_Y_LINE2, &FontT48, "");
395 write_field_button(StMCustom5_CViewPortLayout, 400, 700, ME_Y_LINE3, &FontT48, ""); 423 write_field_button(StMCustom5_CViewPortSpotSize,400, 700, ME_Y_LINE3, &FontT48, "");
396 write_field_button(StMCustom5_CViewPortAmbient, 400, 700, ME_Y_LINE4, &FontT48, ""); 424 write_field_button(StMCustom5_CViewPortLayout, 400, 700, ME_Y_LINE4, &FontT48, "");
425 write_field_button(StMCustom5_CViewPortAmbient, 400, 700, ME_Y_LINE5, &FontT48, "");
397 write_field_button(StMCustom5_CViewPortControl, 400, 700, ME_Y_LINE6, &FontT48, ""); 426 write_field_button(StMCustom5_CViewPortControl, 400, 700, ME_Y_LINE6, &FontT48, "");
398 427
399
400 setEvent(StMCustom5_CViewPortCalib, (uint32_t)OnAction_CViewPortCalib); 428 setEvent(StMCustom5_CViewPortCalib, (uint32_t)OnAction_CViewPortCalib);
429 setEvent(StMCustom5_CViewPortSpotSize, (uint32_t)OnAction_CViewPortSpot);
401 setEvent(StMCustom5_CViewPortLayout, (uint32_t)OnAction_CViewPortLayout); 430 setEvent(StMCustom5_CViewPortLayout, (uint32_t)OnAction_CViewPortLayout);
402 setEvent(StMCustom5_CViewPortAmbient, (uint32_t)OnAction_CViewPortAmbient); 431 setEvent(StMCustom5_CViewPortAmbient, (uint32_t)OnAction_CViewPortAmbient);
403 setEvent(StMCustom5_CViewPortControl, (uint32_t)OnAction_CViewPortControl); 432 setEvent(StMCustom5_CViewPortControl, (uint32_t)OnAction_CViewPortControl);
404 } 433 }
405 434
730 newValue = MOTION_DETECT_OFF; 759 newValue = MOTION_DETECT_OFF;
731 break; 760 break;
732 } 761 }
733 pSettings->MotionDetection = newValue; 762 pSettings->MotionDetection = newValue;
734 return UPDATE_DIVESETTINGS; 763 return UPDATE_DIVESETTINGS;
764 }
765
766 uint8_t OnAction_CViewPortSpot(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
767 {
768 uint8_t newValue = 0;
769 SSettings *pSettings = settingsGetPointer();
770
771 newValue = ((pSettings->viewPortMode >> 5) + 1) & 0x03;
772 if(newValue > MAX_FOCUS_LIMITER)
773 {
774 newValue = 0;
775 }
776 pSettings->viewPortMode &= 0x9F;
777 pSettings->viewPortMode |= (newValue << 5);
778 return UPDATE_DIVESETTINGS;
735 } 779 }
736 780
737 void openEdit_CustomviewDivemode(const uint8_t* pcv_changelist) 781 void openEdit_CustomviewDivemode(const uint8_t* pcv_changelist)
738 { 782 {
739 783