This sample application implements an air mouse using the Zephyr RTOS. It utilizes the Zephyr USB subsystem to create a standard USB HID mouse device and the Sensor API to interface with a LIS2DH accelerometer sensor. The air mouse translates physical movement of the device into cursor movement on a connected computer.
- USB HID mouse device implementation
- LIS2DH accelerometer-based motion detection and translation
- Plug-and-play compatibility with most operating systems
- Low latency motion-to-cursor translation
- Button input support for mouse clicks
- STM32F3 Discovery board featuring:
- STM32F303VC microcontroller
- USB device capability
- LIS2DH accelerometer sensor
- User programmable buttons
- Zephyr RTOS (version 3.4.0 or newer)
- West build tools
- LIS2DH device driver
This sample can be built for the STM32F3 Discovery board.
.. zephyr-app-commands:: :zephyr-app: samples/application_development/air_mouse :board: stm32f3_disco :goals: build flash :compact:
- Connect your STM32F3 Discovery board to a computer via USB
- The device should be recognized as a standard USB mouse
- Move the board in the air to control the cursor
- Use the user buttons on the board for mouse clicks (configured in the device tree).
The application uses the Zephyr sensor API to read acceleration data from the LIS2DH sensor. This data is processed to filter out noise and calculate cursor movement. The USB HID class is then used to send mouse reports to the connected computer.
Key components:
- LIS2DH accelerometer data acquisition
- Motion processing algorithm
- USB HID mouse report generation
- Button input handling
- If the mouse cursor doesn't move, check that the LIS2DH sensor is properly initialized
- Verify that the USB connection is properly established
- Check the system logs for any error messages
- If cursor movement is erratic, try adjusting the sensitivity settings in the code