/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: edam
  • Date: 2012-02-25 01:31:43 UTC
  • Revision ID: tim@ed.am-20120225013143-9fet2y2d3fjlrwez
added ulibc

Show diffs side-by-side

added added

removed removed

1
 
/*
2
 
 * time.h
3
 
 *
4
 
 * Copyright (C) 2011 Tim Marston <tim@ed.am> and Dan Marston.
5
 
 *
6
 
 * This file is part of propeller-clock (hereafter referred to as "this
7
 
 * program"). See http://ed.am/dev/software/arduino/propeller-clock for more
8
 
 * information.
9
 
 *
10
 
 * This program is free software: you can redistribute it and/or modify
11
 
 * it under the terms of the GNU Lesser General Public License as published
12
 
 * by the Free Software Foundation, either version 3 of the License, or
13
 
 * (at your option) any later version.
14
 
 *
15
 
 * This program is distributed in the hope that it will be useful,
16
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 
 * GNU Lesser General Public License for more details.
19
 
 *
20
 
 * You should have received a copy of the GNU Lesser General Public License
21
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 
 */
23
 
#ifndef _TIME_H_
24
 
#define _TIME_H_
25
 
 
26
 
 
27
 
namespace Time
 
1
class Time
28
2
{
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();
 
3
public:
 
4
 
 
5
        /**
 
6
         * Get singleton instance.
 
7
         *
 
8
         * @return instance
 
9
         */
 
10
        static Time &get_instance();
64
11
 
65
12
        /**
66
13
         * Get hours.
88
35
         */
89
36
        void update();
90
37
 
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();
 
38
protected:
 
39
 
 
40
        Time();
 
41
 
 
42
        /** hours */
 
43
        int _hours;
 
44
 
 
45
        /** minutes */
 
46
        int _minutes;
 
47
 
 
48
        /** seconds */
 
49
        int _seconds;
 
50
 
 
51
private:
 
52
 
 
53
        /** milliseconds at last update */
 
54
        unsigned long _last_millis;
 
55
 
 
56
        /** milliseconds carries over from last update */
 
57
        unsigned long _carry;
125
58
 
126
59
};
127
 
 
128
 
 
129
 
#endif _TIME_H_