193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
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
256
257
258
259
260
261
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
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
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));
switch (selection_counter) {
case 1: { /* Exposure selected */
selection_counter += 1;
menu_counter += 1;
move(LINES - 2, 0);
clrtoeol();
mvprintw(LINES - 2, 0, "Select ISO");
refresh();
menu = &iso_menu;
win = &iso_win;
}
break;
case 2: { /* ISO Selected */
selection_counter += 1;
menu_counter += 1;
move(LINES - 2, 0);
clrtoeol();
mvprintw(LINES - 2, 0, "Select Shutter or Aperture");
refresh();
menu = &shutter_menu;
win = &shutter_win;
}
break;
case 3: { /* Shutter or Aperture selected */
if (strcmp("", shutter_sel) == 0) {
char aperture_sel_[4] = "";
strncpy(aperture_sel_, aperture_sel+2, 3);
/* Using menu_driver to go up/down to force refresh and correct highlighting */
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,
n_shutter
)]
);
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,
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;
win = &exposure_win;
move(LINES - 2, 0);
clrtoeol();
mvprintw(LINES - 2, 0, "Select EV");
refresh();
}
break;
/* 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;
menu_counter += 1;
move(LINES - 2, 0);
clrtoeol();
mvprintw(LINES - 2, 0, "Select ISO");
refresh();
menu = &iso_menu;
win = &iso_win;
}
break;
case 2: { /* ISO Selected */
selection_counter += 1;
menu_counter += 1;
move(LINES - 2, 0);
clrtoeol();
mvprintw(LINES - 2, 0, "Select Shutter or Aperture");
refresh();
menu = &shutter_menu;
win = &shutter_win;
}
break;
case 3: { /* Shutter or Aperture selected */
if (strcmp("", shutter_sel) == 0) {
char aperture_sel_[4] = "";
strncpy(aperture_sel_, aperture_sel+2, 3);
/* Using menu_driver to go up/down to force refresh and correct highlighting */
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,
n_shutter
)]
);
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,
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;
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
* 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;
}
wrefresh(*win);
}
/* Unpost and free all the memory taken up */
|