Knob driver implemented through software pcnt

readme

[![Component Registry](https://components.espressif.com/components/espressif/knob/badge.svg)](https://components.espressif.com/components/espressif/knob) ## Component Knob `Knob` is the component that provides the software PCNT, it can be used on chips(esp32c2, esp32c3) that do not have PCNT hardware capabilities. By using this component, you can quickly use a physical encoder, such as the EC11 encoder. Features: 1. Support multiple knobs 2. Support each event can register its own callback 3. Support setting the upper and lower count limits List of supported events: * Knob left * Knob right * Knob high limit * Knob low limit * Knob back to zero ### Examples [USB Surface Dial](https://github.com/espressif/esp-iot-solution/tree/master/examples/usb/device/usb_surface_dial) `Note`: This component is only suitable for decoding low-speed rotary encoders such as EC11, and does not guarantee the complete correctness of the pulse count. For high-speed and accurate calculations, please use hardware [PCNT](https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/api-reference/peripherals/pcnt.html?highlight=pcnt) * | Hardware PCNT Supported Targets | ESP32 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 | | ------------------------------- | ----- | -------- | -------- | -------- | -------- |

changelog

# ChangeLog ## v0.1.4 - 2023-11-23 * Fix possible cmake_utilities dependency issue ## v0.1.3 - 2023-6-2 ### Enhancements: * Add power on knob position detection to avoid logical inversion caused by knob position * Change test to test_apps project ## v0.1.2 - 2023-3-9 ### Enhancements: * Use cu_pkg_define_version to define the version of this component. ## v0.1.1 - 2023-1-18 ### Bug Fixes: * Knob: * Fix callback return usr_data root pointer, the usr_data of the relevant callback will now be returned. ## v0.1.0 - 2023-1-5 ### Enhancements: * Initial version * The following types of events are supported | EVENT | 描述 | | ---------- | -------------------------------------- | | KNOB_LEFT | EVENT: Rotate to the left | | KNOB_RIGHT | EVENT: Rotate to the right | | KNOB_H_LIM | EVENT: Count reaches maximum limit | | KNOB_L_LIM | EVENT: Count reaches the minimum limit | | KNOB_ZERO | EVENT: Count back to 0 | * Support for defining multiple knobs * Support binding callback functions for each event and adding user-data

readme of usb_surface_dial example

## USB HID Surface Dial This example shows how to use the ESP32-Sx USB function to emulate a Windows knob that allows volume control, page up and down, and more. ## Hardware Required ![surface_dial_physical](_static/surface_dial_physical.jpg) - Any ESP32-Sx development board with **knob** functionality. - The knob can be a series of rotary encoders with push function such as EC11 - It is also possible to use three buttons that simulate: press, left turn, right turn - Hardware Connection: - GPIO19 to USB_D- - GPIO20 to USB_D+ - GPIO42 to EC11_E - GPIO1 to EC11_A - GPIO2 to EC11_C ![schematic](_static/schematic.png) ![schematic](_static/package.png) ## Build and Flash 1. Set up the `ESP-IDF` environment variables,you can refer [Set up the environment variables](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html#step-4-set-up-the-environment-variables), Linux can using: ``` . $HOME/esp/esp-idf/export.sh ``` 2. Set ESP-IDF build target to `esp32s2` or `esp32s3` ```bash idf.py set-target esp32s2 ``` 3. Build, Flash, output log ```bash idf.py build flash monitor ``` ## How To Use * Connect the USB to the Windows USB port and wait for the USB device to finish installing * Press and hold the button to wake up the Windows wheel ![Surface dial](_static/surface_dial.png)

Supports all targets

License: Apache-2.0

To add this component to your project, run:

idf.py add-dependency "espressif/knob^0.1.4"

or download archive

Dependencies

  • espressif/cmake_utilities 0.*
  • ESP-IDF >=4.4.1
  • Examples:

    usb_surface_dial

    more details

    Stats

    • Downloaded in total
      Downloaded in total 953 times
    • Downloaded this version
      This version: 36 times

    Badge

    espressif/knob version: 0.1.4 |