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 Side-by-Side Diffs Show Whitespace Changes Patch

Changes to exposurses.c.

   133    133   	iso_menu = add_menu(iso_array, iso_items, n_iso);
   134    134   	shutter_menu = add_menu(shutter_array, shutter_items, n_shutter);
   135    135   	aperture_menu = add_menu(aperture_array, aperture_items, n_aperture);
   136    136   	exposure_win = add_window(4, "EV");
   137    137   	iso_win = add_window(45, "ISO");
   138    138   	shutter_win = add_window(86, "Shutter");
   139    139   	aperture_win = add_window(127, "Aperture");
          140  +	/* Don't know how to avoid the repition below */
   140    141   	set_menu_win(exposure_menu, exposure_win);
   141    142   	set_menu_win(iso_menu, iso_win);
   142    143   	set_menu_win(shutter_menu, shutter_win);
   143    144   	set_menu_win(aperture_menu, aperture_win);
   144    145   	set_menu_sub(exposure_menu, derwin(exposure_win, 6, 38, 3, 1));
   145    146   	set_menu_sub(iso_menu, derwin(iso_win, 6, 38, 3, 1));
   146    147   	set_menu_sub(shutter_menu, derwin(shutter_win, 6, 38, 3, 1));
................................................................................
   227    228   							menu_driver(shutter_menu, REQ_SCR_UPAGE);
   228    229   							menu_driver(shutter_menu, REQ_SCR_DPAGE);
   229    230   							/* There is probably a nicer way to format the below */
   230    231   							set_menu_pattern(
   231    232   								shutter_menu,
   232    233   								shutter_array[nearest_match(
   233    234   									shutter(exposure(atoi(iso_sel)), strtod(aperture_sel_, NULL)),
   234         -									2
          235  +									3
   235    236   								)]
   236    237   							);
   237    238   							menu_driver(shutter_menu, REQ_DOWN_ITEM);
   238    239   							menu_driver(shutter_menu, REQ_UP_ITEM);
   239    240   							wrefresh(shutter_win);
   240    241   						}
   241    242   						if (strcmp("", aperture_sel) == 0) {
   242    243   							menu_driver(aperture_menu, REQ_SCR_UPAGE);
   243    244   							menu_driver(aperture_menu, REQ_SCR_DPAGE);
   244    245   							set_menu_pattern(
   245    246   								aperture_menu,
   246    247   								aperture_array[nearest_match(
   247    248   									aperture(exposure(atoi(iso_sel)), fraction_to_double(shutter_sel)),
   248         -									3
          249  +									4
   249    250   								)]
   250    251   							);
   251    252   							menu_driver(aperture_menu, REQ_DOWN_ITEM);
   252    253   							menu_driver(aperture_menu, REQ_UP_ITEM);
   253    254   							wrefresh(aperture_win);
   254    255   						}
   255    256   						/* clear the selections for next time */
................................................................................
   380    381   	int diff_idx = 0;
   381    382   	char array_value_str[9];
   382    383   	double array_value_db;
   383    384   	double diff;
   384    385   
   385    386   	/* Need a starting value for difference */
   386    387   	switch(menu) {
   387         -		case 1:
   388         -			array_value_db = strtod(iso_array[0], NULL);
   389         -			break;
   390         -		case 2:
          388  +		case 3:
   391    389   			array_value_db = fraction_to_double(shutter_array[0]);
   392    390   			break;
   393         -		case 3:
          391  +		case 4:
   394    392   			strncpy(array_value_str, aperture_array[0]+2, 4);
   395    393   			array_value_db = strtod(array_value_str, NULL);
   396    394   			break;
   397    395   	}
   398    396   	diff = fabs(array_value_db - x);
   399    397   	/* lots of repetition here but pointers to arrays seem to be a bad thing */
   400    398   	switch(menu) {
   401         -		case 1:
   402         -			for ( n = 1; iso_array[n] != NULL; ++n ) {
   403         -				array_value_db = strtod(iso_array[n], NULL);
   404         -				if (fabs(array_value_db - x) < diff) { 
   405         -					diff_idx = n;
   406         -					diff = fabs(array_value_db - x);
   407         -				}
   408         -			}
   409         -			break;
   410         -		case 2:
          399  +		case 3:
   411    400   			for ( n = 1; shutter_array[n] != NULL; ++n ) {
   412    401   				array_value_db = fraction_to_double(shutter_array[n]);
   413    402   				if (fabs(array_value_db - x) < diff) {
   414    403   					diff_idx = n;
   415    404   					diff = fabs(array_value_db - x);
   416    405   				}
   417    406   			}
   418    407   			break;
   419         -		case 3:
          408  +		case 4:
   420    409   			for ( n = 1; aperture_array[n] != NULL; ++n ) {
   421    410   				strncpy(array_value_str, aperture_array[n]+2, 4);
   422    411   				array_value_db = strtod(array_value_str, NULL);
   423    412   				if (fabs(array_value_db - x) < diff) { 
   424    413   					diff_idx = n;
   425    414   					diff = fabs(array_value_db - x);
   426    415   				}