pdf-icon

UIFlow Guide

UiFlow1 Blockly

Event

Unit

UiFlow1 Project

Unit Encoder

Example

Rotary encoder counting

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

screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0xFFFFFF)
encoder_0 = unit.get(unit.ENCODER_LED, unit.PORTA)

while True:
  if encoder_0.get_button_status():
    print((str('count:') + str((encoder_0.get_encoder_count()))))
  encoder_0.set_LED_RGB(3, 0xff0000)
  wait_ms(2)

API

print((str('button:') + str((encoder_0.get_button_status()))))
  • Get button status
print((str('count:') + str((encoder_0.get_encoder_count()))))
  • Get rotary encoder count value
encoder_0.reset_count()
  • Reset encoder count value
encoder_0.set_LED_RGB(3, 0xff0000)
  • Configure encoder LED color parameters
encoder_0.set_LED_RGB(3, 0xff0000)
  • Set target LED color
encoder_0.set_encoder_count(1000)
  • Initialize encoder counter
encoder_0.set_encoder_mode(0)
  • Toggle encoder operation mode
encoder_0.set_LED_RGB(3, 0x000000)
  • Precisely configure LED color using RGB component values
On This Page