diff --git a/components/aw9523/include/aw9523.hpp b/components/aw9523/include/aw9523.hpp index be4d715f2..52c57c415 100644 --- a/components/aw9523/include/aw9523.hpp +++ b/components/aw9523/include/aw9523.hpp @@ -76,16 +76,21 @@ class Aw9523 { MaxLedCurrent max_led_current = MaxLedCurrent::IMAX; ///< Max current allowed on each LED. write_fn write; ///< Function to write to the device. read_fn read; ///< Function to read from the device. + bool auto_init = true; ///< Automatically initialize the device. Logger::Verbosity log_level{Logger::Verbosity::WARN}; ///< Log verbosity for the component. }; /** - * @brief Construct the Aw9523. Initialization called separately. + * @brief Construct the Aw9523. Will call initialize() if auto_init is true. * @param config Config structure for configuring the AW9523 */ Aw9523(const Config &config) : config_(config), address_(config.device_address), write_(config.write), read_(config.read), - logger_({.tag = "Aw9523", .level = config.log_level}) {} + logger_({.tag = "Aw9523", .level = config.log_level}) { + if (config.auto_init) { + initialize(); + } + } /** * @brief Initialize the component class. diff --git a/docs/adc/adc_types.html b/docs/adc/adc_types.html index 98a7b8e11..8ff416490 100644 --- a/docs/adc/adc_types.html +++ b/docs/adc/adc_types.html @@ -141,7 +141,7 @@
Construct the Aw9523. Initialization called separately.
+Construct the Aw9523. Will call initialize() if auto_init is true.
config – Config structure for configuring the AW9523
@@ -789,6 +789,12 @@Function to read from the device.
Automatically initialize the device.
+