/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.pde

  • Committer: edam
  • Date: 2011-12-22 01:23:27 UTC
  • Revision ID: edam@waxworlds.org-20111222012327-orbuaeekm9y9ni39
renamed notes

Show diffs side-by-side

added added

removed removed

1
1
/*
2
 
 * propeller-clock.ino
 
2
 * propeller-clock.pde
3
3
 *
4
 
 * Copyright (C) 2011 Tim Marston <tim@ed.am> and Dan Marston.
 
4
 * Copyright (C) 2011 Tim Marston <edam@waxworlds.org>
5
5
 *
6
6
 * This file is part of propeller-clock (hereafter referred to as "this
7
 
 * program"). See http://ed.am/dev/software/arduino/propeller-clock for more
 
7
 * program"). See http://ed.am/software/arduino/propeller-clock for more
8
8
 * information.
9
9
 *
10
10
 * This program is free software: you can redistribute it and/or modify
35
35
   13 is at the outside.
36
36
 
37
37
 * if a longer hand (and a larger clock face) is desired, pin 4 can be
38
 
   used to indirectly drive a transistor which in turn drives several
39
 
   LEDs that turn on anf off in unison in the centre of the clock.
 
38
   used to indirectly drive (via a MOSFET) multiple LEDs which turn on
 
39
   and off in unison in the centre of the clock.
40
40
 
41
41
 * a button should be attached to pin 3 that grounds it when pressed.
42
42
 
43
 
 * A DS1307 remote clock is connected via I2C on analog pins 4 and 5.
44
 
 
45
43
Implementation details:
46
44
 
47
 
 * for a schematic, see ../project/propeller-clock.sch.
 
45
 * for a schematic, see project/propeller-clock.sch.
48
46
 
49
47
 * the timing of the drawing of the clock face is recalculated with
50
48
   every rotation of the propeller.
69
67
    - pressing the button increments the field currently being set
70
68
    - pressing and holding the button for a second cycles through the
71
69
      fields that can be set
72
 
    - pressing and holding the button for 5 seconds sets the time and
73
 
      exits "time set" mode
 
70
    - press and holding the button for 5 seconds to finish
74
71
 
75
72
******************************************************************************/
76
73
 
77
74
 
78
75
#include <Bounce.h>
79
 
#include <DS1307.h>
80
 
#include <Wire.h>
81
76
 
82
77
//_____________________________________________________________________________
83
78
//                                                                         data
194
189
        // what needs to be drawn?
195
190
        bool draw_tick = !segment && second % 5 == 0;
196
191
        bool draw_second = !segment && second == time_seconds;
197
 
        bool draw_minute = !segment && second == time_minutes;
198
 
        bool draw_hour = !segment && second == time_hours;
 
192
        bool draw_minute = !segment && second == time_minute;
 
193
        bool draw_hour = !segment && second == time_hour;
199
194
 
200
195
        // set the LEDs
201
196
        digitalWrite( 13, HIGH );
309
304
        // set up mode-switch button on pin 3
310
305
        pinMode( 3, INPUT );
311
306
 
312
 
        // get the time from the real-time clock
313
 
        int rtc_data[ 7 ];
314
 
        RTC.get( rtc_data, true );
315
 
        time_hours = rtc_data[ DS1307_HR ];
316
 
        time_minutes = rtc_data[ DS1307_MIN ];
317
 
        time_seconds = rtc_data[ DS1307_SEC ];
318
 
 
319
307
        // serial comms
320
308
        Serial.begin( 9600 );
321
309
}