pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

HMI

Example

Print the rotary encoder count value, increment value, button status, and firmware version of the HMI Module.
from m5stack import *
from m5ui import *
from uiflow import *
import module

setScreenColor(0x222222)

hmi = module.get(module.HMI)

hmi.init_i2c_address(0x41)
while True:
  print((str('counter value: ') + str((hmi.get_counter_value()))))
  print((str('increment value: ') + str((hmi.get_increment_value()))))
  print((str('button status: ') + str((hmi.get_button_status(0)))))
  print((str('Firmware version: ') + str((hmi.get_device_status(0xFE)))))
  wait_ms(2)

API

hmi.get_button_status(0)
  • Get the status of a specified button. In the dropdown menu, there are three options to choose from. Based on the selected button, this block will return the current status of the corresponding button, such as pressed or not pressed.
    • 0: Get the status of Button 1.
    • 1: Get the status of Button 2.
    • 2: Get the status of Button 3.
hmi.get_counter_value()
  • Get the current value of the counter. Returns an integer representing the cumulative count of the counter.
hmi.get_device_status(0xFE)
  • Get the firmware version of the device. Returns a string representing the current firmware version running on the device.
hmi.get_increment_value()
  • Get the increment value. Returns an integer representing the incremental change of the encoder.
hmi.init_i2c_address(0x41)
  • Initialize the device's I2C address, used for communication on the I2C bus.
hmi.reset_counter_value()
  • Reset the counter value. This will clear the current value of the counter.
hmi.set_counter_value(1000)
  • Set the counter value. This allows you to set the counter to a specified integer value.
hmi.set_i2c_address(0x41)
  • Set the I2C address of the device.
hmi.set_LED(0, 1)
  • Set the state of LED 1/2. You can choose to set it to ON or OFF to control the LED's state. This allows you to control the on/off status of different LEDs.
    • LED: You can choose the LED number to control, with options for 1 and 2.
    • state: You can choose the LED's state, with options for ON (on) or OFF (off).
On This Page