From ba284ba2ae96e0670d4305c0f8a431c0341fd932 Mon Sep 17 00:00:00 2001 From: Gitshaoxiang <1026025056@qq.com> Date: Thu, 12 Nov 2020 18:41:14 +0800 Subject: [PATCH] add coreInk sleep API --- docs/en/api/coreink/system_api.md | 56 ++++++++++++++++++++++++++++ docs/zh_CN/api/coreink/system_api.md | 44 +++++++--------------- 2 files changed, 70 insertions(+), 30 deletions(-) diff --git a/docs/en/api/coreink/system_api.md b/docs/en/api/coreink/system_api.md index 548bfac8..522dc03d 100644 --- a/docs/en/api/coreink/system_api.md +++ b/docs/en/api/coreink/system_api.md @@ -186,3 +186,59 @@ void loop() { } ``` +## shutdown() + +### function overload-1: + +Power off and wake up again via PWR button + +`void shutdown();` + +### function overload-2: + +Turn off the power and wake up the device via RTC at the end of the delay based on the number of seconds of incoming delay. + +`int shutdown( int seconds );` + +### function overload-3: + +Turn off the power, pass in the RTC time structure that specifies a certain point in time, and wake up the device via RTC when the `hours`, `minutes`, and `seconds` of that time are met. + +`int shutdown( const RTC_TimeTypeDef &RTC_TimeStruct);` + +### function overload-4: + +Turn off the power, pass in the RTC time structure specified for a certain point in time, and wake up the device by RTC when the `week number`, `day number`, and `time` of that point in time match at the same time. + +`int shutdown( const RTC_DateTypeDef &RTC_DateStruct, const RTC_TimeTypeDef &RTC_TimeStruct);` + +**Example:** + +``` +#include "M5CoreInk.h" +void setup() +{ + M5.begin(); + digitalWrite(LED_EXT_PIN,LOW); + M5.update(); + + M5.M5Ink.clear(); + delay(500); +} + +void loop() +{ + + if( M5.BtnPWR.wasPressed()) + { + Serial.printf("Btn %d was pressed \r\n",BUTTON_EXT_PIN); + digitalWrite(LED_EXT_PIN,LOW); + M5.shutdown(5); + //M5.shutdown(RTC_TimeTypeDef(10,2,0)); + } + + //M5.rtc.SetAlarmIRQ(RTC_TimeTypeDef(10,2,0)); + + M5.update(); +} +``` diff --git a/docs/zh_CN/api/coreink/system_api.md b/docs/zh_CN/api/coreink/system_api.md index e37383b9..d837a62a 100644 --- a/docs/zh_CN/api/coreink/system_api.md +++ b/docs/zh_CN/api/coreink/system_api.md @@ -218,44 +218,28 @@ void loop() { ``` #include "M5CoreInk.h" - -Ink_Sprite InkPageSprite(&M5.M5Ink); - -void ButtonTest(char* str) +void setup() { - InkPageSprite.clear(); - InkPageSprite.drawString(35,59,str); - InkPageSprite.pushSprite(); - delay(2000); -} - -void setup() { - M5.begin(); - if( !M5.M5Ink.isInit()) - { - Serial.printf("Ink Init faild"); - } - M5.M5Ink.clear(); - delay(1000); - //creat ink refresh Sprite - if( InkPageSprite.creatSprite(0,0,200,200,true) != 0 ) - { - Serial.printf("Ink Sprite creat faild"); - } + digitalWrite(LED_EXT_PIN,LOW); + M5.update(); - ButtonTest("Press Btn PWR for sleep , after 5 sec wakeup."); + M5.M5Ink.clear(); + delay(500); } -void loop() { +void loop() +{ + if( M5.BtnPWR.wasPressed()) { Serial.printf("Btn %d was pressed \r\n",BUTTON_EXT_PIN); - M5.shutdown(20); - // M5.shutdown(RTC_TimeTypeDef(10,2,0)); + digitalWrite(LED_EXT_PIN,LOW); + M5.shutdown(5); + //M5.shutdown(RTC_TimeTypeDef(10,2,0)); } - M5.update(); -} + //M5.rtc.SetAlarmIRQ(RTC_TimeTypeDef(10,2,0)); -``` \ No newline at end of file + M5.update(); +} \ No newline at end of file