Wheel module

The wheel module is responsible for generating events related to the rotation of the mouse wheel.

Module events

Source Module

Input Event

This Module

Output Event

Sink Module

Power manager module

power_down_event

wheel

Source modules for module_state_event

module_state_event

Bluetooth LE advertising module

wake_up_event

Buttons module

HID forward module

Motion module

Power manager module

Wheel module

module_state_event

Sink modules for module_state_event

wake_up_event

Sink modules for wake_up_event

wheel_event

HID state module

Note

See the Overview: Firmware architecture for more information about the event-based communication in the nRF Desktop application and about how to read this table.

Configuration

Enable the module with the CONFIG_DESKTOP_WHEEL_ENABLE Kconfig option.

For detecting rotation, the wheel module uses Zephyr’s QDEC driver. The module can be enabled only when QDEC is configured in DTS (that is, CONFIG_QDEC_NRFX is set).

The QDEC DTS configuration specifies how many steps are done during one full angle. The sensor reports the rotation data in angle degrees. Then, CONFIG_DESKTOP_WHEEL_SENSOR_VALUE_DIVIDER (a wheel configuration option) converts the angle value into a value that is passed with a wheel_event to the destination module.

For example, configuring QDEC with 24 steps means that for each step the sensor will report a rotation of 15 degrees. For HID to see this rotation as increment of one, CONFIG_DESKTOP_WHEEL_SENSOR_VALUE_DIVIDER should be set to 15.

Implementation details

The wheel module can be in the following states:

  • STATE_DISABLED

  • STATE_ACTIVE_IDLE

  • STATE_ACTIVE

  • STATE_SUSPENDED

When in STATE_ACTIVE, the module enables the QDEC driver and waits for callback that indicates rotation. The QDEC driver may consume power during its operation.

If no rotation is detected after the time specified in CONFIG_DESKTOP_WHEEL_SENSOR_IDLE_TIMEOUT, the wheel module switches to STATE_ACTIVE_IDLE, in which QDEC is disabled. In this state, the rotation is detected using GPIO interrupts. When the rotation is detected, the module switches back to STATE_ACTIVE.

When the system enters the low power state, the wheel module goes to STATE_SUSPENDED. In this state, the rotation is detected using the GPIO interrupts. The module issues a system wake-up event on wheel movement.