Is there a way to flash an external led (connected to a GPIO pin) while the Spark Core is booting/connecting to the cloud? When users power on my device with the on/off switch, I want to start blinking a light so they know something is happening. They will not be able to see the led on the core. I currently have the led turn green in the loop(), but it only lights after the core is connected.
If that led is RGB can I mimic the onboard led with the full range of signals?
Sure thing! You might need to do some firmware hacking, but If you wanted to mirror the RGB led to another one, you could just copy the signals to your own device. You’ll find references in core-firmware and core-common-lib for:
TIM1->CCR2 TIM1->CCR3 TIM1->CCR1
Thanks @Dave. Those core files are going to be quite useful.
Unfortunately, I do not see how to have anything in my loop() or setup() run until AFTER the Core completes it’s full WLAN initialization. If I need an indicator light to come on immediately when the power switch is turned on to so the users see that something is happening, can I do that in my firmware sketch or does it require customization to the cores firmware?
Maybe I just need to better understand the boot sequence and where my sketch fits into that sequence.
In the current implementation, you’ll need to modify the firmware to have your bit of code run first. The boot sequence looks something like this (very crude):
- Initialize the clock
- Initialize the hardware
- Set up the WiFi
- Run the setup() once
- Run the user loop()
- Run the WiFi loop
- Goto user loop()
You can add your bit of code to run before the main.cpp enters the while(1) loop. Or if you know what you are doing you can also modify the
I wonder if we shouldn’t add a pre-setup hook?
A hook would be nice so that the device could continue to get firmware updates without having to worry about overwriting any changes that I made. The hook would allow me to start sending signals to the led (or call some pre-init function) as soon as the device is powered. I imaginge that my loop() could then check for the initialization procees to be complete (some spark_wlan isRunning() boolean) to indicate all system are running.