/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/button.h

  • Committer: edam
  • Date: 2012-02-28 16:50:26 UTC
  • Revision ID: edam@waxworlds.org-20120228165026-pwnwo300xx2e2kg6
removed ulibc, fixed button, added text rendering

Show diffs side-by-side

added added

removed removed

24
24
#define _BUTTON_H_
25
25
 
26
26
 
27
 
#include <map>
28
 
 
29
 
 
30
27
class Button
31
28
{
32
29
public:
39
36
        Button( int pin );
40
37
 
41
38
        /**
42
 
         * Add a duration at which the specified event id should be triggered.
43
 
         *
44
 
         * @oaram duration the time at which the event should be triggered
45
 
         * @param event_id a unique identifier for the event (not 0)
46
 
         */
47
 
        void add_event_at( int duration, int event_id );
48
 
 
49
 
        /**
50
 
         * Update internal state
51
 
         */
52
 
        int update();
53
 
 
54
 
        /**
55
 
         * Retrieve the event id of the event that was triggered at the last
56
 
         * update, if there was one.
57
 
         *
58
 
         * @return event id, or 0
59
 
         */
60
 
        int get_triggered_event();
 
39
         * Set event times.
 
40
         *
 
41
         * @oaram pointer to ordered, zero-terminated array of event times
 
42
         */
 
43
        void set_event_times( int *event_times );
 
44
 
 
45
        /**
 
46
         * Update internal state (call as regularly sa possible!)
 
47
         */
 
48
        void update();
 
49
 
 
50
        /**
 
51
         * Get the first pending event.
 
52
         *
 
53
         * @return event id, 0 if there isn't any
 
54
         */
 
55
        int get_event();
61
56
 
62
57
protected:
63
58
 
74
69
         * triggering events) since current state began */
75
70
        unsigned long _state_duration;
76
71
 
77
 
        /** triggered event */
78
 
        int _event_id;
 
72
        /** pointer to event times */
 
73
        int *_event_times;
79
74
 
80
 
        /** press events durations -> event ids */
81
 
        std::map< int, int > _press_events;
 
75
        /** pending event */
 
76
        int _pending_event;
82
77
 
83
78
};
84
79