Giter VIP home page Giter VIP logo

oversampling's People

Contributors

ircama avatar muink avatar regimantas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

oversampling's Issues

Overflow warning

I'm getting a warning when using this library:

C:\Users...\Documents\Arduino\libraries\Oversampling\src\Oversampling.cpp: In member function 'int Oversampling::read(int)':
C:\Users...\Documents\Arduino\libraries\Oversampling\src\Oversampling.cpp:55:23: warning: overflow in implicit constant conversion [-Woverflow]
OversampleCount = 65536;

Being declared as int, OversampleCount cannot be 65536, but rather 65535. I'd suggest to reduce all the SampleCount specific OverSampleCounts by one and to adjust the range of the for loop instead within the Oversampling.ccp file:

for (int i=0; i<=OversampleCount; i++){
      TotalADC = TotalADC + analogRead(pin);
    }

change int to long in a loop variable

Hi!
in the oversampling section

// Can Lead To Overflow
unsigned long TotalADC = 0;
for (int i=0; i<_Averaging; i++){
for (**long** i=0; i<OversampleCount; i++){
TotalADC = TotalADC + (unsigned long)analogRead(pin);
}
}
TotalADC = (TotalADC >> DecimationCount) / _Averaging; //_Averaging
return TotalADC;

i have changed the internal loop variable counting up to "OversamplingCount" to "long" because of overflow when DecimationCount = 8. In this case OversamplingCount =65536 that equals to zero for an Arduino "int" variable.

Nice job! regards!

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.