3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

M5Stack Core2: UIFlow の使い方

Last updated at Posted at 2021-09-08

UIFlow のインストール方法はこちら
M5Stack Core 2でUIFlowを使ってみよう

https://flow.m5stack.com/
にアクセスして、API KEY を入れることで、使うことが出来ます。

サンプルのスケッチ

Blockly でなく python のコードを打ち込みました。
uiflow_aa.png


from m5stack import *
from m5stack_ui import *
from uiflow import *

screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0x00f0f0)

label0 = M5Label('0', x=12, y=10, color=0x000, font=FONT_MONT_48, parent=None)
label1 = M5Label('0', x=12, y=60, color=0x000, font=FONT_MONT_48, parent=None)
label2 = M5Label('0', x=12, y=110, color=0x000, font=FONT_MONT_48, parent=None)

from numbers import Number

@timerSch.event('timer1')
def ttimer1():
  global counter
  label0.set_text(str(counter))
  jt = counter + 1
  label1.set_text(str(jt))
  kt = counter + 2
  label2.set_text(str(kt))
  counter += 1

counter = 0
timerSch.run('timer1', 2000, 0x00)

プログラムを実行した時の様子
IMG_20210908_143157.jpg

UIFlow では python のプログラムは保存できません。
コピーして、自分で保存しておく必要があります。

上記のプログラムを改造したサンプル

ex01.py
from m5stack import *
from m5stack_ui import *
from uiflow import *

screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0x00f0f0)

xpos = 120
label0 = M5Label('0', x=xpos, y=10, color=0x000, font=FONT_MONT_48, parent=None)
label1 = M5Label('0', x=xpos, y=60, color=0x000, font=FONT_MONT_48, parent=None)
label2 = M5Label('0', x=xpos, y=110, color=0x000, font=FONT_MONT_48, parent=None)
label3 = M5Label('0', x=xpos, y=160, color=0x000, font=FONT_MONT_48, parent=None)

from numbers import Number

@timerSch.event('timer1')
def ttimer1():
  global counter
  label0.set_text(str(counter))
  jt = counter + 100
  label1.set_text(str(jt))
  kt = counter + 200
  label2.set_text(str(kt))
  lt = counter + 300
  label3.set_text(str(lt))
  counter += 1

counter = 0
timerSch.run('timer1', 2000, 0x00)

IMG_20211001_115016.jpg

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?