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

Changes to exposurses.c.

   161    161   	post_menu(aperture_menu);
   162    162   	wrefresh(exposure_win);
   163    163   	wrefresh(iso_win);
   164    164   	wrefresh(shutter_win);
   165    165   	wrefresh(aperture_win);
   166    166   	attron(COLOR_PAIR(2));
   167    167   	mvprintw(LINES - 2, 0, "Select EV");
   168         -	/*mvprintw(LINES - 2, 0, "Select ISO and then one of Shutter/Aperture to calculate other of Shutter/Aperture");*/
   169    168   	mvprintw(LINES - 1, 0, "Arrow keys to navigate, Enter to select, Q to exit");
   170    169   	attroff(COLOR_PAIR(2));
   171    170   	refresh();
   172    171   
   173         -	/* set default menu */
          172  +	/* Set default menu */
   174    173   	menu = &exposure_menu;
   175    174   	win = &exposure_win;
   176    175   
   177    176   	while((c = getch()) != 81) { /* 81 is Q */
   178    177   		switch(c) {
   179    178   			case KEY_LEFT:
   180    179   				if (selection_counter > 2) {
................................................................................
   198    197   				break;
   199    198   			case 10: { /* ENTER */
   200    199   				ITEM *cur;
   201    200   				void (*p)(char *);
   202    201   
   203    202   				cur = current_item(*menu);
   204    203   				p = item_userptr(cur);
   205         -				/* Learning notes - Don't understand this bit */
   206         -				/* Is this a function pointer? */
          204  +				/* Learning notes - Don't understand this bit. Is this a function pointer? */
   207    205   				p((char *)item_name(cur));
   208         -				/* need to igore over/under if selected, probably easier than try to prevent selection */
          206  +				/* Need to igore over/under if selected, probably easier than try to prevent selection */
   209    207   				if (!((strcmp("OVER", shutter_sel) == 0)
   210    208   						|| (strcmp("UNDER", shutter_sel) == 0) 
   211    209   						|| (strcmp("OVER", aperture_sel) == 0) 
   212    210   						|| (strcmp("UNDER", aperture_sel) == 0))) {
   213    211   					switch (selection_counter) {
   214    212   						case 1: { /* Exposure selected */
   215    213   							selection_counter += 1;
................................................................................
   264    262   										n_aperture
   265    263   									)]
   266    264   								);
   267    265   								menu_driver(aperture_menu, REQ_DOWN_ITEM);
   268    266   								menu_driver(aperture_menu, REQ_UP_ITEM);
   269    267   								wrefresh(aperture_win);
   270    268   							}
   271         -							/* clear the selections for next time */
          269  +							/* Clear the selections for next time */
   272    270   							strcpy(iso_sel, "");
   273    271   							strcpy(shutter_sel, "");
   274    272   							strcpy(aperture_sel, "");
   275    273   							/* And set defaults back to start */
   276    274   							selection_counter = 1;
   277    275   							menu_counter = 1;
   278    276   							menu = &exposure_menu;
................................................................................
   281    279   							clrtoeol();
   282    280   							mvprintw(LINES - 2, 0, "Select EV");
   283    281   							refresh();
   284    282   						}
   285    283   						break;
   286    284   					}
   287    285   				}
   288         -				/* If over/under need to clear selection so know which is blank
   289         -				 * when a proper selection is made */
          286  +				/* If over/under need to clear selection so know which is blank when a proper selection is made */
   290    287   				if ((strcmp("OVER", shutter_sel) == 0) || (strcmp("UNDER", shutter_sel) == 0)) {
   291    288   					strcpy(shutter_sel, "");
   292    289   				}
   293    290   				if ((strcmp("OVER", aperture_sel) == 0) || (strcmp("UNDER", aperture_sel) == 0)) {
   294    291   					strcpy(aperture_sel, "");
   295    292   				}
   296    293   			}
................................................................................
   422    419   			break;
   423    420   		case 4:
   424    421   			strncpy(array_value_str, aperture_array[1]+2, 4);
   425    422   			array_value_db = strtod(array_value_str, NULL);
   426    423   			break;
   427    424   	}
   428    425   	diff = fabs(array_value_db - x);
   429         -	/* lots of repetition here but pointers to arrays seem to be a bad thing */
   430         -	/* Could do from n = 3 (2 above) until != under/over
   431         -	 * but also need to do something like if diff is more than twice max/min then under/over */
          426  +	/* Lots of repetition here but pointers to arrays seem to be a bad thing */
   432    427   	switch(menu) {
   433    428   		case 3:
   434    429   			for ( n = 2; n < n_array-2; ++n ) {
   435    430   				array_value_db = fraction_to_double(shutter_array[n]);
   436    431   				if (fabs(array_value_db - x) < diff) {
   437    432   					diff_idx = n;
   438    433   					diff = fabs(array_value_db - x);
   439    434   				}
   440    435   			}
   441    436   			/* Check if at extremities and then if under/over exposed */
   442    437   			if (diff_idx == 1) {
   443         -				if (diff >= fraction_to_double(shutter_array[1])/2) { /* diff is greater than diff of next one down minus max/min */
          438  +				if (diff >= fraction_to_double(shutter_array[1])/2) { 
          439  +					/* diff is greater than diff of next one down minus max/min */
   444    440   					diff_idx = 0;
   445    441   				}
   446    442   			}
   447    443   			if (diff_idx == n_array-3) {
   448    444   				if (diff >= fraction_to_double(shutter_array[n_array-3])*2) {
   449    445   					diff_idx = n_array-2;	
   450    446   				}
................................................................................
   459    455   					diff = fabs(array_value_db - x);
   460    456   				}
   461    457   			}
   462    458   			/* Apertures similarly. Although progression is fiddlier.*/
   463    459   			if (diff_idx == 1) {
   464    460   				strncpy(array_value_str, aperture_array[1]+2, 4);
   465    461   				array_value_db = strtod(array_value_str, NULL);
   466         -				if (diff >= array_value_db/sqrt(2.0)) { /* diff is greater than diff of next one down minus max/min */
          462  +				if (diff >= array_value_db/sqrt(2.0)) {
          463  +					/* diff is greater than diff of next one down minus max/min */
   467    464   					diff_idx = 0;
   468    465   				}
   469    466   			}
   470    467   			if (diff_idx == n_array-3) {
   471    468   				strncpy(array_value_str, aperture_array[n_array-3]+2, 4);
   472    469   				array_value_db = strtod(array_value_str, NULL);
   473    470   				if (diff >= array_value_db*sqrt(2.0)) {