Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add under/over exposure indication in |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | temp |
Files: | files | file ages | folders |
SHA3-256: |
216708513b4cb8368aae0f372602d797 |
User & Date: | base@atomicules.co.uk 2013-09-15 17:22:07 |
Context
2013-09-15
| ||
21:25 | Ignore selection of OVER/UNDER check-in: d4b0749e89 user: base@atomicules.co.uk tags: temp, trunk | |
17:22 | Add under/over exposure indication in check-in: 216708513b user: base@atomicules.co.uk tags: temp, trunk | |
2013-09-13
| ||
09:31 | Fix menu numbering (from adding exposure menu in) check-in: b12e9bb5c7 user: base@atomicules.co.uk tags: temp, trunk | |
Changes
Changes to exposurses.c.
︙ | ︙ | |||
28 29 30 31 32 33 34 | "10", "11", "12", "13", "14", "15", "16", | < < > | > < > | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | "10", "11", "12", "13", "14", "15", "16", }; char *iso_array[] = { "50", "100", "200", "400", "800", "1600", "3200", }; char *shutter_array[] = { "OVER", "1/1000", "1/500", "1/250", "1/125", "1/60", "1/30", "1/15", "1/8", "1/4", "1/2", "1", "UNDER", }; char *aperture_array[] = { "UNDER", "f/1.4", "f/2", "f/2.8", "f/4", "f/5.6", "f/8", "f/11", "f/16", "OVER", }; ITEM **exposure_items; ITEM **iso_items; ITEM **shutter_items; ITEM **aperture_items; MENU *exposure_menu; |
︙ | ︙ | |||
90 91 92 93 94 95 96 | void remove_menu(ITEM **items, MENU *men, int n); void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color); MENU *add_menu(char **array, ITEM **items, int n); WINDOW *add_window(int xpos, char *title); int exposure(int iso); double shutter(int exposure, double aperture); double aperture(int exposure, double shutter); | | | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | void remove_menu(ITEM **items, MENU *men, int n); void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color); MENU *add_menu(char **array, ITEM **items, int n); WINDOW *add_window(int xpos, char *title); int exposure(int iso); double shutter(int exposure, double aperture); double aperture(int exposure, double shutter); int nearest_match(double x, int menu, int n_array); double fraction_to_double(char *fraction); /* No one will ever need more than 9 bytes! */ char exposure_sel[9] = ""; char iso_sel[9] = ""; char shutter_sel[9] = ""; char aperture_sel[9] = ""; int selection_counter = 1; |
︙ | ︙ | |||
229 230 231 232 233 234 235 | 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)), | | > | > | 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 | 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 */ |
︙ | ︙ | |||
372 373 374 375 376 377 378 | } double aperture (int exposure, double shutter) { /* EV = log2 (N^2/t) */ return sqrt(pow(2, exposure) * shutter); } | | | | | > > | > > > > > > > > > > > | > > > > > > > > > > > > > > > > | 374 375 376 377 378 379 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 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 | } double aperture (int exposure, double shutter) { /* EV = log2 (N^2/t) */ return sqrt(pow(2, exposure) * shutter); } int nearest_match (double x, int menu, int n_array) { /* Need to search array for closest match */ int n; int diff_idx = 1; 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[1]); 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-1; ++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-2) { if (diff >= fraction_to_double(shutter_array[n_array-2])*2) { diff_idx = n_array-1; } } break; case 4: for ( n = 2; n < n_array-1; ++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); } } /* 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-2) { strncpy(array_value_str, aperture_array[n_array-2]+2, 4); array_value_db = strtod(array_value_str, NULL); if (diff >= array_value_db*sqrt(2.0)) { diff_idx = n_array-1; } } break; } return diff_idx; } double fraction_to_double(char *fraction) { double fraction_as_db; |
︙ | ︙ |