adxl345_nse2019

Files at this revision

API Documentation at this revision

Comitter:
zeutel
Date:
Wed Jul 31 15:30:53 2019 +0000
Parent:
1:d9412b56f98a
Commit message:
denshi

Changed in this revision

ADXL345_I2C.cpp Show annotated file Show diff for this revision Revisions of this file
ADXL345_I2C.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
diff -r d9412b56f98a -r 554c2f97ee93 ADXL345_I2C.cpp
--- a/ADXL345_I2C.cpp	Thu May 12 01:19:36 2011 +0000
+++ b/ADXL345_I2C.cpp	Wed Jul 31 15:30:53 2019 +0000
@@ -418,6 +418,10 @@
 
 }
 
+void ADXL345_I2C::setOpticalResolution(char settings){
+    SingleByteWrite(ADXL345_I2C_ADDRESS, 0x31);
+    SingleByteWrite(ADXL345_I2C_ADDRESS, settings);
+}
 
 
 
diff -r d9412b56f98a -r 554c2f97ee93 ADXL345_I2C.h
--- a/ADXL345_I2C.h	Thu May 12 01:19:36 2011 +0000
+++ b/ADXL345_I2C.h	Wed Jul 31 15:30:53 2019 +0000
@@ -527,6 +527,8 @@
      * @return The contents of the INT_SOURCE register.
      */
      char getInterruptSource(void);
+     
+     void setOpticalResolution(char settings);
     
    
 private:
diff -r d9412b56f98a -r 554c2f97ee93 main.cpp
--- a/main.cpp	Thu May 12 01:19:36 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-#include "ADXL345_I2C.h"
-
- ADXL345_I2C accelerometer(p28, p27);
- Serial pc(USBTX, USBRX);
-
- int main() {
-       pc.baud(115200);
-     int readings[3] = {0, 0, 0};
-     
-     pc.printf("Starting ADXL345 test...\n");
-     wait(.001);
-     pc.printf("Device ID is: 0x%02x\n", accelerometer.getDeviceID());
-    wait(.001);
-    
-     // These are here to test whether any of the initialization fails. It will print the failure
-    if (accelerometer.setPowerControl(0x00)){
-         pc.printf("didn't intitialize power control\n"); 
-         return 0;  }
-     //Full resolution, +/-16g, 4mg/LSB.
-     wait(.001);
-     
-     if(accelerometer.setDataFormatControl(0x0B)){
-        pc.printf("didn't set data format\n");
-        return 0;  }
-     wait(.001);
-     
-     //3.2kHz data rate.
-     if(accelerometer.setDataRate(ADXL345_3200HZ)){
-        pc.printf("didn't set data rate\n");
-        return 0;    }
-     wait(.001);
-     
-     //Measurement mode.
-     
-     if(accelerometer.setPowerControl(MeasurementMode)) {
-        pc.printf("didn't set the power control to measurement\n"); 
-        return 0;   } 
- 
-     while (1) {
-     
-         wait(0.1);
-         
-         accelerometer.getOutput(readings);
-         
-
-        pc.printf("%i, %i, %i\n", (int16_t)readings[0], (int16_t)readings[1], (int16_t)readings[2]);
-     }
- 
- }
diff -r d9412b56f98a -r 554c2f97ee93 mbed.bld
--- a/mbed.bld	Thu May 12 01:19:36 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912