[comp.sys.handhelds] A Clock Program

jodell@hpcupt1.HP.COM (Jamie Odell) (07/12/90)

I'm posting this for a friend who cannot post to notes....
----------------------------------------------------------
 
The following programs display a running analog clock (with a second hand).
Put all of these routines in the same directory and execute CLOK.  The clock
face came from Matt Squire's original analog clock program posted in
comp.sys.handhelds on USENET News.
 
Enjoy!
 
--
| Pete Stoppani          | stoppani@decwet.dec.com                   |
|  DECwest Engineering   | decwrl!slough.enet!stoppani               |
|  Bellevue, WA          | HPDESK: stoppani("decwet.dec.com")/hpunix |
| "The wise learn more from fools than fools learn from the wise."   |
 
-------------------------------------------------------------------------------
 
@ CLOK - main clock program
%%HP: T(3)A(D)F(.);
\<<
  RCLF -16 SF -17 CF -18 CF -19 SF ERASE 'PPAR' PURGE
  PICT { # 34d # 1d } FACE GOR { # 0d # 0d } PVIEW
  GET.TMS \-> pt pm ps
  \<<
    pt HR.HND pm MIN.HND ps SEC.HND
    1 WAIT
    DO
      GET.TMS \-> t m s
      \<<
        IF 's\=/ps'
        THEN ps SEC.HND s SEC.HND s 'ps' STO
        END
        IF 'm\=/pm'
        THEN
          IF 'm MOD 12==0'
          THEN pt HR.HND t HR.HND t 'pt' STO
          END
          pm MIN.HND m MIN.HND m 'pm' STO
        END
      \>>
    UNTIL KEY
    END DROP STOF 'PPAR' PURGE
  \>>
\>>
 
@ GET.TMS - time, minutes and seconds
%%HP: T(3)A(D)F(.);
\<<
  TIME DUP FP 100 * DUP IP SWAP FP 100 * IP
\>>
 
@ HR.HND - draw the hour hand
%%HP: T(3)A(D)F(.);
\<<
  1.55 SWAP HMS\-> 12 MOD 30 * NEG 90 + \->V2 (0,0) SWAP TLINE
\>>
 
@ MIN.HND - draw the minute hand
%%HP: T(3)A(D)F(.);
\<<
  2.5 SWAP 60 / 360 * NEG 90 + \->V2 (0,0) TLINE
\>>
 
@ SEC.HND - draw the second hand
%%HP: T(3)A(D)F(.);
\<<
  60 / 360 * NEG 90 + \-> d
  \<<
    2.3 d \->V2 2.7 d \->V2 TLINE
  \>>
\>>
 
@ FACE - the clock face GROB
%%HP: T(3)A(D)F(.);
GROB 63 63
000000CFF100000000000C380E1000000000830800E00000000060080003000000081000
000C000000041000000410000002200000042000008120000002C0000040000000000100
002000000000020000100000000004000800000000000800080000000000080004000000
000000100200000000000020010000000000004003000000000000608C00000000000890
800000000000008040000000000000014000000000000001400000000000000120000000
000000022000000000000002200000000000000220000000000000021000000000000004
100000000000000410000000000000041000000E300000041000000220000004F0000002
2000008710000002200000041000000E3000000410000000000000041000000000000004
100000000000000420000000000000022000000000000002200000000000000220000000
000000024000000000000001400000000000000140000000000000018000000000000080
880000000000088007000000000000700100000000000040020000000000002004000000
000000100800000000000800080000000000080000100000000004000020000000000200
0040000000000100008120000002C0000002200000042000000410000004100000081000
000C000000006008000300000000830800E0000000000C380E100000000000CFF1000000

steveh@hpcvra.CV.HP.COM (Steve Harper) (07/17/90)

I too had problems trying to download the grob....
Turns out the size of the grob and the number of hex chars
after it don't agree....
If you change the "grob 63 63" to "grob 63 64" you will
have better luck.
However, the hex chars can't have any embedded line feeds,
either, that is, the entire grob must be a single line as
far as the 48 is concerned.  I editted out the end-lines
before I downloaded to my 48.
After these two fixes, no prob...

Steve

rayde@hpcvia.CV.HP.COM (ray_depew) (07/17/90)

I think you have to get into the text file (on your big computer) and
remove any CR/LF's at the end of the lines.  A grob is just a big string 
of hex digits, like

     GROB 21 8 0000000000000.....

and when you upload/download on some systems, the terminal emulator does
you the favor of braking up the string into 75- or 80-character lines.
Some favor, huh?

Try that; it should work fine for you.

Regards
Ray Depew
rayde@hpcvia.CV.HP.COM
HP InkJet Components Operation