exposurses

Check-in [4a3cabadc2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix menu numbering (from adding exposure menu in) Didn't change functionality (it was still working), but just gives better consistency to the code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 4a3cabadc2567cc5dd199cb547e22bb46ce29baecc3e4a5c6b66def8e882cb69
User & Date: base@atomicules.co.uk 2013-09-18 11:01:39
Context
2013-09-18
12:48
Add under/over exposure indication in to the shutter/aperture menus Keeping the NULLs in makes array indices very confusing, but this seems to be the right thing to do. check-in: 7312ab2b6f user: base@atomicules.co.uk tags: origin/master, trunk
11:01
Fix menu numbering (from adding exposure menu in) Didn't change functionality (it was still working), but just gives better consistency to the code. check-in: 4a3cabadc2 user: base@atomicules.co.uk tags: origin/master, trunk
11:01
Make the add_menu and add_win subs work I was still using the "variable pointers" technique, well trying to, and it wasn't working for things like `set_menu_win` so pull this back out into main. Seg faults on exit, but haven't fixed that bit yet. check-in: c2741c67e7 user: base@atomicules.co.uk tags: origin/master, trunk
Changes
Hide Diffs Unified Diffs Show Whitespace Changes Patch

Changes to exposurses.c.

133
134
135
136
137
138
139

140
141
142
143
144
145
146
...
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
...
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
	iso_menu = add_menu(iso_array, iso_items, n_iso);
	shutter_menu = add_menu(shutter_array, shutter_items, n_shutter);
	aperture_menu = add_menu(aperture_array, aperture_items, n_aperture);
	exposure_win = add_window(4, "EV");
	iso_win = add_window(45, "ISO");
	shutter_win = add_window(86, "Shutter");
	aperture_win = add_window(127, "Aperture");

	set_menu_win(exposure_menu, exposure_win);
	set_menu_win(iso_menu, iso_win);
	set_menu_win(shutter_menu, shutter_win);
	set_menu_win(aperture_menu, aperture_win);
	set_menu_sub(exposure_menu, derwin(exposure_win, 6, 38, 3, 1));
	set_menu_sub(iso_menu, derwin(iso_win, 6, 38, 3, 1));
	set_menu_sub(shutter_menu, derwin(shutter_win, 6, 38, 3, 1));
................................................................................
							menu_driver(shutter_menu, REQ_SCR_UPAGE);
							menu_driver(shutter_menu, REQ_SCR_DPAGE);
							/* There is probably a nicer way to format the below */
							set_menu_pattern(
								shutter_menu,
								shutter_array[nearest_match(
									shutter(exposure(atoi(iso_sel)), strtod(aperture_sel_, NULL)),
									2
								)]
							);
							menu_driver(shutter_menu, REQ_DOWN_ITEM);
							menu_driver(shutter_menu, REQ_UP_ITEM);
							wrefresh(shutter_win);
						}
						if (strcmp("", aperture_sel) == 0) {
							menu_driver(aperture_menu, REQ_SCR_UPAGE);
							menu_driver(aperture_menu, REQ_SCR_DPAGE);
							set_menu_pattern(
								aperture_menu,
								aperture_array[nearest_match(
									aperture(exposure(atoi(iso_sel)), fraction_to_double(shutter_sel)),
									3
								)]
							);
							menu_driver(aperture_menu, REQ_DOWN_ITEM);
							menu_driver(aperture_menu, REQ_UP_ITEM);
							wrefresh(aperture_win);
						}
						/* clear the selections for next time */
................................................................................
	int diff_idx = 0;
	char array_value_str[9];
	double array_value_db;
	double diff;

	/* Need a starting value for difference */
	switch(menu) {
		case 1:
			array_value_db = strtod(iso_array[0], NULL);
			break;
		case 2:
			array_value_db = fraction_to_double(shutter_array[0]);
			break;
		case 3:
			strncpy(array_value_str, aperture_array[0]+2, 4);
			array_value_db = strtod(array_value_str, NULL);
			break;
	}
	diff = fabs(array_value_db - x);
	/* lots of repetition here but pointers to arrays seem to be a bad thing */
	switch(menu) {
		case 1:
			for ( n = 1; iso_array[n] != NULL; ++n ) {
				array_value_db = strtod(iso_array[n], NULL);
				if (fabs(array_value_db - x) < diff) { 
					diff_idx = n;
					diff = fabs(array_value_db - x);
				}
			}
			break;
		case 2:
			for ( n = 1; shutter_array[n] != NULL; ++n ) {
				array_value_db = fraction_to_double(shutter_array[n]);
				if (fabs(array_value_db - x) < diff) {
					diff_idx = n;
					diff = fabs(array_value_db - x);
				}
			}
			break;
		case 3:
			for ( n = 1; aperture_array[n] != NULL; ++n ) {
				strncpy(array_value_str, aperture_array[n]+2, 4);
				array_value_db = strtod(array_value_str, NULL);
				if (fabs(array_value_db - x) < diff) { 
					diff_idx = n;
					diff = fabs(array_value_db - x);
				}







>







 







|













|







 







|
<
<
<


|







|
<
<
<
<
<
<
<
<
<








|







133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
...
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
...
381
382
383
384
385
386
387
388



389
390
391
392
393
394
395
396
397
398
399









400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
	iso_menu = add_menu(iso_array, iso_items, n_iso);
	shutter_menu = add_menu(shutter_array, shutter_items, n_shutter);
	aperture_menu = add_menu(aperture_array, aperture_items, n_aperture);
	exposure_win = add_window(4, "EV");
	iso_win = add_window(45, "ISO");
	shutter_win = add_window(86, "Shutter");
	aperture_win = add_window(127, "Aperture");
	/* Don't know how to avoid the repition below */
	set_menu_win(exposure_menu, exposure_win);
	set_menu_win(iso_menu, iso_win);
	set_menu_win(shutter_menu, shutter_win);
	set_menu_win(aperture_menu, aperture_win);
	set_menu_sub(exposure_menu, derwin(exposure_win, 6, 38, 3, 1));
	set_menu_sub(iso_menu, derwin(iso_win, 6, 38, 3, 1));
	set_menu_sub(shutter_menu, derwin(shutter_win, 6, 38, 3, 1));
................................................................................
							menu_driver(shutter_menu, REQ_SCR_UPAGE);
							menu_driver(shutter_menu, REQ_SCR_DPAGE);
							/* There is probably a nicer way to format the below */
							set_menu_pattern(
								shutter_menu,
								shutter_array[nearest_match(
									shutter(exposure(atoi(iso_sel)), strtod(aperture_sel_, NULL)),
									3
								)]
							);
							menu_driver(shutter_menu, REQ_DOWN_ITEM);
							menu_driver(shutter_menu, REQ_UP_ITEM);
							wrefresh(shutter_win);
						}
						if (strcmp("", aperture_sel) == 0) {
							menu_driver(aperture_menu, REQ_SCR_UPAGE);
							menu_driver(aperture_menu, REQ_SCR_DPAGE);
							set_menu_pattern(
								aperture_menu,
								aperture_array[nearest_match(
									aperture(exposure(atoi(iso_sel)), fraction_to_double(shutter_sel)),
									4
								)]
							);
							menu_driver(aperture_menu, REQ_DOWN_ITEM);
							menu_driver(aperture_menu, REQ_UP_ITEM);
							wrefresh(aperture_win);
						}
						/* clear the selections for next time */
................................................................................
	int diff_idx = 0;
	char array_value_str[9];
	double array_value_db;
	double diff;

	/* Need a starting value for difference */
	switch(menu) {
		case 3:



			array_value_db = fraction_to_double(shutter_array[0]);
			break;
		case 4:
			strncpy(array_value_str, aperture_array[0]+2, 4);
			array_value_db = strtod(array_value_str, NULL);
			break;
	}
	diff = fabs(array_value_db - x);
	/* lots of repetition here but pointers to arrays seem to be a bad thing */
	switch(menu) {
		case 3:









			for ( n = 1; shutter_array[n] != NULL; ++n ) {
				array_value_db = fraction_to_double(shutter_array[n]);
				if (fabs(array_value_db - x) < diff) {
					diff_idx = n;
					diff = fabs(array_value_db - x);
				}
			}
			break;
		case 4:
			for ( n = 1; aperture_array[n] != NULL; ++n ) {
				strncpy(array_value_str, aperture_array[n]+2, 4);
				array_value_db = strtod(array_value_str, NULL);
				if (fabs(array_value_db - x) < diff) { 
					diff_idx = n;
					diff = fabs(array_value_db - x);
				}