Categories
linux

设置静态IP

一般通过命令nmtui设置

Categories
python

树莓派 香橙派 PWM问题

查看GPIO引脚

gpio readall

用python调用PWM有两种方法

1.RPi.GPIO

import RPi.GPIO  as GPIO


GPIO.setmode(GPIO.BCM)

GPIO.setup(18,GPIO.OUT) #设置引脚为输出
pwm = GPIO.PWM(18,100) #只有12脚 和 18脚 支持硬件PWM   100为100hz
pwm.start(50) #占空比为50并输出

pwm.changeDutyCycle(20) #改变占空比
pwm.stop() #停止PWM波形输出

2OPI.GPIO

PWM is created in the form of an object.

1. First set up OPi.GPIO and create the object

    .. code:: python

       import OPi.GPIO as GPIO
       PWM_Class = GPIO.PWM(PWM_chip, PWM_pin, frequency_Hz, Duty_Cycle_Percent)


一般PWM_chip 为0 第一块 可以通过
 ls -l /sys/class/pwm/ 查看 一般返回 pwmchip0

PWM_pin 就是引脚了 


    Note currently you do not need to specify setmode before creating the class as for a GPIO
    only the PWM_chip number and the PWM_pin.
    The reson for this and how to find what they are is explained in the sysfs PWM section.

2. Begin the PWM cycle

    .. code:: python

        PWM_Class.start_pwm()

3. Change PWM duty Cycle

    .. code:: python
        PWM_Class.duty_cycle(50)

    Note this changes the Duty cycle to 50%

4. Change the frequency

    .. code:: python
        PWM_Class.change_frequency(500)

    Note this changes the Frequency to 500Hz

5. Stop the PWM device

    .. code:: python
        PWM_Class.stop_pwm()

    Note this stops the signal by setting the duty cycle to 0%

6. Change the Polarity of the signal

    .. code:: python
        PWM_Class.pwm_polarity()

    Note this changes swaps the on-off times. For example a duty cycle set to 75% before
    this will result in the signal being on 75% and off 25% of the time. After this is
    called it would be on 25% and off 75%.

7. Remove PWM Object

    .. code:: python
        PWM_Class.pwm_close()

3.wiringpi

import wiringpi

pwm0 =  wiringpi.GPIO(0)        
pwm0.pinMode(1,pwm0.PWM_OUTPUT)
pwm0.pwmSetMode(pwm0.PWM_MODE_MS)
pwm0.pwmSetClock(25)
pwm0.pwmWrite(1,self.brightness)




import wiringpi

PWM_OUTPUT  = 2
PWM_PIN = 1  #指定第二个PWM接口

# 初始化
wiringpi.wiringPiSetup()
wiringpi.pinMode(PWM_PIN, PWM_OUTPUT)  #初始化第二个PWM接口 18  

wiringpi.pwmSetMode(wiringpi.PWM_MODE_MS)  
#设置PWM工作模式 有两个值PWM_MODE_MS PWM_MODE_BAL
#一般选第一个  PWM_MODE_BAL or PWM_MODE_MS(平衡模式/占空比模式)

wiringpi.pwmSetRange(1024)  


#设置总周期默认1024 所以一个周期是 600khz/1024 约等于600hz

wiringpi.pwmSetClock(32)  
#设置分频 默认32 即600khz 总时钟频率是19.2Mhz 

wiringpi.pwmWrite(PWM_PIN,0) #设置占空比 0~1024  512 为一半  
#0的话相当于写入全部低电平 没有波形输出

while 1:
    for bright in range(0, 1000):
        wiringpi.pwmWrite(PWM_PIN, bright)
        wiringpi.delay(1)
    for bright in range(1000, 0, -1):
        wiringpi.pwmWrite(PWM_PIN, bright)
        wiringpi.delay(1)
Categories
linux

树莓派 电源固件升级问题

树莓派论坛提到

https://forums.raspberrypi.com/viewtopic.php?t=361383

升级方法

Tue Dec 12, 2023 5:44 pm

3B+ v1.4 has a new PMIC and needs Sept 2021 or newer firmware.

Follow https://pip.raspberrypi.com/categories/ ... 6-WP-1.pdf to update the firmware in your image.

树莓派更换了新的PMIC(电源管理芯片)

https://pip.raspberrypi.com/categories/685/documents/RP-003476-WP/RP-003476-WP-1.pdf

该PDF有说明最新固件情况

Updating only the firmware

Sometimes, going through the standard upgrade procedure may not be possible. For example, you may have acustomised distribution with no update facilities, or that cannot be upgraded without causing further issues. In thesecircumstances, and possibly others, you will need to update the firmware files in the distribution manually.You can download the firmware files from the following location:

https://github.com/raspberrypi/firmware/archive/refs/heads/stable.zip

This zip file contains a number of items, but the ones we are interested in at this stage are in the boot folder.

The firmwarefiles have names of the form

start*.elf, and their associated support files are fixup*.dat.

The basic principle is to copy the required start and fixup files from this zip file to replace the same named files in thedestination OS image.

The exact process will depend on how the OS has been set up, but this is an example of how itwould be done for a Raspberry Pi OS image:

1. Extract or open the zip file so you can access the required files.

2. Open up the boot folder in the destination OS image (this could be on an SD card, or a disk-based copy).

3. Determine which start.elf and fixup.dat files are present in the destination OS image.

4. Copy those files from the zip archive to the destination image.The image should now be ready for use on the latest Raspberry Pi Ltd hardware.

其实就是下载最新固件包 在压缩包里打开boot目录

替换start*.elf 和 fixup*.dat.

当然命令行系统 用的是start.elf fixup.dat

桌面系统用的是 start_x.elf fixup_x.dat

Categories
linux

Raspbian OS

全量搜索地址 清华开源镜像网站

https://mirrors.tuna.tsinghua.edu.cn/raspberry-pi-os-images/

Categories
linux

树莓派 配置自启动桌面程序

利用aotostart 目录进行配置

创建设置文件/home/pi/.config/autostart/map2output.desktop,如果autostart目录不存在就自己创建。

文件内容如下:

[Desktop Entry]


Type=Application

Name=map2output


Exec=/home/rock/map.sh  #执行脚本

Categories
android

树莓派 安装 android

https://konstakang.com/ 非官方树莓派安卓镜像制作商

https://androidfilehost.com/?w=profile&uid=24665539028713562

在androidfilehost 可以找到其他人做的系统镜像

Categories
linux Uncategorized

树莓派 book worm 安装记录

3B插上网线

sudo raspian-config //开启ssh


sudo apt install python3-pip
sudo apt install python3-opencv
sudo apt install python3-dbus
sudo apt install python3-bluetooth
sudo apt install python3-serial

sudo apt install vim

sudo apt install lrzsz


pip install wiringpi --break-system-wide

开启orthocone 自启动

sudo chmod 777 /etc/init.d/orthocone
sudo update-rc.d orthocone defaults
sudo systemctl enable orthocone.service

sudo chmod 777 recon.out

还需要重新安装opencv_core opencv_imgproc  opencv_highgui

用opencv4  重新编译 recon   
超级辛苦

多余service 取消自启动

sudo update-rc.d xxx remove

或者

sudo systemctl disable xxx.service

移除windows 字符
vim
:set ff=unix

修改i2c 波特率
config.txt
dtparam=i2c_arm=on,i2c_arm_baudrate=100000

python3.9 后 timer.isAlive() 改为 timer.is_live()

树莓派系统

虚拟键盘

https://blog.csdn.net/weixin_37613240/article/details/131095728

https://blog.csdn.net/weixin_46235937/article/details/128966933

https://blog.csdn.net/qq_27865227/article/details/127394944

https://blog.csdn.net/m0_46324847/article/details/128962898

新版树莓派摄像头驱动

Categories
linux

树莓派5 双触摸屏

第一禁用Wayland 用回x11设置

raspi-config 里设置后 重启

xinput查看当前当前触摸屏与设备 xrandr也可查看当前屏幕

xinput map-to-output 7 HDMI-1

xinput map-to-output 8 HDMI-2

Categories
linux

Bluetoothctl

linux下一个蓝牙工具 可控制设备信任 配对 连接 等生命周期

sudo bluetoothctl 进入控制台

devices 列出设备

scan on 搜索

scan off 关闭搜索

trust 信任设备 untrust 不信任设备

pair 配对设备 unpair 不配对设备