English
English
简体中文
日本語

UiFlow Tutorial

UiFlow1 Development Guide

Project Management

Use LTE network

UiFlow1 Blockly

Event

Unit

Functions

Example

Define two functions that take parameters for simple arithmetic operations

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

x = None
y = None
result = None

# Describe this function...
def func(x, y):
  global result
  if x < y:
    print(x + y)
  else:
    print(x - y)

# Describe this function...
def mathfuc(y, x):
  global result
  if x < 0:
    return y - x
  return x + y

func(2, 3)
result = mathfuc(10, 5)

API

def func(x, y):
  global result
  if x < y:
    print(x + y)
  else:
    print(x - y)
  • Create a function that can be configured with parameters and the function does not return a value
def mathfuc(y, x):
  global result
  return x + y
  • Create a function that can be configured with parameters and the function does return a value
if x < 0:
    return y - x
  • Perform a simple if logic operation within the function, end the function operation, and return a value
Page Tools
PDF
On This Page