ShutterController.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #ifndef SHUTTER_CONTROLLER_H
  2. #define SHUTTER_CONTROLLER_H
  3. /// <summary>
  4. /// Interface for camera shutter control operations.
  5. /// Defines the contract for controlling camera focus and shutter functionality.
  6. /// </summary>
  7. class IShutterController
  8. {
  9. public:
  10. virtual ~IShutterController() = default;
  11. /// <summary>
  12. /// Performs a half press of the shutter to initiate focus.
  13. /// This is equivalent to pressing the shutter button halfway down.
  14. /// </summary>
  15. virtual void halfPress() = 0;
  16. /// <summary>
  17. /// Performs a full press of the shutter to take a photo.
  18. /// Automatically calls halfPress() if not already pressed.
  19. /// </summary>
  20. virtual void fullPress() = 0;
  21. /// <summary>
  22. /// Releases the shutter and returns to neutral position.
  23. /// Resets focus state and shutter pin to LOW.
  24. /// </summary>
  25. virtual void unPress() = 0;
  26. /// <summary>
  27. /// Presses the shutter fully, waits for specified delay, then releases.
  28. /// </summary>
  29. /// <param name="ms">Delay in milliseconds between full press and release</param>
  30. virtual void pressFullWithDelay(int ms) = 0;
  31. /// <summary>
  32. /// Takes multiple photos in sequence with configurable timing.
  33. /// </summary>
  34. /// <param name="ms">Duration of each full press in milliseconds</param>
  35. /// <param name="count">Number of photos to take</param>
  36. /// <param name="delayMs">Delay between consecutive shots in milliseconds</param>
  37. virtual void multipleShoot(int ms, int count, int delayMs) = 0;
  38. };
  39. /// <summary>
  40. /// Implementation of camera shutter control for Minolta remote.
  41. /// Controls focus and shutter via GPIO pins to simulate button presses.
  42. /// </summary>
  43. class ShutterController : public IShutterController
  44. {
  45. private:
  46. /// <summary>GPIO pin number for focus control</summary>
  47. uint8_t focusPin;
  48. /// <summary>GPIO pin number for shutter control</summary>
  49. uint8_t shutterPin;
  50. /// <summary>Flag indicating whether focus is currently pressed</summary>
  51. bool isFocusPressed;
  52. public:
  53. /// <summary>
  54. /// Constructs a ShutterController instance.
  55. /// </summary>
  56. /// <param name="focusPin">GPIO pin for focus control (e.g., D1/GPIO5)</param>
  57. /// <param name="shutterPin">GPIO pin for shutter control (e.g., D2/GPIO4)</param>
  58. ShutterController(uint8_t focusPin, uint8_t shutterPin);
  59. /// <summary>
  60. /// Performs a half press of the shutter to initiate focus.
  61. /// </summary>
  62. void halfPress() override;
  63. /// <summary>
  64. /// Performs a full press of the shutter to take a photo.
  65. /// </summary>
  66. void fullPress() override;
  67. /// <summary>
  68. /// Releases the shutter and returns to neutral position.
  69. /// </summary>
  70. void unPress() override;
  71. /// <summary>
  72. /// Presses the shutter fully, waits for specified delay, then releases.
  73. /// </summary>
  74. /// <param name="ms">Delay in milliseconds between full press and release</param>
  75. void pressFullWithDelay(int ms) override;
  76. /// <summary>
  77. /// Takes multiple photos in sequence with configurable timing.
  78. /// </summary>
  79. /// <param name="ms">Duration of each full press in milliseconds</param>
  80. /// <param name="count">Number of photos to take</param>
  81. /// <param name="delayMs">Delay between consecutive shots in milliseconds</param>
  82. void multipleShoot(int ms, int count, int delayMs) override;
  83. /// <summary>
  84. /// Gets the current focus press state.
  85. /// </summary>
  86. /// <returns>True if focus is currently pressed, false otherwise</returns>
  87. bool getFocusPressedState() const;
  88. };
  89. #endif // SHUTTER_CONTROLLER_H