Comments (5)
Possible solution:
void ArduinoLowPowerClass::idle(uint32_t delay)
{
uint32_t ticks = delay;
while (ticks > 0)
{
uint32_t lastMillis = millis();
idle();
uint32_t delta = millis() - lastMillis;
if (delta > ticks) {
ticks = 0;
} else {
ticks -= delta;
}
}
}
from arduinolowpower.
Note that it is possible to turn off systick which prevents idle from returning every millisecond:
SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
LowPower.idle();
SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;
from arduinolowpower.
Sure, I know.
But what's the interest ? Without SysTick, delay(), millis(), etc. don't work anymore.
If the device is internally driven, say take a measure every so often and record it somehow, putting the controller to sleep is fine, and 50 ms of full speed CPU is an acceptable price to pay, even once per sec.
If you have to handle interrupts and debounce button presses, it's not an option.
from arduinolowpower.
Agree, use case is limited, but sometimes it might be useful. It relates to this issue because it solves the problem of "idle() doesn't work as expected" by preventing it from returning every millisecond.
However, I did some testing testing and looping on idle() every millisecond (ex: 100 loops for 100 milliseconds) takes only a few percent more power than waiting for an interrupt from the RTC with idle(100), so not a lot to be gained.
from arduinolowpower.
The way LowPower.idle()
(the version without parameter) works is perfect for me, just as I said in my initial post.
It just needs to be documented.
And yes, said documentation could explain how to disable SysTick, or even how to configure the controller such that it returns to idle state after having handled an interrupt.
One the other hand, LowPower.idle(uint32_t millis)
doesn't at all do what it's supposed to, and needs to be fixed.
from arduinolowpower.
Related Issues (20)
- Add RTC time setting and getting functionality
- Absence of README.md file
- Clock disabling code looks wrong HOT 6
- Allow access to RTC HOT 1
- Boards without SERIAL_PORT_USBVIRTUAL HOT 1
- ArduinoLowPower not working (put in Incompatible list) HOT 1
- LowPower.sleep() on Arduino MKR WiFi 1010 HOT 2
- Add GitHub Action based CI
- ArduinoLowPower and RTCZERO.h HOT 2
- Arduino Nano RP2040 Connect not working with this library
- Add GitHub Actions workflow to synchronise with shared repository labels
- Serial not working after attachAdcInterrupt HOT 1
- Making Low Power great again HOT 1
- Compile problem in Arduino2.0 [nrf_lpcomp_input_t does not name a type] and more HOT 4
- LowPower.detachAdcInterrupt() casues issues with LowPower.attachInterruptWakeup()
- SAMD21 wrong sleep time with Seeedstudio XIAO
- attaching an InterruptWakeup before and after deepSleep breaks RTCZero::getEpoch HOT 2
- detachInterruptWakeup function HOT 1
- Calling LowPower.attachInterruptWakeup with irq_mode CHANGE causes ISR to be fired
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduinolowpower.