0
0

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.

M5Paper: ボタン (G37,G38,G39) の操作

0
Posted at

プログラム

button.ino
// ---------------------------------------------------------------
//	button.ino
//
//					Jun/23/2022
// ---------------------------------------------------------------
#include <M5EPD.h>

M5EPD_Canvas canvas(&M5.EPD);

// ---------------------------------------------------------------
void ButtonTest(char str[])
{
	canvas.fillCanvas(0);
	canvas.drawString(str, 100, 200);
	canvas.pushCanvas(0,0,UPDATE_MODE_DU4);
	delay(500);
}

// ---------------------------------------------------------------
void setup() {

	M5.begin();
	M5.EPD.SetRotation(90);
	M5.EPD.Clear(true);
	canvas.createCanvas(540, 960);
	canvas.setTextSize(3);
	const int xpos = 100;
	canvas.drawString("Push Button", xpos, 200);
	canvas.drawString("G37", xpos, 300);
	canvas.drawString("G38", xpos, 350);
	canvas.drawString("G39", xpos, 400);
	canvas.pushCanvas(0,0,UPDATE_MODE_DU4);
}

// ---------------------------------------------------------------
void loop()
{
	if( M5.BtnL.wasPressed())
		{
		ButtonTest("Btn L G37 Pressed");
		}

	if( M5.BtnP.wasPressed())
		{
		ButtonTest("Btn P G38 Pressed");
		}
	if( M5.BtnR.wasPressed())
		{
		ButtonTest("Btn R G39 Pressed");
		}

	M5.BtnL.lastChange();

	M5.update();
	delay(100);
}

// ---------------------------------------------------------------

Arduino IDE
image.png

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?