Skip to content

Conversation

@whywaita
Copy link
Owner

@whywaita whywaita commented Jan 8, 2026

Summary

  • replace the global timer vars with a ShotClock struct that tracks timing, flashing, and alarm state
  • update the touch handling to reset, start, and stop based on shot clock status
  • keep the display in sync with timer flashes and show time up messaging

Testing

  • not run (hardware dependent)

@whywaita whywaita requested a review from Copilot January 8, 2026 20:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@whywaita whywaita requested a review from Copilot January 8, 2026 20:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

isRunning = false;
flashState = false;
updateDisplay();
delay(10);
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loop delay was reduced from 1000ms to 10ms, which increases CPU usage 100x. Since the timer only needs second-level precision and flash updates occur every 500ms, consider using a delay of at least 100ms to balance responsiveness with power efficiency.

Suggested change
delay(10);
delay(100);

Copilot uses AI. Check for mistakes.
const unsigned long elapsed = now - lastSecondTick;
if (elapsed >= 1000) {
const int secondsPassed = elapsed / 1000;
lastSecondTick += secondsPassed * 1000;
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The drift correction logic assumes secondsPassed is always 1 in normal operation. If the device experiences significant lag (e.g., >2 seconds), remaining could underflow. Consider adding a bounds check: remaining = max(0, remaining - secondsPassed) or limiting secondsPassed to prevent unexpected behavior.

Copilot uses AI. Check for mistakes.
drawButton(startButton, startButton.label);

const Button& activeButton = shotClock.timeUp ? resetButton : stopButton;
const char* label = shotClock.timeUp ? resetButton.label : stopButton.label;
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The label is redundantly extracted from the same button that was just assigned to activeButton. Since activeButton.label already contains the correct label, this line can be simplified to const char* label = activeButton.label;

Suggested change
const char* label = shotClock.timeUp ? resetButton.label : stopButton.label;
const char* label = activeButton.label;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants