from m5stack import *
from m5ui import *
from uiflow import *
import time
remoteInit()
setScreenColor(0x222222)
switch_value = None
slider_value = None
stepper_value = None
rp_label1_data = None
from numbers import Number
def button_1_callback():
global rp_label1_data, switch_value, slider_value, stepper_value
print('Button Press')
def switch_1_callback(switch_value):
global rp_label1_data, slider_value, stepper_value
print(switch_value)
def slider_1_callback(slider_value):
global rp_label1_data, switch_value, stepper_value
print(slider_value)
def stepper_1_callback(stepper_value):
global rp_label1_data, switch_value, slider_value
print(stepper_value)
def label_1_callback():
global rp_label1_data, switch_value, slider_value, stepper_value
return rp_label1_data
lcd.qrcode('https://flow.m5stack.com/remote?id=undefined', 72, 32, 176)
rp_label1_data = 0
while True:
rp_label1_data = (rp_label1_data if isinstance(rp_label1_data, Number) else 0) + 1
wait(1)
wait_ms(2)
lcd.qrcode('https://flow.m5stack.com/remote?id=undefined', 72, 32, 176)
Set the position and size of the QR code of the generated web page. Note: After the web page is run for the first time, the remote parameter of the URL in the code will be updated automatically, so this API needs to be run once through UIFlow online mode first.
In the program block menu, click Remote+ function, a preview window will appear on the right side of the page for adding controls, users can drag and drop to add controls to the blank space of the page. After all controls have been configured and the program has been pushed, click on the QR code at the top of the preview window to get a link to the control page.
def button_1_callback():
pass
Properties | Description |
---|---|
Name | Control Title |
Show Title | Whether to display the control title True/False |
Color | Title font color |
Background | Title background color |
Edges | key edge style. sharp/Pill |
Style | Setting the Key Fill Style. Outline/Solid |
def switch_1_callback(switch_value):
print(switch_value)
switch_value
. The content of the function will be triggered when the switch is activated, and the switch state will be passed through the variable switch_value
. switch_value: 1(ON)/0(OFF)Properties | Description |
---|---|
Name | Control Title |
Show Title | Whether to display the control title True/False |
Off Label | Closed status symbol |
On Label | Open Status Logo |
Off Color | Off state font color |
On Color | Open status font color |
Off Background | Off state background color |
On Background | Open state background color |
def slider_1_callback(slider_value):
print(slider_value)
slider_value
. slider_value: can be configured through the Properties. The slider action will trigger the content of the callback function and pass the slider position status through the variable slider_value
. slider_value: Configurable value range through Properties.Properties | Description |
---|---|
Name | Control Title |
Show Title | Whether to display the control title True/False |
Show Value | Whether to display the current slider value True/False |
Color | Slider color |
Min Value | Slider range min. |
Max Value | Slider Range Maximum |
def stepper_1_callback(stepper_value):
print(stepper_value)
stepper_value
.Properties | Description |
---|---|
Name | Control Title |
Show Title | Whether to display the control title True/False |
Min Value | Stepper range min. |
Max Value | Stepper Range Maximum |
Step | Set the Step value for each click |
def label_1_callback():
global rp_label1_data
return rp_label1_data
Properties | Description |
---|---|
Name | Control Title |
Show Title | Whether to display the control title True/False |
Font Size | Text font size |
Color | Data text display color |
Interval(ms) | Data reporting interval/ms |
def joystick_1_callback(joystick_x_value, joystick_y_value):
print(joystick_y_value)
print(joystick_x_value)
joystick_x_value
and joystick_y_value
.Properties | Description |
---|---|
Name | Control Title |
Show Title | Whether to display the control title True/False |
Color | Rocker Color |
Auto Return | Whether to automatically return to the home position when releasing the joystick True/False |
X Min | Minimum X-axis position value |
X Max | Maximum X-axis position value |
Y Min | Minimum Y-axis position value |
Y Max | Maximum Y-axis position value |
def input_1_callback(input_value):
print(input_value)
input_value
.Properties | Description |
---|---|
Name | Control Title |
Show Title | Whether to display the control title True/False |
Font Size | Text font size |
Color | Data text display color |
Hint | Enter text prompts |
Character Limit | Input character length limit, default is 8 |
def image_1_callback():
global rp_img1_url
return rp_img1_url
Properties | Description |
---|---|
Name | Control Title |
Show Title | Whether to display the control title True/False |
Interval(ms) | Data reporting interval/ms |
Fallback URL | URL of the requested image |
def gauge_1_callback():
global rp_gauge1_data
return rp_gauge1_data
Properties | Description |
---|---|
Name | Control Title |
Show Title | Whether to display the control title True/False |
Label | Dashboard Title |
Color | Dashboard display color |
Suffix | Dashboard Data Suffix |
Min Value | Dashboard range min. |
Max Value | Dashboard range max. |
Interval(ms) | Data reporting interval/ms |
Add a chart to the control page, the icon needs to specify the data source via Ezdata function, and it supports to configure the chart refresh interval and the basic style.
List
, Not a Topic
map
(map
), which is a map of the data to be used. You need to use map
(dictionary) to pass data in the form of key-value
. The key needs to correspond to the X, Y Data Source field in the chart control, if it is left empty, the data will not be displayed.Properties | Description |
---|---|
Name | Control Title |
Show Title | Whether to display the control title True/False |
Theme | Setting the Chart Topic Light/Dark |
Color | Setting chart element colors |
Chart Type | Setting the Chart Type, Bar/Line |
Interval(ms) | Setting the chart refresh interval |
Show Legend | Show legend True/False |
Dataset Name | Configure the dataset name |
Y Axis Label Suffix | Configure the Y-axis data suffix |
EzData Token | Configuring the EzData Data Source Token |
List | Specified List of EzData data source |
X Data Source | Set a field in the List data as the X-axis content (usually use time as the data to form a historical record) |
Y Data Source | Setting a field in List data to be the Y-axis content (Usually, monitoring content is used as data to create a trend of data changes) |
Max Count | Maximum amount of data to be displayed on the current chart |