Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial alarm and sleep PR: time alarms with light and deep sleep; PinAlarms not yet implemented #3767

Merged
merged 41 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
90b9ec6
Initial Sleep Support
microdev1 Sep 18, 2020
3a30887
Update soft reboot message
microdev1 Sep 18, 2020
e310b87
Get io wake working
microdev1 Sep 19, 2020
05a3f20
Add function to get time elapsed during sleep
microdev1 Sep 22, 2020
21ba61a
Add function to disable alarm
microdev1 Sep 22, 2020
e5ff55b
Renamed alarm modules
microdev1 Sep 23, 2020
4d8ffdc
restructure alarm modules
microdev1 Sep 24, 2020
da44972
Fix build error
microdev1 Sep 24, 2020
59df1a1
Add alarm_touch module
microdev1 Sep 24, 2020
e359389
Add description of alarm modules
microdev1 Sep 24, 2020
930cf14
Add check for invalid io, function to disable all alarms
microdev1 Sep 26, 2020
0e444f0
Implement sleep on code.py exit
microdev1 Sep 30, 2020
354536c
Update translation
microdev1 Oct 7, 2020
1196d4b
move to new module
tannewt Oct 14, 2020
85dadf3
More API changes
tannewt Oct 15, 2020
9a4efed
Start tweaking the workflow to sleep
tannewt Oct 28, 2020
bb77f1d
wip: initial code changes, starting from @tannewt's sleepio branch
dhalbert Nov 16, 2020
ffff02c
Merge remote-tracking branch 'adafruit/main' into sleep
dhalbert Nov 16, 2020
682054a
WIP: redo API; not compiled yet
dhalbert Nov 19, 2020
5bb3c32
merge from main
dhalbert Nov 19, 2020
649c930
wip
dhalbert Nov 19, 2020
cd436ba
Merge remote-tracking branch 'adafruit/main' into sleep
dhalbert Nov 19, 2020
39e1f52
wip; not compiling yet
dhalbert Nov 19, 2020
e4c6699
compiles
dhalbert Nov 21, 2020
75559f3
wip: ResetReason to microcontroller.cpu
dhalbert Nov 22, 2020
a0f1ec3
wip
dhalbert Nov 23, 2020
25591a3
Merge branch 'esp32s2-common-hal-mcu-delay-us' into sleep
dhalbert Nov 23, 2020
3abee9b
compiles; maybe ready to test, or almost
dhalbert Nov 23, 2020
7a45afc
working, but need to avoid deep sleeping too fast before USB ready
dhalbert Nov 24, 2020
f868cc5
some API renaming and bug fixes; fix docs
dhalbert Nov 25, 2020
9dbea36
changed alarm.time API
dhalbert Nov 25, 2020
ef0830b
merge from upstream + wip
dhalbert Nov 25, 2020
104a089
deep sleep working; deep sleep delay when connected
dhalbert Nov 27, 2020
e308a9e
working! PinAlarm not implemented yet.
dhalbert Nov 27, 2020
596e0e4
merge from upstream
dhalbert Nov 27, 2020
f96475c
update Requests; rolled back by accident
dhalbert Nov 27, 2020
65e2fe4
fix stub problems; touch up doc
dhalbert Nov 28, 2020
2830cc9
make translate
dhalbert Nov 28, 2020
28d9e91
Disable complex arithmetic on SAMD21 builds to make space
dhalbert Nov 28, 2020
8b7c23c
address review comments
dhalbert Dec 2, 2020
72fa7d8
fix doc errors
dhalbert Dec 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
compiles; maybe ready to test, or almost
  • Loading branch information
dhalbert committed Nov 23, 2020
commit 3abee9b2563f0203f3d9521631499008708bb407
8 changes: 5 additions & 3 deletions ports/esp32s2/common-hal/alarm/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@
*/

#include "py/objtuple.h"
#include "py/runtime.h"

#include "shared-bindings/alarm/__init__.h"
#include "shared-bindings/alarm/pin/PinAlarm.h"
#include "shared-bindings/alarm/time/DurationAlarm.h"
#include "shared-bindings/microcontroller/__init__.h"

#include "esp_sleep.h"

STATIC mp_obj_tuple_t *_deep_sleep_alarms;

void alarm_reset(void) {
_deep_sleep_alarms = &mp_const_empty_tuple;
_deep_sleep_alarms = mp_const_empty_tuple;
}

void common_hal_alarm_disable_all(void) {
Expand Down Expand Up @@ -94,8 +96,8 @@ void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *ala
}

void common_hal_deep_sleep_with_alarms(void) {
for (size_t i = 0; i < _deep_sleep_alarms.len; i++) {
mp_obj_t alarm = _deep_sleep_alarms.items[i]
for (size_t i = 0; i < _deep_sleep_alarms->len; i++) {
mp_obj_t alarm = _deep_sleep_alarms->items[i];
if (MP_OBJ_IS_TYPE(alarm, &alarm_time_duration_alarm_type)) {
alarm_time_duration_alarm_obj_t *duration_alarm = MP_OBJ_TO_PTR(alarm);
esp_sleep_enable_timer_wakeup(
Expand Down
32 changes: 32 additions & 0 deletions ports/esp32s2/common-hal/alarm/__init__.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2020 Dan Halbert for Adafruit Industries.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_ALARM__INIT__H
#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_ALARM__INIT__H

void alarm_reset(void);

#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_ALARM__INIT__H
1 change: 1 addition & 0 deletions ports/esp32s2/common-hal/microcontroller/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "freertos/FreeRTOS.h"

#include "esp_sleep.h"
#include "esp_wifi.h"

void common_hal_mcu_delay_us(uint32_t delay) {
mp_hal_delay_us(delay);
Expand Down
2 changes: 1 addition & 1 deletion shared-bindings/alarm/__init__.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "py/obj.h"

extern mp_obj_t common_hal_alarm_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms);
extern mp_obj_t common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms);
extern void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms);

// Used by wake-up code.
extern void common_hal_alarm_set_wake_alarm(mp_obj_t alarm);
Expand Down