Description
Functions were provided to sense the life ring being picked up to command a Jettison the Crew, the bell being rung to command a Suppress Mutiny, the AoC/FD button being pushed to command an Assertion of Command, the AoC/FD button being pushed to command a Free Digital Command, and the FA button being pushed to command a Free Analog Command. For the most part, these functions simply consisted of checking whether the input pin in question had been low the last time it checked and now was high, indicating a button push.
Since Assertion of Command and Free Digital Command shared a push-button, additional logic was implemented to ensure that a long button-press for Assertion of Command did not result in the system thinking that Free Digital had been activated as soon as the “Paired” state was entered. When an Assertion of Command button-press was sensed, an additional flag was set. In the Free Digital function, a button-press is only declared if the input pin is high and the additional flag from Assertion of Command is not set. Lowering that flag when Free Digital senses the lack of a button-press ensures that Free Digital is only sensed once the button has been released after entering the “Paired” state, but is sensed at all other times.
Since the Free Analog command also comes with a magnitude parameter, a function was provided to read the value of the Free Analog potentiometer and convert the reading to an integer between -100 and 100. Reading the A/D port, subtracting the midpoint for the A/D subsystem, dividing by that midpoint, and multiplying by 100 achieves this desired range.
Pseudo-Code
CrewJettison:
Set current Jettison Status to be the value of input pin AD5
If Jettison Status is high and the previous Jettison Status was not, we’ll return 1 (otherwise 0)
But, before returning, save this Jettison Status for reference next time
CheckMutinySuppression:
Set current Mutiny Status to be the value of input pin AD4
If Mutiny Status is high and the previous Mutiny Status was not, we’ll return 1 (otherwise 0)
But, before returning, save this Mutiny Status for reference next time
CheckAssertionCommand:
Set current Assertion Status to be the opposite of input pin AD6 (this button is active low)
If Assertion Status is high and the previous Assertion Status was not, we’ll return 1 (otherwise 0)
Also set an additional flag high since we share this button with Free Digital
But, before returning, save this Assertion Status for reference next time
FreeDigitalActivate:
Set current Free Digital Status to be the opposite of input pin AD6 (this button is active low)
If Free Digital Status is high and the previous Free Digital Status was not
If the additional Assertion of Command Flag was low, we’ll return 1 (otherwise 0)
Otherwise, we’ll return zero and set that additional flag low
But, before returning, save this Free Digital Status for reference next time
FreeAnalogActivate:
Set current Free Analog Status to be the opposite of input pin AD7 (this button is active low)
If Free Analog Status is high and the previous Free Analog Status was not
We’ll return 1 (otherwise 0)
But, before returning, save this Assertion Status for reference next time
GetFreeAnalogParameter:
Read analog input pin AD1
Subtract the AD midpoint, 512
Divide by the AD midpoint, 512
Multiply by 100
The number is now an integer between -100 and 100, so return it