/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-03-10 12:56:55 UTC
  • Revision ID: tim@ed.am-20120310125655-z72qh4bqou2byi2r
added frame reset code and inited minor mode flavours on mode activation

Show diffs side-by-side

added added

removed removed

28
28
 
29
29
 * a PC fan is wired up to a 12V power supply
30
30
 
31
 
 * the fan's SENSE (tachiometer) pin connected to pin 2 on the
32
 
   arduino.
 
31
 * the fan's SENSE (tachometer) pin connected to pin 2 on the
 
32
   Arduino.
33
33
 
34
 
 * the pins 4 to 13 on the arduino should directly drive an LED (the
 
34
 * the pins 4 to 13 on the Arduino should directly drive an LED (the
35
35
   LED on pin 4 is in the centre of the clock face and the LED on pin
36
36
   13 is at the outside.
37
37
 
38
38
 * if a longer hand (and a larger clock face) is desired, pin 4 can be
39
39
   used to indirectly drive a transistor which in turn drives several
40
 
   LEDs that turn on anf off in unison in the centre of the clock.
 
40
   LEDs that turn on and off in unison in the centre of the clock.
41
41
 
42
42
 * a button should be attached to pin 3 that grounds it when pressed.
43
43
 
44
 
 * A DS1307 remote clock is connected via I2C on analog pins 4 and 5.
 
44
 * A DS1307 remote clock is connected via I2C on analogue pins 4 and 5.
45
45
 
46
46
Implementation details:
47
47
 
50
50
 * the timing of the drawing of the clock face is recalculated with
51
51
   every rotation of the propeller.
52
52
    
53
 
 * a PC fan actually sends 2 tachiometer pulses per revolution, so the
 
53
 * a PC fan actually sends 2 tachometer pulses per revolution, so the
54
54
   software skips every other one. This means that the clock may
55
55
   appear upside-down if started with the propeller in the wrong
56
 
   position. You will need to experiment to dicsover the position that
 
56
   position. You will need to experiment to discover the position that
57
57
   the propeller must be in when starting the clock.
58
58
    
59
59
Usage instructions:
122
122
void activate_minor_mode()
123
123
{
124
124
        switch( _minor_mode ) {
 
125
        case ANALOGUE_CLOCK_IDX: analogue_clock_activate(); break;
125
126
        case DIGITAL_CLOCK_IDX: digital_clock_activate(); break;
126
127
        }
127
128
}
185
186
        if( reset ) segment = NUM_SEGMENTS - 1 - CLOCK_SHIFT;
186
187
#endif
187
188
 
 
189
        // frame reset
 
190
        if( reset ) {
 
191
                switch( _major_mode ) {
 
192
                case MAIN_MODE_IDX:
 
193
                        switch( _minor_mode ) {
 
194
                        case ANALOGUE_CLOCK_IDX: analogue_clock_draw_reset(); break;
 
195
                        case DIGITAL_CLOCK_IDX: digital_clock_draw_reset(); break;
 
196
                        }
 
197
                        break;
 
198
                }
 
199
        }
 
200
 
188
201
        // draw
189
202
        switch( _major_mode ) {
190
203
        case MAIN_MODE_IDX:
282
295
        static int event_times[] = { 5, 500, 4000, 0 };
283
296
        _button.set_event_times( event_times );
284
297
 
285
 
        // get time from RTC
 
298
        // initialise RTC
286
299
        Time::init();
287
300
 
288
301
        // activate the minor mode