/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock

« back to all changes in this revision

Viewing changes to src/time.h

  • Committer: Tim Marston
  • Date: 2012-03-21 19:37:33 UTC
  • Revision ID: tim@ed.am-20120321193733-29euxt0t0h9dwsj3
added .dep directories to bzrignore

Show diffs side-by-side

added added

removed removed

24
24
#define _TIME_H_
25
25
 
26
26
 
27
 
class Time
 
27
namespace Time
28
28
{
29
 
public:
30
 
 
31
 
        /**
32
 
         * Get singleton instance.
33
 
         *
34
 
         * @return instance
35
 
         */
36
 
        static Time &get_instance();
 
29
        /**
 
30
         * Get year.
 
31
         *
 
32
         * @return year
 
33
         */
 
34
        int get_year();
 
35
 
 
36
        /**
 
37
         * Get month.
 
38
         *
 
39
         * @return month, 1 to 12
 
40
         */
 
41
        int get_month();
 
42
 
 
43
        /**
 
44
         * Get month name.
 
45
         *
 
46
         * @return month name
 
47
         */
 
48
        const char *get_month_name();
 
49
 
 
50
        /**
 
51
         * Get day.
 
52
         *
 
53
         * @return date, 1 to 31
 
54
         */
 
55
        int get_day();
 
56
 
 
57
        /**
 
58
         * Get number suffix.
 
59
         *
 
60
         * @param number
 
61
         * @return suffix
 
62
         */
 
63
        const char *get_day_suffix();
37
64
 
38
65
        /**
39
66
         * Get hours.
61
88
         */
62
89
        void update();
63
90
 
64
 
protected:
65
 
 
66
 
        Time();
67
 
 
68
 
        /** hours */
69
 
        int _hours;
70
 
 
71
 
        /** minutes */
72
 
        int _minutes;
73
 
 
74
 
        /** seconds */
75
 
        int _seconds;
76
 
 
77
 
private:
78
 
 
79
 
        /** milliseconds at last update */
80
 
        unsigned long _last_millis;
81
 
 
82
 
        /** milliseconds carries over from last update */
83
 
        unsigned long _carry;
 
91
        /**
 
92
         * Initialise time data
 
93
         */
 
94
        void init();
 
95
 
 
96
        /**
 
97
         * Increment the hours and save the time.
 
98
         */
 
99
        void inc_hours();
 
100
 
 
101
        /**
 
102
         * Increment the minutes and save the time.
 
103
         */
 
104
        void inc_minutes();
 
105
 
 
106
        /**
 
107
         * Reset the seconds and save the time.
 
108
         */
 
109
        void reset_seconds();
 
110
 
 
111
        /**
 
112
         * Increment the year and save the time.
 
113
         */
 
114
        void inc_year();
 
115
 
 
116
        /**
 
117
         * Increment the month and save the time.
 
118
         */
 
119
        void inc_month();
 
120
 
 
121
        /**
 
122
         * Increment the day and save the time.
 
123
         */
 
124
        void inc_day();
84
125
 
85
126
};
86
127