pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Logic

Example

Logical processing functions are used

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

date = None
boolean = None
oldData1 = None

date = 5
if date < 10:
  date = date + 1

if date != 10:
  date = date + 1
else:
  date = date - 1

boolean = date <= 6

date = 0 if date <= 6 else 2

try :
  boolean = True and False
  pass
except:
  boolean = not date == 0

if date==6:
  date = date + 1
elif date==7:
  date = date + 2
else:
  date = date - 1

if date != oldData1:
  oldData1 = date
  date = date + 1
else:
  date = date - 1
  pass

API

if date < 10:
  date = date + 1
  • Evaluate a condition and execute the code on the right side of "Do" if the condition is true
if date != 10:
  date = date + 1
else:
  date = date - 1
  • Evaluate a condition and execute the code on the right side of "Do" if the condition is true, otherwise execute the code on the right side of "else"
  • Boolean values can be used as substitutes for conditional expressions, where true represents a successful condition and false represents an unsuccessful one
date = 0 if date <= 6 else 2
  • Ternary operator, which can be seen as a shorthand alternative to an if-else statement
boolean = date <= 6
  • Logical expressions are often used as conditions in if statements (equal to, not equal to, greater than, less than, greater than or equal to, less than or equal to) to evaluate the relationship between the data on both sides of the operation, ultimately yielding a true or false value for the if condition
boolean = not date == 0
  • Invert the logical result of an expression, i.e., notTrue becomes False, notFalse becomes True
  • Assigning a null value in a boolean operation context
if date==6:
  date = date + 1
elif date==7:
  date = date + 2
else:
  date = date - 1
  • switch-case logical syntax
try :
  boolean = True and False
  pass
except:
  boolean = not date == 0
  • try-except exception handling. When code in the try block raises an exception, the program's control flow immediately jumps to the except block that matches the exception type (if any)
boolean = True and False
  • and operator: The logical operation result is True if both left and right logical expressions are True, otherwise it is False
  • or operator: The logical operation result is True only if both left and right logical expressions are True, otherwise it is False
if date != oldData1:
  oldData1 = date
  date = date + 1
else:
  date = date - 1
  pass
  • Functions that are triggered when specific data changes
On This Page