It’s taken three months, but I’ve finally finished my little learning exercise in C/Ncurses. It is probably at about the level of complexity and sophistication that a non-computing student would achieve at the first year of university - if I recall correctly from when we learnt Pascal. Which just goes to show that a) I don’t have a lot of time and, more sadly, b) I’m just not as clever as I wish. However, it supports my general aim to be mediocre in as many languages as possible rather than to excel in one.
It is interesting though as you can see how it evolved from the menu_scroll.c
from which it was based on and follow along as I make some brilliant mistakes. I blame the lack of sleep.
I’ve learnt a fair few things though:
- What Macros are - which I think some distant part of my mind was aware of.
- About Pointers - I seem to have leapt straight in the deep end with pointers to pointers, got utterly confused with variable pointers and didn’t even try to understand function pointers.
- A neat substring trick.
- Using GDB to debug - As long as you remember to compile with debug symbols, this is mega useful. Also using Ncurses itself to debug can be handy.
Anyway, on to how it works (and what it does!). It is basically a little exposure calculator, but is menu driven (just because I wanted it to be).
- You select the EV value (you are constrained to selecting this first).
- Once that is selected you are moved to the ISO menu.
- With that selected you can then make a choice between Aperture and Shutter speed.
- Whichever is picked then triggers setting the other to the correct value.
- The process then repeats.
It works off actual exposure equations and then searches for the nearest value in the menu. It also attempts to indicate over or under exposure if the calculated value is smaller/greater than value that comes after minimum/maximum values in the menus. That bit could probably do with some tweaking to indicate under/over exposure sooner, but it’s not like I’m actually expecting anyone to use it (what use is a console based exposure calculator?!) - this was just written for fun and learning (and to some how kid myself that I’ve managed to do something photography related this year). Apart from not being able to DRY up the window and menu creation as much as I hoped (I think that might just be a Ncurses limitation), there’s just one little glitch I’d like to fix on the menu highlighting of the “calculated” value, which sometimes leaves two values highlighted. I’ve tried to fix it, but it hasn’t worked.