home *** CD-ROM | disk | FTP | other *** search
- (* ------------------------------------------------------ *)
- (* UHR.PAS *)
- (* Analoguhr in Turbo-Pascal 4.0 *)
- (* (c) 1989 Michael Thom & TOOLBOX *)
- (* ------------------------------------------------------ *)
- {$R+,S+,I+,D+,F+,V+,B+,N-,L+ }
- {$M 16384,0,24576 }
-
- UNIT Uhr;
-
- INTERFACE USES Crt, Dos, Graph;
-
- PROCEDURE _Uhr;
- PROCEDURE NotAus;
-
- IMPLEMENTATION
-
- CONST
- Radius = 80;
- RadiusZurueckZeigerS = -6;
- RadiusZurueckZeigerM = -10;
- RadiusZurueckZeigerH = -8;
- BreiteZeigerM = 14;
- BreiteZeigerH = 16;
-
- VAR
- Original, Grafik : POINTER;
- ch : CHAR;
- WinkelZeigerS,
- WinkelZeigerM,
- WinkelZeigerH,
- MitteX, MitteY,
- Gr, Mo, std, min : INTEGER;
- Std1, Min1,
- Sek1, Hun1,
- Std2, Min2,
- sek2, hun2,
- AspX, AspY, gross : WORD;
- Zaehler : REAL;
- AlarmGesetzt : BOOLEAN;
-
- {$F+}
- Procedure CgaDriver; EXTERNAL;
- {$L CGA.OBJ}
- {$F-}
-
- PROCEDURE Fehler;
- BEGIN
- WriteLn('Es ist ein Fehler aufgetreten: ', GraphResult);
- Halt(0);
- END;
-
- PROCEDURE Adressermittlung;
- BEGIN
- IF RegisterBGIdriver(Addr(CgaDriver)) < 0 THEN Fehler;
- END;
-
- PROCEDURE ZaehleZeitZu;
- BEGIN
- IF std1 > 24 THEN Std1 := Std1 - 24;
- Inc(Sek1);
- IF Sek1 > 59 THEN BEGIN
- Inc(Min1);
- Sek1 := 0;
- IF Min1 > 59 THEN BEGIN
- Inc(Std1);
- Min1 := 0;
- END;
- END;
- END;
-
- {$F+}
- PROCEDURE Verzweigung; INTERRUPT;
- BEGIN
- Zaehler := Zaehler + 1.000033333;
- { Zeitausgleich für Bearbeitungszeit }
- END;
- {$F-}
-
- {$F+}
- PROCEDURE ZeitVergleich; INTERRUPT;
- VAR i : INTEGER;
- BEGIN
- IF Zaehler > 18.2 THEN BEGIN
- ZaehleZeitZu;
- Zaehler := Zaehler - 18.2;
- END;
- IF (std2 = std1) AND (min2 = min1) THEN BEGIN
- GotoXY(50,1);
- Write('Die Alarmzeit ist erreicht !!!');
- SetIntVec($1c, Original);
- FOR i := 1 TO 4 DO BEGIN
- Sound(440); Delay(100);
- Sound(880); Delay(100);
- END;
- NoSound;
- END;
- Zaehler := Zaehler + 1.000033333;
- END;
- {$F-}
-
- FUNCTION Rad(Grad : INTEGER) : REAL;
- BEGIN
- Rad := Grad * PI / 180;
- END;
-
- PROCEDURE ZeigerPunkt(VAR x1, y1 : INTEGER;
- Grad, Radius : INTEGER);
- BEGIN
- x1 := Round(MitteX + (Radius/AspX*AspY)*
- COS(RAD(Grad-90)));
- y1 := Round(MitteY + Radius*SIN(RAD(Grad-90)));
- END;
-
- PROCEDURE UhrenRahmen;
- VAR i, x1, y1, x2, y2 : INTEGER;
- BEGIN
- ClearViewPort;
- SetLineStyle(SolidLn, 0, ThickWidth);
- FOR i := 1 TO 60 DO BEGIN
- ZeigerPunkt(x1, y1, i*6, Radius + 3);
- ZeigerPunkt(x2, y2, i*6, Radius - 3);
- Line(x1, y1, x2, y2);
- END;
- FOR i := 0 TO 11 DO BEGIN
- ZeigerPunkt(x1, y1, i*30, Radius - 3);
- ZeigerPunkt(x2, y2, i*30, Radius - 13);
- Line(x1, y1, x2, y2);
- END;
- OutTextXY( 15, 10, 'T O O L B O X');
- OutTextXY(450, 10, 'A n a l o g u h r');
- OutTextXY( 15,175, 'F 1 = SystemZeit setzen');
- OutTextXY( 15,185, 'F 2 = AlarmZeit setzen');
- OutTextXY(450,175, 'F10 = Ende mit Alarm');
- OutTextXY(450,185, 'ESC = Ende ohne Alarm');
- SetLineStyle(SolidLn, 0, ThickWidth);
- END;
-
- PROCEDURE ZeichneZeigerS(Grad : INTEGER);
- VAR x1, x2, y1, y2 : INTEGER;
- BEGIN
- SetColor(Black);
- ZeigerPunkt(x1, y1, Grad-6, Radius-20);
- ZeigerPunkt(x2, y2, Grad-6, RadiusZurueckZeigerS);
- Line(x1, y1, x2, y2);
- SetColor(Yellow);
- ZeigerPunkt(x1, y1, Grad, Radius-20);
- ZeigerPunkt(x2, y2, Grad, RadiusZurueckZeigerS);
- Line(x1, y1, x2, y2);
- END;
-
- PROCEDURE ZeichneZeigerM(Grad : INTEGER);
- VAR x1, x2, x3, y1, y2, y3 : INTEGER;
- BEGIN
- IF sek1 < 1 THEN BEGIN
- SetColor(Black);
- ZeigerPunkt(x1, y1, Grad-6-BreiteZeigerM,
- RadiusZurueckZeigerM);
- ZeigerPunkt(x2, y2, Grad-6, Radius-20);
- ZeigerPunkt(x3, y3, Grad-6 + BreiteZeigerM,
- RadiusZurueckZeigerM);
- Line(x1, y1, x2, y2); Line(x2, y2, x3, y3);
- Line(x3, y3, x1, y1);
- END;
- SetColor(Yellow);
- ZeigerPunkt(x1, y1, Grad-BreiteZeigerM,
- RadiusZurueckZeigerM);
- ZeigerPunkt(x2, y2, Grad, Radius-20);
- ZeigerPunkt(x3, y3, Grad + BreiteZeigerM,
- RadiusZurueckZeigerM);
- Line(x1, y1, x2, y2); Line(x2, y2, x3, y3);
- Line(x3, y3, x1, y1);
- END;
-
- PROCEDURE ZeichneZeigerH(Grad : INTEGER);
- VAR x1, x2, x3, y1, y2, y3 : INTEGER;
- BEGIN
- IF sek1 < 1 THEN BEGIN
- IF min1 DIV 5 IN [0..11] THEN BEGIN
- SetColor(Black);
- ZeigerPunkt(x1, y1, Grad-3-BreiteZeigerH,
- RadiusZurueckZeigerH);
- ZeigerPunkt(x2, y2, Grad-3, Radius-35);
- ZeigerPunkt(x3, y3, Grad-3 + BreiteZeigerH,
- RadiusZurueckZeigerH);
- Line(x1, y1, x2, y2); Line(x2, y2, x3, y3);
- Line(x3, y3, x1, y1);
- END;
- END;
- SetColor(Yellow);
- ZeigerPunkt(x1, y1, Grad - BreiteZeigerH,
- RadiusZurueckZeigerH);
- ZeigerPunkt(x2, y2, Grad, Radius-35);
- ZeigerPunkt(x3, y3, Grad + BreiteZeigerH,
- RadiusZurueckZeigerH);
- Line(x1, y1, x2, y2); Line(x2, y2, x3, y3);
- Line(x3, y3, x1, y1);
- END;
-
- PROCEDURE ZeitAnzeige;
- VAR i : INTEGER;
- BEGIN
- WinkelZeigerS := sek1*6;
- WinkelZeigerM := min1*6;
- WinkelZeigerH := std1*30 + (WinkelZeigerM DIV 12);
- ZeichneZeigerS(WinkelZeigerS);
- ZeichneZeigerH(WinkelZeigerH);
- ZeichneZeigerM(WinkelZeigerM);
- ZaehleZeitZu;
- IF (std2 = std1) AND (min2 = min1) THEN BEGIN
- GotoXY(50,1);
- Write('Die Alarmzeit ist erreicht !!!');
- FOR i := 1 TO 4 DO BEGIN
- Sound(440); Delay(100);
- Sound(880); Delay(100);
- END;
- NoSound;
- END;
- END;
-
- PROCEDURE BSsichern;
- BEGIN
- gross := ImageSize(0, 0, MitteX*2 + 1, MitteY*2 + 1);
- GetMem(Grafik, gross);
- GetImage(0, 0, MitteX*2 + 1, MitteY*2 + 1, Grafik^);
- END;
-
- PROCEDURE BSwiederherstellen;
- BEGIN
- ClrScr; UhrenRahmen;
- PutImage(0, 0, Grafik^, NormalPut);
- END;
-
- PROCEDURE Uhrzeitsetzen;
- BEGIN
- std := -1; min := -1;
- GotoXY(10,3); Write('Neue Uhrzeit eingeben :');
- GotoXY(10,5); Write('Stunde : ');
- REPEAT
- GoToXY(20,5); Read(std);
- UNTIL std > -1;
- GoToXY(30,5); Write('Minute : ');
- REPEAT
- GotoXY(40,5); ReadLn(min);
- UNTIL min > -1;
- std1 := std; min1 := min;
- sek1 := 0; hun1 := 0;
- SetTime(std1, min1, sek1, hun1);
- Zaehler := 18.21;
- END;
-
- PROCEDURE Alarmzeitsetzen;
- BEGIN
- std := -1; min := -1;
- GotoXY(10,3); Write('Die Alarmzeit eingeben :');
- GoToXY(10,5); Write('Stunde : ');
- REPEAT
- GoToXY(22,5); Read(std);
- UNTIL std > -1;
- GoToXY(32,5); Write('Minute : ');
- REPEAT
- GotoXY(42,5); ReadLn(min);
- UNTIL min > -1;
- std2 := std; min2 := min;
- sek2 := 0; Hun2 := 0;
- AlarmGesetzt := TRUE;
- END;
-
- PROCEDURE _Uhr;
- BEGIN
- UhrenRahmen;
- BSsichern;
- REPEAT
- REPEAT
- IF Zaehler > 18.2 THEN BEGIN
- Zeitanzeige;
- Zaehler := Zaehler - 18.2;
- END;
- UNTIL KeyPressed;
- ch := ReadKey;
- IF ch = #0 THEN BEGIN
- ch := ReadKey;
- IF ch = #59 THEN BEGIN
- ClearViewPort;
- UhrZeitSetzen;
- BSwiederherstellen;
- END;
- IF ch = #60 THEN BEGIN
- ClearViewPort;
- AlarmZeitSetzen;
- BSwiederherstellen;
- END;
- IF (ch = #68) AND AlarmGesetzt THEN BEGIN
- ClearViewPort;
- CloseGraph;
- RestoreCrtMode;
- SetIntVec($1C, Addr(ZeitVergleich));
- Ch := #27;
- End;
- End;
- UNTIL ch = #27;
- IF NOT AlarmGesetzt THEN SetIntVec($1C, Original);
- FreeMem(Grafik, gross);
- CloseGraph;
- RestoreCrtMode;
- END;
-
- PROCEDURE NotAus;
- BEGIN
- SetIntVec($1C, Original);
- END;
-
- BEGIN
- Adressermittlung;
- AlarmGesetzt := FALSE;
- Zaehler := 18.21;
- Gr := Detect;
- InitGraph(Gr, Mo, '');
- DirectVideo := FALSE;
- GetAspectRatio(AspX, AspY);
- SetColor(Yellow);
- SetGraphMode(CGAHi);
- SetViewPort(0, 0, GetMaxX, GetMaxY, TRUE);
- SetLineStyle(SolidLn, 0, ThickWidth);
- SetTextStyle(DefaultFont, HorizDir, 1);
- MitteX := GetMaxX DIV 2;
- MitteY := GetMaxY DIV 2;
- GetTime(Std1, Min1, Sek1, Hun1);
- GetIntVec($1C, Original);
- SetIntVec($1C, Addr(Verzweigung));
- END.
- (* ------------------------------------------------------ *)
- (* Ende von UHR.PAS *)