pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Ext Encoder Unit

Example

from m5stack import *
from m5ui import *
from uiflow import *
import unit

setScreenColor(0x222222)
extencoder_0 = unit.get(unit.EXT_ENCODER, unit.PORTA)

extencoder_0.init_i2c_address(0x59)
while True:
  print((str('encoder:') + str((extencoder_0.get_encoder_value()))))
  print((str('meter:') + str((extencoder_0.get_meter_value()))))
  print((str('string meter') + str((extencoder_0.get_str_meter_value()))))
  wait_ms(2)

API

extencoder_0.init_i2c_address(0x59)
  • Create an ExtEncoderUnit object
print(extencoder_0.get_firmware_status())
  • Retrieve the firmware version of the ExtEncoderUnit object
print(extencoder_0.get_encoder_value())
  • Get the encoder pulse count value
print(extencoder_0.get_meter_value())
  • Get the meter value of the ExtEncoderUnit object. Unit: millimeters
print(extencoder_0.get_perimeter_value())
  • Get the circumference of the ExtEncoderUnit object. Unit: millimeters
print(extencoder_0.get_pulse_value())
  • Get the pulses per revolution value
print(extencoder_0.get_str_meter_value())
  • Get the string representation of the meter pulse count value
print(extencoder_0.get_zero_counter_value())
  • Get the zero mode of the ExtEncoderUnit object
print(extencoder_0.get_z_trigger_mode())
  • Transition to Z-trigger mode
extencoder_0.reset_encoder()
  • Reset the encoder and meter count values
extencoder_0.set_i2c_address(0x59)
  • Set the device I2C slave address
extencoder_0.set_perimeter_value(1000)
  • Set peripheral values
extencoder_0.set_pulse_value(1000)
  • Set the pulses per revolution value
extencoder_0.set_zero_counter_value(0)
  • Set the total zero pulse value for the object
extencoder_0.set_z_trigger_mode(0)
  • Set the clear Z-trigger mode
    • NOT CLEAR
    • Z-RISING EDGE
    • Z-FALLING EDGE
On This Page