Giter VIP home page Giter VIP logo

Comments (5)

be-philippe avatar be-philippe commented on June 12, 2024

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.

jsiddall avatar jsiddall commented on June 12, 2024

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.

be-philippe avatar be-philippe commented on June 12, 2024

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.

jsiddall avatar jsiddall commented on June 12, 2024

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.

be-philippe avatar be-philippe commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.