树莓派支持鼠标和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 驱动器中,完成固件上传。

  • 5
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我们可以创建一个基于 Vue 3 和 TypeScript 的 todo 应用。首先需要创建一个 Vue 3 项目,可以使用 Vue CLI 进行快速创建。 1. 首先安装 Vue CLI: ``` npm install -g @vue/cli ``` 2. 创建一个新项目: ``` vue create vue3-todo --default ``` 在选择 features 时选择 TypeScript,这样就可以创建一个基于 TypeScript 的 Vue 3 项目。 3. 安装依赖: ``` cd vue3-todo npm install ``` 4. 创建一个 Todo 组件: ```vue <template> <div> <h1>Todo List</h1> <form @submit.prevent="addTodo"> <input type="text" v-model="newTodo" /> <button type="submit">Add</button> </form> <ul> <li v-for="(todo, index) in todos" :key="index">{{ todo }}</li> </ul> </div> </template> <script lang="ts"> import { defineComponent, ref } from 'vue'; export default defineComponent({ name: 'Todo', setup() { const newTodo = ref(''); const todos = ref<string[]>([]); const addTodo = () => { if (newTodo.value.trim()) { todos.value.push(newTodo.value.trim()); newTodo.value = ''; } }; return { newTodo, todos, addTodo, }; }, }); </script> ``` 在这个组件中,我们使用了 `ref` 来定义了一个 `newTodo` 和 `todos` 变量,`newTodo` 表示新增的待办事项,`todos` 是一个待办事项列表。我们还定义了一个 `addTodo` 方法,用来向 `todos` 中添加一个新的待办事项。 在模板中,我们使用了 `v-for` 来遍历 `todos`,并将每个待办事项渲染为一个列表项。同时,我们使用了 `v-model` 来绑定 `newTodo` 变量,当用户在输入框中输入内容时,`newTodo` 的值会自动更新。 5. 在 `App.vue` 中使用 `Todo` 组件: ```vue <template> <div id="app"> <Todo /> </div> </template> <script lang="ts"> import { defineComponent } from 'vue'; import Todo from './components/Todo.vue'; export default defineComponent({ name: 'App', components: { Todo, }, }); </script> ``` 6. 运行项目: ``` npm run serve ``` 打开浏览器访问 http://localhost:8080,就可以看到一个简单的 todo 应用了。 以上就是基于 Vue 3 和 TypeScript 创建 todo 应用的简单步骤。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值