MCPcopy Create free account
hub / github.com/bmorcelli/Launcher / reboot

Function reboot

boards/m5stack-tab5/interface.cpp:135–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135void reboot() {
136 auto &ioe = M5.getIOExpander(1);
137 if (M5.Rtc.isEnabled()) {
138 launcherConsolePrintf("%s\n", String("reboot: RTC alarm").c_str());
139 M5.Rtc.clearIRQ();
140 auto now = M5.Rtc.getDateTime();
141
142 auto set_dt = now;
143 auto alarm_dt = now;
144
145 if (now.time.seconds <= 29) {
146 // set to hh:mm-1:59 and alarm hh:mm:00
147 set_dt.time.seconds = 59;
148 int y = set_dt.date.year;
149 int mo = set_dt.date.month;
150 int d = set_dt.date.date;
151 int h = set_dt.time.hours;
152 int mi = set_dt.time.minutes;
153 tab5_adjust_date_minutes(y, mo, d, h, mi, -1);
154 set_dt.date.year = y;
155 set_dt.date.month = mo;
156 set_dt.date.date = d;
157 set_dt.time.hours = h;
158 set_dt.time.minutes = mi;
159
160 alarm_dt.time.seconds = 0;
161 } else {
162 // set to hh:mm:59 and alarm hh:mm+1:00
163 set_dt.time.seconds = 59;
164
165 alarm_dt.time.seconds = 0;
166 int y = alarm_dt.date.year;
167 int mo = alarm_dt.date.month;
168 int d = alarm_dt.date.date;
169 int h = alarm_dt.time.hours;
170 int mi = alarm_dt.time.minutes;
171 tab5_adjust_date_minutes(y, mo, d, h, mi, 1);
172 alarm_dt.date.year = y;
173 alarm_dt.date.month = mo;
174 alarm_dt.date.date = d;
175 alarm_dt.time.hours = h;
176 alarm_dt.time.minutes = mi;
177 }
178
179 M5.Rtc.setDateTime(set_dt);
180 M5.Rtc.setAlarmIRQ(alarm_dt.date, alarm_dt.time);
181 }
182 for (int i = 0; i < 3; ++i) {
183 ioe.digitalWrite(4, HIGH);
184 launcherDelayMs(100);
185 ioe.digitalWrite(4, LOW);
186 launcherDelayMs(100);
187 }
188}

Callers

nothing calls this directly

Calls 3

launcherConsolePrintfFunction · 0.85
tab5_adjust_date_minutesFunction · 0.85
launcherDelayMsFunction · 0.85

Tested by

no test coverage detected