Minicom All In One

Minicom All In One

minicom bugs / minicom errors

Minicom 2.8

# 0000000000001 ❌
$ minicom -b 115200 -o -D /dev/tty.usbmodem0000000000001

# tty ❌
$ minicom -b 115200 -o -D /dev/tty.usbmodem14601

# cu ✅
$ minicom -b 115200 -o -D /dev/cu.usbmodem14601

官方 SDK 文檔 ❌ bug

https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-python-sdk.pdf

Thonny IDE

https://electrocredible.com/raspberry-pi-pico-with-macos-thonny-getting-started/

https://microcontrollerslab.com/getting-started-raspberry-pi-pico-thonny-ide/

MicroPython REPL

MicroPython v1.19.1-994-ga4672149b on 2023-03-29; Raspberry Pi Pico with RP2040

>>> pin25 = machine.Pin(25)
>>> print("pin25 =", type(pin25))
>>> pin25 = <class 'Pin'>

>>> import time
>>> from time import sleep
>>>
>>> GPIO_PIN = 25
>>> led = machine.Pin(GPIO_PIN, machine.Pin.OUT)
>>>
>>> led.value(1)
>>> time.sleep(1)
>>> led.value(0)
>>>
>>> led.high()
>>> time.sleep(1)
>>> led.low()
>>>

https://micropython.org/help/


MPY: soft reboot
MicroPython v1.19.1-994-ga4672149b on 2023-03-29; Raspberry Pi Pico with RP2040
Type "help()" for more information.
>>> help()
Welcome to MicroPython!

For online help please visit https://micropython.org/help/.

For access to the hardware use the 'machine' module.  RP2 specific commands
are in the 'rp2' module.

Quick overview of some objects:
  machine.Pin(pin) -- get a pin, eg machine.Pin(0)
  machine.Pin(pin, m, [p]) -- get a pin and configure it for IO mode m, pull mode p
    methods: init(..), value([v]), high(), low(), irq(handler)
  machine.ADC(pin) -- make an analog object from a pin
    methods: read_u16()
  machine.PWM(pin) -- make a PWM object from a pin
    methods: deinit(), freq([f]), duty_u16([d]), duty_ns([d])
  machine.I2C(id) -- create an I2C object (id=0,1)
    methods: readfrom(addr, buf, stop=True), writeto(addr, buf, stop=True)
             readfrom_mem(addr, memaddr, arg), writeto_mem(addr, memaddr, arg)
  machine.SPI(id, baudrate=1000000) -- create an SPI object (id=0,1)
    methods: read(nbytes, write=0x00), write(buf), write_readinto(wr_buf, rd_buf)
  machine.Timer(freq, callback) -- create a software timer object
    eg: machine.Timer(freq=1, callback=lambda t:print(t))

Pins are numbered 0-29, and 26-29 have ADC capabilities
Pin IO modes are: Pin.IN, Pin.OUT, Pin.ALT
Pin pull modes are: Pin.PULL_UP, Pin.PULL_DOWN

Useful control commands:
  CTRL-C -- interrupt a running program
  CTRL-D -- on a blank line, do a soft reset of the board
  CTRL-E -- on a blank line, enter paste mode

For further help on a specific object, type help(obj)
For a list of available modules, type help('modules')
>>>
Meta-Z for help | 115200 8N1 | NOR | Minicom 2.8 | VT102 | Offline | cu.usbmodem14601

machine

Pin

# machine.Pin(pin)
# -- get a pin, eg machine.Pin(0)

# machine.Pin(pin, m, [p])
# -- get a pin and configure it for IO mode m, pull mode p
    methods: init(..), value([v]), high(), low(), irq(handler)

# machine.Pin(pin, m, [p])
led = machine.Pin(25, machine.Pin.OUT)

# value([v])
led.value(1)
led.value(0)

# high(), low()
led.high()
led.low()

# init(..) ???
led.init()

# irq(handler) ???
def handler():
  print("function")

led.irq(handler)

ADC

PWM

I2C

minicom 無法退出 bug ❌

Ctrl + A 可以切換到 > 模式;但是再依次按 Z 鍵,X 鍵 也無法退出 ❓ 不好使 ❌
Ctrl + A 連續按兩次也不好使 ❌

Ctrl + B 可以切換到 >>> MicroPython 的 REPL 模式;
>>> help() 可以正常使用 ✅

macOS 配置 Python 環境變量

Python 3

$ which python
# python not found

$ python --version
# zsh: command not found: python

$ which python3
# /usr/bin/python3
$ python3 --version
# Python 3.9.6

#  ✅
$ cd /usr/bin/ && ls | grep "python"

#  ✅
$ cd /usr/bin/ && ls -al | grep "python"

image

$ code .zshrc
$ source ~/.zshrc

# Python 3 ✅ alias
alias python=/usr/bin/python3

# export PATH="/usr/bin/python3:$PATH"
# export PATH="/usr/bin/:$PATH"
# $ cd /usr/bin/ && ls | grep "python" ✅
# $ cd /usr/bin/ && ls -al | grep "python" ✅


# .bash_profile
source ~/.bash_profile

# end zsh
# source ~/.zshrc

image

https://www.python.org/downloads/

https://docs.python.org/3/using/mac.html

macOS 安裝多個 Python 版本 ???

$ brew install python3

Raspberry Pi 3 B

$ ssh [email protected]
[email protected]'s password: 
Linux raspberrypi 4.19.118-v7+ #1311 SMP Mon Apr 27 14:21:24 BST 2020 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Mar 29 00:18:23 2023 from 192.168.18.195

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.
$ python --version
Python 2.7.16
$ which python
/usr/bin/python

$  python3 --version
Python 3.7.3
$ which python3
/usr/bin/python3

$ vim test.py
$ python ./test.py 10

$ python3 ./test.py 10
# #!/usr/bin/env python3 ✅
# #!/usr/bin/python3
# # coding: utf8 ✅

gpio.py

#!/usr/bin/env python3

# coding: utf8

import RPi.GPIO as GPIO
import time

import sys

arg1 = sys.argv[1]

print("arg1 =", arg1);

# 指定 BCM 模式下的GPIO 針腳編號
PIN = 12
# BCM 模式
GPIO.setmode(GPIO.BCM)

# 指定 GPIO 針腳爲一個電流輸出針腳
GPIO.setup(PIN, GPIO.OUT)

# 輸出低電平
GPIO.output(PIN, GPIO.LOW)

# index
i = 0
# max
# n = 7

# 類型轉換,str => int
n = int(arg1)

print("n =", n)

print('開始閃爍⏳')

while (i < n):
    print("i =", i)
    # 高電平,LED 點亮
    GPIO.output(PIN, GPIO.HIGH)
    # 休眠 1 秒,防止 LED 長時間點亮燒壞了
    time.sleep(1.0)
    # 低電平,LED 熄滅
    GPIO.output(PIN, GPIO.LOW)
    # 休眠 1 秒
    time.sleep(1.0)
    i = i + 1

# 輸出低電平,LED 關閉
# GPIO.output(PIN, GPIO.LOW)

# 清除,釋放內存
GPIO.cleanup()

print('結束閃爍 👌🏻')

# ip, wlan0 ??? grep
$ ifconfig

# 查看內存佔用
$ df -h
文件系統        容量  已用  可用 已用% 掛載點
/dev/root        29G  6.4G   22G   23% /
devtmpfs        243M     0  243M    0% /dev
tmpfs           248M     0  248M    0% /dev/shm
tmpfs           248M  6.6M  241M    3% /run
tmpfs           5.0M  4.0K  5.0M    1% /run/lock
tmpfs           248M     0  248M    0% /sys/fs/cgroup
/dev/mmcblk0p1  253M   51M  202M   21% /boot
tmpfs            50M     0   50M    0% /run/user/1000

nvm

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
#  port 443: 拒絕連接

$ sudo vim /etc/hosts
$ cat /etc/hosts
127.0.0.1	localhost
::1		localhost ip6-localhost ip6-loopback
ff02::1		ip6-allnodes
ff02::2		ip6-allrouters

127.0.1.1		raspberrypi

# github
185.199.108.133 raw.githubusercontent.com

image

https://www.cnblogs.com/xgqfrms/p/16852071.html#5163462

image

# ✅ ---lts !== --lst ❌
$ nvm ls-remote --lst

image

$ sudo apt-get install imagemagick

# display ❌
$ display css-輪播圖.gif 
# display-im6.q16: unable to open X server `' @ error/display.c/DisplayImageCommand/433.

$ echo $DISPLAY
$ export DISPLAY=:0.0
$ sudo apt-get update
獲取:1 http://archive.raspberrypi.org/debian buster InRelease [32.6 kB]
獲取:2 http://raspbian.raspberrypi.org/raspbian buster InRelease [15.0 kB]             
正在讀取軟件包列表... 完成          
E: 倉庫'http://archive.raspberrypi.org/debian buster InRelease'將其'Suite'值從'testing'修改到了'oldstable'
N: 爲了讓這個倉庫能夠應用,這必須在更新之前顯式接受。更多細節請參閱 apt-secure(8) 手冊。
E: 倉庫'http://raspbian.raspberrypi.org/raspbian buster InRelease'將其'Suite'值從'stable'修改到了'oldstable'
N: 爲了讓這個倉庫能夠應用,這必須在更新之前顯式接受。更多細節請參閱 apt-secure(8) 手冊。


$ sudo vim /etc/apt/sources.list 

$ sudo vim /etc/apt/sources.list.d/raspi.list


$ sudo cat /etc/apt/sources.list.d/raspi.list
# new ✅
deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ buster main

# old ❌
#deb http://archive.raspberrypi.org/debian/ buster main

# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspberrypi.org/debian/ buster main

$ sudo cat /etc/apt/sources.list
# new ✅
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi

# tsinghua 不好使 ❌
# deb http://mirror.tuna.tsinghua.edu.cn/raspberrypi/ stretch main ui
# deb-src http://mirror.tuna.tsinghua.edu.cn/raspberrypi/ stretch main ui

# old ❌
# deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

zh-Hans

# 中文輸入法 設置成功

\`\`\`sh
# 1. 更新
$ sudo apt-get update

# 2. 安裝中文輸入法 chinese input
$ sudo apt-get install scim-pinyin

# 3. 重啓系統
$ sudo reboot
# 或者
$ sudo shutdown -r now

# sudo apt-get install fcitx fcitx-googlepinyin fcitx-module-cloudpinyin fcitx-sunpinyin

\`\`\`

切換中英文輸入法方式

1. Shift
2. Ctrl + Space

https://blog.csdn.net/u012313335/article/details/53519302

截圖 ?

\`\`\`sh

sudo shutdown -r +1 "一分鐘後重啓系統"

\`\`\`


## emoji bug

 ✅
🇨🇳 China flag

https://www.emojicopy.com/ 

(🐞 反爬蟲測試!打擊盜版⚠️)如果你看到這個信息, 說明這是一篇剽竊的文章,請訪問 https://www.cnblogs.com/xgqfrms/ 查看原創文章!

refs

https://www.cnblogs.com/xgqfrms/p/17274811.html



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 發佈文章使用:只允許註冊用戶纔可以訪問!

原創文章,版權所有©️xgqfrms, 禁止轉載 🈲️,侵權必究⚠️!


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章