pdf-icon

UIFlow Guide

UiFlow1 Blockly

Event

Unit

UiFlow1 Project

Unit Neco

Example

Set the color of the Unit Neco LED

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

screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0xFFFFFF)
neco_0 = unit.get(unit.NECO, unit.PORTB, 70)

def neco_0_button_wasPressed_cb():
  # global params
  neco_0.setRamdomColor(6)
  pass
neco_0.button.wasPressed(neco_0_button_wasPressed_cb)

print((str('status:') + str((neco_0.button.wasPressed()))))
neco_0.setBrightness(20)
while True:
  neco_0.setColorFrom(1, 5, 0xff0000)
  wait_ms(2)

API

def neco_0_button_wasPressed_cb():
  # global params
  pass
neco_0.button.wasPressed(neco_0_button_wasPressed_cb)
  • Button callback function
print((str('status:') + str((neco_0.button.wasPressed()))))
  • Get button status
neco_0.setBrightness(20)
  • Set LED brightness
neco_0.setColor(1, 0xff0000)
  • Set LED color
neco_0.setColorAll(0xff0000)
  • Set all LED colors
neco_0.setColorAll(0xff0000)
  • Set all LED colors
    • Palette
    • RGB
    • HEX
neco_0.setColorFrom(1, 5, 0xff0000)
  • Set partial LED colors
neco_0.setColorFrom(1, 5, 0xff0000)
  • Set partial LED colors
neco_0.setColorFrom(1, 5, 0xff0000)
  • Customize any LED color
neco_0.setRandomColorAll()
  • Set all LED positions to one random color
neco_0.setRandomColorFrom(1, 5)
  • Set a specified range of LEDs to random colors
neco_0.setRamdomColor(1)
  • Set a specified range of LEDs to one random color
neco_0.setRandomColorRandomLed()
  • Set all LED colors randomly
neco_0.setRandomColorRandomLedFrom(1, 5)
  • Set a specified range of LEDs to random colors
On This Page