/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/propeller-clock.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

116
116
// current major mode
117
117
static int _mode = 0;
118
118
 
 
119
// interupt handler's "ignore every other" flag
 
120
static bool _pulse_ignore = true;
 
121
 
119
122
//_____________________________________________________________________________
120
123
//                                                                         code
121
124
 
141
144
                        if( !_modes[ ++_mode ] ) _mode = 0;
142
145
                        _modes[ _mode ]->activate();
143
146
                        break;
 
147
                case 4:
 
148
                        // switch display upside-down
 
149
                        _pulse_ignore = !_pulse_ignore;
 
150
                        break;
144
151
                }
145
152
        }
146
153
}
150
157
void draw_next_segment( bool reset )
151
158
{
152
159
        // keep track of segment
 
160
        static int segment = 0;
153
161
#if CLOCK_FORWARD
154
 
        static int segment = ( NUM_SEGMENTS - CLOCK_SHIFT ) % NUM_SEGMENTS;
155
162
        if( reset ) segment = ( NUM_SEGMENTS - CLOCK_SHIFT ) % NUM_SEGMENTS;
156
163
#else
157
 
        static int segment = NUM_SEGMENTS - 1 - CLOCK_SHIFT;
158
164
        if( reset ) segment = NUM_SEGMENTS - 1 - CLOCK_SHIFT;
159
165
#endif
160
166
 
237
243
        // may not be exactly evenly distributed around the rotation, so
238
244
        // we can't recalculate times on every pulse. Instead, we ignore
239
245
        // every other pulse so timings are based on a complete rotation.
240
 
        static bool ignore = true;
241
 
        ignore = !ignore;
242
 
        if( !ignore )
 
246
        _pulse_ignore = !_pulse_ignore;
 
247
        if( !_pulse_ignore )
243
248
        {
244
249
                // set a new pulse time
245
250
                _new_pulse_at = micros();
261
266
        // set up mode-switch button on pin 3
262
267
        pinMode( 3, INPUT );
263
268
        digitalWrite( 3, HIGH );
264
 
        static int event_times[] = { 5, 500, 4000, 0 };
 
269
        static int event_times[] = { 10, 500, 2000, 4000, 0 };
265
270
        _button.set_event_times( event_times );
266
271
 
267
272
        // initialise RTC
268
 
//      Time::load_time();
 
273
        Time::load_time();
269
274
 
270
275
        // init text renderer
271
276
        TextRenderer::init();