supperthomas / bluetoothlover_doc

this is about the learning station about friends.
https://supperthomas-wiki.readthedocs.io/
Apache License 2.0
44 stars 26 forks source link

RP2040 树莓派学习 #289

Open supperthomas opened 2 years ago

supperthomas commented 2 years ago

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

supperthomas commented 2 years ago

活动链接 https://www.eetree.cn/project/detail/698

supperthomas commented 2 years ago

官方user guide https://projects.raspberrypi.org/en/projects/getting-started-with-the-pico/2

supperthomas commented 2 years ago

micropython https://www.raspberrypi.com/documentation/microcontrollers/micropython.html#what-is-micropython

firmware rp2-pico-20210902-v1.17.zip

supperthomas commented 2 years ago

MDK 开发PICO

https://github.com/GorgonMeducer/Pico_Template 教程 https://mp.weixin.qq.com/s/8_bFVi71PYgcnznr52daSw

supperthomas commented 2 years ago

PICO 自我调试: firmware.zip

参考教程: https://mp.weixin.qq.com/s/QGxRPN3qjZ9QXs2kK_HlOA

supperthomas commented 2 years ago

PICO 调试pico 图片

supperthomas commented 2 years ago

https://github.com/balanceTWK/BalanceDAP.git

supperthomas commented 2 years ago

https://github.com/supperthomas/Develop_board_floating_bottle/issues/25

supperthomas commented 2 years ago

Mma7660.py https://gitee.com/picospuch/eetree-mpy-lecture-code/blob/main/bsp/mma7660.py

supperthomas commented 2 years ago

项目1 - 能控制LCD和电脑界面的“鼠标”

利用板上的四向摇杆和按键设计一款“鼠标” 在240*240的LCD屏幕内可以通过该鼠标进行菜单选择和参数控制(在屏幕上要有上图中图形化的箭头形状) 通过USB端口可以控制PC屏幕上的光标移动和点击操作,行使电脑鼠标的功能

可以用箭头指示相应的按键方向,圆点指示按键

项目2 - 带学习功能的红外遥控器

通过板上的红外接收器,接收任何一款家用遥控器的控制信号,并能够对遥控器的控制信号进行识别 在LCD上绘制一个遥控器控制界面,并能够通过四向摇杆和按键来行使原来遥控器的控制操作

项目3 - 复古游戏移植

设计或移植一款经典的游戏(硬禾学堂上已经实现的贪吃蛇等游戏除外),通过LCD屏显示,通过按键和四向摇杆控制游戏的动作: 经典的Pong 挖地雷 打飞机 俄罗斯方块 ....... 在游戏中要通过蜂鸣器播放背景音乐

项目4 - 制作一款MCU、FPGA调试器、下载器

使用板上的扩展端口上的数字信号 可以对任意一款MCU或FPGA进行调试、固件的下载

项目5 - 制作一款简易的逻辑分析仪,并支持SPI、I2C的协议分析

使用板上的扩展端口上的数字信号 能够对SPI、I2C的外设进行控制设置、参数读写 数字信号的波形显示在LCD上或通过USB传输到PC上在上位机进行显示

项目6 - 实现历届全国大学生电子设计竞赛中的任意一个题目

使用板上的扩展端口上的数字信号以及2路模拟输入 自行搭配外围器件或模块 实现以下类型中的任意一个题目: 搭载模拟链路实现信号采集及分析,可以针对电路分析、测试测量类的题目 搭载传感器、电机、开关等实现控制类的题目 以上的6个项目不限用MicroPython或C/C++语言编写。

supperthomas commented 2 years ago

https://github.com/wokwi/rp2040js

supperthomas commented 2 years ago

项目2 - 带学习功能的红外遥控器

通过板上的红外接收器,接收任何一款家用遥控器的控制信号,并能够对遥控器的控制信号进行识别 在LCD上绘制一个遥控器控制界面,并能够通过四向摇杆和按键来行使原来遥控器的控制操作

RT-THREAD: PWM驱动和HWTIMER驱动,以及LCD驱动需要完成 arduino: 库比较多。 mpy: 库比较少,感觉。

supperthomas commented 2 years ago

https://arduino-pico.readthedocs.io/en/latest/

supperthomas commented 2 years ago

https://github.com/raspberrypi/openocd

supperthomas commented 2 years ago

https://www.instructables.com/Arduino-NES/?amp_page=true

supperthomas commented 2 years ago

sdk set PICO_SDK_PATH=F:\04_git_repo\GITEE\pico-sdk

supperthomas commented 2 years ago

https://github.com/adafruit/Adafruit_CircuitPython_HID

supperthomas commented 2 years ago

https://circuitpython.readthedocs.io/projects/hid/en/latest/api.html#adafruit-hid-mouse-mouse

supperthomas commented 2 years ago

https://codewith.mu/en/download

supperthomas commented 2 years ago

https://www.waveshare.net/wiki/Raspberry_Pi_Pico

supperthomas commented 2 years ago

https://github.com/picospuch/st7789_mpy

supperthomas commented 2 years ago

https://github.com/Bodmer/TFT_eSPI

supperthomas commented 2 years ago

https://github.com/Wiz-IO/wizio-pico

supperthomas commented 2 years ago

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

supperthomas commented 2 years ago

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");
}
supperthomas commented 2 years ago

imagemagick

supperthomas commented 2 years ago

https://github.com/skb666/rp2040-game-kit-bsp.git

supperthomas commented 2 years ago

树莓派庆祝 Raspberry Pi Pico 发布一周年

https://mp.weixin.qq.com/s/FnpkWMtDic967tnK_KR8vQ

supperthomas commented 2 years ago

显示图片


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()
supperthomas commented 2 years ago
### 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()
supperthomas commented 2 years ago

这个已经完成了。

supperthomas commented 2 years ago

后续RTT 看能不能提交一些bsp代码。