Changes to exposurses.c.
︙ | | |
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
-
-
+
|
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 */
/* 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) {
|
︙ | | |
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
-
+
-
-
+
|
break;
case 10: { /* ENTER */
ITEM *cur;
void (*p)(char *);
cur = current_item(*menu);
p = item_userptr(cur);
/* Learning notes - Don't understand this bit */
/* Learning notes - Don't understand this bit. Is this a function pointer? */
/* Is this a function pointer? */
p((char *)item_name(cur));
/* need to igore over/under if selected, probably easier than try to prevent selection */
/* 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;
|
︙ | | |
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
|
-
+
-
+
-
|
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 */
/* 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;
win = &exposure_win;
move(LINES - 2, 0);
clrtoeol();
mvprintw(LINES - 2, 0, "Select EV");
refresh();
}
break;
}
}
/* If over/under need to clear selection so know which is blank
/* If over/under need to clear selection so know which is blank when a proper selection is made */
* 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, "");
}
}
|
︙ | | |
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
|
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
|
-
+
-
-
-
+
+
|
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 */
/* 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 */
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;
}
|
︙ | | |
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
|
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
|
-
+
+
|
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 */
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)) {
|
︙ | | |