pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Mini EncoderC

Example

Sets the Mini Encoder communication address and LED color to white. The encoder value and button status are continuously printed in the serial output.

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

setScreenColor(0x111111)

hat_mini_encoderc_0 = hat.get(hat.MINI_ENCODERC)

hat_mini_encoderc_0.init_i2c_address(0x42)
hat_mini_encoderc_0.set_LED_RGB24(50, 50, 50)
while True:
  print(hat_mini_encoderc_0.get_counter_value())
  print(hat_mini_encoderc_0.get_button_status())
  wait_ms(2)

API

hat_mini_encoderc_0.init_i2c_address(0x42)
  • Initializes the I2C address for the Mini Encoder, here set to 0x42.
hat_mini_encoderc_0.get_button_status()
  • Retrieves the button status of the Mini Encoder.
hat_mini_encoderc_0.get_counter_value()
  • Retrieves the current counter value of the encoder.
hat_mini_encoderc_0.get_device_status()
  • Checks the device status of the Mini Encoder.
hat_mini_encoderc_0.get_increment_value()
  • Retrieves the increment value since the last check.
hat_mini_encoderc_0.reset_counter_value()
  • Resets the encoder counter value to zero.
hat_mini_encoderc_0.set_counter_value(0)
  • Sets the encoder counter value to a specified value, here set to 0.
hat_mini_encoderc_0.set_i2c_address(new_address)
  • Changes the I2C address of the Mini Encoder to new_address.
hat_mini_encoderc_0.set_LED_RGB24(red, green, blue)
  • Sets the RGB LED color of the Mini Encoder by specifying the red, green, and blue values.
On This Page