diff --git a/components/aw9523/example/main/aw9523_example.cpp b/components/aw9523/example/main/aw9523_example.cpp index 2d4ab791b..317b06ec7 100644 --- a/components/aw9523/example/main/aw9523_example.cpp +++ b/components/aw9523/example/main/aw9523_example.cpp @@ -8,11 +8,11 @@ using namespace std::chrono_literals; -#define I2C_NUM (I2C_NUM_1) -#define I2C_SCL_IO (GPIO_NUM_19) -#define I2C_SDA_IO (GPIO_NUM_22) -#define I2C_FREQ_HZ (400 * 1000) -#define I2C_TIMEOUT_MS (10) +static constexpr auto I2C_NUM = I2C_NUM_1; +static constexpr auto I2C_SCL_IO = GPIO_NUM_19; +static constexpr auto I2C_SDA_IO = GPIO_NUM_22; +static constexpr auto I2C_FREQ_HZ = (400 * 1000); +static constexpr auto I2C_TIMEOUT_MS = 10; extern "C" void app_main(void) { { diff --git a/components/aw9523/include/aw9523.hpp b/components/aw9523/include/aw9523.hpp index 0688259a9..ee7eaa93a 100644 --- a/components/aw9523/include/aw9523.hpp +++ b/components/aw9523/include/aw9523.hpp @@ -111,35 +111,106 @@ class Aw9523 { } /** - * @brief Set the pin values on the provided port. + * @brief Write the pin values on the provided port. + * @param port The Port for which to write the pins + * @param value The pin values to apply. + * @note This will overwrite any previous pin values on the port for all + * output pins on the port. + */ + void output(Port port, uint8_t value) { + auto addr = port == Port::PORT0 ? Registers::OUTPORT0 : Registers::OUTPORT1; + write_one_((uint8_t)addr, value); + } + + /** + * @brief Write the pin values on both Port 0 and Port 1. + * @param p0 The pin values to apply to Port 0. + * @param p1 The pin values to apply to Port 1. + * @note This will overwrite any previous pin values on the port for all + * output pins on the ports. + */ + void output(uint8_t p0, uint8_t p1) { + output(Port::PORT0, p0); + output(Port::PORT1, p1); + } + + /** + * @brief Write the pin values on both Port 0 and Port 1. + * @param value The pin values to apply as a 16 bit value (P0_0 lsb, P1_7 msb). + * @note This will overwrite any previous pin values on the port for all + * output pins on the ports. + */ + void output(uint16_t value) { + output(Port::PORT0, value & 0xFF); + output(Port::PORT1, value >> 8); + } + + /** + * @brief Clear the pin values on the provided port according to the provided mask. + * @details Reads the current pin values and clears any bits set in the mask. + * @param port The Port for which to clear the pin outputs. + * @param mask The pin values as an 8 bit mask to clear. + */ + void clear_pins(Port port, uint8_t mask) { + auto addr = port == Port::PORT0 ? Registers::OUTPORT0 : Registers::OUTPORT1; + auto data = read_one_((uint8_t)addr); + data &= ~mask; + write_one_((uint8_t)addr, data); + } + + /** + * @brief Clear the pin values for Port 0 and Port 1 according to the provided masks. + * @details Reads the current pin values and clears any bits set in the masks. + * @param p0 The pin values as an 8 bit mask for Port 0 to clear. + * @param p1 The pin values as an 8 bit mask for Port 1 to clear. + */ + void clear_pins(uint8_t p0, uint8_t p1) { + clear_pins(Port::PORT0, p0); + clear_pins(Port::PORT1, p1); + } + + /** + * @brief Clear the pin values for Port 0 and Port 1 according to the provided mask. + * @details Reads the current pin values and clears any bits set in the mask. + * @param mask The pin values as a 16 bit mask (P0_0 lsb, P1_7 msb) to clear. + */ + void clear_pins(uint16_t mask) { + clear_pins(Port::PORT0, mask & 0xFF); + clear_pins(Port::PORT1, mask >> 8); + } + + /** + * @brief Set the pin values on the provided port according to the provided mask. + * @brief Reads the current pin values and sets any bits set in the mask. * @param port The Port for which to set the pin outputs. - * @param output The pin values as an 8 bit mask to set. + * @param mask The pin values as an 8 bit mask to set. */ - void set_pins(Port port, uint8_t output) { + void set_pins(Port port, uint8_t mask) { auto addr = port == Port::PORT0 ? Registers::OUTPORT0 : Registers::OUTPORT1; - write_one_((uint8_t)addr, output); + auto data = read_one_((uint8_t)addr); + data |= mask; + write_one_((uint8_t)addr, data); } /** - * @brief Set the pin values for Port 0 and Port 1. + * @brief Set the pin values for Port 0 and Port 1 according to the provided masks. + * @details Reads the current pin values and sets any bits set in the masks. * @param p0 The pin values for Port 0 as an 8 bit mask to set. * @param p1 The pin values for Port 1 as an 8 bit mask to set. */ void set_pins(uint8_t p0, uint8_t p1) { - auto addr = Registers::OUTPORT0; - uint8_t data[] = {p0, p1}; - write_many_((uint8_t)addr, data, 2); + set_pins(Port::PORT0, p0); + set_pins(Port::PORT1, p1); } /** - * @brief Set the pin values for Port 0 and Port 1. - * @param pins The pin values for Port 0 and Port 1 as a 16 bit mask to set. + * @brief Set the pin values for Port 0 and Port 1 according to the provided mask. + * @details Reads the current pin values and sets any bits set in the mask. + * @param mask The pin values as a 16 bit mask (P0_0 lsb, P1_7 msb) to set. */ - void set_pins(uint16_t pins) { - auto addr = Registers::OUTPORT0; - // first byte is P0, second byte is P1 - uint8_t data[] = {(uint8_t)pins, (uint8_t)(pins >> 8)}; - write_many_((uint8_t)addr, data, 2); + void set_pins(uint16_t mask) { + set_pins(Port::PORT0, mask & 0xFF); + set_pins(Port::PORT1, mask >> 8); } /** diff --git a/docs/adc/adc_types.html b/docs/adc/adc_types.html index 7952c23ea..f62813bdc 100644 --- a/docs/adc/adc_types.html +++ b/docs/adc/adc_types.html @@ -141,7 +141,7 @@
Warning
-doxygenfunction: Unable to resolve function “to_time_t” with arguments None in doxygen xml output for project “esp-docs” from directory: /Users/bob/backbone/lodestone/components/espp/doc/_build/en/esp32/xml_in/. +
doxygenfunction: Unable to resolve function “to_time_t” with arguments None in doxygen xml output for project “esp-docs” from directory: /Users/bob/esp-cpp/espp/doc/_build/en/esp32/xml_in/. Potential matches:
- template<typename TP> std::time_t to_time_t(TP tp)
diff --git a/docs/ftp/index.html b/docs/ftp/index.html
index e0ffacea9..481486e3b 100644
--- a/docs/ftp/index.html
+++ b/docs/ftp/index.html
@@ -130,7 +130,7 @@
Write the pin values on the provided port.
+Note
+This will overwrite any previous pin values on the port for all output pins on the port.
+port – The Port for which to write the pins
value – The pin values to apply.
Write the pin values on both Port 0 and Port 1.
+Note
+This will overwrite any previous pin values on the port for all output pins on the ports.
+p0 – The pin values to apply to Port 0.
p1 – The pin values to apply to Port 1.
Write the pin values on both Port 0 and Port 1.
+Note
+This will overwrite any previous pin values on the port for all output pins on the ports.
+value – The pin values to apply as a 16 bit value (P0_0 lsb, P1_7 msb).
+Clear the pin values on the provided port according to the provided mask.
+Reads the current pin values and clears any bits set in the mask.
+port – The Port for which to clear the pin outputs.
mask – The pin values as an 8 bit mask to clear.
Clear the pin values for Port 0 and Port 1 according to the provided masks.
+Reads the current pin values and clears any bits set in the masks.
+p0 – The pin values as an 8 bit mask for Port 0 to clear.
p1 – The pin values as an 8 bit mask for Port 1 to clear.
Clear the pin values for Port 0 and Port 1 according to the provided mask.
+Reads the current pin values and clears any bits set in the mask.
+mask – The pin values as a 16 bit mask (P0_0 lsb, P1_7 msb) to clear.
+Set the pin values on the provided port.
+inline void set_pins(Port port, uint8_t mask)Set the pin values on the provided port according to the provided mask.
+Reads the current pin values and sets any bits set in the mask.
port – The Port for which to set the pin outputs.
output – The pin values as an 8 bit mask to set.
mask – The pin values as an 8 bit mask to set.
Set the pin values for Port 0 and Port 1.
+Set the pin values for Port 0 and Port 1 according to the provided masks.
+Reads the current pin values and sets any bits set in the masks.
Set the pin values for Port 0 and Port 1.
+inline void set_pins(uint16_t mask)Set the pin values for Port 0 and Port 1 according to the provided mask.
+Reads the current pin values and sets any bits set in the mask.
pins – The pin values for Port 0 and Port 1 as a 16 bit mask to set.
+mask – The pin values as a 16 bit mask (P0_0 lsb, P1_7 msb) to set.
Simple c++ class for printing tables using libfmt.
+Does simple width calculations and alignment, then prints the table using fmt::print (drawing boxes with unicode characters).
+Public Functions
+Construct a new Tabulate object.
+Construct a new Tabulate object with the first row / headers provided. Will set the num_columns based on the size of the headers. Will also set the column_widths to the size of the headers.
+headers – First row of the table
+Get a reference to a row in the table.
+row – Row of the table
+std::vector<std::string>& Reference to the row
+Add a row to the table.
+row – Row to add to the table
+Print the table to stdout.
+Get the table as a string.
+std::string Table as a string
+Table maker for modern c++ convenience wrapper around p-ranav/tabulate which exposes tabulate::Table for creating human-readable tables in console/terminal applications.
using namespace tabulate;
- using Row_t = Table::Row_t;
+ // using namespace tabulate;
+ // using Row_t = Table::Row_t;
- Table universal_constants;
+ // Table universal_constants;
+ espp::Tabulate universal_constants({"Quantity", "Value"});
- universal_constants.add_row({"Quantity", "Value"});
+ //universal_constants.add_row({"Quantity", "Value"});
universal_constants.add_row({"Characteristic impedance of vacuum", "376.730 313 461... Ω"});
universal_constants.add_row(
{"Electric constant (permittivity of free space)", "8.854 187 817... × 10⁻¹²F·m⁻¹"});
@@ -192,27 +257,29 @@ Tabulate Example universal_constants.add_row({"Dirac's constant", "1.054 571 68(18) × 10⁻³⁴ J·s"});
universal_constants.add_row({"Speed of light in vacuum", "299 792 458 m·s⁻¹"});
- universal_constants.format()
- .font_style({FontStyle::bold})
- .border_top(" ")
- .border_bottom(" ")
- .border_left(" ")
- .border_right(" ")
- .corner(" ");
-
- universal_constants[0]
- .format()
- .padding_top(1)
- .padding_bottom(1)
- .font_align(FontAlign::center)
- .font_style({FontStyle::underline})
- .font_background_color(Color::red);
-
- universal_constants.column(1).format().font_color(Color::yellow);
-
- universal_constants[0][1].format().font_background_color(Color::blue).font_color(Color::white);
-
- std::cout << universal_constants << std::endl << std::endl;
+ /*
+ universal_constants.format()
+ .font_style({FontStyle::bold})
+ .border_top(" ")
+ .border_bottom(" ")
+ .border_left(" ")
+ .border_right(" ")
+ .corner(" ");
+
+ universal_constants[0]
+ .format()
+ .padding_top(1)
+ .padding_bottom(1)
+ .font_align(FontAlign::center)
+ .font_style({FontStyle::underline})
+ .font_background_color(Color::red);
+
+ universal_constants.column(1).format().font_color(Color::yellow);
+
+ universal_constants[0][1].format().font_background_color(Color::blue).font_color(Color::white);
+ std::cout << universal_constants << std::endl << std::endl;
+ */
+ std::cout << universal_constants.get() << std::endl << std::endl;
diff --git a/docs/task.html b/docs/task.html
index a1ec5153b..49cf2fd62 100644
--- a/docs/task.html
+++ b/docs/task.html
@@ -135,7 +135,7 @@