Skip to content

Commit

Permalink
feat(esp32-timer-cam): Add battery voltage scale and camera pin defs (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
finger563 authored Aug 27, 2024
1 parent cad9e08 commit f7c5024
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 2 deletions.
89 changes: 88 additions & 1 deletion components/esp32-timer-cam/include/esp32-timer-cam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,74 @@ class EspTimerCam : public BaseComponent {
/// @return A shared pointer to the RTC
std::shared_ptr<Rtc> rtc();

/////////////////////////////////////////////////////////////////////////////
// Camera
/////////////////////////////////////////////////////////////////////////////

/// @brief Get the camera reset pin
/// @return The camera reset pin
static gpio_num_t get_camera_reset_pin() { return camera_reset_pin; }

/// @brief Get the camera XCLK pin
/// @return The camera XCLK pin
static gpio_num_t get_camera_xclk_pin() { return camera_xclk_pin; }

/// @brief Get the camera SDA pin
/// @return The camera SDA pin
static gpio_num_t get_camera_sda_pin() { return camera_sda_pin; }

/// @brief Get the camera SCL pin
/// @return The camera SCL pin
static gpio_num_t get_camera_scl_pin() { return camera_scl_pin; }

/// @brief Get the camera D0 pin
/// @return The camera D0 pin
static gpio_num_t get_camera_d0_pin() { return camera_d0_pin; }

/// @brief Get the camera D1 pin
/// @return The camera D1 pin
static gpio_num_t get_camera_d1_pin() { return camera_d1_pin; }

/// @brief Get the camera D2 pin
/// @return The camera D2 pin
static gpio_num_t get_camera_d2_pin() { return camera_d2_pin; }

/// @brief Get the camera D3 pin
/// @return The camera D3 pin
static gpio_num_t get_camera_d3_pin() { return camera_d3_pin; }

/// @brief Get the camera D4 pin
/// @return The camera D4 pin
static gpio_num_t get_camera_d4_pin() { return camera_d4_pin; }

/// @brief Get the camera D5 pin
/// @return The camera D5 pin
static gpio_num_t get_camera_d5_pin() { return camera_d5_pin; }

/// @brief Get the camera D6 pin
/// @return The camera D6 pin
static gpio_num_t get_camera_d6_pin() { return camera_d6_pin; }

/// @brief Get the camera D7 pin
/// @return The camera D7 pin
static gpio_num_t get_camera_d7_pin() { return camera_d7_pin; }

/// @brief Get the camera VSYNC pin
/// @return The camera VSYNC pin
static gpio_num_t get_camera_vsync_pin() { return camera_vsync_pin; }

/// @brief Get the camera HREF pin
/// @return The camera HREF pin
static gpio_num_t get_camera_href_pin() { return camera_href_pin; }

/// @brief Get the camera PCLK pin
/// @return The camera PCLK pin
static gpio_num_t get_camera_pclk_pin() { return camera_pclk_pin; }

/// @brief Get the camera XCLK frequency
/// @return The camera XCLK frequency in Hz
static int get_camera_xclk_freq_hz() { return camera_xclk_freq; }

protected:
EspTimerCam();
float led_breathe();
Expand All @@ -138,8 +206,27 @@ class EspTimerCam : public BaseComponent {
static constexpr gpio_num_t internal_i2c_sda = GPIO_NUM_12;
static constexpr gpio_num_t internal_i2c_scl = GPIO_NUM_14;

// Camera
// Battery
static constexpr float BATTERY_VOLTAGE_SCALE = 1.0f / 661.0f; // measured mV across divider to battery volts
static constexpr gpio_num_t battery_hold_pin = GPIO_NUM_33; // NOTE: unused

// Camera
static constexpr gpio_num_t camera_reset_pin = GPIO_NUM_15;
static constexpr gpio_num_t camera_xclk_pin = GPIO_NUM_27;
static constexpr gpio_num_t camera_sda_pin = GPIO_NUM_25;
static constexpr gpio_num_t camera_scl_pin = GPIO_NUM_23;
static constexpr gpio_num_t camera_d0_pin = GPIO_NUM_32;
static constexpr gpio_num_t camera_d1_pin = GPIO_NUM_35;
static constexpr gpio_num_t camera_d2_pin = GPIO_NUM_34;
static constexpr gpio_num_t camera_d3_pin = GPIO_NUM_5;
static constexpr gpio_num_t camera_d4_pin = GPIO_NUM_39;
static constexpr gpio_num_t camera_d5_pin = GPIO_NUM_18;
static constexpr gpio_num_t camera_d6_pin = GPIO_NUM_36;
static constexpr gpio_num_t camera_d7_pin = GPIO_NUM_19;
static constexpr gpio_num_t camera_vsync_pin = GPIO_NUM_22;
static constexpr gpio_num_t camera_href_pin = GPIO_NUM_26;
static constexpr gpio_num_t camera_pclk_pin = GPIO_NUM_21;
static constexpr int camera_xclk_freq = 10 * 1000 * 1000;

// TODO: allow core id configuration
I2c internal_i2c_{{.port = internal_i2c_port,
Expand Down
2 changes: 1 addition & 1 deletion components/esp32-timer-cam/src/esp32-timer-cam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ float EspTimerCam::get_battery_voltage() {
auto mv = maybe_mv.value();
measurement = mv;
}
return measurement / 1000.0f;
return measurement * BATTERY_VOLTAGE_SCALE;
}

////////////////////////
Expand Down

0 comments on commit f7c5024

Please sign in to comment.