Skip to content

Commit

Permalink
Made stopwatch optional
Browse files Browse the repository at this point in the history
  • Loading branch information
n8vi authored and Jeremy O'Brien committed Feb 6, 2011
1 parent 0704c35 commit 24374f8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions driver/ports.c
Expand Up @@ -229,13 +229,15 @@ __interrupt void PORT2_ISR(void)

if( !sys.flag.lock_buttons)
{
#ifdef CONFIG_STOP_WATCH
// Faster reaction for stopwatch split button press
if (is_stopwatch_run())
{
split_stopwatch();
button.flag.num = 0;

}
#endif
}
}
}
Expand Down Expand Up @@ -266,6 +268,7 @@ __interrupt void PORT2_ISR(void)

if( !sys.flag.lock_buttons)
{
#ifdef CONFIG_STOP_WATCH
// Faster reaction for stopwatch stop button press
if (is_stopwatch_run())
{
Expand All @@ -278,6 +281,7 @@ __interrupt void PORT2_ISR(void)
start_stopwatch();
button.flag.down = 0;
}
#endif
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions driver/timer.c
Expand Up @@ -279,8 +279,10 @@ void Timer0_A4_Delay(u16 ticks)
// Service watchdog
WDTCTL = WDTPW + WDTIS__512K + WDTSSEL__ACLK + WDTCNTCL;
#endif
#ifdef CONFIG_STOP_WATCH
// Redraw stopwatch display
if (is_stopwatch_run()) display_stopwatch(LINE2, DISPLAY_LINE_UPDATE_PARTIAL);
#endif

// Check stop condition
if (sys.flag.delay_over) break;
Expand Down Expand Up @@ -634,14 +636,18 @@ __interrupt void TIMER0_A1_5_ISR(void)
// Reset IRQ flag
TA0CCTL2 &= ~CCIFG;
// Load CCR register with next capture point
#ifdef CONFIG_STOP_WATCH
update_stopwatch_timer();
#endif
#ifdef CONFIG_EGGTIMER
update_eggtimer_timer();
#endif
// Enable timer interrupt
TA0CCTL2 |= CCIE;
// Increase stopwatch counter
#ifdef CONFIG_STOP_WATCH
stopwatch_tick();
#endif
#ifdef CONFIG_EGGTIMER
eggtimer_tick();
#endif
Expand Down
2 changes: 2 additions & 0 deletions ezchronos.c
Expand Up @@ -379,8 +379,10 @@ void init_global_variables(void)
// Set buzzer to default value
reset_buzzer();

#ifdef CONFIG_STOP_WATCH
// Reset stopwatch
reset_stopwatch();
#endif

// Reset altitude measurement
#ifdef CONFIG_ALTITUDE
Expand Down
6 changes: 6 additions & 0 deletions logic/menu.c
Expand Up @@ -118,10 +118,12 @@ u8 update_time(void)
{
return (display.flag.update_time);
}
#ifdef CONFIG_STOP_WATCH
u8 update_stopwatch(void)
{
return (display.flag.update_stopwatch);
}
#endif
u8 update_date(void)
{
return (display.flag.update_date);
Expand Down Expand Up @@ -279,6 +281,7 @@ const struct menu menu_L2_Vario =
#endif

// Line2 - Stopwatch
#ifdef CONFIG_STOP_WATCH
const struct menu menu_L2_Stopwatch =
{
FUNCTION(sx_stopwatch), // direct function
Expand All @@ -287,6 +290,7 @@ const struct menu menu_L2_Stopwatch =
FUNCTION(display_stopwatch),// display function
FUNCTION(update_stopwatch), // new display data
};
#endif
#ifdef CONFIG_EGGTIMER
// Line2 - Eggtimer (Counts down from set time)
const struct menu menu_L2_Eggtimer =
Expand Down Expand Up @@ -454,7 +458,9 @@ const struct menu *menu_L2[]={
#ifdef CONFIG_VARIO
&menu_L2_Vario,
#endif
#ifdef CONFIG_STOP_WATCH
&menu_L2_Stopwatch,
#endif
#ifdef CONFIG_EGGTIMER
&menu_L2_Eggtimer,
#endif
Expand Down
2 changes: 2 additions & 0 deletions logic/stopwatch.c
Expand Up @@ -41,6 +41,7 @@

// system
#include "project.h"
#ifdef CONFIG_STOP_WATCH
#include <string.h>

// driver
Expand Down Expand Up @@ -526,3 +527,4 @@ void display_stopwatch(u8 line, u8 update)
// Clean up symbols when leaving function
}
}
#endif /* CONFIG_STOP_WATCH */
6 changes: 6 additions & 0 deletions logic/user.c
Expand Up @@ -109,7 +109,9 @@ void set_value(s32 * value, u8 digits, u8 blanks, s32 limitLow, s32 limitHigh, u
stepValue=1;
}
u8 doRound = 0;
#ifdef CONFIG_STOP_WATCH
u8 stopwatch_state;
#endif
u32 val;
s32 orig_val=*value;

Expand All @@ -122,9 +124,11 @@ void set_value(s32 * value, u8 digits, u8 blanks, s32 limitLow, s32 limitHigh, u
// For safety only - buzzer on/off and button_repeat share same IRQ
stop_buzzer();

#ifdef CONFIG_STOP_WATCH
// Disable stopwatch display update while function is active
stopwatch_state = sStopwatch.state;
sStopwatch.state = STOPWATCH_HIDE;
#endif

// Init step size and repeat counter
sButton.repeats = 0;
Expand Down Expand Up @@ -312,7 +316,9 @@ void set_value(s32 * value, u8 digits, u8 blanks, s32 limitLow, s32 limitHigh, u
// Turn off button repeat function
button_repeat_off();

#ifdef CONFIG_STOP_WATCH
// Enable stopwatch display updates again
sStopwatch.state = stopwatch_state;
#endif
}

0 comments on commit 24374f8

Please sign in to comment.