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: Light Sleep の使い方

0
Last updated at Posted at 2022-07-10

IMG_20220710_203540.jpg

プログラム

light_sleep.ino
// ---------------------------------------------------------------
//	light_sleep.ino
//
//					Jul/10/2022
// ---------------------------------------------------------------
#include <M5EPD.h>

M5EPD_Canvas canvas_home(&M5.EPD);

int count = 0;
// ---------------------------------------------------------------
void setup()
{
	M5.begin();
	M5.TP.SetRotation(90);
	M5.EPD.SetRotation(90);

	M5.EPD.Clear(true);

	Serial.println("*** setup *** aaa");

	canvas_home.createCanvas(540,960);
	canvas_home.setTextSize(5);

	int ypos[]= {30,110,190,270,350,430,510};
	int xx = 50;
	
	canvas_home.drawString("Light", xx, ypos[0]);
	canvas_home.drawString("Sleep", xx, ypos[1]); 
	canvas_home.pushCanvas(0,0,UPDATE_MODE_A2);
	delay(2000);

	canvas_home.drawString("Good Afternoon", xx, ypos[2]);
	canvas_home.drawString("Good Evening", xx, ypos[3]);
	canvas_home.drawString("Good Night", xx, ypos[4]);
	canvas_home.drawString("Jul/10/2022", xx, ypos[5]);
	canvas_home.drawString("PM 20:21", xx, ypos[6]);
	canvas_home.pushCanvas(0,0,UPDATE_MODE_A2);

	delay(1000);

	Serial.println("*** setup *** ccc ***");
	delay(1000);

	Serial.println("*** setup *** end");
}

// ---------------------------------------------------------------
void loop()
{
	Serial.println("*** loop *** aaa ***");
	Serial.flush();  // Serialをflushさせておく

	char buf[30];
	sprintf(buf, " %d ",count);
	const int xpos = 270;
	const int ypos = 630;
	
	canvas_home.setTextSize(5);
	canvas_home.setTextDatum(TC_DATUM);
	canvas_home.drawString(buf, xpos, ypos);
	canvas_home.drawString(" Sleeping ", xpos, 800);
	canvas_home.pushCanvas(0,0,UPDATE_MODE_A2);

	esp_sleep_enable_ext0_wakeup(GPIO_NUM_38, LOW);
	Serial.println("Going to sleep now");
	Serial.flush();

	esp_light_sleep_start();

	canvas_home.drawString(" Working ", xpos, 800);
	canvas_home.pushCanvas(0,0,UPDATE_MODE_A2);
	Serial.println("*** loop *** ccc");
	Serial.printf("count = %d\r\n", count);

	count++;
	delay(2000);
}

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

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?