Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for analog timer. #3

Merged
4 commits merged into from
Oct 24, 2010
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Blitz_Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@

#define SECONDS_PER_SLIDE (15)
#define UPDATES_PER_SECOND (60)
#define NUMBER_OF_SLIDES (20)
#endif
4 changes: 2 additions & 2 deletions CounterView.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ - (void)drawRect:(NSRect)rect {
[outerSlideElapsedWedge moveToPoint:center];

float slideSeconds = fmod(self.secondsElapsed, SECONDS_PER_SLIDE);
if (slideSeconds == 0.0f) {
if (slideSeconds < 0.0001f) {
if (self.secondsElapsed == 0) {
degreesElapsed = 0;
} else {
Expand Down Expand Up @@ -152,7 +152,7 @@ - (void)drawRect:(NSRect)rect {
NSBezierPath *innerTalkElapsedWedge = [NSBezierPath bezierPath];
[innerTalkElapsedWedge moveToPoint:center];

CGFloat degreesElapsed = ((CGFloat)self.secondsElapsed * 360.0f) / 300.0f;
CGFloat degreesElapsed = ((CGFloat)self.secondsElapsed * 360.0f) / (SECONDS_PER_SLIDE * NUMBER_OF_SLIDES);
[innerTalkElapsedWedge appendBezierPathWithArcWithCenter:center
radius:innerCircleBounds.size.width / 2.0f
startAngle:twelveOclock-degreesElapsed
Expand Down
6 changes: 4 additions & 2 deletions MyAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ - (void) advanceSlide {
}

- (void) tick:(NSTimer*) timer {
if (self.secondsElapsed < 5 * 60)
if ((NUMBER_OF_SLIDES * SECONDS_PER_SLIDE - self.secondsElapsed) > (1.0f / UPDATES_PER_SECOND / 2.0f))
{
self.secondsElapsed += 1.0 / UPDATES_PER_SECOND;

if ((int)floor(UPDATES_PER_SECOND * self.secondsElapsed) % (UPDATES_PER_SECOND * SECONDS_PER_SLIDE) == 0)
bool justAboutDone = (self.secondsElapsed > ((NUMBER_OF_SLIDES * SECONDS_PER_SLIDE) - (1.0f / UPDATES_PER_SECOND / 2.0f)));
if ( !justAboutDone &&
((int)floor(UPDATES_PER_SECOND * self.secondsElapsed) % (UPDATES_PER_SECOND * SECONDS_PER_SLIDE) == 0))
[self advanceSlide];
}
else
Expand Down