
State 1 (stfDef): Opens database and loads longitude,
latitude, and GMSTNoon. It then ensures that the currently
selected object is valid and loads it's RA and DEC. It also
displays the objects symbol and name and loads it's text message into a
buffer for later display.


State 5 (stfLMST): Gets the current time from the
watch. Calculates #minutes since midnight. Converts this to
a floating point number. Subtracts 720 minutes (12*60) to get
#minutes since noon (can be negative). Multiplies by 1.0028 to
convert to sidereal minutes. Multiplies by 0.25 (360/(24*60)=1/4)
to convert minutes to degrees. Adds GMSTNoon. Subtract
longitude. Now have LMST (local mean sidereal time)! Then,
subracts RA of object to get the HA (hour angle) of the object.


State 6 (stfSinCos): This state has the code to do Sine and
Cosine of an angle. First calculates and stores sin(HA) so we can
later tell if object is east or west. Then, calculates
cos(HA), cos(LAT), cos(DEC), sin(LAT), sin(DEC) and stores all these for
later.


State 7 (stfZenith): This state calculates the cosine of the
objects zenith and azimuth angles it has square root code to get cos(alt)
from cos(zenith). Uses cos(zenith)=sin(dec)*sin(lat)+cos(dec)*cos(lat)*cos(HA).
To calculate cos(azimuth), first does cos(alt)=sqrt(1cos(zenith)^2).
Then, does cos(azimuth)=(sin(dec)*cos(lat)+cos(dec)*sin(lat)*cos(HA))/cos(alt).
Then does sin(azimuth)=sin(HA)*cos(DEC)/cos(alt).


State 9 (stfAcos): Takes first step toward calculating the
inverse cosine
of cos(altitude) and cos(azimuth) by doing the x/sqrt(1x*x) part.
This state also has square root code.


State 10: (stfATN): Finishes up calculating altitude and
azimuth angles by doing the pi/2arctangent(x) part of the calculation
started in state 9. This state is taken up by a lot of code to do
the arctangent function.


State 11: (stfPlot): This state plots the position in
the polar display and writes the azimuth and elevation angles to the
screen. First, it makes sure elevation (AKA altitude) is <90
degrees. If bigger, we subtract 180 and show it as negative.
Then we calculate the polar position via: x=9+8*(zenith/90)*sin(azimuth),
y=65*(zenith/90)*cos(azim) and converts x and y to an integer. We
then convert azimuth angle to an integer and correct for sign (if sin(HA)
is positive then azimuth=360azimuth) and show on line 1. Then
calculate Altitude=90Zenith and show on line2.


State 8: (stfShowing): This state just prints "A:" and
"E:" on the screen for azimuth and elevation and blinks the star
location on the chart. It also shows the object's message if user
pushes the start button. If the user rotates the crown, the
current object number is incremented and we go back to state 1.


Another state (State 4: stfShowY) is used only for debugging,
not in application.
