English
English
简体中文
日本語

UiFlow Tutorial

UiFlow1 Development Guide

Project Management

Use LTE network

UiFlow1 Blockly

Event

Unit

Hat BugC

Example

The car alternates between moving forward and backward, with the lights changing colors.

from m5stack import *
from m5ui import *
from uiflow import *
import time
import hat

setScreenColor(0x111111)

hat_bugc_0 = hat.get(hat.BUGC)

while True:
  hat_bugc_0.SetAllRGB(0xff0000)
  hat_bugc_0.SetPulse(0, 255)
  hat_bugc_0.SetPulse(1, -255)
  hat_bugc_0.SetPulse(2, 255)
  hat_bugc_0.SetPulse(3, -255)
  wait(5)
  hat_bugc_0.SetAllRGB(0x00ff00)
  hat_bugc_0.SetAllPulse(-255, 255, -255, 255)
  wait(5)
  wait_ms(2)

API

hat.get(hat.BUGC)
  • Set the color of the RGB light strip.
hat_bugc_0.SetRGB(0, 0xff0000)
  • Set the color of the RGB light strip using RGB color values.
hat_bugc_0.SetRGB(0, 0x000000)
  • Set the RGB light strip color by specifying values for R (red), G (green), and B (blue).
hat_bugc_0.SetAllRGB(0x000000)
  • Set the pulse width for all channels.
hat_bugc_0.SetAllPulse(0, 0, 0, 0)
  • Set the pulse width for specific channels.
Page Tools
PDF
On This Page