///
/// Minolta Remote Control Application
///
/// This application implements a WiFi-controlled remote for Minolta cameras.
/// Running on an ESP8266 microcontroller, it creates a WiFi access point and provides
/// an HTTP API for controlling camera focus and shutter functions remotely.
///
/// Features:
/// - WiFi Access Point for remote connectivity
/// - HTTP REST API for camera control
/// - Support for half-press (focus), full-press (capture), and multiple shots
/// - Status LED feedback (GPIO-2/LED_BUILTIN)
///
/// Hardware:
/// - ESP8266 D1 Mini microcontroller
/// - GPIO5 (D1) - Focus control pin
/// - GPIO4 (D2) - Shutter control pin
/// - GPIO2 (LED_BUILTIN) - Status LED indicator
///
/// API Endpoints:
/// - GET / - Home page with web interface for camera control
/// - GET /api/focus - Perform a half press (focus)
/// - GET /api/takePhoto[?msec=duration] - Take a photo
/// - GET /api/reset - Release the shutter
/// - GET /api/multiple?count=n&delay=ms[&msec=duration] - Take multiple photos
/// - GET /api/healthcheck - Health check endpoint
///
#include
#include "Config.h"
#include "ShutterController.h"
#include "HTTPServer.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
static const uint8_t D1 = Config::PIN_FOCUS;
static const uint8_t D2 = Config::PIN_SHUTTER;
static const char* ssid = Config::WIFI_SSID;
static const char* password = Config::WIFI_PASSWORD;
IPAddress local_IP = Config::WIFI_IP;
IPAddress gateway = Config::WIFI_GATEWAY;
IPAddress subnet = Config::WIFI_SUBNET;
/// Pointer to the ShutterController instance for camera control operations
IShutterController* shutterController = nullptr;
/// Pointer to the HTTPServer instance for handling API requests
HTTPServer* httpServer = nullptr;
///
/// Initializes all hardware components: serial communication and GPIO pins.
/// Sets up serial communication at the configured baud rate,
/// configures all GPIO pins as outputs, and initializes them to LOW.
/// Logs a confirmation message to the serial console upon completion.
///
void initializeHardware()
{
Serial.begin(Config::SERIAL_BAUD);
pinMode(LED_BUILTIN, OUTPUT);
pinMode(D1, OUTPUT);
pinMode(D2, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(D1, LOW);
digitalWrite(D2, LOW);
Serial.println("Hardware initialized");
}
///
/// Arduino setup function called once on device boot.
/// Initializes all system components in sequence:
/// 1. Hardware (serial, GPIO pins)
/// 2. ShutterController for camera control
/// 3. HTTPServer with WiFi access point
/// After setup completes, the device is ready to accept API requests.
///
void setup() {
// Initialize hardware (serial and pins)
initializeHardware();
// Initialize ShutterController
shutterController = new ShutterController(D1, D2);
// Initialize HTTPServer
httpServer = new HTTPServer(shutterController);
httpServer->begin();
}
///
/// Arduino loop function called repeatedly after setup completes.
/// Currently empty as the HTTP server runs asynchronously via interrupts.
/// Can be extended in the future for periodic tasks or health monitoring.
///
void loop() {
// put your main code here, to run repeatedly:
}