exposurses

Check-in [946bdcbbb6]
Login

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

Overview
Comment:Clean up comments
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 946bdcbbb6d5631c051e8828941384c5d284bd4c6f73ef6f71f9316e9f87d853
User & Date: base@atomicules.co.uk 2013-09-18 12:49:38
Context
2013-09-18
12:51
I never noticed it originated in DOS format. Poop check-in: 0b2d1fbf49 user: base@atomicules.co.uk tags: origin/master, trunk
12:49
Clean up comments check-in: 946bdcbbb6 user: base@atomicules.co.uk tags: origin/master, trunk
12:49
Split out ITEM creation into separate func so can clean on exit I still hadn't got things quite right from when I'd split out the menu and window creation functions. The segfault on exit was due to the item pointers I thought existed not actually existing. Need to make sure they exist as expected as otherwise I can't free up the memory, etc. Yay, pretty much done. check-in: d39151ac51 user: base@atomicules.co.uk tags: origin/master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to exposurses.c.

161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
...
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
...
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
...
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
...
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442

443
444
445
446
447
448
449
450
...
459
460
461
462
463
464
465

466
467
468
469
470
471
472
473
	post_menu(aperture_menu);
	wrefresh(exposure_win);
	wrefresh(iso_win);
	wrefresh(shutter_win);
	wrefresh(aperture_win);
	attron(COLOR_PAIR(2));
	mvprintw(LINES - 2, 0, "Select EV");
	/*mvprintw(LINES - 2, 0, "Select ISO and then one of Shutter/Aperture to calculate other of Shutter/Aperture");*/
	mvprintw(LINES - 1, 0, "Arrow keys to navigate, Enter to select, Q to exit");
	attroff(COLOR_PAIR(2));
	refresh();

	/* set default menu */
	menu = &exposure_menu;
	win = &exposure_win;

	while((c = getch()) != 81) { /* 81 is Q */
		switch(c) {
			case KEY_LEFT:
				if (selection_counter > 2) {
................................................................................
				break;
			case 10: { /* ENTER */
				ITEM *cur;
				void (*p)(char *);

				cur = current_item(*menu);
				p = item_userptr(cur);
				/* Learning notes - Don't understand this bit */
				/* Is this a function pointer? */
				p((char *)item_name(cur));
				/* need to igore over/under if selected, probably easier than try to prevent selection */
				if (!((strcmp("OVER", shutter_sel) == 0)
						|| (strcmp("UNDER", shutter_sel) == 0) 
						|| (strcmp("OVER", aperture_sel) == 0) 
						|| (strcmp("UNDER", aperture_sel) == 0))) {
					switch (selection_counter) {
						case 1: { /* Exposure selected */
							selection_counter += 1;
................................................................................
										n_aperture
									)]
								);
								menu_driver(aperture_menu, REQ_DOWN_ITEM);
								menu_driver(aperture_menu, REQ_UP_ITEM);
								wrefresh(aperture_win);
							}
							/* clear the selections for next time */
							strcpy(iso_sel, "");
							strcpy(shutter_sel, "");
							strcpy(aperture_sel, "");
							/* And set defaults back to start */
							selection_counter = 1;
							menu_counter = 1;
							menu = &exposure_menu;
................................................................................
							clrtoeol();
							mvprintw(LINES - 2, 0, "Select EV");
							refresh();
						}
						break;
					}
				}
				/* If over/under need to clear selection so know which is blank
				 * when a proper selection is made */
				if ((strcmp("OVER", shutter_sel) == 0) || (strcmp("UNDER", shutter_sel) == 0)) {
					strcpy(shutter_sel, "");
				}
				if ((strcmp("OVER", aperture_sel) == 0) || (strcmp("UNDER", aperture_sel) == 0)) {
					strcpy(aperture_sel, "");
				}
			}
................................................................................
			break;
		case 4:
			strncpy(array_value_str, aperture_array[1]+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 */
	/* Could do from n = 3 (2 above) until != under/over
	 * but also need to do something like if diff is more than twice max/min then under/over */
	switch(menu) {
		case 3:
			for ( n = 2; n < n_array-2; ++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);
				}
			}
			/* Check if at extremities and then if under/over exposed */
			if (diff_idx == 1) {

				if (diff >= fraction_to_double(shutter_array[1])/2) { /* diff is greater than diff of next one down minus max/min */
					diff_idx = 0;
				}
			}
			if (diff_idx == n_array-3) {
				if (diff >= fraction_to_double(shutter_array[n_array-3])*2) {
					diff_idx = n_array-2;	
				}
................................................................................
					diff = fabs(array_value_db - x);
				}
			}
			/* Apertures similarly. Although progression is fiddlier.*/
			if (diff_idx == 1) {
				strncpy(array_value_str, aperture_array[1]+2, 4);
				array_value_db = strtod(array_value_str, NULL);

				if (diff >= array_value_db/sqrt(2.0)) { /* diff is greater than diff of next one down minus max/min */
					diff_idx = 0;
				}
			}
			if (diff_idx == n_array-3) {
				strncpy(array_value_str, aperture_array[n_array-3]+2, 4);
				array_value_db = strtod(array_value_str, NULL);
				if (diff >= array_value_db*sqrt(2.0)) {







<




|







 







|
<

|







 







|







 







|
<







 







|
<
<











>
|







 







>
|







161
162
163
164
165
166
167

168
169
170
171
172
173
174
175
176
177
178
179
...
197
198
199
200
201
202
203
204

205
206
207
208
209
210
211
212
213
...
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
...
279
280
281
282
283
284
285
286

287
288
289
290
291
292
293
...
419
420
421
422
423
424
425
426


427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
...
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
	post_menu(aperture_menu);
	wrefresh(exposure_win);
	wrefresh(iso_win);
	wrefresh(shutter_win);
	wrefresh(aperture_win);
	attron(COLOR_PAIR(2));
	mvprintw(LINES - 2, 0, "Select EV");

	mvprintw(LINES - 1, 0, "Arrow keys to navigate, Enter to select, Q to exit");
	attroff(COLOR_PAIR(2));
	refresh();

	/* Set default menu */
	menu = &exposure_menu;
	win = &exposure_win;

	while((c = getch()) != 81) { /* 81 is Q */
		switch(c) {
			case KEY_LEFT:
				if (selection_counter > 2) {
................................................................................
				break;
			case 10: { /* ENTER */
				ITEM *cur;
				void (*p)(char *);

				cur = current_item(*menu);
				p = item_userptr(cur);
				/* Learning notes - Don't understand this bit. Is this a function pointer? */

				p((char *)item_name(cur));
				/* Need to igore over/under if selected, probably easier than try to prevent selection */
				if (!((strcmp("OVER", shutter_sel) == 0)
						|| (strcmp("UNDER", shutter_sel) == 0) 
						|| (strcmp("OVER", aperture_sel) == 0) 
						|| (strcmp("UNDER", aperture_sel) == 0))) {
					switch (selection_counter) {
						case 1: { /* Exposure selected */
							selection_counter += 1;
................................................................................
										n_aperture
									)]
								);
								menu_driver(aperture_menu, REQ_DOWN_ITEM);
								menu_driver(aperture_menu, REQ_UP_ITEM);
								wrefresh(aperture_win);
							}
							/* Clear the selections for next time */
							strcpy(iso_sel, "");
							strcpy(shutter_sel, "");
							strcpy(aperture_sel, "");
							/* And set defaults back to start */
							selection_counter = 1;
							menu_counter = 1;
							menu = &exposure_menu;
................................................................................
							clrtoeol();
							mvprintw(LINES - 2, 0, "Select EV");
							refresh();
						}
						break;
					}
				}
				/* If over/under need to clear selection so know which is blank when a proper selection is made */

				if ((strcmp("OVER", shutter_sel) == 0) || (strcmp("UNDER", shutter_sel) == 0)) {
					strcpy(shutter_sel, "");
				}
				if ((strcmp("OVER", aperture_sel) == 0) || (strcmp("UNDER", aperture_sel) == 0)) {
					strcpy(aperture_sel, "");
				}
			}
................................................................................
			break;
		case 4:
			strncpy(array_value_str, aperture_array[1]+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 = 2; n < n_array-2; ++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);
				}
			}
			/* Check if at extremities and then if under/over exposed */
			if (diff_idx == 1) {
				if (diff >= fraction_to_double(shutter_array[1])/2) { 
					/* diff is greater than diff of next one down minus max/min */
					diff_idx = 0;
				}
			}
			if (diff_idx == n_array-3) {
				if (diff >= fraction_to_double(shutter_array[n_array-3])*2) {
					diff_idx = n_array-2;	
				}
................................................................................
					diff = fabs(array_value_db - x);
				}
			}
			/* Apertures similarly. Although progression is fiddlier.*/
			if (diff_idx == 1) {
				strncpy(array_value_str, aperture_array[1]+2, 4);
				array_value_db = strtod(array_value_str, NULL);
				if (diff >= array_value_db/sqrt(2.0)) {
					/* diff is greater than diff of next one down minus max/min */
					diff_idx = 0;
				}
			}
			if (diff_idx == n_array-3) {
				strncpy(array_value_str, aperture_array[n_array-3]+2, 4);
				array_value_db = strtod(array_value_str, NULL);
				if (diff >= array_value_db*sqrt(2.0)) {