/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/modes/settings_major_mode.cc

  • 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

Lines of Context:
40
40
}
41
41
 
42
42
 
 
43
void SettingsMajorMode::draw( int segment )
 
44
{
 
45
        // check button state for unpress
 
46
        if( _press_state == 1 && !_button.get_state() )
 
47
                _press_state = 2;
 
48
}
 
49
 
 
50
 
43
51
void SettingsMajorMode::draw_reset()
44
52
{
 
53
        // do a short button press?
 
54
        if( _press_state == 2 ) {
 
55
                _press_state = 0;
 
56
                switch( _item )
 
57
                {
 
58
                case TIME_SET_IDX:
 
59
                        switch( _part ) {
 
60
                        case 0: Time::inc_hours(); break;
 
61
                        case 1: Time::inc_minutes(); break;
 
62
                        case 2: Time::reset_seconds(); break;
 
63
                        }
 
64
                        break;
 
65
                case DATE_SET_IDX:
 
66
                        switch( _part ) {
 
67
                        case 0: Time::inc_year(); break;
 
68
                        case 1: Time::inc_month(); break;
 
69
                        case 2: Time::inc_day(); break;
 
70
                        }
 
71
                        break;
 
72
                case FONT_SET_IDX:
 
73
                        TextRenderer::inc_font();
 
74
                        break;
 
75
                }
 
76
        }
 
77
 
45
78
        bool flash = ( ::millis() % 1000 ) > 600;
46
79
        PString str0( Text::_messages[ 0 ], MESSAGE_LEN * 2 );
47
 
        str0.begin();
48
80
 
49
81
        switch( _item ) {
50
82
        case TIME_SET_IDX:
102
134
void SettingsMajorMode::activate()
103
135
{
104
136
        _item = _part = 0;
 
137
        _press_state = 0;
105
138
 
106
139
        reset_messages();
107
 
 
108
 
        _button.set_press_mode( false );
109
140
}
110
141
 
111
142
 
112
143
void SettingsMajorMode::deactivate()
113
144
{
114
 
        _button.set_press_mode( true );
115
 
 
116
145
        // save time
117
 
 
 
146
        Time::save_time();
118
147
}
119
148
 
120
149
 
121
150
void SettingsMajorMode::press()
122
151
{
123
 
        switch( _item )
124
 
        {
125
 
        case TIME_SET_IDX:
126
 
                switch( _part ) {
127
 
                case 0: Time::inc_hours(); break;
128
 
                case 1: Time::inc_minutes(); break;
129
 
                case 2: Time::reset_seconds(); break;
130
 
                }
131
 
                break;
132
 
        case DATE_SET_IDX:
133
 
                switch( _part ) {
134
 
                case 0: Time::inc_year(); break;
135
 
                case 1: Time::inc_month(); break;
136
 
                case 2: Time::inc_day(); break;
137
 
                }
138
 
                break;
139
 
        case FONT_SET_IDX:
140
 
                TextRenderer::inc_font();
141
 
                break;
142
 
        }
 
152
        _press_state = 1;
143
153
}
144
154
 
145
155
 
146
156
void SettingsMajorMode::long_press()
147
157
{
 
158
        _press_state = 0;
 
159
 
148
160
        // how many parts does this item have?
149
161
        int max = 1;
150
162
        switch( _item ) {
166
178
void SettingsMajorMode::reset_messages()
167
179
{
168
180
        Text::reset();
169
 
 
170
181
        Text::set_up_message( 0, Text::MODE_TOP | Text::MODE_ALL );
171
182
}