wip
This commit is contained in:
parent
5bb3c321e9
commit
649c930536
18
main.c
18
main.c
@ -63,6 +63,10 @@
|
||||
|
||||
#include "boards/board.h"
|
||||
|
||||
#if CIRCUITPY_ALARM
|
||||
#include "shared-bindings/alarm/__init__.h"
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_DISPLAYIO
|
||||
#include "shared-module/displayio/__init__.h"
|
||||
#endif
|
||||
@ -88,10 +92,6 @@
|
||||
#include "common-hal/canio/CAN.h"
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_SLEEP
|
||||
#include "shared-bindings/sleep/__init__.h"
|
||||
#endif
|
||||
|
||||
void do_str(const char *src, mp_parse_input_kind_t input_kind) {
|
||||
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0);
|
||||
if (lex == NULL) {
|
||||
@ -320,7 +320,7 @@ bool run_code_py(safe_mode_t safe_mode) {
|
||||
#endif
|
||||
rgb_status_animation_t animation;
|
||||
bool ok = result->return_code != PYEXEC_EXCEPTION;
|
||||
#if CIRCUITPY_SLEEP
|
||||
#if CIRCUITPY_ALARM
|
||||
// If USB isn't enumerated then deep sleep.
|
||||
if (ok && !supervisor_workflow_active() && supervisor_ticks_ms64() > CIRCUITPY_USB_ENUMERATION_DELAY * 1024) {
|
||||
common_hal_sleep_deep_sleep();
|
||||
@ -361,7 +361,7 @@ bool run_code_py(safe_mode_t safe_mode) {
|
||||
#endif
|
||||
bool animation_done = tick_rgb_status_animation(&animation);
|
||||
if (animation_done && supervisor_workflow_active()) {
|
||||
#if CIRCUITPY_SLEEP
|
||||
#if CIRCUITPY_ALARM
|
||||
int64_t remaining_enumeration_wait = CIRCUITPY_USB_ENUMERATION_DELAY * 1024 - supervisor_ticks_ms64();
|
||||
// If USB isn't enumerated then deep sleep after our waiting period.
|
||||
if (ok && remaining_enumeration_wait < 0) {
|
||||
@ -423,9 +423,13 @@ void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
|
||||
if (!skip_boot_output) {
|
||||
// Wait 1.5 seconds before opening CIRCUITPY_BOOT_OUTPUT_FILE for write,
|
||||
// in case power is momentary or will fail shortly due to, say a low, battery.
|
||||
if (common_hal_sleep_get_reset_reason() == RESET_REASON_POWER_VALID) {
|
||||
#if CIRCUITPY_ALARM
|
||||
if (common_hal_sleep_get_reset_reason() == RESET_REASON_POWER_ON) {
|
||||
#endif
|
||||
mp_hal_delay_ms(1500);
|
||||
#if CIRCUITPY_ALARM
|
||||
}
|
||||
#endif
|
||||
|
||||
// USB isn't up, so we can write the file.
|
||||
filesystem_set_internal_writable_by_usb(false);
|
||||
|
52
ports/esp32s2/common-hal/alarm/pin/PinAlarm.c
Normal file
52
ports/esp32s2/common-hal/alarm/pin/PinAlarm.c
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 @microDev1 (GitHub)
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "esp_sleep.h"
|
||||
|
||||
#include "shared-bindings/alarm/time/DurationAlarm.h"
|
||||
|
||||
void common_hal_alarm_pin_pin_pin_alarm_construct(alarm_pin_pin_alarm_obj_t *self, mcu_pin_obj_t *pin, bool level, bool edge, bool pull) {
|
||||
self->pin = pin;
|
||||
self->level = level;
|
||||
self->edge = edge;
|
||||
self->pull = pull;
|
||||
|
||||
mcu_pin_obj_t *common_hal_alarm_pin_pin_alarm_get_pin(alarm_pin_pin_alarm_obj_t *self) {
|
||||
return self->pin;
|
||||
}
|
||||
|
||||
bool common_hal_alarm_pin_pin_alarm_get_level(alarm_pin_pin_alarm_obj_t *self) {
|
||||
return self->level;
|
||||
}
|
||||
|
||||
bool common_hal_alarm_pin_pin_alarm_get_edge(alarm_pin_pin_alarm_obj_t *self) {
|
||||
return self->edge;
|
||||
}
|
||||
|
||||
bool common_hal_alarm_pin_pin_alarm_get_pull(alarm_pin_pin_alarm_obj_t *self) {
|
||||
return self->pull;
|
||||
}
|
36
ports/esp32s2/common-hal/alarm/pin/PinAlarm.h
Normal file
36
ports/esp32s2/common-hal/alarm/pin/PinAlarm.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "py/obj.h"
|
||||
|
||||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
mcu_pin_obj_t *pin;
|
||||
bool level;
|
||||
bool edge;
|
||||
bool pull;
|
||||
} alarm_pin_pin_alarm_obj_t;
|
48
ports/esp32s2/common-hal/alarm/time/DurationAlarm.c
Normal file
48
ports/esp32s2/common-hal/alarm/time/DurationAlarm.c
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 @microDev1 (GitHub)
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "esp_sleep.h"
|
||||
|
||||
#include "shared-bindings/alarm/time/DurationAlarm.h"
|
||||
|
||||
void common_hal_alarm_time_duration_alarm_construct(alarm_time_duration_alarm_obj_t *self, mp_float_t duration) {
|
||||
self->duration = duration;
|
||||
}
|
||||
|
||||
mp_float_t common_hal_alarm_time_duration_alarm_get_duration(alarm_time_duration_alarm_obj_t *self) {
|
||||
return self->duration;
|
||||
}
|
||||
void common_hal_alarm_time_duration_alarm_enable(alarm_time_duration_alarm_obj_t *self)
|
||||
if (esp_sleep_enable_timer_wakeup((uint64_t) (self->duration * 1000000)) == ESP_ERR_INVALID_ARG) {
|
||||
mp_raise_ValueError(translate("duration out of range"));
|
||||
}
|
||||
}
|
||||
|
||||
void common_hal_alarm_time_duration_alarm_disable (alarm_time_duration_alarm_obj_t *self) {
|
||||
(void) self;
|
||||
esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER);
|
||||
}
|
34
ports/esp32s2/common-hal/alarm/time/DurationAlarm.h
Normal file
34
ports/esp32s2/common-hal/alarm/time/DurationAlarm.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 @microDev1 (GitHub)
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "py/obj.h"
|
||||
|
||||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
mp_float_t duration; // seconds
|
||||
} alarm_time_duration_alarm_obj_t;
|
@ -1,13 +0,0 @@
|
||||
#include "esp_sleep.h"
|
||||
|
||||
#include "shared-bindings/alarm_time/__init__.h"
|
||||
|
||||
void common_hal_alarm_time_duration (uint32_t ms) {
|
||||
if (esp_sleep_enable_timer_wakeup((ms) * 1000) == ESP_ERR_INVALID_ARG) {
|
||||
mp_raise_ValueError(translate("time out of range"));
|
||||
}
|
||||
}
|
||||
|
||||
void common_hal_alarm_time_disable (void) {
|
||||
esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER);
|
||||
}
|
@ -302,9 +302,8 @@ SRC_COMMON_HAL_ALL = \
|
||||
_pew/PewPew.c \
|
||||
_pew/__init__.c \
|
||||
alarm/__init__.c \
|
||||
alarm/pin/__init__.c \
|
||||
alarm/time/__init__.c \
|
||||
alarm/touch/__init__.c \
|
||||
alarm/pin/PinAlarm.c \
|
||||
alarm/time/DurationAlarm.c \
|
||||
analogio/AnalogIn.c \
|
||||
analogio/AnalogOut.c \
|
||||
analogio/__init__.c \
|
||||
|
@ -42,9 +42,6 @@ CFLAGS += -DCIRCUITPY_AESIO=$(CIRCUITPY_AESIO)
|
||||
# TODO: CIRCUITPY_ALARM will gradually be added to
|
||||
# as many ports as possible
|
||||
# so make this 1 or CIRCUITPY_FULL_BUILD eventually
|
||||
CIRCUITPY_SLEEPIO ?= 0
|
||||
CFLAGS += -DCIRCUITPY_SLEEPIO=$(CIRCUITPY_SLEEPIO)
|
||||
|
||||
CIRCUITPY_ALARM ?= 0
|
||||
CFLAGS += -DCIRCUITPY_ALARM=$(CIRCUITPY_ALARM)
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include "shared-bindings/alarm/ResetReason.h"
|
||||
|
||||
MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, POWER_VALID, RESET_REASON_POWER_VALID);
|
||||
MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, POWER_VALID, RESET_REASON_POWER_ON);
|
||||
MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, SOFTWARE, RESET_REASON_SOFTWARE);
|
||||
MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, DEEP_SLEEP_ALARM, RESET_REASON_DEEP_SLEEP_ALARM);
|
||||
MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, EXTERNAL, RESET_REASON_EXTERNAL);
|
||||
@ -36,23 +36,31 @@ MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, EXTERNAL, RESET_REASON_EX
|
||||
//| class ResetReason:
|
||||
//| """The reason the chip was last reset"""
|
||||
//|
|
||||
//| POWER_VALID: object
|
||||
//| """The chip was reset and started once power levels were valid."""
|
||||
//| POWER_ON: object
|
||||
//| """The chip was started from power off."""
|
||||
//|
|
||||
//| BROWNOUT: object
|
||||
//| """The chip was reset due to voltage brownout."""
|
||||
//|
|
||||
//| SOFTWARE: object
|
||||
//| """The chip was reset from software."""
|
||||
//|
|
||||
//| DEEP_SLEEP_ALARM: object
|
||||
//| """The chip was reset for deep sleep and started by an alarm."""
|
||||
//| """The chip was reset for deep sleep and restarted by an alarm."""
|
||||
//|
|
||||
//| EXTERNAL: object
|
||||
//| """The chip was reset by an external input such as a button."""
|
||||
//| RESET_PIN: object
|
||||
//| """The chip was reset by a signal on its reset pin. The pin might be connected to a reset buton."""
|
||||
//|
|
||||
//| WATCHDOG: object
|
||||
//| """The chip was reset by its watchdog timer."""
|
||||
//|
|
||||
MAKE_ENUM_MAP(alarm_reset_reason) {
|
||||
MAKE_ENUM_MAP_ENTRY(reset_reason, POWER_VALID),
|
||||
MAKE_ENUM_MAP_ENTRY(reset_reason, POWER_ON),
|
||||
MAKE_ENUM_MAP_ENTRY(reset_reason, BROWNOUT),
|
||||
MAKE_ENUM_MAP_ENTRY(reset_reason, SOFTWARE),
|
||||
MAKE_ENUM_MAP_ENTRY(reset_reason, DEEP_SLEEP_ALARM),
|
||||
MAKE_ENUM_MAP_ENTRY(reset_reason, EXTERNAL),
|
||||
MAKE_ENUM_MAP_ENTRY(reset_reason, RESET_PIN),
|
||||
MAKE_ENUM_MAP_ENTRY(reset_reason, WATCHDOG),
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(alarm_reset_reason_locals_dict, alarm_reset_reason_locals_table);
|
||||
|
||||
|
@ -28,12 +28,16 @@
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM__RESET_REASON__H
|
||||
|
||||
typedef enum {
|
||||
RESET_REASON_POWER_APPLIED,
|
||||
RESET_REASON_POWER_ON,
|
||||
RESET_REASON_BROWNOUT,
|
||||
RESET_REASON_SOFTWARE,
|
||||
RESET_REASON_DEEP_SLEEP_ALARM,
|
||||
RESET_REASON_BUTTON,
|
||||
RESET_REASON_RESET_PIN,
|
||||
RESET_REASON_WATCHDOG,
|
||||
} alarm_reset_reason_t;
|
||||
|
||||
extern const mp_obj_type_t alarm_reset_reason_type;
|
||||
|
||||
extern alarm_reset_reason_t common_hal_alarm_get_reset_reason(void);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM__RESET_REASON__H
|
||||
|
@ -91,10 +91,14 @@ STATIC mp_obj_t alarm_pin_pin_alarm_binary_op(mp_binary_op_t op, mp_obj_t lhs_in
|
||||
if (MP_OBJ_IS_TYPE(rhs_in, &alarm_pin_pin_alarm_type)) {
|
||||
// Pins are singletons, so we can compare them directly.
|
||||
return mp_obj_new_bool(
|
||||
common_hal_pin_pin_alarm_get_pin(lhs_in) == common_hal_pin_pin_alarm_get_pin(rhs_in) &&
|
||||
common_hal_pin_pin_alarm_get_level(lhs_in) == common_hal_pin_pin_alarm_get_level(rhs_in) &&
|
||||
common_hal_pin_pin_alarm_get_edge(lhs_in) == common_hal_pin_pin_alarm_get_edge(rhs_in) &&
|
||||
common_hal_pin_pin_alarm_get_pull(lhs_in) == common_hal_pin_pin_alarm_get_pull(rhs_in))
|
||||
common_hal_alarm_pin_pin_alarm_get_pin(lhs_in) ==
|
||||
common_hal_alarm_pin_pin_alarm_get_pin(rhs_in) &&
|
||||
common_hal_alarm_pin_pin_alarm_get_level(lhs_in) ==
|
||||
common_hal_alarm_pin_pin_alarm_get_level(rhs_in) &&
|
||||
common_hal_alarm_pin_pin_alarm_get_edge(lhs_in) ==
|
||||
common_hal_alarm_pin_pin_alarm_get_edge(rhs_in) &&
|
||||
common_hal_alarm_pin_pin_alarm_get_pull(lhs_in) ==
|
||||
common_hal_alarm_pin_pin_alarm_get_pull(rhs_in));
|
||||
}
|
||||
return mp_const_false;
|
||||
|
||||
|
@ -28,9 +28,14 @@
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_PIN_PIN_ALARM_H
|
||||
|
||||
#include "py/obj.h"
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
|
||||
extern const mp_obj_type_t alarm_pin_pin_alarm_type;
|
||||
|
||||
extern void common_hal_alarm_pin_pin_pin_alarm_construct(alarm_pin_pin_alarm_obj_t *self, const mcu_pin_obj_t *pin, bool level, bool edge, bool pull);
|
||||
extern mcu_pin_obj_t *common_hal_alarm_pin_pin_alarm_get_pin(alarm_pin_pin_alarm_obj_t *self);
|
||||
extern bool common_hal_alarm_pin_pin_alarm_get_level(alarm_pin_pin_alarm_obj_t *self);
|
||||
extern bool common_hal_alarm_pin_pin_alarm_get_edge(alarm_pin_pin_alarm_obj_t *self);
|
||||
extern bool common_hal_alarm_pin_pin_alarm_get_pull(alarm_pin_pin_alarm_obj_t *self);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_PIN_PIN_ALARM_H
|
||||
|
@ -31,4 +31,10 @@
|
||||
|
||||
extern const mp_obj_type_t alarm_time_duration_alarm_type;
|
||||
|
||||
extern void common_hal_alarm_time_duration_alarm_construct(alarm_time_duration_alarm_obj_t *self, mp_float_t duration);
|
||||
extern mp_float_t common_hal_alarm_time_duration_alarm_get_duration(alarm_time_duration_alarm_obj_t *self);
|
||||
|
||||
extern void common_hal_alarm_time_duration_alarm_enable(alarm_time_duration_alarm_obj_t *self);
|
||||
extern void common_hal_alarm_time_duration_alarm_disable (alarm_time_duration_alarm_obj_t *self);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME_DURATION_ALARM_H
|
||||
|
@ -367,7 +367,6 @@ void prep_rgb_status_animation(const pyexec_result_t* result,
|
||||
status->found_main = found_main;
|
||||
status->total_exception_cycle = 0;
|
||||
status->ok = result->return_code != PYEXEC_EXCEPTION;
|
||||
status->cycles = 0;
|
||||
if (status->ok) {
|
||||
// If this isn't an exception, skip exception sorting and handling
|
||||
return;
|
||||
@ -419,9 +418,8 @@ bool tick_rgb_status_animation(rgb_status_animation_t* status) {
|
||||
// All is good. Ramp ALL_DONE up and down.
|
||||
if (tick_diff > ALL_GOOD_CYCLE_MS) {
|
||||
status->pattern_start = supervisor_ticks_ms32();
|
||||
status->cycles++;
|
||||
new_status_color(BLACK);
|
||||
return status->cycles;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint16_t brightness = tick_diff * 255 / (ALL_GOOD_CYCLE_MS / 2);
|
||||
@ -436,8 +434,7 @@ bool tick_rgb_status_animation(rgb_status_animation_t* status) {
|
||||
} else {
|
||||
if (tick_diff > status->total_exception_cycle) {
|
||||
status->pattern_start = supervisor_ticks_ms32();
|
||||
status->cycles++;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
// First flash the file color.
|
||||
if (tick_diff < EXCEPTION_TYPE_LENGTH_MS) {
|
||||
|
@ -76,6 +76,6 @@ void prep_rgb_status_animation(const pyexec_result_t* result,
|
||||
bool found_main,
|
||||
safe_mode_t safe_mode,
|
||||
rgb_status_animation_t* status);
|
||||
void tick_rgb_status_animation(rgb_status_animation_t* status);
|
||||
bool tick_rgb_status_animation(rgb_status_animation_t* status);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SUPERVISOR_RGB_LED_STATUS_H
|
||||
|
@ -29,6 +29,9 @@
|
||||
#include "mphalport.h"
|
||||
|
||||
#include "shared-bindings/digitalio/DigitalInOut.h"
|
||||
#if CIRCUITPY_ALARM
|
||||
#include "shared-bindings/alarm/ResetReason.h"
|
||||
#endif
|
||||
|
||||
#include "supervisor/serial.h"
|
||||
#include "supervisor/shared/rgb_led_colors.h"
|
||||
@ -52,10 +55,12 @@ safe_mode_t wait_for_safe_mode_reset(void) {
|
||||
current_safe_mode = safe_mode;
|
||||
return safe_mode;
|
||||
}
|
||||
if (common_hal_sleep_get_reset_reason() != RESET_REASON_POWER_VALID &&
|
||||
common_hal_sleep_get_reset_reason() != RESET_REASON_BUTTON) {
|
||||
#if CIRCUITPY_ALARM
|
||||
if (common_hal_alarm_get_reset_reason() != RESET_REASON_POWER_ON &&
|
||||
common_hal_alarm_get_reset_reason() != RESET_REASON_RESET_PIN) {
|
||||
return NO_SAFE_MODE;
|
||||
}
|
||||
#endif
|
||||
port_set_saved_word(SAFE_MODE_DATA_GUARD | (MANUAL_SAFE_MODE << 8));
|
||||
// Wait for a while to allow for reset.
|
||||
temp_status_color(SAFE_MODE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user