/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: Tim Marston
  • Date: 2012-05-23 23:02:50 UTC
  • Revision ID: tim@ed.am-20120523230250-3pls2u6zt3av0uam
fixed text glitch; extended all modes; added screen flip super-long press;
added button unpress debounde; moved interim button press ignoration to
settings mode; fixed left-over led issue; finished for demo!

Show diffs side-by-side

added added

removed removed

43
43
        void set_event_times( int *event_times );
44
44
 
45
45
        /**
 
46
         * Set button press mode
 
47
         *
 
48
         * @param send_interim send interim presses during a long press?
 
49
         */
 
50
        void set_press_mode( bool send_interim );
 
51
 
 
52
        /**
46
53
         * Update internal state (call as regularly sa possible!)
47
54
         */
48
55
        void update();
54
61
         */
55
62
        int get_event();
56
63
 
 
64
        /**
 
65
         * Get the current button state.
 
66
         *
 
67
         * @return true if the button is pressed
 
68
         */
 
69
        bool get_state();
 
70
 
57
71
protected:
58
72
 
59
73
        /** pin */
60
74
        int _pin;
61
75
 
62
 
        /** current state */
 
76
        /** last real state */
 
77
        bool _last_real_state;
 
78
 
 
79
        /** time when the real state began */
 
80
        unsigned long _millis_real_state;
 
81
 
 
82
        /** accepted state */
63
83
        bool _state;
64
84
 
65
 
        /** time when current state began */
66
 
        unsigned long _state_millis;
 
85
        /** time when the accepted state began */
 
86
        unsigned long _millis_state;
67
87
 
68
 
        /** milliseconds that have been accountred for (in terms of
69
 
         * triggering events) since current state began */
70
 
        unsigned long _state_duration;
 
88
        /** amount of time that we've already triggered events for this press */
 
89
        unsigned long _millis_done;
71
90
 
72
91
        /** pointer to event times */
73
92
        int *_event_times;
74
93
 
75
94
        /** pending event */
76
95
        int _pending_event;
77
 
 
78
96
};
79
97
 
80
98