Open supperthomas opened 2 years ago
PICO 自我调试: firmware.zip
PICO 调试pico
利用板上的四向摇杆和按键设计一款“鼠标” 在240*240的LCD屏幕内可以通过该鼠标进行菜单选择和参数控制(在屏幕上要有上图中图形化的箭头形状) 通过USB端口可以控制PC屏幕上的光标移动和点击操作,行使电脑鼠标的功能
可以用箭头指示相应的按键方向,圆点指示按键
通过板上的红外接收器,接收任何一款家用遥控器的控制信号,并能够对遥控器的控制信号进行识别 在LCD上绘制一个遥控器控制界面,并能够通过四向摇杆和按键来行使原来遥控器的控制操作
设计或移植一款经典的游戏(硬禾学堂上已经实现的贪吃蛇等游戏除外),通过LCD屏显示,通过按键和四向摇杆控制游戏的动作: 经典的Pong 挖地雷 打飞机 俄罗斯方块 ....... 在游戏中要通过蜂鸣器播放背景音乐
使用板上的扩展端口上的数字信号 可以对任意一款MCU或FPGA进行调试、固件的下载
使用板上的扩展端口上的数字信号 能够对SPI、I2C的外设进行控制设置、参数读写 数字信号的波形显示在LCD上或通过USB传输到PC上在上位机进行显示
使用板上的扩展端口上的数字信号以及2路模拟输入 自行搭配外围器件或模块 实现以下类型中的任意一个题目: 搭载模拟链路实现信号采集及分析,可以针对电路分析、测试测量类的题目 搭载传感器、电机、开关等实现控制类的题目 以上的6个项目不限用MicroPython或C/C++语言编写。
项目2 - 带学习功能的红外遥控器
通过板上的红外接收器,接收任何一款家用遥控器的控制信号,并能够对遥控器的控制信号进行识别 在LCD上绘制一个遥控器控制界面,并能够通过四向摇杆和按键来行使原来遥控器的控制操作
RT-THREAD: PWM驱动和HWTIMER驱动,以及LCD驱动需要完成 arduino: 库比较多。 mpy: 库比较少,感觉。
sdk set PICO_SDK_PATH=F:\04_git_repo\GITEE\pico-sdk
https://github.com/EETree-git/RP2040_Game_Kit/raw/main/lecture/mpy-sge-pimoroni-hid-v20220116.uf2
ball.py可以测试pimoroni的驱动,mpy支持和测试文件都在这里: https://github.com/EETree-git/RP2040_Game_Kit/tree/main/lecture
platformio
#include <Arduino.h>
void setup() {
Serial.begin(115200);
pinMode(p4, OUTPUT);
// put your setup code here, to run once:
}
void loop() {
digitalWrite(p4, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(p4, LOW); // turn the LED off by making the voltage LOW
delay(1000);
Serial.println("hello");
}
imagemagick
树莓派庆祝 Raspberry Pi Pico 发布一周年
显示图片
import gc
from machine import Pin, SPI
import st7789c
from board import game_kit
from time import sleep
gc.enable()
gc.collect()
def main():
spi = SPI(0, baudrate=31250000, polarity=1, phase=1,
sck=Pin(game_kit.lcd_sck, Pin.OUT),
mosi=Pin(game_kit.lcd_sda, Pin.OUT))
tft = st7789c.ST7789(
spi,
240,
240,
reset=Pin(game_kit.lcd_rst, Pin.OUT),
dc=Pin(game_kit.lcd_dc, Pin.OUT),
#xstart=0,
#ystart=0,
rotation=0)
# enable display and clear screen
tft.init()
i = 0
tft.jpg("mini.jpg", 50, 50, st7789c.FAST)
sleep(1)
main()
### rp2040-ani.py --- play rp2040 chip tear-down animation.
## author: picospuch
## resource-from: https://twitter.com/johndmcmaster
### 转换图片的方法
## tjpgd只支持baseline编码的jpeg标准, 所以需要对资源进行转换. 步骤如下:
## 1. 下载imagemagick并安装
## 2. 打开命令提示符
## 3. 运行`convert rp2040.mp4 -type TrueColor -resize 240x240 rp2040.jpg`
## 4. 把转换后的jpg文件上传pico
import gc
from machine import Pin, SPI,ADC
import st7789c
from board import game_kit
from time import sleep
import hid
import usb_hid
m = hid.Mouse()
xAxis = ADC(Pin(29))
yAxis = ADC(Pin(28))
buttonB = Pin(5,Pin.IN, Pin.PULL_UP) #B
buttonA = Pin(6,Pin.IN, Pin.PULL_UP) #A
gc.enable()
gc.collect()
def main():
spi = SPI(0, baudrate=31250000, polarity=1, phase=1,
sck=Pin(game_kit.lcd_sck, Pin.OUT),
mosi=Pin(game_kit.lcd_sda, Pin.OUT))
tft = st7789c.ST7789(
spi,
240,
240,
reset=Pin(game_kit.lcd_rst, Pin.OUT),
dc=Pin(game_kit.lcd_dc, Pin.OUT),
#xstart=0,
#ystart=0,
rotation=0)
# enable display and clear screen
tft.init()
ab_x = 50
ab_y = 50
btn_A_state = 0
btn_B_state = 0
while True:
xValue = xAxis.read_u16()
yValue = yAxis.read_u16()
x = 0
y = 0
step = 15
if xValue <1000:
x = -step
ab_x = ab_x - 5
elif xValue >40000:
x = +step
ab_x = ab_x + 5
if yValue <1000:
y = -step
ab_y = ab_y - 5
elif yValue >40000:
y = step
ab_y = ab_y + 5
#ab_x = ab_x + x
#ab_y = ab_y + y
#print("\r\n"+str(ab_x)+","+str(ab_y))
i = 0
tft.fill(st7789c.WHITE)
tft.jpg("mini.jpg", ab_x, ab_y, st7789c.FAST)
i+=50
m.move(x,y)
buttonValueA = buttonA.value()
buttonValueB = buttonB.value()
#print("\r\n"+str(buttonValueA)+","+str(buttonValueB))
if buttonValueA == 0:
btn_A_state = 1
m.press(m.BUTTON_RIGHT)
else:
if btn_A_state == 1:
btn_A_state = 0
m.release(m.BUTTON_RIGHT)
if buttonValueB == 0:
btn_B_state = 1
m.press(m.BUTTON_LEFT)
else:
if btn_B_state == 1:
btn_B_state = 0
m.release(m.BUTTON_LEFT)
sleep(0.05)
main()
这个已经完成了。
后续RTT 看能不能提交一些bsp代码。
https://space.bilibili.com/399210127/channel/seriesdetail?sid=1891684
参考代码 https://github.com/EETree-git/RP2040_Game_Kit.git
树莓派RP2040官方介绍:https://www.raspberrypi.com/documentation/microcontrollers/rp2040.html#welcome-to-rp2040 树莓派Pico官方上手教程:https://projects.raspberrypi.org/en/projects/getting-started-with-the-pico/0 Thonny官方下载网址:https://thonny.org/ 树莓派Pico MicroPython固件官方网址:https://www.raspberrypi.com/documentation/microcontrollers/micropython.html#what-is-micropython MicroPython官方文档(英文):https://docs.micropython.org/en/latest/index.html MicroPython官方文档(中文):http://micropython.circuitpython.com.cn/en/latet/index.html