pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

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
On This Page