Skip to content

Simplify the status LED to save power #4743

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

Merged
merged 8 commits into from
May 21, 2021

Conversation

tannewt
Copy link
Member

@tannewt tannewt commented May 10, 2021

This also removes the need to pin share because we don't use the
status LED while user code is running.

The status flashes fallback to the HW_STATUS LED if no RGB LED is
present. Each status has a unique blink pattern as well.

One caveat is the REPL state. In order to not pin share, we set the
RGB color once. PWM and single color will be shutoff immediately but
DotStars and NeoPixels will hold the color until the user overrides
it.

Fixes #4133

@tannewt tannewt added this to the 7.0.0 milestone May 10, 2021
@tannewt tannewt requested a review from hierophect May 10, 2021 22:09
@Neradoc
Copy link

Neradoc commented May 11, 2021

I tested: the green blink after the code ends, red on exception and yellow when reset to safe mode.

  • works as expected on a QT PY 2040
  • works on the Feather NRF52840 Express after uncommenting MICROPY_HW_NEOPIXEL

On a Feather M4 and Feather M0 Express, the LED stays either black or lit. It comes back to life when doing things like opening the drive in the Finder or activating and sending data to CDC2.

@tannewt
Copy link
Member Author

tannewt commented May 12, 2021

On a Feather M4 and Feather M0 Express, the LED stays either black or lit. It comes back to life when doing things like opening the drive in the Finder or activating and sending data to CDC2.

Thanks for finding this! I'm able to reproduce it but can't find the issue. Will have to get the debugger out tomorrow.

This also removes the need to pin share because we don't use the
status LED while user code is running.

The status flashes fallback to the HW_STATUS LED if no RGB LED is
present. Each status has a unique blink pattern as well.

One caveat is the REPL state. In order to not pin share, we set the
RGB color once. PWM and single color will be shutoff immediately but
DotStars and NeoPixels will hold the color until the user overrides
it.

Fixes micropython#4133
@tannewt tannewt force-pushed the simplify_status_led branch from e96dcc2 to 2464f2a Compare May 14, 2021 00:55
RTC needed to wait for sync. NeoPixel on SAMD doesn't need disabled
caches. It just needed timing adjustment for 120mhz clock speed.
@tannewt tannewt force-pushed the simplify_status_led branch from 2464f2a to 5c33c9d Compare May 14, 2021 23:14
@jposada202020
Copy link

Led does not turn on
was tested on

Adafruit CircuitPython 7.0.0-alpha.2-573-g49bad0797 on 2021-05-14; Adafruit Feather M4 CAN with same51j19a

Neopixel only turns green on bootoader mode.

@tannewt
Copy link
Member Author

tannewt commented May 18, 2021

Led does not turn on
was tested on

Adafruit CircuitPython 7.0.0-alpha.2-573-g49bad0797 on 2021-05-14; Adafruit Feather M4 CAN with same51j19a

Neopixel only turns green on bootoader mode.

I think this was broken before this change. The M4 CAN has a neopixel power pin that the core doesn't know how to turn on. On some boards with turn it off and on with board_init and board_deinit but I don't see that code for the M4 CAN.

tannewt added 3 commits May 18, 2021 11:32
This no longer turns on status LED power before running user code.
Therefore, use of the status LED on some boards will also have to
enable the power.
This causes safe mode to skip the wait for reset when waking up
from an alarm. (It also means we don't flash the LED for it.)
@tannewt
Copy link
Member Author

tannewt commented May 19, 2021

@jposada202020 Please test the latest artifacts. The M4 CAN has a power enable pin for the neopixel that should now be handled.

@hierophect I've fixed the STM safe mode blinks too. It didn't have the reset reason implemented which caused CP to wait for safe mode reset after each deep sleep.

@jposada202020
Copy link

Tested on

Adafruit CircuitPython 7.0.0-alpha.2-608-gd134e2af8 on 2021-05-19; Adafruit Feather M4 CAN with same51j19a

Results

REPL : NO light

Init : 3 Yellow - 1 Green

Code Running: 1 Green every 5-6 sec

Code Error: 2 Reds

Bootloader: Green all the time

@tannewt tannewt force-pushed the simplify_status_led branch from 7af33cd to 499a438 Compare May 20, 2021 15:28
kattni
kattni previously approved these changes May 20, 2021
Copy link

@kattni kattni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested final change on MagTag. LEDs are acting as expected - purple, three yellow blinks on startup, and blinking three yellows when in safe mode.

@Neradoc
Copy link

Neradoc commented May 21, 2021

We can PR them after this one is merged, but there are 2 more boards that need their MICROPY_HW_LED_[RGB] changed to CIRCUITPY_RGB_STATUS_[RGB]:

  • pimoroni_tiny2040 (also CIRCUITPY_RGB_STATUS_INVERTED_PWM)
  • pimoroni_picosystem (probably inverted too ?)

@tannewt tannewt requested a review from kattni May 21, 2021 17:03
Copy link

@kattni kattni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested safe mode on ItsyBitsy, it now works properly. LEDs are intermittently flashing yellow as expected. Flashing on startup was also as expected.

@tannewt tannewt merged commit 20946d9 into adafruit:main May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Revamp status LED signaling
4 participants