树莓派支持鼠标和LCD(TODO)

这个工作量比较大,估计要晚一些搞了。。。

安装树莓派 Pico 的 C/C++ SDK

git clone https://github.com/hathach/tinyusb.git

CMakeList.txt

复制代码

cmake_minimum_required(VERSION 3.13)

include(pico_sdk_import.cmake)

project(usb_host_mouse_example)

pico_sdk_init()

add_executable(usb_host_mouse_example

main.c

)

# 添加对 TinyUSB 的支持

add_subdirectory(tinyusb)

target_link_libraries(usb_host_mouse_example pico_stdlib tinyusb_host)

pico_add_extra_outputs(usb_host_mouse_example)

main.c

#include "pico/stdlib.h"

#include "bsp/board.h"

#include "tusb.h"

// USB HID 鼠标回调函数

void tuh_hid_mouse_mounted_cb(uint8_t dev_addr) {

printf("A USB mouse is mounted.\n");

}

void tuh_hid_mouse_unmounted_cb(uint8_t dev_addr) {

printf("A USB mouse is unmounted.\n");

}

void tuh_hid_mouse_isr(uint8_t dev_addr, uint8_t instance, const uint8_t* report, uint16_t len) {

// 解析鼠标报告

int8_t x = report1;

int8_t y = report2;

int8_t wheel = report3;

printf("Mouse movement: x=%d, y=%d, wheel=%d\n", x, y, wheel);

}

int main() {

// 初始化板子和 USB 主机

board_init();

tusb_init();

while (true) {

// 处理 USB 事件

tuh_task();

}

return 0;

}

复制代码

mkdir build

cd build

cmake ..

make

生成的 usb_host_mouse_example.uf2 文件拖放到树莓派 Pico 的 USB 驱动器中,完成固件上传。

相关推荐
忆~遂愿17 小时前
免密连接+快捷键+虚拟鼠标:ToDesk远程操作AI效率拉满
人工智能·python·深度学习·神经网络·自然语言处理·计算机外设·安全架构
硅基手札18 小时前
【串口技术系列文档 07】UART控制器寄存器详解
驱动开发·stm32·单片机·嵌入式硬件·mcu·计算机外设
硅基手札18 小时前
【串口技术系列文档 09】FIFO管理与流控
驱动开发·stm32·单片机·嵌入式硬件·mcu·计算机外设
硅基手札18 小时前
【串口技术系列文档 08】中断驱动vs轮询vs DMA
驱动开发·stm32·单片机·嵌入式硬件·mcu·计算机外设
承渊政道21 小时前
鸿蒙设备远控电脑实测:ToDesk蓝牙键鼠、双模式鼠标、跨端剪贴板,远控电脑更顺手了
计算机外设·电脑·harmonyos·远程工作·todesk
ji_shuke2 天前
使用 Canvas 和 mix-blend-mode 实现跟随鼠标的反色圆圈
microsoft·计算机外设·canvas
硅基手札2 天前
【串口技术系列文档 04】UART协议深度解析
驱动开发·stm32·单片机·嵌入式硬件·mcu·计算机外设
开开心心_Every2 天前
电脑OCR识别软件支持表格识别图片转Excel
java·开发语言·微信·计算机外设·ocr·intellij-idea·excel
野蛮人6号4 天前
macbook连上外接显示器后,字体变小,如何设置成像原来本机的界面一样呢?
计算机外设
打工仔折腾 AI4 天前
从零写一个CAD 05:以鼠标为中心的滚轮缩放,招法能复用但顺序不能反
开发语言·后端·python·性能优化·计算机外设·swift·ai agent 实战