GithubHelp home page GithubHelp logo

narcoleptic's People

Contributors

cathedrow avatar

Watchers

 avatar

narcoleptic's Issues

change delay from int to long

with int delay, aren't we limited to 60 seconds roughly ?
i need to wake up every 10 minutes or more, I changed to long and it seems to 
be working pretty fine

Original issue reported on code.google.com by [email protected] on 22 Mar 2014 at 11:11

Not working on Arduino Pro Mini 3.3v ATMega 328

The library is imported into project - no problem.  The call to the delay 
method executes without error but I see no evidence that the thing is going to 
sleep.  I have monitored its current draw at ~17 mA and noted that it does not 
drop at all.  Any ideas would be greatly appreciated.

Original issue reported on code.google.com by [email protected] on 31 Jul 2013 at 1:33

propose new interface for delay

Narcoleptic's delay interface is defined as

void delay(int milliseconds);

I propose to make it:  void delay(uint32_t milliseconds);

Current implementation has a maximum of ~32767 milliseconds sleep()  ==> ~half 
a minute
Proposed interface has a maximum of ~4294967296 milliseconds sleep() ==> ~49.7 
days

Proposed interface is backwards compatible, and makes narcoleptic delay() 
interface identical to Arduino's delay(). 
Costs : 2 bytes





Original issue reported on code.google.com by [email protected] on 16 Sep 2013 at 11:19

improvement suggestion: switch AD converter off

Very comfortable library. It would be possible to save a little more power, 
even if AD converter would be switched off.

# ifndef cbi
# define cbi (sfr, bit) (_SFR_BYTE (sfr) & = ~ _BV (bit))
# endif
# ifndef sbi
# define sbi (sfr, bit) (_SFR_BYTE (sfr) | = _BV (bit))
# endif

[...]

NarcolepticClass :: void delay (int milliseconds) {
   cbi (ADCSRA, ADEN);
  [...]
   sbi (ADCSRA, ADEN);
}


Original issue reported on code.google.com by [email protected] on 14 Jul 2013 at 8:08

Time overflow for delays shorter than 16-17ms

What steps will reproduce the problem?
1. call Narcoleptic.delay(10)

What is the expected output? What do you see instead?
Expected: MCU should sleep for 10ms and then resume working
Actual outcome: MCU freezes apparently - in reality the counters in delay 
method underflow/overflow and MCU sleeps for ~15 minutes.

The problem is in these 2 lines in delay():
  microseconds -= watchdogTime_us;
  if (microseconds > 0) {
- microseconds variable is defined as uint32_t, so it can never be negative - 
if the requested delay is shorter than watchdog time, it gets a very high value 
(which will again overflow in 16-bit sleep_periods).
Solution would be to change the two lines above to:
  if (microseconds > watchdogTime_us) {
    microseconds -= watchdogTime_us;
- functionally the same, only without annoying freezes ;-)
It might also make sense to change milliseconds parameter to uint32_t for 
sleeps longer than ~32s, and also same for sleep_periods to get it over ~15 
minutes (maximum sleep time would then be some 1h15m).

I'm attaching the patch with all my local changes, if anyone's interested 
(can't push it directly into the repo):
- fixed microseconds underflow bug in delay()
- delay() parameter changed to uint32_t with microseconds overflow protection
- sleep_periods changed to uint32_t

Original issue reported on code.google.com by [email protected] on 28 Apr 2015 at 7:42

Attachments:

change implementation of delay()

Some processors do not have WTDO_4S and WDTO_8S implemented. See wdt.h

To support these devices the implementation of delay() should include some 
conditional code. Proposal:

void NarcolepticClass::delay(uint32_t milliseconds) 
{
#if defined WDP3
  while (milliseconds >= 8000) { sleep(WDTO_8S); milliseconds -= 8000; }
  if (milliseconds >= 4000)    { sleep(WDTO_4S); milliseconds -= 4000; }
  if (milliseconds >= 2000)    { sleep(WDTO_2S); milliseconds -= 2000; }
#else
  while (milliseconds >= 2000) { sleep(WDTO_2S); milliseconds -= 2000; }
#endif
  if (milliseconds >= 1000)    { sleep(WDTO_1S); milliseconds -= 1000; }
  if (milliseconds >= 500)     { sleep(WDTO_500MS); milliseconds -= 500; }
  if (milliseconds >= 250)     { sleep(WDTO_250MS); milliseconds -= 250; }
  if (milliseconds >= 125)     { sleep(WDTO_120MS); milliseconds -= 120; }
  if (milliseconds >= 64)      { sleep(WDTO_60MS); milliseconds -= 60; }
  if (milliseconds >= 32)      { sleep(WDTO_30MS); milliseconds -= 30; }
  if (milliseconds >= 16)      { sleep(WDTO_15MS); milliseconds -= 15; }
}

Original issue reported on code.google.com by [email protected] on 16 Sep 2013 at 11:28

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.