/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-18 18:29:50 UTC
  • Revision ID: tim@ed.am-20120518182950-t85bn9a21n72uzm8
text messages are now individually enabled and draw()n automatically

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