/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: 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

Lines of Context:
42
42
 
43
43
void SettingsMajorMode::draw( int segment )
44
44
{
45
 
        Text::draw( 0, segment );
 
45
        // check button state for unpress
 
46
        if( _press_state == 1 && !_button.get_state() )
 
47
                _press_state = 2;
46
48
}
47
49
 
48
50
 
49
51
void SettingsMajorMode::draw_reset()
50
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
 
51
78
        bool flash = ( ::millis() % 1000 ) > 600;
52
79
        PString str0( Text::_messages[ 0 ], MESSAGE_LEN * 2 );
53
 
        str0.begin();
54
80
 
55
81
        switch( _item ) {
56
82
        case TIME_SET_IDX:
101
127
                break;
102
128
        }
103
129
 
104
 
        Text::set_message( 0, str0 );
 
130
        Text::set_message_text( 0, str0 );
105
131
}
106
132
 
107
133
 
108
134
void SettingsMajorMode::activate()
109
135
{
110
136
        _item = _part = 0;
 
137
        _press_state = 0;
111
138
 
112
139
        reset_messages();
113
 
 
114
 
        _button.set_press_mode( false );
115
140
}
116
141
 
117
142
 
118
143
void SettingsMajorMode::deactivate()
119
144
{
120
 
        _button.set_press_mode( true );
121
 
 
122
145
        // save time
123
 
 
 
146
        Time::save_time();
124
147
}
125
148
 
126
149
 
127
150
void SettingsMajorMode::press()
128
151
{
129
 
        switch( _item )
130
 
        {
131
 
        case TIME_SET_IDX:
132
 
                switch( _part ) {
133
 
                case 0: Time::inc_hours(); break;
134
 
                case 1: Time::inc_minutes(); break;
135
 
                case 2: Time::reset_seconds(); break;
136
 
                }
137
 
                break;
138
 
        case DATE_SET_IDX:
139
 
                switch( _part ) {
140
 
                case 0: Time::inc_year(); break;
141
 
                case 1: Time::inc_month(); break;
142
 
                case 2: Time::inc_day(); break;
143
 
                }
144
 
                break;
145
 
        case FONT_SET_IDX:
146
 
                TextRenderer::inc_font();
147
 
                break;
148
 
        }
 
152
        _press_state = 1;
149
153
}
150
154
 
151
155
 
152
156
void SettingsMajorMode::long_press()
153
157
{
 
158
        _press_state = 0;
 
159
 
154
160
        // how many parts does this item have?
155
161
        int max = 1;
156
162
        switch( _item ) {
171
177
 
172
178
void SettingsMajorMode::reset_messages()
173
179
{
174
 
        Text::reset_message( 0, Text::MODE_TOP | Text::MODE_ALL );
 
180
        Text::reset();
 
181
        Text::set_up_message( 0, Text::MODE_TOP | Text::MODE_ALL );
175
182
}