Skip to content

add cooldown parameter to filtered-camera#47

Merged
bhaney merged 1 commit intomainfrom
add-cooldown
Feb 24, 2026
Merged

add cooldown parameter to filtered-camera#47
bhaney merged 1 commit intomainfrom
add-cooldown

Conversation

@bhaney
Copy link
Collaborator

@bhaney bhaney commented Feb 24, 2026

Core logic — image_buffer/image_buffer.go:

  • Added cooldownSecs and cooldownTill fields to ImageBuffer struct
  • Updated NewImageBuffer constructor with cooldownSecs parameter
  • MarkShouldSend now computes cooldownTill = captureTill + cooldownSecs
  • New IsInCooldown(now) method — returns true when past capture window but within cooldown period
  • New SetCooldownTill test helper
  • When cooldownSecs == 0, IsInCooldown naturally returns false (no cooldown)

Filtered camera — cam.go:

  • Added CooldownSecs int with json:"cooldown_s" to Config
  • Validation: cooldown_s cannot be negative
  • Passed to NewImageBuffer in constructor
  • Added cooldown check in images() between IsWithinCaptureWindow and filter checks — during cooldown, drains remaining buffered images but suppresses new triggers

Conditional camera — conditional_camera/conditional_cam.go:

  • Same config, validation, constructor, and images() cooldown check

Tests:

  • 3 new unit tests in image_buffer_test.go: TestCooldownBlocksRetrigger, TestCooldownZeroHasNoEffect, TestCooldownExtendsWithRetrigger
  • 3 new integration tests in cam_test.go: TestCooldownValidation, TestCooldownSuppressesNewTrigger, TestCooldownAllowsTriggerAfterExpiry
  • All existing NewImageBuffer calls updated with 0 for backward compatibility

@bhaney bhaney requested a review from kharijarrett February 24, 2026 17:13
Copy link
Collaborator

@kharijarrett kharijarrett left a comment

Choose a reason for hiding this comment

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

LGTM! Glad we'll still clear out the buffer even in cooldown

@bhaney bhaney merged commit cfeab19 into main Feb 24, 2026
1 check passed
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