-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(base_component): add new base component and improve I2C class + …
…example (#149) * feat(base_component): add new base component * Add base component which contains logger with some methods for setting logging level and tag for the logger * Update i2c to subclass base component and add some extra methods for writing / reading with std::vector. Also added some logging to the i2c component * Add i2c format helpers for logging the i2c bus which is initialized * Add missing i2c destructor * Update i2c example to test new i2c destructor * Add i2c menu to i2c example for allowing interactive control / query of the i2c bus using cli component * Update i2c and cli component to have s3 defualts file configuring the console output port to be usb serial/jtag * added missing base component * minor update to i2c menu to enable easier reuse * minor update to deinit * feat(i2c): change naming of new functions so that older std::bind based peripheral code still compiles * doc: update * doc: rebuild * set logger verbosity to default level so that it doesnt have to be provided * update to change BMI formatting * update non-peripheral components to use new base_component class * doc: rebuild * fix(controller): fix typo from refactor to base component * fix(base_component): make constructors with arguments explicit * add explicit cast * fix(rtsp): fix out of order BMI member use * doc: rebuild
- Loading branch information
Showing
168 changed files
with
4,748 additions
and
567 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
idf_component_register( | ||
INCLUDE_DIRS "include" | ||
REQUIRES logger task esp_adc) | ||
REQUIRES base_component task esp_adc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
idf_component_register( | ||
INCLUDE_DIRS "include" | ||
REQUIRES logger) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#pragma once | ||
|
||
#include <chrono> | ||
#include <string> | ||
|
||
#include "logger.hpp" | ||
|
||
namespace espp { | ||
/// Base class for all components | ||
/// Provides a logger and some basic logging configuration | ||
class BaseComponent { | ||
public: | ||
/// Set the tag for the logger | ||
/// \param tag The tag to use for the logger | ||
void set_log_tag(const std::string_view &tag) { logger_.set_tag(tag); } | ||
|
||
/// Set the log level for the logger | ||
/// \param level The verbosity level to use for the logger | ||
/// \sa Logger::Verbosity | ||
/// \sa Logger::set_verbosity | ||
void set_log_level(Logger::Verbosity level) { logger_.set_verbosity(level); } | ||
|
||
/// Set the log verbosity for the logger | ||
/// \param level The verbosity level to use for the logger | ||
/// \note This is a convenience method that calls set_log_level | ||
/// \sa set_log_level | ||
/// \sa Logger::Verbosity | ||
/// \sa Logger::set_verbosity | ||
void set_log_verbosity(Logger::Verbosity level) { set_log_level(level); } | ||
|
||
/// Set the rate limit for the logger | ||
/// \param rate_limit The rate limit to use for the logger | ||
/// \note Only calls to the logger that have _rate_limit suffix will be rate limited | ||
/// \sa Logger::set_rate_limit | ||
void set_log_rate_limit(std::chrono::duration<float> rate_limit) { | ||
logger_.set_rate_limit(rate_limit); | ||
} | ||
|
||
protected: | ||
BaseComponent() = default; | ||
|
||
explicit BaseComponent(std::string_view tag, Logger::Verbosity level = Logger::Verbosity::WARN) | ||
: logger_({.tag = tag, .level = level}) {} | ||
|
||
explicit BaseComponent(const Logger::Config &logger_config) | ||
: logger_(logger_config) {} | ||
|
||
/// The logger for this component | ||
Logger logger_ = espp::Logger({.tag = "BaseComponent", .level = Logger::Verbosity::INFO}); | ||
}; | ||
} // namespace espp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
idf_component_register( | ||
INCLUDE_DIRS "include" | ||
REQUIRES logger driver) | ||
REQUIRES base_component driver) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
idf_component_register( | ||
INCLUDE_DIRS "include" | ||
REQUIRES logger math pid task bldc_motor | ||
REQUIRES base_component math pid task bldc_motor | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
idf_component_register( | ||
INCLUDE_DIRS "include" | ||
REQUIRES logger math pid task | ||
REQUIRES base_component math pid task | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
idf_component_register( | ||
INCLUDE_DIRS "include" | ||
REQUIRES driver logger task) | ||
REQUIRES driver base_component task) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# on the ESP32S3, which has native USB, we need to set the console so that the | ||
# CLI can be configured correctly: | ||
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y |
Oops, something went wrong.