GithubHelp home page GithubHelp logo

Comments (4)

rocketscream avatar rocketscream commented on June 27, 2024

I would have to say no to this as not that many people would want to murk around with WDT unless they know what they are doing. And the only thing I would suggest in an ISR routine is setting or clearing a flag/semaphore, not more than that.

from low-power.

jk987 avatar jk987 commented on June 27, 2024

Well, so now we are two of us who would like to have this possibility.

And as @rocketscream was saying I needed it for setting or clearing one flag.

I "solved" it by copying the powerDown() code (and the dependecies) into my own library.

Btw, as I'm thinking about it I needed to have a flag inside WDT ISR only to recognize whether Arduino was woken by WDT or eg. serial line. Maybe I wouldn't need having my own WDT ISR if powerDown() had been returning true or false, whether it slept all the requested time (ie. WDT ISR was executed) or no.

from low-power.

jk987 avatar jk987 commented on June 27, 2024

Draft of my idea:

LowPower:

volatile bool _woken_by_wdt;
bool LowPowerClass::powerDown(...) {
  _woken_by_wdt = false;
  ...
    lowPowerBodOnOrOff(...);
  ...
  return _woken_by_wdt;
}

ISR (WDT_vect) {
  wdt_disable();
  _woken_by_wdt = true;
}

User code:

if (LowPower.powerDown(...))
  // I was sleeping all the time.
else
  // I was woken up by something else, eg. some digital input.

from low-power.

ortegafernando avatar ortegafernando commented on June 27, 2024

I am also interested in a "special WDT_vect". I have finally delete the library's definition of ISR(WDT_vect) and defined my own in my sketch
The primary objetive is to have an option in my sketch to sleep the ATMEGA and also to have an extend watchdog reset protection of more than 8 seconds.

@rocketscream may be you know how to define "wake" your ISR(DWT_vect) in your library, so anyone than wants to override your function could do it in his sketch

This way, there vill be no problem with your library and also we could change the behaviour of the ISR(WDT_vect).

is it possible?

regards,

from low-power.

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.