GithubHelp home page GithubHelp logo

Comments (7)

RobTillaart avatar RobTillaart commented on June 11, 2024

Thanks for reporting, I will look into it asap.

from gy521.

RobTillaart avatar RobTillaart commented on June 11, 2024

Good catch, I will fix it today.

from gy521.

RobTillaart avatar RobTillaart commented on June 11, 2024

@SyberMafia
Should the library have a conversion for AccelSensitivity from 0123 ==> 2g, 4g,8g,16g ?
idem from GyroSensititity 01234 => 250, 500, 1000, 2000 dps

imho these are not core but can be useful ...

from gy521.

RobTillaart avatar RobTillaart commented on June 11, 2024

@SyberMafia
Fixed in development branch, please verify

void GY521::setAccelSensitivity(uint8_t as)
{
  _afs = as;
  if (_afs > 3) _afs = 3;
  uint8_t val = getRegister(GY521_ACCEL_CONFIG);
  // no need to write same value
  if (((val >> 3) & 3) != _afs)
  {
    val &= 0xE7;
    val |= (_afs << 3);
    setRegister(GY521_ACCEL_CONFIG, val);
  }
  // calculate conversion factor.
  _raw2g = (1 << _afs) / 16384.0;
}

also added new functions + new test sketch test_2.ino

  void     setThrottleTime(uint16_t ti )     { _throttleTime = ti; };
  uint16_t getThrottleTime()                 { return _throttleTime; };
  uint8_t  getAccelSensitivity();          // returns 0,1,2,3
  uint8_t  getGyroSensitivity();           // returns 0,1,2,3

from gy521.

SyberMafia avatar SyberMafia commented on June 11, 2024

@SyberMafia
Fixed in development branch, please verify

void GY521::setAccelSensitivity(uint8_t as)
{
  _afs = as;
  if (_afs > 3) _afs = 3;
  uint8_t val = getRegister(GY521_ACCEL_CONFIG);
  // no need to write same value
  if (((val >> 3) & 3) != _afs)
  {
    val &= 0xE7;
    val |= (_afs << 3);
    setRegister(GY521_ACCEL_CONFIG, val);
  }
  // calculate conversion factor.
  _raw2g = (1 << _afs) / 16384.0;
}

also added new functions + new test sketch test_2.ino

  void     setThrottleTime(uint16_t ti )     { _throttleTime = ti; };
  uint16_t getThrottleTime()                 { return _throttleTime; };
  uint8_t  getAccelSensitivity();          // returns 0,1,2,3
  uint8_t  getGyroSensitivity();           // returns 0,1,2,3

Good job, working properly.

from gy521.

SyberMafia avatar SyberMafia commented on June 11, 2024

I've realized now.
GY521.cpp

uint8_t GY521::getAccelSensitivity()
{
  uint8_t val = getRegister(GY521_GYRO_CONFIG);     REPLACE --> GY521_ACCEL_CONFIG
  _afs = (val >> 3) & 3;
  return _afs;
}

from gy521.

RobTillaart avatar RobTillaart commented on June 11, 2024

Good catch, fixed it.
time to merge!

from gy521.

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.