树莓派支持鼠标和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 = report[1];

int8_t y = report[2];

int8_t wheel = report[3];

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 驱动器中,完成固件上传。

相关推荐
暖光资讯2 小时前
从「秒罄」到「溢价」:前行者×洛天依联名键盘如何重写外设市场规则
计算机外设
驱动男孩3 小时前
新主机和显示器到了之后,如何让自己显示器 ,显示没有朦胧感呢?新机开荒
计算机外设·win11
Wpa.wk1 天前
自动化测试-鼠标+键盘操作 - Actions高级控件
java·开发语言·测试工具·自动化·计算机外设·actions·高级控件
徐徐图之!2 天前
你对键盘知多少?
计算机外设
ACP广源盛139246256733 天前
GSV6155@ACP#6155产品规格详解及产品应用分享
嵌入式硬件·计算机外设·音视频
电脑小管家3 天前
路由器怎么重新设置wifi密码
网络·windows·计算机外设·智能路由器·电脑
非凡ghost3 天前
Brightness.Manager.OK(显示器亮度调节软件)
android·智能手机·计算机外设·软件需求
hashiqimiya3 天前
拓展显示器,与显示器相关软件
计算机外设
uuleaf4 天前
26键打字训练小游戏:键盘练习游戏合集
游戏·计算机外设·编程打字
我送炭你添花4 天前
Pelco KBD300A 模拟器:01.Pelco 协议前世今生 & KBD300A 键盘基础解析
网络·python·计算机外设·pyqt