M5Stack UiFlow for Beginners - Lesson 01 - Hello World

M5Stack
21 Feb 202012:07

Summary

TLDRこのビデオは、M5StackデバイスでUI Flowを使用してプログラミングの基本を学ぶためのチュートリアルです。「Hello World」プログラムから始まり、テキストとグラフィック要素を画面上に配置する方法を学びます。UIマネージャーを使ってラベルやシェイプを追加し、ブロックプログラミングでそれらの要素をコントロールする方法を解説しています。最終的には名刺のようなデザインを作成し、プログラムをデバイスにアップロードして実行する過程を紹介しています。視覚的な例を交えながら、プログラミングの基礎を分かりやすく学べる内容となっています。

Takeaways

  • 👋 この講座では、M5 Stackデバイスの画面上にテキストと画像を表示する方法を学びます。
  • 🌍 最初に「Hello World」プログラムから始めます。これはプログラミング言語を学ぶ際の定番の第一歩です。
  • 📺 画面はたくさんの小さな点(ピクセル)から構成されており、X座標とY座標を使ってピクセルの位置を指定します。
  • 🧩 UIFlowというブロックプログラミングインターフェースを使用して、プログラミングの基礎を学びます。
  • ✏️ UIマネージャーを使ってスクリーン上の要素を配置し、プロパティを設定します。
  • 📄 テキストボックスやグラフィック要素のプロパティ(名前、位置、色、フォントなど)を変更できます。
  • 💻 プログラムをM5デバイスにアップロードして実行できます。またデスクトップに保存することもできます。
  • 🎨 名刺を作成するチャレンジがあり、創造性を発揮してテキストと図形を組み合わせることができます。
  • 🔖 レイヤーを使うと、要素の前面/背面の重なり順を制御できます。
  • 🆘 分からない点があれば質問できるようサポートが用意されています。

Q & A

  • ビデオの主な目的は何ですか?

    -このビデオの主な目的は、M5Stackデバイスの画面にテキストや画像を表示する方法を初心者に紹介することです。最初はHello Worldプログラムから始め、その後名刺の作成を通して、さまざまな要素を画面に配置する方法を学びます。

  • UIフローのインターフェースについて説明してください。

    -UIフローインターフェースには、コーディング領域、コードブロック領域、UIマネージャー、ユニット領域、ナビゲーションバーなどがあります。コーディング領域でプログラムを作成し、コードブロック領域から必要なブロックを選択します。UIマネージャーでは画面上の要素を設定できます。

  • プログラミングにおいて、X座標とY座標はどのような役割を果たしますか?

    -X座標とY座標は、画面上の位置を指定するために使用されます。X座標は水平方向の位置を、Y座標は垂直方向の位置を表します。これらの座標を指定することで、テキストや図形を画面上の正確な位置に配置できます。

  • UIマネージャーで要素のプロパティをカスタマイズする方法を教えてください。

    -UIマネージャーで要素をドラッグアンドドロップすると、その要素をクリックして各プロパティ(名前、X/Y座標、色、フォントサイズ、回転角度など)を編集できます。必要に応じてこれらのプロパティを調整することで、要素の外観や位置を変更できます。

  • デバイスにプログラムをロードする方法は何ですか?

    -デバイスにプログラムをロードする方法は2つあります。1つ目は「再生」ボタンを押して即座にデバイスに送信する方法です。2つ目は「設定」メニューから「ダウンロード」を選択し、デバイスのメモリにプログラムを保存する方法です。後者の方法では電源を切っても保存されたプログラムを実行できます。

  • プログラムをデスクトップに保存する方法を教えてください。

    -設定メニューから「保存」ボタンを選択すると、プログラムをデスクトップに保存できます。ファイル名は自由に付けられますが、拡張子は .m5f のままにする必要があります。

  • このビデオでは、名刺の作成を例に挙げていますが、名刺にはどのような情報を含めるべきでしょうか。

    -名刺には通常、氏名、電話番号、住所、趣味などの個人情報を含めます。このビデオでは、これらの情報をテキストボックスに入力し、円形の図形を使ってデザインを飾る例が紹介されています。

  • Blocklyモードとは何ですか?

    -Blocklyモードとは、UIフローエディターのブロックプログラミングモードのことです。このモードでは、プログラミングの構文を視覚的にブロックで表現することができ、初心者がプログラミングの基本を学ぶのに適しています。また、Pythonモードへの切り替えも可能です。

  • レイヤーの機能について教えてください。

    -レイヤーの機能を使うと、画面上の要素の前後関係を制御できます。より複雑な画像を作成する際に、特定の要素を手前や背面に配置したい場合に、このレイヤー設定が役立ちます。

  • フォーラムとドキュメントについて説明してください。

    -UIフローインターフェースには、フォーラムとドキュメントへのリンクがあります。フォーラムでは、プログラミングに関する質問をしたり、助言を求めたりできます。ドキュメントには、M5Stackデバイスの使用方法や機能に関する詳細な情報が記載されています。

Outlines

00:00

🤖 プログラミングの基本的な「Hello World」

このレッスンシリーズの第1回目では、M5 Stackのスクリーンにテキストと画像を表示する方法を学びます。プログラミングの基本である「Hello World」プログラムから始め、画面上にテキストを表示する方法を説明しています。また、スクリーンがX座標とY座標で構成されるピクセルの集合体であることを説明し、UIフローのインターフェースについて概要を述べています。最後に、画面上にラベルを配置し、そのプロパティを変更する方法を示しています。

05:00

🖼️ 名刺の作成

このパラグラフでは、UIマネージャーを使用して名刺を作成する方法を説明しています。最初に自分の名前を表示するテキストラベルを追加し、次に電話番号、住所、趣味などを表示するためのさらなるラベルを追加します。さらに、グラフィカル要素として円を追加し、犬の足跡のようなデザインを作成する方法を示しています。プロパティを変更して円の半径や色を調整する方法も説明されています。

10:02

💻 プログラムのアップロードと保存

最後のパラグラフでは、作成したプログラムをM5 Goデバイスにアップロードする方法と、デスクトップに保存する方法を説明しています。プログラムをデバイスにアップロードするには、プレイボタンを押すか、設定メニューからダウンロードオプションを選択します。デスクトップに保存する場合は、設定メニューの保存ボタンを使用します。最後に、名刺の作品を改善するよう読者に促し、次のビデオに向けて励まし言葉を述べています。

Mindmap

Keywords

💡プログラミング言語

プログラミング言語とは、コンピューターに指示を与えるための人工的に作られた言語のことです。この動画では、プログラミング言語を使ってM5スタックの画面にテキストや画像を表示する方法を説明しています。冒頭で、「プログラミング言語を学ぶ際には、まず「Hello World」と画面に出力するのが一般的」と述べられています。

💡ピクセル

ピクセルとは、画面を構成する最小単位の点のことです。動画では、「画面はX方向とY方向の座標で構成された多数のピクセルで出来ている」と説明されています。ピクセルの位置を指定することで、画面上に任意の位置にテキストや画像を配置できます。

💡UIフロー

UIフローとは、この動画で使用されているビジュアルプログラミングツールの名称です。UIフローではブロックを組み合わせることで、プログラミングができます。動画の中で「UIフローの画面上にあるコードブロックエリアからブロックを選んでプログラムを作成する」と説明されています。

💡ラベル

ラベルとは、画面上にテキストを表示するための要素のことです。動画では「ラベルをドラッグして画面上に配置し、位置やフォントなどのプロパティを設定できる」と紹介されています。また、プログラミングでラベルのテキストを変更する方法も示されています。

💡座標

座標とは、画面上の位置を示すX座標とY座標の組み合わせのことです。動画の中で「テキストや図形の位置は座標で指定する」と説明されています。例えば「(100, 200)」のような値を設定することで、その位置にオブジェクトを配置できます。

💡フォント

フォントとは、文字の書体のことです。動画ではラベルのプロパティとして、「フォントを変更できる」ということが紹介されています。適切なフォントを選ぶことで、テキストの見栄えを良くすることができます。

💡レイヤー

レイヤーとは、画面上のオブジェクトの前後関係を管理する機能のことです。動画で「レイヤーを使うと、オブジェクトを前面や背面に配置できる」と説明されています。複雑な画面を作る際に、オブジェクトの重なり順を適切に設定することが重要です。

💡アップロード

アップロードとは、作成したプログラムをM5スタック本体に転送することです。動画の中で「再生ボタンを押すと即座にプログラムがM5スタックにアップロードされる」と説明されています。また、プログラムを本体の メモリに保存する「ダウンロード」機能も紹介されています。

💡名刺

動画の後半では、名刺のようなデザインを作成する例が示されています。名刺には、名前や住所、電話番号などの個人情報が記載されます。動画では、ラベルとして文字を、円などの図形要素を組み合わせて、シンプルな名刺のデザインを作成しています。

💡図形

図形とは、円や四角形、線分などの形状のことです。動画では、円の図形を使って「犬の足跡」を表現する例が示されています。図形のプロパティとして、大きさや色、枠線の太さなどを変更できることが紹介されています。テキストと組み合わせることで、さまざまなデザインが可能になります。

Highlights

Here we are in the first lesson of this series, and we're going to be displaying text and images on the screen of the M5 Stack.

We're going to be doing the hello world program, which is what everybody starts out when they're doing any kind of programming language.

Screens are made up of lots of tiny dots called pixels, and we need to know the X&Y coordinates to place things on the screen.

We'll be using the UI Flow block programming interface to get you to grips with learning programming.

We'll start by naming our first project 'Hello World'.

For the most part of this course, we'll be focusing on Blockly to get you up and running with the basics of programming.

We can add a label to the screen by dragging a text or graphical element into the UI manager space.

We can change the properties of the label, such as its name, position, color, font, rotation, and layering.

Elements we design in the UI manager will appear in the UI tab of the code blocks menu.

We can use code blocks from the UI tab to control the text box we added.

We'll be making a name card by using the UI manager to show different graphical elements and text elements on the screen.

We can add more text boxes to the name card by duplicating code blocks and changing their content.

We can add graphical elements like circles to the name card and change their properties like size, color, and border.

We can send our program to the M5 Go device instantly by pressing the play button or download it to the device's memory.

We can also save our program to the desktop by clicking the Save button in the settings menu.

Transcripts

play00:03

[Music]

play00:25

here we are in the first lesson of this

play00:28

series and we're going to be displaying

play00:31

text and images on the screen of the m5

play00:34

stack to get us started we're going to

play00:36

be doing the hello world program which

play00:39

is what everybody starts out when

play00:41

they're doing any kind of programming

play00:43

language it's simply displaying the

play00:45

words hello world on the screen of your

play00:48

device once we get started with that and

play00:51

we can start to build an end card

play00:55

nowadays we see screens of all shapes

play00:58

and sizes

play00:58

all around us they come in many

play01:01

different technologies LCD TFT or LED

play01:06

too many to mention but all we need to

play01:09

know is screens are made up of lots of

play01:11

tiny dots called pixels in the

play01:15

horizontal direction we call it X in the

play01:19

vertical direction we call it Y so in

play01:22

order to place things on the screen we

play01:25

need to know the X&Y coordinates of

play01:27

where we want to place it here we are in

play01:31

UI flow a block programming interface to

play01:35

get you to grips with learning

play01:37

programming let's have a look around the

play01:40

interface and familiarize ourselves with

play01:42

it on the right hand side here we see

play01:46

the coding area we have one code block

play01:49

here already in the middle here we can

play01:53

see the code block section this is where

play01:57

we'll find all the blocks we need to

play01:59

create our programs over on the left

play02:03

hand side is the UI manager here we can

play02:07

grab elements and add them to the screen

play02:10

below we have the units where we'll be

play02:14

adding different sensors to the m5 go

play02:17

and the top bar we have all of the

play02:20

navigation that we need here we can

play02:23

rename our project and we'll start by

play02:27

naming it for our first project hello

play02:31

world

play02:33

you see here in the middle we have the

play02:36

change between blockly and Python for

play02:39

the most part of this course we'll be

play02:41

focusing on blockly to get you up and

play02:44

running with the basics of programming

play02:47

over here we have various icons that

play02:50

will help us to send the code to the

play02:54

device upload our code for reality or

play02:58

readdy to our device redo and undo

play03:02

examples documentation for the device

play03:06

our forums for help if you get stuck and

play03:10

updating of the new versions of the

play03:13

editor over here we'll also see the

play03:17

Settings tab to set our device up with

play03:19

the platform we can go down to setting

play03:23

if we're in the offline version we can

play03:26

set the come port here we can also set

play03:30

it to multiple languages change our

play03:32

device if we're using another m5 stack

play03:35

device and also change the theme let's

play03:42

start by adding a label to the screen

play03:45

when we drag a text or other graphical

play03:50

element into this space we can click on

play03:53

it and then alter the properties by

play03:57

default will be given a name such as

play04:00

label or circle or image we can change

play04:05

this if we like say for instance I could

play04:10

call it text 1 the following portion

play04:14

here X&Y shows where it will be

play04:17

displayed on the screen in terms of

play04:21

graphics we know that things are laid

play04:24

out with x and y-coordinates so if we

play04:27

want to change the position of the text

play04:30

on the screen then we can set this to a

play04:32

different area and we notice once we

play04:35

change these numbers its position

play04:38

changes accordingly let's set it to the

play04:42

center of the screen

play04:53

we can also edit the color but I'm going

play05:00

to keep it with white for now as far as

play05:04

the text goes we could preset the text

play05:07

to show something if we don't intend to

play05:09

program the text box we can change the

play05:17

phone we have a few selections of

play05:20

different fonts that we can choose from

play05:23

we could even rotate the text if we need

play05:26

it but I'm just going to keep it the

play05:30

default for now finally we have layers

play05:35

when we get to creating more complex

play05:37

pictures we might want to set things in

play05:40

front of or behind each other and we'll

play05:43

use the layers to do this now for now we

play05:48

could descend this over to the device

play05:50

but I'm going to show you how we can now

play05:53

program this text label that we just

play05:56

added on the screen if we click into the

play05:59

UI tab of the code blocks menu we see

play06:03

now label has appeared elements that we

play06:08

design in the UI manager will only

play06:11

appear here

play06:11

once we drag them to the screen inside

play06:16

the label menu here I can see a whole

play06:18

bunch of different code blocks which I

play06:20

can use to control my text box for now

play06:24

we're just going to be using the first

play06:25

one you notice that I changed the name

play06:28

of my text label to text one and there's

play06:32

none other in the list because I didn't

play06:35

add any other text boxes there now here

play06:39

I can enter hello world and now when we

play06:45

press play that text will appear on the

play06:50

screen of our device so we're going to

play06:55

make a name card for ourselves we'll be

play06:58

using the UI manager to show different

play07:01

graphical elements and text elements on

play07:04

the screen

play07:08

what would it make sense to add to our

play07:11

text label well of course your name

play07:14

first would make sense so we can go

play07:18

ahead and change this first label to

play07:21

show our name what else might we put on

play07:27

a business card perhaps our phone number

play07:30

let's add another label in there now if

play07:36

we duplicate this code block we can

play07:40

change the first field to show a

play07:44

different label notice that the name of

play07:51

the label that is there has not changed

play07:55

from the default the higher number has

play07:59

just been added if we wanted to change

play08:02

the name we could go back into

play08:03

properties but let's just change the

play08:06

content for now so perhaps I would want

play08:10

to put my phone number in here

play08:19

okay now let's add two more text boxes

play08:24

and change them again we'll duplicate

play08:29

two more labels and change them to

play08:33

represent the corresponding text box

play08:36

that we added in the UI manager now I

play08:41

could perhaps enter my home address

play08:55

and perhaps even huh a hobby

play09:06

notice that in the new UI manager

play09:09

nothing changes

play09:11

this is just simply to help us know

play09:13

where our text will be displayed upon

play09:15

the screen when we run the program on

play09:18

the device then we'll see the changes of

play09:22

the labels now this name card is looking

play09:27

a little boring

play09:28

perhaps we can add some graphical

play09:30

elements to spice it up a little let's

play09:34

start by adding some of these circles in

play09:38

here I'm just going to design a simple

play09:41

dog sport as with the text label we can

play09:47

also change the properties of these

play09:50

graphical elements by clicking on them

play09:53

we could change the name the XY position

play09:56

and here with a circle we change the

play10:01

radius so for this part of the dog's paw

play10:05

I want to make this circle bigger

play10:07

let's try 30 that looks just about right

play10:11

I could also change the border color

play10:14

which is the edge of the circle or the

play10:19

background but for now I'm just going to

play10:22

keep it its default color now when we're

play10:28

loading programs on the device we can

play10:31

either press the play button and this

play10:34

will instantaneously send the code over

play10:37

to the m5 go device if I want to show my

play10:41

friends my name card or load at a

play10:43

different time I might want to download

play10:46

it to the device so if we go into

play10:49

settings we can find this option here

play10:51

download you'll notice that now it says

play10:57

uploading on the screen of our m5 girl

play10:59

device it's now saving your program in

play11:03

the memory of the device so the even if

play11:06

you switch the device off I can choose

play11:09

in a menu on booting the device a list

play11:13

of my programs

play11:16

if we want to save the program to our

play11:19

desktop you can also do that by pressing

play11:22

the Save button in the settings menu you

play11:26

can here change the name it will always

play11:29

have the extension m5f and we shouldn't

play11:32

change that we can also open those

play11:35

programs by clicking the Open button and

play11:38

there we have it our name card I'm sure

play11:42

you can do a much better job than I have

play11:44

and I want you to challenge yourself add

play11:47

lots of text and different colored

play11:50

shapes make a cool picture and I want to

play11:54

see what results you come up with if you

play11:56

get stuck you can always leave us a

play11:58

message

play11:59

drop a comment and I'll see you in the

play12:01

next video

play12:04

you

Rate This

5.0 / 5 (0 votes)

Related Tags
プログラミング入門UIフローM5Stackテキスト配置グラフィック配置名刺作成ブロックプログラミングPythonマルチメディアビジュアル学習
Do you need a summary in English?