M5Spinner
M5Spinner is a spinning arc over a ring, typically used to show some type of activity is in progress.
UiFlow2 Example
spinner
Open the core2_spinner_example.m5f2 project in UiFlow2.
This example shows a spinning arc over a ring.
UiFlow2 Code Block:
Example output:
None
MicroPython Example
spinner
This example shows a spinning arc over a ring.
MicroPython Code Block:
1# SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8import m5ui 9import lvgl as lv 10 11 12page0 = None 13spinner0 = None 14 15 16def setup(): 17 global page0, spinner0 18 19 M5.begin() 20 Widgets.setRotation(1) 21 m5ui.init() 22 page0 = m5ui.M5Page(bg_c=0xFFFFFF) 23 spinner0 = m5ui.M5Spinner( 24 x=71, 25 y=81, 26 w=100, 27 h=100, 28 anim_t=10000, 29 angle=180, 30 bg_c=0xE7E3E7, 31 bg_c_indicator=0x2193F3, 32 parent=page0, 33 ) 34 35 page0.screen_load() 36 37 38def loop(): 39 global page0, spinner0 40 M5.update() 41 42 43if __name__ == "__main__": 44 try: 45 setup() 46 while True: 47 loop() 48 except (Exception, KeyboardInterrupt) as e: 49 try: 50 m5ui.deinit() 51 from utility import print_error_msg 52 53 print_error_msg(e) 54 except ImportError: 55 print("please update to latest firmware")
Example output:
None
API
M5Spinner
- class m5ui.spinner.M5Spinner(*args, **kwargs)
Bases:
spinnerCreate a spinner object.
- Parameters:
x (int) – The x position of the spinner.
y (int) – The y position of the spinner.
w (int) – The width of the spinner.
h (int) – The height of the spinner.
anim_t (int) – The animation time in milliseconds.
angle (int) – The angle of the spinner in degrees.
bg_c (int) – The background color of the spinner in hexadecimal format.
bg_c_indicator (int) – The indicator color of the spinner in hexadecimal format.
parent (lv.obj) – The parent object to attach the spinner to. If not specified, the spinner will be attached to the default screen.
UiFlow2 Code Block:
None
MicroPython Code Block:
from m5ui import M5Spinner import lvgl as lv m5ui.init() spinner_0 = M5Spinner(x=120, y=80, w=60, h=30, anim_t=1000, angle=180, bg_c=0xE7E3E7, bg_c_indicator=0x0288FB, parent=page0)
- set_flag(flag, value)
Set a flag on the object. If
valueis True, the flag is added; if False, the flag is removed.- Parameters:
- Returns:
None
UiFlow2 Code Block:

MicroPython Code Block:
spinner_0.set_flag(lv.obj.FLAG.HIDDEN, True)
- set_pos(x, y)
Set the position of the spinner.
UiFlow2 Code Block:

MicroPython Code Block:
spinner_0.set_pos(100, 100)
- set_x(x)
Set the x-coordinate of the spinner.
- Parameters:
x (int) – The x-coordinate of the spinner.
UiFlow2 Code Block:

MicroPython Code Block:
spinner_0.set_x(100)
- set_y(y)
Set the y-coordinate of the spinner.
- Parameters:
y (int) – The y-coordinate of the spinner.
UiFlow2 Code Block:

MicroPython Code Block:
spinner_0.set_y(100)
- set_size(width, height)
Set the size of the spinner.
UiFlow2 Code Block:

MicroPython Code Block:
spinner_0.set_size(100, 50)
- align_to(obj, align, x, y)
Align the spinner to another object.
- Parameters:
UiFlow2 Code Block:

MicroPython Code Block:
spinner_0.align_to(page_0, lv.ALIGN.CENTER, 0, 0)
- set_anim_params(anim_t, angle)
Set the animation parameters of the spinner.
- Parameters:
UiFlow2 Code Block:

MicroPython Code Block:
spinner_0.set_anim_params(1000, 180)
- set_spinner_color(color, opa, part)
Set the color of the spinner.
- Parameters:
UiFlow2 Code Block:


MicroPython Code Block:
spinner_0.set_spinner_color(0x2196F3, 255, lv.PART.MAIN | lv.STATE.DEFAULT)
