How to consume the PCA9685 driver in your CMake or ESP-IDF project.
ESP-IDF Integration
The driver ships with an ESP-IDF component wrapper in examples/esp32/components/hf_pca9685/.
1. Reference the Component
Option 1 — Symlink or copy the wrapper:
your-esp-project/
├── CMakeLists.txt
├── main/
│ ├── CMakeLists.txt
│ └── app_main.cpp
└── components/
└── hf_pca9685/
└── CMakeLists.txt ← copy from driver's examples/esp32/components/
Option 2 — Use EXTRA_COMPONENT_DIRS:
# In your project-level CMakeLists.txt, before include($ENV{IDF_PATH}/...)
set(EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/../path/to/hf-pca9685-driver/examples/esp32/components")
2. Override the Driver Root (if needed)
The component wrapper auto-detects the driver root via a relative path. If your directory layout differs, override it:
set(HF_PCA9685_ROOT "/absolute/path/to/hf-pca9685-driver" CACHE PATH "")
3. Require the Component
In your main/CMakeLists.txt:
idf_component_register(
SRCS "app_main.cpp"
INCLUDE_DIRS "."
REQUIRES hf_pca9685 driver
)
target_compile_features(${COMPONENT_LIB} PRIVATE cxx_std_20)
4. Include and Use
#include "pca9685.hpp"
#include "pca9685_version.h"
pca9685::PCA9685<MyI2cBus> driver(&bus, 0x40);
Version Header
The build system generates pca9685_version.h from inc/pca9685_version.h.in at configure time. It provides:
#define HF_PCA9685_VERSION_MAJOR 1
#define HF_PCA9685_VERSION_MINOR 0
#define HF_PCA9685_VERSION_PATCH 0
#define HF_PCA9685_VERSION_STRING "1.0.0"
Include it in your application to verify at runtime which version is compiled in:
#include "pca9685_version.h"
printf("PCA9685 driver v%s\n", HF_PCA9685_VERSION_STRING);