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

1
 
/* -*- mode: c++; compile-command: "BOARD=pro5v make"; -*- */
 
1
/* -*- mode: c++; compile-command: "make"; -*- */
2
2
/*
3
3
 * propeller-clock.ino
4
4
 *
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
 
172
178
        // draw
173
179
        _modes[ _mode ]->draw( segment );
174
180
 
175
 
        // TODO: remove this hack
176
 
        Text::post_draw();
 
181
        // draw text
 
182
        Text::draw( segment );
177
183
 
178
184
        // draw text rednerer's buffer
179
185
        TextRenderer::output_buffer();
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::init();
 
273
        Time::load_time();
269
274
 
270
275
        // init text renderer
271
276
        TextRenderer::init();
275
280
        leds_off();
276
281
 
277
282
        static SwitcherMajorMode switcher;
278
 
        static SettingsMajorMode settings;
 
283
        static SettingsMajorMode settings( _button );
279
284
 
280
285
        // add major modes
281
286
        int mode = 0;