From d1c15610bbec4e49a69c7c56ebcfade740a0dc98 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Sun, 17 Dec 2017 16:15:05 +0200 Subject: [PATCH] Add low power example scripts. --- usr/examples/19-Low-Power/deep_sleep.py | 21 +++++++++++++++++++++ usr/examples/19-Low-Power/stop_mode.py | 19 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 usr/examples/19-Low-Power/deep_sleep.py create mode 100644 usr/examples/19-Low-Power/stop_mode.py diff --git a/usr/examples/19-Low-Power/deep_sleep.py b/usr/examples/19-Low-Power/deep_sleep.py new file mode 100644 index 000000000..2fc583575 --- /dev/null +++ b/usr/examples/19-Low-Power/deep_sleep.py @@ -0,0 +1,21 @@ +# Deepsleep Mode Example +# This example demonstrates using the low-power Deepsleep Mode. +# Note the camera will reset after wake-up from deep sleep. To find out if the cause of reset +# is deep sleep, call the machine.reset_cause() function and test for machine.DEEPSLEEP_RESET +import pyb, machine + +# Create and init RTC object. +rtc = pyb.RTC() + +# (year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]]) +rtc.datetime((2014, 5, 1, 4, 13, 0, 0, 0)) + +# Print RTC info. +print(rtc.datetime()) + +# Enable RTC interrupts every 5 seconds. +# Note the camera will RESET after wakeup from Deepsleep Mode. +rtc.wakeup(5000) + +# Enter Deepsleep Mode. +machine.deepsleep() diff --git a/usr/examples/19-Low-Power/stop_mode.py b/usr/examples/19-Low-Power/stop_mode.py new file mode 100644 index 000000000..c84dc9ba8 --- /dev/null +++ b/usr/examples/19-Low-Power/stop_mode.py @@ -0,0 +1,19 @@ +# Stop Mode Example +# This example demonstrates using the low-power Stop Mode. + +import time, pyb, machine + +# Create and init RTC object. +rtc = pyb.RTC() +# (year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]]) +rtc.datetime((2014, 5, 1, 4, 13, 0, 0, 0)) + +# Print RTC info. +print(rtc.datetime()) + +# Enable RTC interrupts every 5 seconds. +rtc.wakeup(2000) + +# Enter Stop Mode. +# Note the IDE will disconnect. +machine.sleep()