EE445M RTOS
Taken at the University of Texas Spring 2015
clock.h
Go to the documentation of this file.
1 #ifndef __CLOCK__
2 #define __CLOCK__
3 
4 /* clock.h
5  * Hershal Bhave and Eric Crosson
6  * 2014-02-09
7  * Clock Hands Library
8  * Lab 3
9  * Last Revision: LOOK IN GIT FGT
10  * LM3S1968
11  */
12 
13 #include "libmath/geometry/shape.h"
14 #include "timekit.h"
15 
16 #define CH_HOURS 1
17 #define CH_MINUTES 2
18 #define CH_SECONDS 3
19 #define CH_MS 4
20 
21 #define CH_MAX_HOURS 12
22 #define CH_MAX_MINUTES 60
23 #define CH_MAX_SECONDS 60
24 #define CH_MAX_MS 1000
25 
26 #define CH_MAX_DEGREES 360
27 #define CH_ANGLE_OFFSET 90.0
28 
29 #define PI_PI 3.142159
30 
31 typedef struct clockhand {
32 
33  /* Client Properties: */
34  /* Radius in units of pixels */
36  /* The point is managed by client code */
38  /* Hand type; use the #defines */
40 
41  /* ClockFace-managed Properties */
42  /* shapeBuffer is an internally-managed shape */
44  /* The origin of this angle is at 12-o-clock */
47 } clockhand;
48 
49 
50 typedef struct clockface {
51 
52  /* The individual hands' client properties managed by the client
53  * code, but the clockface manages the angle and shapeBuffer */
56 
57  /* Time is also managed by the client code (i.e. the client will
58  * call TKIncrement*), but the clock face will notice this when
59  * CFUpdateTime is called and the associated hands' shapes will be
60  * updated to reflect the time given by the timehandle pointer */
62 
63  /* shapeBuffer is an internally-managed array of clock hand
64  * shapes */
66 } clockface;
67 
68 
69 clockhand* CHCreateClockHand(point* center, ushort radius, uchar type);
70 void CHCalculateAngle(clockhand* ch, clocktime* tm);
74 
77 void CFUpdateTime(clockface* cf);
79 void CFDestroyShapes(clockface* cf);
80 
81 #endif /* __CLOCK__ */
struct clockhand clockhand
void CFDestroyClockFace(clockface *cf)
Definition: clock.c:112
clockface * CFCreateClockFace(ushort numHands, clockhand **chs, clocktime *th)
Definition: clock.c:91
Representation of a shape.
Definition: shape.h:26
struct clockface clockface
ushort radius
Definition: clock.h:35
unsigned short ushort
Definition: defines.h:35
shape * shapeBuffer
Definition: clock.h:43
void CFDestroyShapes(clockface *cf)
Definition: clock.c:146
clocktime * timehandle
Definition: clock.h:61
shape * CHToShape(clockhand *ch)
Definition: clock.c:15
unsigned char uchar
Definition: defines.h:34
uchar type
Definition: clock.h:39
point * center
Definition: clock.h:37
point * pointOnCircumference
Definition: clock.h:46
ushort angle
Definition: clock.h:45
void CFUpdateTime(clockface *cf)
Definition: clock.c:128
Representation of an ordered pair with a shade.
Definition: shape.h:13
shape ** shapeBuffer
Definition: clock.h:65
void CHDestroyClockHand(clockhand *ch)
Definition: clock.c:71
void CHCalculateAngle(clockhand *ch, clocktime *tm)
Definition: clock.c:46
void CHDestroyClockHandShape(clockhand *ch)
Definition: clock.c:80
shape ** CFToShapes(clockface *cf)
Definition: clock.c:135
clockhand * CHCreateClockHand(point *center, ushort radius, uchar type)
Definition: clock.c:32
clockhand ** hands
Definition: clock.h:54
ushort numHands
Definition: clock.h:55