/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: 2013-03-31 17:07:36 UTC
  • Revision ID: tim@ed.am-20130331170736-hphm2hg0y6l7w6z1
made rtc-test's DS1307 library a symlink to the main one in src/util

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
         * Initialise time from store.
 
31
         */
 
32
        void load_time();
 
33
 
 
34
        /**
 
35
         * Save the time to the store.
 
36
         */
 
37
        void save_time();
 
38
 
 
39
        /**
 
40
         * Get year.
 
41
         *
 
42
         * @return year
 
43
         */
 
44
        int get_year();
 
45
 
 
46
        /**
 
47
         * Get month.
 
48
         *
 
49
         * @return month, 1 to 12
 
50
         */
 
51
        int get_month();
 
52
 
 
53
        /**
 
54
         * Get month name.
 
55
         *
 
56
         * @return month name
 
57
         */
 
58
        const char *get_month_name();
 
59
 
 
60
        /**
 
61
         * Get day.
 
62
         *
 
63
         * @return date, 1 to 31
 
64
         */
 
65
        int get_day();
 
66
 
 
67
        /**
 
68
         * Get number suffix.
 
69
         *
 
70
         * @param number
 
71
         * @return suffix
 
72
         */
 
73
        const char *get_day_suffix();
37
74
 
38
75
        /**
39
76
         * Get hours.
61
98
         */
62
99
        void update();
63
100
 
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;
 
101
        /**
 
102
         * Increment the hours and save the time.
 
103
         */
 
104
        void inc_hours();
 
105
 
 
106
        /**
 
107
         * Increment the minutes and save the time.
 
108
         */
 
109
        void inc_minutes();
 
110
 
 
111
        /**
 
112
         * Reset the seconds and save the time.
 
113
         */
 
114
        void reset_seconds();
 
115
 
 
116
        /**
 
117
         * Increment the year and save the time.
 
118
         */
 
119
        void inc_year();
 
120
 
 
121
        /**
 
122
         * Increment the month and save the time.
 
123
         */
 
124
        void inc_month();
 
125
 
 
126
        /**
 
127
         * Increment the day and save the time.
 
128
         */
 
129
        void inc_day();
84
130
 
85
131
};
86
132
 
87
133
 
88
 
#endif _TIME_H_
 
134
#endif //_TIME_H_