lib para o framework sgam

Dependencies:   MPU6050 Grove_temperature

Dependents:   example_smart-grid

Revision:
3:f998244e9f80
Child:
4:f21aab30658a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/peripheral/impl/Gyroscope.cpp	Sun Jun 02 16:51:13 2019 -0300
@@ -0,0 +1,37 @@
+#include "mbed.h"
+#include "MPU6050.h"
+
+#include "Gyroscope.h"
+
+#define LOG(args...)   // printf(args)     
+
+Gyroscope::Gyroscope(I2C i2c): mpu(i2c, MPU6050_ADDRESS_AD0_LOW) { 
+    mpu.initialize();
+
+    if(mpu.testConnection()) {
+        LOG("MPU6050 test passed !!\r\n");
+    } else {
+        LOG("MPU6050 test failed !!\r\n");
+    }
+}
+
+Gyroscope::~Gyroscope() {
+    // mpu.
+}
+
+void Gyroscope::getMotion(GyroscopeData* data) {
+    mpu.getMotion6(
+        &data->ax, &data->ay, &data->az,
+        &data->gx, &data->gy, &data->gz
+    );
+}
+
+GyroscopeData* Gyroscope::getValue() {
+    getMotion(&value);
+    return &value;
+}
+
+void Gyroscope::readOcurred(void* (*callBack)(GyroscopeData* value), float timeout) {
+    if(callBack != NULL)
+        callBack(&value);
+}