(Comp.sys.handhelds) Item: 2951 by elliott at veronica.cs.wisc.edu Author: [James Elliott] Subj: A Sun Clock for the HP 48sx Date: Sun Apr 28 1991 I've had my HP 48sx for a month now, and it seemed like time to write a sizable program for it, just to achieve a sense of proper ownership. Actually, a better explanation for my motivation involves the fact that I have a lot of icky class projects coming due and I need better and better distractions from that ugly realization... One of my all-time favorite UNIX workstation programs is called "sunclock", and it shows the regions of the Earth which are in daylight by drawing the sunlight on a Mercator projection map of the globe. It seemed to me that it was a moral imperative that my calculator should be able to do this too. So, Wednesday night I set about re-writing the program in RPL. On Thursday night I had a working version; since then I've come up with a set of improvements to make it need less room, update faster, and generally work well in its new HP handheld environment. So here is an HP version of sunclock! I'm posting both an ASCII version, and a uuencoded binary version. The ASCII one has been commented, the binary is faster to download. SunClk is a directory which contains all the programs and variables needed to implement the program. When you go into the directory, you'll see a menu with "NOW", "THEN", "HELP", "ABOUT" and "TZ" as the first five entries. The first thing you should do is set TZ to the difference between your current time zone and UTC. For example, I am presently in CDT, U.S. Central Daylight savings Time. That's five hours west of Greenwich, so I store -5 in TZ. HELP gives you brief help about the package, ABOUT gives credits for various aspects of its design and implementation. Pressing "NOW" will draw the state of the Earth as it is the moment you press the button. This will take about a minute the first time, since it will probably have to compute the daylight widths from scratch. However, subsequent runs will be a lot faster, until the sun's declination changes enough to force a recomputation. Once the first map display is complete, it will be updated roughly once every ten seconds (taking longer if changes need to be made). To end the program, hit any key other than ON/ATTN. In a few seconds it will notice the keypress, stop whatever it is doing, and clean up after itself before exiting (so you don't get garbage in your variable menu). If you accidentally hit ON, you can manually purge the variables that are before "NOW" in the menu. Or, they'll be cleaned up on the next run. Pressing "THEN" will let you specify a particular date and time for which you'd like to see the daylight pattern. It has an interface that is very similar to the setting of an alarm; you edit the date and time presented by entering numbers and hitting ">DATE", ">TIME" or "A/PM". Partial dates are defaulted to the displayed day/year. Once you've entered the time you'd like to see, press "GO", and the map will be displayed. This is probably going to take about a minute, since the sun will likely be in a very different place from the last computation performed. Once the map is drawn, the program will terminate. (There is no updating to do, since you've requested just one time to view.) Again, if you want to interrupt the program before it draws or finishes the map, you can press any key other than ON/ATTN and it will stop shortly. Of particular viewing interest this year are March 20 and September 23 (the first days of spring and of autumn, respectively). If you have the ticking clock display enabled (system flag -40, or "CLK" on the second page of the "MODES" menu) the current date and time will be drawn at the bottom of the map on each update. Around the transitions between summer and winter, it will probably be difficult to read, because the terminator boundaries will fall right in the middle of the text. Anyway, I think it's a lot of fun, I hope other people enjoy it too. Let me know if you like it!