xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

色彩学基础:三原色 All In One

色彩学基础:三原色 All In One

三原色:RGB / 红绿蓝

三原色

色光三原色:RGB / 红绿蓝

颜料三原色: CMY / 青绿、品红、黄 (红黄蓝 ❓)

image

image

demos

RGB LED sensor

每次信号数据循环的中间会有 50us 的延迟

WS2812B / WS2812X

rpi-ws281x

https://pypi.org/project/rpi-ws281x/

https://github.com/jgarff/rpi_ws281x

https://github.com/rpi-ws281x/rpi-ws281x-python

bug ❌

https://github.com/rpi-ws281x/rpi-ws281x-python/issues/95

https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel/issues/151#issuecomment-1572096327

demo

image

$ sudo pip3 install rpi_ws281x adafruit-circuritypython-neopixel

$ sudo python3 -m pip install --force-reinstall adafruit-blinka


(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

CircuitPython

https://github.com/adafruit/circuitpython
https://circuitpython.org/

https://circuitpython.org/downloads

https://circuitpython.org/libraries

Adafruit_CircuitPython_WS2801

https://github.com/adafruit/Adafruit_CircuitPython_WS2801

Adafruit CircuitPython NeoPixel

https://pypi.org/project/adafruit-circuitpython-neopixel/

https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel

https://readthedocs.org/projects/adafruit-circuitpython-neopixel/

https://docs.circuitpython.org/projects/neopixel/en/latest/
https://docs.circuitpython.org/projects/neopixel/en/latest/index.html
https://docs.circuitpython.org/projects/neopixel/en/3.1.1/_modules/neopixel.html

bugs ❌

https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel/issues/151

https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel/issues/153

CircuitPython NeoPixel

https://learn.adafruit.com/circuitpython-essentials/circuitpython-neopixel

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/CircuitPython_Essentials/CircuitPython_NeoPixel/code.py
https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/CircuitPython_Essentials/CircuitPython_NeoPixel_RGBW/code.py

Python RPi.GPIO All In One

https://pypi.org/project/RPi.GPIO/

docs / 源码 ???

https://pythonhosted.org/RPIO/

https://github.com/metachris/RPIO

⚠️ This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

https://github.com/metachris/RPIO/blob/master/source/RPIO/init.py#L75

https://github.com/metachris/RPIO/blob/master/source/RPIO/PWM/init.py#L78

RPi.GPIO demo

#!/usr/bin/env python3
# coding: utf8

import RPi.GPIO as GPIO

from datetime import datetime
import time
import sys

arg1 = sys.argv[1]
print("arg1 =", arg1);

# shell 获取时间戳 ✅
# SH_DATE=$(TZ=':Asia/Shanghai' date '+%Y-%m-%d %T');
# datetime = $(date '+%Y-%m-%d %T')

# Python 获取时间戳 ✅
now = datetime.now()
# 转换为指定的格式
currentTime = now.strftime("%Y-%m-%d %H:%M:%S")
print("⏰ current datetime =", currentTime);

# $ pinout 命令查看,或 https://pinout.xyz/
# 指定 BCM 模式下的 GPIO 针脚编号是 12
# 对应的物理针脚编号是 32
PIN = 12
# BCM 模式
GPIO.setmode(GPIO.BCM)

# 指定 GPIO 针脚为一个电流输出针脚
GPIO.setup(PIN, GPIO.OUT)
# 输出低电平
GPIO.output(PIN, GPIO.LOW)

# index
i = 0
# 类型转换,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('结束闪烁 👌🏻')

refs

https://www.bilibili.com/video/BV16U4y1879Q?p=15



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2023-05-05 15:49  xgqfrms  阅读(20)  评论(4编辑  收藏  举报