作者:Peter Misenko
树莓PICO掌上电脑的通用Python教程
我注意尽量减少外部组件,使用 PICO 板上集成的最大功能: 电源开关使用 PICO 上的使能输入,由于缺少阻焊层和 PICO 启动按钮孔,板上 LED 可见。外形尺寸尽可能小。
原理图
实物图
特征:
- 尽可能小 100x100x10mm
- 绝对最小的组件。
- 辅助 USB-C 仅用于供电。
- 访问启动按钮
- 带有内部 LED 的奖金闪烁星。
- IPS 240x240 显示屏/320x240。3种以上
- 压电扬声器
- 免费 GPIO 接头
- 复位按钮
- 电源开关控制内部升降压
- 微型 SD 卡
- 可选 RFM95 LoRa 无线电
支持的显示器:
- 12 针 st7789 IPS 240x240 通过柔性电缆 1.3" 英寸
- 12 针 st7789 IPS 240x240 通过柔性电缆 1.54" 英寸
- 12 针 st7789 IPS 320x240 通过柔性电缆 2" 英寸
- 8pin st7789 IPS 240x240 通过接头
- 任何带有流行中国模块引脚的显示器 GND,VCC,SCK,DAT,RES,DC,CS,BACKLIT
所需组件:
- 1x 覆盆子 PICO
- 37x DTS63K轻触开关7mm高,或者另外1N力按压很舒服
- 1x BSS123 晶体管,用于显示背光
- 1x 10R 0603 显示器背光电阻
- 1x 4k7 显示器背光电阻
- 1x LPT1109DS PIEZO 蜂鸣器
- 1x JS202011CQN C&K 或 MSS-2235 NINIGI 侧开关 用于关闭电源,但无需
代码示例和定义
DISPLAY
- tft_cs = board.GP21
- tft_dc = board.GP16
- spi_mosi = board.GP19
- spi_clk = board.GP18
- spi = busio.SPI(spi_clk, spi_mosi)
- backlight = board.GP20
- display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)
- display = ST7789(display_bus, rotation=270, width=320, height=240, backlight_pin=backlight)
复制代码
KEYBOARD
- cols = [digitalio.DigitalInOut(x) for x in (board.GP1, board.GP2, board.GP3, board.GP4, board.GP5, board.GP14)]
- rows = [digitalio.DigitalInOut(x) for x in (board.GP6, board.GP9, board.GP15, board.GP8, board.GP7, board.GP22)]
- keys1 = ((' ', '.', 'm', 'n', 'b',"dn"),
- ("ent", 'l', 'k', 'j', 'h',"lt"),
- ('p', 'o', 'i', 'u', 'y',"up"),
- ("bsp", 'z', 'x', 'c', 'v',"rt"),
- ('a', 's', 'd', 'f', 'g',"tab"),
- ('q', 'w', 'e', 'r', 't',"alt"))
- keys2 = (('_', ',', '>', '<','""','{'),
- ('~', '-', '*', '&', '+','['),
- ('0', '9', '8', '7', '6','}'),
- ('=', '(', ')', '?', '/',']'),
- ('!', '@', '#', '[size=4][b]LORA Radio[/b][/size][code]# Define pins connected to the chip.
- CS = digitalio.DigitalInOut(board.GP13)
- RESET = digitalio.DigitalInOut(board.GP17)
- spi = busio.SPI(board.GP10, MOSI=board.GP11, MISO=board.GP12)
- # Initialze radio
- RADIO_FREQ_MHZ = config.freq #869.45 # Frequency of the radio in Mhz. Must match your
- print('starting Lora')
- try:
- rfm9x = ulora.LoRa(spi, CS, modem_config=ulora.ModemConfig.Bw500Cr45Sf128,tx_power=23) #, interrupt=28
- except:
- print("Lora module not detected !!!") #None
复制代码
OTHER THINGS, speaker, internal PICO features
- def beep():
- audioPin = PWMOut(board.GP0, duty_cycle=0, frequency=440, variable_frequency=True)
- audioPin.frequency = 5000
- audioPin.duty_cycle = 1000*(config.volume)
- time.sleep(0.002)
- audioPin.duty_cycle = 0
- audioPin.deinit()
- def get_VSYSvoltage():
- VSYSin = ((VSYS_voltage.value * 3.3) / 65536) * 3
- return VSYSin
- LED = digitalio.DigitalInOut(board.LED)
- LED.direction = digitalio.Direction.OUTPUT
- VSYS_voltage = analogio.AnalogIn(board.VOLTAGE_MONITOR)
- VBUS_status = digitalio.DigitalInOut(board.VBUS_SENSE) # defaults to input
- VBUS_status.pull = digitalio.Pull.UP # turn on internal pull-up resistor
- SMPSmode = digitalio.DigitalInOut(board.SMPS_MODE)
- SMPSmode.direction = digitalio.Direction.OUTPUT
- SMPSmode.value=True
复制代码
GPS I2C connection / configuration
- uart = busio.UART(None, board.GP17, baudrate=9600, timeout=10)
- gps = adafruit_gps.GPS(uart, debug=False)
- i2c = busio.I2C( board.GP27, board.GP26, frequency=200_000)
- rtc = adafruit_ds3231.DS3231(i2c)
复制代码
代码合集:
4
|
|
|
|