please publish my library

Fork of accelerometer by Aisyah Syahana

Files at this revision

API Documentation at this revision

Comitter:
asifahmad
Date:
Tue Aug 06 10:36:35 2013 +0000
Parent:
1:e965533a31b2
Commit message:
please forgive the errors..this is the updated library

Changed in this revision

Accelerometer.cpp Show annotated file Show diff for this revision Revisions of this file
Accelerometer.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Accelerometer.cpp	Tue Aug 06 10:07:46 2013 +0000
+++ b/Accelerometer.cpp	Tue Aug 06 10:36:35 2013 +0000
@@ -1,38 +1,35 @@
 #include "mbed.h"
-#include "accelorometer.h"
+#include "Accelerometer.h"
 
-xyz data;
+
 float scale=0.8;
  
 Accel::Accel(PinName xpin, PinName ypin, PinName zpin) : _zpin(zpin) , _ypin(ypin), _xpin(xpin){
-        _xpin=0;
-        _ypin=0;
-        _zpin=0;
+       
         }
         
-xyz Accel::readall() {
-xyz data;
-        float x = data.readx();
-        float y = data.ready();
-        float z = data.readz();
+float Accel::readall() {
+
+        float x = readx();
+        float y = ready();
+        float z = readz();
         return sqrt (x*x + y*y + z*z);
   
 }   
 
-float Accel::readx() {
-    xyz data;
-    data.x=((xpin*3.3)-1.65)/scale;
-    return data.x;
+float Accel::readx() 
+    {
+    return ((_xpin*3.3)-1.65)/scale;
     }
  float Accel::ready() {
-    xyz data;
-    data.y=((ypin*3.3)-1.65)/scale;
-    return data.y;
+    
+   return ((_ypin*3.3)-1.65)/scale;
+    
     }   
  float Accel::readz() {
-    xyz data;
-    data.z=((zpin*3.3)-1.65)/scale;
-    return data.z;
+
+   return ((_zpin*3.3)-1.65)/scale;
+    
     }   
     
          
\ No newline at end of file
--- a/Accelerometer.h	Tue Aug 06 10:07:46 2013 +0000
+++ b/Accelerometer.h	Tue Aug 06 10:36:35 2013 +0000
@@ -2,11 +2,7 @@
 #define ACCELEROMETER_H
 
 #include "mbed.h"
-struct xyz {
-    float x;
-    float y;
-    float z;
-};
+
 class Accel  {
 public:
     /** create a accelerometer Object
--- a/main.cpp	Tue Aug 06 10:07:46 2013 +0000
+++ b/main.cpp	Tue Aug 06 10:36:35 2013 +0000
@@ -1,11 +1,11 @@
 #include "mbed.h"
 #include "Accelerometer.h"
-Serial pc(USBTX, USBRX)
+Serial pc(USBTX, USBRX);
 
-int main() {
+void main() {
     Accel acc(p18, p19, p20);
     while(1){
     pc.printf("accel = %5.3f, accelX = %5.3f, accelY = %5.3f, accelZ = %5.3f\n",
-                Accel.readall(),Accel.readx(), Accel.ready(), Accel.readz());
+                acc.readall(),acc.readx(), acc.ready(), acc.readz());
                 wait(1.0);
                 }}
\ No newline at end of file