pdf-icon

UIFlow 上手教程

UiFlow1 Blockly

Event

Unit

UiFlow1 开发指南

项目管理

Unit RGB LED

案例程序

矩阵流水灯

from m5stack import *
from m5stack_ui import *
from uiflow import *
import time
import unit

screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0xFFFFFF)
neopixel_0 = unit.get(unit.NEOPIXEL, unit.PORTB, 10)

R = None
G = None
B = None
i = None

import random

while True:
  R = random.randint(0, 255)
  G = random.randint(0, 255)
  B = random.randint(0, 255)
  for i in range(1, 31):
    neopixel_0.setColorFrom(1,i,(R << 16) | (G << 8) | B)
  wait_ms(500)
  for i in range(1, 31):
    neopixel_0.setColorFrom(1, i, 0x000000)
  wait_ms(500)
  wait_ms(2)

功能说明

neopixel_0.setBrightness(20)
  • 设置亮度
neopixel_0.setColor(1, 0xff0000)
  • 设置颜色
neopixel_0.setColorAll(0xff0000)
  • 设置指定单个 LED 颜色
neopixel_0.setColorAll(0xff0000)
  • 设置所有 LED 颜色
neopixel_0.setColorFrom(1, 5, 0xff0000)
  • 设置指定范围 RGB LED 颜色
neopixel_0.setColorFrom(1, 5, 0xff0000)
  • 设置指定范围 RGB LED 颜色
neopixel_0.setColorFrom(1, 5, 0x000000)
  • 设置指定范围 RGB LED 颜色 (RGB)
neopixel_0.setColor(1, 0xff0000)
  • 设置指定 RGB LED 颜色
neopixel_0.setShowLock(True)
  • 设置六边形矩阵
neopixel_0.setShowLock(True)
  • 设置六边形矩阵RGB 灯
neopixel_0.setShowLock(True)
  • 设置显示锁定状态
neopixel_0.show()
  • 显示 RGB LED
On This Page