df

Dependencies:   mbed

Fork of APP1 by Team APP

Revision:
19:f5aa0ce5546b
Parent:
9:12519f9dd3cd
Child:
21:a111be2582be
--- a/Accelerometer.cpp	Tue Jan 17 19:45:02 2017 +0000
+++ b/Accelerometer.cpp	Tue Jan 17 20:01:40 2017 +0000
@@ -54,9 +54,11 @@
     Accelerometer::Accelerometer(
         PinName sda_pin, 
         PinName scl_pin, 
+        const int filter_size,
         const int slave_address
         ) :
         device(sda_pin, scl_pin),
+        filter(filter_size),
         slave_address(slave_address)
     {
     }
@@ -152,7 +154,8 @@
     
     double Accelerometer::get_angle_from_horizontal()
     {
-        const int z_axis_data = read_axis_data_8_bits(AXIS_Z);        
-        return angle_from_int_axis_data(z_axis_data);
+        const int z_axis_data = read_axis_data_8_bits(AXIS_Z);
+        const int filtered_z_axis_data = this->filter.calculate(z_axis_data);
+        return angle_from_int_axis_data(filtered_z_axis_data);
     }
 }
\ No newline at end of file