Skip to content

Commit

Permalink
Moved time setting into a function setTime()
Browse files Browse the repository at this point in the history
  • Loading branch information
k-popov committed Dec 13, 2012
1 parent 724f0af commit 95fd038
Showing 1 changed file with 30 additions and 25 deletions.
55 changes: 30 additions & 25 deletions arduino_clock.ino
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,7 @@ void printTime() {
}
}

void setup() {
/*
* setting up timer1
*/
cli();
//CTC vaweform mode | 1024 prescaler
// TCCR1B = (1 << WGM12) | (1 << CS12) | (1 << CS10);
//will start the timer on button press
TCCR1B = 0x00; //now the timer is stopped
//normal mode, all waveform ganeration bits are 0
TCCR1A = 0x00;
//reset the timer
TCNT1 = 0x0000;
//clear timer1 interrupt flags
TIFR1 = 0x00;
//counter seed for 1 second triggering
OCR1A = TIMER_SEED;
//enable output compare interrupt
TIMSK1 = (1 << OCIE1A);
sei();

//initialize LCD disply
slcd.begin();
slcd.backlight();

void setTime() {
byte prev_time_value = 0;
slcd.setCursor(0, 0);
slcd.print("Setting hours:"); //hours setting indicator
Expand Down Expand Up @@ -140,6 +116,35 @@ void setup() {
slcd.setCursor(4, 0);
seconds = 0; //reset seconds to 0
slcd.setCursor(0, 0);
}

void setup() {
/*
* setting up timer1
*/
cli();
//CTC vaweform mode | 1024 prescaler
// TCCR1B = (1 << WGM12) | (1 << CS12) | (1 << CS10);
//will start the timer on button press
TCCR1B = 0x00; //now the timer is stopped
//normal mode, all waveform ganeration bits are 0
TCCR1A = 0x00;
//reset the timer
TCNT1 = 0x0000;
//clear timer1 interrupt flags
TIFR1 = 0x00;
//counter seed for 1 second triggering
OCR1A = TIMER_SEED;
//enable output compare interrupt
TIMSK1 = (1 << OCIE1A);
sei();

//initialize LCD disply
slcd.begin();
slcd.backlight();

//set hours and minutes, reset seconds to 0 and wait for start
setTime();
slcd.print("Press to start. ");
slcd.setCursor(0, 0);

Expand Down

0 comments on commit 95fd038

Please sign in to comment.