Rotary
Rotary is used to control the rotary encoder integrated inside the host. Below is the detailed Rotary support for the host:
Controller |
Rotary |
|---|---|
Dial |
✔ |
DinMeter |
✔ |
Micropython Example:
1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8from hardware import * 9 10 11label0 = None 12rotary = None 13 14 15def btnA_wasClicked_event(state): # noqa: N802 16 global label0, rotary 17 rotary.reset_rotary_value() 18 label0.setText(str(rotary.get_rotary_value())) 19 20 21def setup(): 22 global label0, rotary 23 24 M5.begin() 25 Widgets.fillScreen(0x222222) 26 label0 = Widgets.Label("0", 96, 80, 1.0, 0xFFA000, 0x222222, Widgets.FONTS.DejaVu72) 27 28 BtnA.setCallback(type=BtnA.CB_TYPE.WAS_CLICKED, cb=btnA_wasClicked_event) 29 30 rotary = Rotary() 31 32 33def loop(): 34 global label0, rotary 35 M5.update() 36 if rotary.get_rotary_status(): 37 label0.setText(str(rotary.get_rotary_value())) 38 39 40if __name__ == "__main__": 41 try: 42 setup() 43 while True: 44 loop() 45 except (Exception, KeyboardInterrupt) as e: 46 try: 47 from utility import print_error_msg 48 49 print_error_msg(e) 50 except ImportError: 51 print("please update to latest firmware")
UIFLOW2 Example:
class Rotary
Constructors
- class Rotary
Creates a Rotary object.
UIFLOW2:

Methods
- Rotary.get_rotary_value() int
Note
Cannot be used simultaneously with
Rotary.get_rotary_increments().Gets the rotation value of the Rotary object.
UIFLOW2:

- Rotary.get_rotary_increments() int
Note
Cannot be used simultaneously with
Rotary.get_rotary_increments().Gets the rotation increment of the Rotary object. Can be used to determine the direction of rotation.
UIFLOW2:




