Giter Site home page Giter Site logo

6483-just-breathe's Introduction

6483-Just-Breathe

Members

  • Yujie Yu, Net ID yy3913
  • Weijie Li, Net ID wl2369
  • Tong Wu, Net ID tw2593
  • Junda Ai, Net ID ja4426

Setup

This project uses the library mbed-goncaloc/ADXL_I2C, to install it as dependency, run the following command:

pio pkg install

Upon successful installation of the dependency, you might get the following error:

identifier "wait_ms" is undefined

Quote from arm mbed API reference about wait:

The function wait is deprecated in favor of explicit sleep functions. To sleep, replace wait with ThisThread::sleep_for (C++) or thread_sleep_for (C). To wait (without sleeping), call wait_us. wait_us is safe to call from ISR context.

Change the 3 affected functions in ADXL_I2C.cpp to the following per reference above:

int ADXL345::oneByteRead(int address) {

    char rx[1];
    rx[0] = address;
    i2c_ -> write((ADXL345_I2C_ADDRESS << 1) & 0xFE, rx, 1);
    ThisThread::sleep_for(1ms); // change
    i2c_ -> read((ADXL345_I2C_ADDRESS << 1) | 0x01, rx, 1);
    ThisThread::sleep_for(1ms) // change
    return rx[0];
}

void ADXL345::oneByteWrite(int address, char data) {

    char tx[2];
    tx[0] = address;
    tx[1] = data;
    i2c_ -> write((ADXL345_I2C_ADDRESS << 1) & 0xFE, tx, 2);
    ThisThread::sleep_for(1ms) // change

}

void ADXL345::multiByteRead(int address, char* data, int bytes) {

    char cmd[6];
    cmd[0] = address;
    i2c_ -> write((ADXL345_I2C_ADDRESS << 1) & 0xFE, cmd, 1);
    ThisThread::sleep_for(1ms) // change
    i2c_ -> read((ADXL345_I2C_ADDRESS << 1) | 0x01, data, bytes );
    ThisThread::sleep_for(1ms) // change

}

6483-just-breathe's People

Contributors

alan052918 avatar idleoo avatar

Watchers

 avatar

Forkers

idleoo

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.