#include "ShutterController.h" #include /// /// Constructs a ShutterController instance with specified GPIO pins. /// ShutterController::ShutterController(uint8_t focusPin, uint8_t shutterPin) : focusPin(focusPin), shutterPin(shutterPin), isFocusPressed(false) { } /// /// Performs a half press of the shutter to initiate focus. /// Sets the focus pin HIGH and marks focus as pressed. /// void ShutterController::halfPress() { digitalWrite(focusPin, HIGH); isFocusPressed = true; } /// /// Performs a full press of the shutter to take a photo. /// Automatically half-presses the shutter if not already pressed. /// Sets the shutter pin HIGH to simulate a full button press. /// void ShutterController::fullPress() { if (!isFocusPressed) { halfPress(); delay(1000); } digitalWrite(shutterPin, HIGH); } /// /// Presses the shutter fully, waits for the specified delay, then releases. /// Automatically returns to neutral position after the delay. /// /// Delay in milliseconds between full press and release void ShutterController::pressFullWithDelay(int ms) { fullPress(); delay(ms); unPress(); } /// /// Releases the shutter and returns to neutral position. /// Sets both focus and shutter pins LOW and updates the focus state. /// void ShutterController::unPress() { digitalWrite(shutterPin, LOW); digitalWrite(focusPin, LOW); isFocusPressed = false; } /// /// Takes multiple photos in sequence with configurable timing. /// Ensures focus is locked before taking photos, then executes the sequence. /// /// Duration of each full press in milliseconds /// Number of photos to take /// Delay between consecutive shots in milliseconds void ShutterController::multipleShoot(int ms, int count, int delayMs) { if (!isFocusPressed) { halfPress(); delay(1000); } while (count > 0) { fullPress(); delay(ms); digitalWrite(shutterPin, LOW); count--; delay(delayMs); } } /// /// Returns the current focus press state. /// /// True if focus is currently pressed, false otherwise bool ShutterController::getFocusPressedState() const { return isFocusPressed; }