pganssle/Magnetometer-Controller — Issue #9: Function implementation
Author: pganssle
Created: 2012-01-25 02:18:56+00:00
State: open
Labels: Features, File IO, Medium Priority, UI

I've done some of the ground work for this, but much more work needs to be done to implement functions (i.e. pre-set instructions or sets of instructions that can be re-used.

I have the conception that we should probably build a custom function such that when one of the custom functions is selected, the LED array disappears and is replaced by a few input boxes, labeled with the function inputs. The function-builder then would look exactly like the normal "create program" dialog, but you'd have the ability in a sidebar to create variables.

The simplest functions would be things like "x pulse", which take a variable that would be converted to a pulse. The function panel itself would look like a single instruction with the specified x LED lit, and in the duration box you would write 200us*f, if you had calibrated an x-pulse as being 200us. Then in a side panel, you'd add a variable "f". In the main screen, the user would then select "function" where they want the x-pulse to go, and enter 0.5 in the box for "f", if they want a 90 pulse. Since it's doing math-evaulation, you could also imagine that you could enter it as 200us*f + 1us*f^2, etc, to compensate for pulse imperfections.

To this point, the implementation is actually easier than it sounds. I've already written a math-evaluation library (MathLib.c/.h), and most of the UI elements can be re-used.

####The tough part
The toughest part of all of this will be creating a robust way to save these functions as part of the pulse programs. You want to save only the functions that you actually need, and since this is C and not java you can't use a hash with a key to refer to these things, so we'll be iterating over loops checking strings for a match. You want to make sure a copy of each function is saved in the .tdm pulse program file, but it is **very important** that this only be used when the function cannot be found at all. Otherwise it defeats the purpose of being able to update a configuration and still use the same pulse programs.