I banged out an unoptimized firmware build for implementing some light patterns and the power-saving mode. So far, we have for light patterns:
- Candlelight: bottom LEDs off, top LED flickers
- Solid: bottom LEDs on at 100% brightness, top LED flickers
- Blink (slow): bottom LEDs blink at a 1 Hz rate, top LED flickers
- Blink (fast): bottom LEDs blink at a 2 Hz rate, top LED flickers
- LED chaser
- Software flicker: all LEDs flicker at different offsets from the source RNG array; bottom LEDs flicker in software, top LED flickers in hardware with PCA0-based PWM generator
- Half-brightness: bottom LEDs are set to a reduced brightness through software PWM, top LED flickers
So far, I've implemented a crude power saving function that shuts off all LEDs and places the CPU in idle mode, where all interrupts may wake the CPU. Unfortunately, this is not ideal as the way I implement timekeeping is through Timer2 driven by the RTC crystal divided by 8, so the CPU will wake up every 1 second and need to be put back to sleep.
Ideally, I can place the CPU into sleep mode, where all peripherals and the core are both off. This would cut power consumption even more, but require me to re-implement several features:
- The button interfaces with the CPU through the INT0 interrupt, which is disabled during sleep mode. However, I can re-map the button to a port match interrupt on P0 and allow it to wake the CPU during sleep mode.
- Timekeeping is not implemented through the RTC timer right now, but I will have to do so if I want to allow the CPU to wake itself through RTC alarms.
This will require some re-writing of the code, so I'm going to dump what I have in my files for now.
Zachary Murtishi
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.