Skip to content

Commit

Permalink
doc: update
Browse files Browse the repository at this point in the history
  • Loading branch information
finger563 committed Mar 11, 2024
1 parent 4c842ae commit 0678002
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
2 changes: 2 additions & 0 deletions doc/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ EXAMPLE_PATH += $(PROJECT_PATH)/components/gt911/example/main/gt911_example.cpp
EXAMPLE_PATH += $(PROJECT_PATH)/components/hid-rp/example/main/hid_rp_example.cpp
EXAMPLE_PATH += $(PROJECT_PATH)/components/hid_service/example/main/hid_service_example.cpp
EXAMPLE_PATH += $(PROJECT_PATH)/components/i2c/example/main/i2c_example.cpp
EXAMPLE_PATH += $(PROJECT_PATH)/components/interrupt/example/main/interrupt_example.cpp
EXAMPLE_PATH += $(PROJECT_PATH)/components/joystick/example/main/joystick_example.cpp
EXAMPLE_PATH += $(PROJECT_PATH)/components/kts1622/example/main/kts1622_example.cpp
EXAMPLE_PATH += $(PROJECT_PATH)/components/led/example/main/led_example.cpp
Expand Down Expand Up @@ -134,6 +135,7 @@ INPUT += $(PROJECT_PATH)/components/hid-rp/include/hid-rp.hpp
INPUT += $(PROJECT_PATH)/components/hid-rp/include/hid-rp-gamepad.hpp
INPUT += $(PROJECT_PATH)/components/hid_service/include/hid_service.hpp
INPUT += $(PROJECT_PATH)/components/i2c/include/i2c.hpp
INPUT += $(PROJECT_PATH)/components/interrupt/include/interrupt.hpp
INPUT += $(PROJECT_PATH)/components/input_drivers/include/encoder_input.hpp
INPUT += $(PROJECT_PATH)/components/input_drivers/include/keypad_input.hpp
INPUT += $(PROJECT_PATH)/components/input_drivers/include/touchpad_input.hpp
Expand Down
21 changes: 10 additions & 11 deletions doc/en/button.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
Button APIs
***********

The `Button` class provides a simple wrapper around the ESP-IDF gpio API to
provide a simple interface for reading the state of a button. The class sets the
GPIO pin to input mode and installs an ISR to detect button presses. The ISR
sends data to the `Button`'s queue which is read by the `Button`'s task. The
task periodically checks the queue for new data and updates the button state
accordingly, additionally calling the provided callback function if one was
registered.
The `Button` class provides a simple way to read the state of a button. There
are two ways to configure the functionality of the button.

Note: the data passed to the callback function is a `espp::Button::Event` object
which contains the button's state and the gpio associated with the button.
The first uses `Button::Config` to configure the button to call a function when
the button is pressed or released and uses the `Interrupt` class' task and ISR
for signaling. At any time, a user may also call the `is_pressed` method to read
the current state of the button's input pin.

Additionally, users can check the state of the button by calling the
`is_pressed` method.
The second uses `Button::SimpleConfig` to simply configure the button as an
input with configurable pull-up or pull-down resistors and a configurable active
state (high or low). In this configuration, the input is read manually any time
the user calls the `is_pressed` method.

.. ---------------------------- API Reference ----------------------------------
Expand Down
1 change: 1 addition & 0 deletions doc/en/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ This is the documentation for esp-idf c++ components, ESPP (`espp <https://githu
haptics/index
hid/index
i2c
interrupt
input/index
io_expander/index
joystick
Expand Down
22 changes: 22 additions & 0 deletions doc/en/interrupt.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Interrupt APIs
**************

The `Interrupt` class provides APIs to register interrupt handlers for GPIO and
configure the interrupts. Interrupts can be configured to trigger on rising
edge, falling edge, high level, low level, or any change in the input signal. A
single interrupt object can manage multiple GPIO pins with separate callbacks
for each GPIO, or separte `Interrupt` objects can be created (though that uses
more memory and CPU as each `Interrupt` will has its own queue, ISR handler, and
task.

Finally, the `Interrupt` class is also designed to be subclassed if desired to
provide additional functionality, or it can of course be included as a member
within another class. The Button class provides a very simple implementation of
a subclass of `Interrupt`.

.. ---------------------------- API Reference ----------------------------------
API Reference
-------------

.. include-build-file:: inc/interrupt.inc

0 comments on commit 0678002

Please sign in to comment.