-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathM5CoreInk.cpp
More file actions
91 lines (77 loc) · 1.68 KB
/
M5CoreInk.cpp
File metadata and controls
91 lines (77 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "M5CoreInk.h"
#include "driver/gpio.h"
M5CoreInk::M5CoreInk(/* args */)
{
}
M5CoreInk::~M5CoreInk()
{
}
int M5CoreInk::begin(bool InkEnable, bool wireEnable, bool SpeakerEnable)
{
pinMode(POWER_HOLD_PIN, OUTPUT);
digitalWrite(POWER_HOLD_PIN, HIGH); // Hold power
gpio_hold_en((gpio_num_t)POWER_HOLD_PIN); // Hold power during deepSleep
pinMode(LED_EXT_PIN, OUTPUT);
Serial.begin(115200);
Serial.printf("initializing github library OK\n");
if (wireEnable)
{
Wire.begin(32, 33, 10000);
}
if (SpeakerEnable)
{
Speaker.begin();
}
rtc.begin();
rtc.clearIRQ();
if (InkEnable)
{
M5Ink.begin();
if (!M5.M5Ink.isInit())
{
Serial.printf("Ink initializ is faild\n");
return -1;
}
}
return 0;
}
void M5CoreInk::update()
{
BtnUP.read();
BtnDOWN.read();
BtnMID.read();
BtnEXT.read();
BtnPWR.read();
Speaker.update();
}
void M5CoreInk::shutdown()
{
// Disable power to shutdown device
gpio_hold_dis((gpio_num_t)POWER_HOLD_PIN);
digitalWrite(POWER_HOLD_PIN, LOW);
}
int M5CoreInk::deepSleepESP(int seconds)
{
rtc.clearIRQ();
rtc.SetAlarmIRQ(seconds);
delay(10);
esp_deep_sleep_start();
return 0;
}
int M5CoreInk::shutdown(const RTC_TimeTypeDef &RTC_TimeStruct)
{
rtc.clearIRQ();
rtc.SetAlarmIRQ(RTC_TimeStruct);
delay(10);
esp_deep_sleep_start();
return 0;
}
int M5CoreInk::shutdown(const RTC_DateTypeDef &RTC_DateStruct, const RTC_TimeTypeDef &RTC_TimeStruct)
{
rtc.clearIRQ();
rtc.SetAlarmIRQ(RTC_DateStruct,RTC_TimeStruct);
delay(10);
esp_deep_sleep_start();
return 0;
}
M5CoreInk M5;