324

Files at this revision

API Documentation at this revision

Comitter:
turumputum
Date:
Thu May 21 19:09:28 2020 +0000
Parent:
0:ec69fa9832e5
Commit message:
223131

Changed in this revision

AS5600.cpp Show annotated file Show diff for this revision Revisions of this file
AS5600.h Show annotated file Show diff for this revision Revisions of this file
diff -r ec69fa9832e5 -r e4b72c71ca47 AS5600.cpp
--- a/AS5600.cpp	Tue Feb 28 12:26:56 2017 +0000
+++ b/AS5600.cpp	Thu May 21 19:09:28 2020 +0000
@@ -8,8 +8,19 @@
 AS5600::AS5600(PinName sda, PinName scl) : i2c(sda,scl)
 {
     addresse=0x36;
-    i2c.frequency(400000);
+    i2c.frequency(40000);
 }
+
+int AS5600::sensorState()
+{
+    char cmd=0x0B,data=0,value=0;
+    data=this->read(cmd);
+    //value=(char) (data & 0x20) >> 5 ;
+
+    return data;
+}
+
+
 int AS5600::isMagnetPresent()
 {
     char cmd=0x0B,data=0,value=0;
@@ -31,6 +42,17 @@
     return data;
 }
 
+int AS5600::getMagnitude()
+{
+    char cmd1=0x1B,cmd2=0x1C;
+    int data=0;
+
+    data=this->read(cmd1) << 8;
+    data=data+this->read(cmd2);
+
+    return data;
+}
+
 int AS5600::getAngleRelative()
 {
     return ((this->getAngleAbsolute() + (2047 - relative_zero)) % 4096) - 2047;
diff -r ec69fa9832e5 -r e4b72c71ca47 AS5600.h
--- a/AS5600.h	Tue Feb 28 12:26:56 2017 +0000
+++ b/AS5600.h	Thu May 21 19:09:28 2020 +0000
@@ -9,9 +9,12 @@
     float getAngleDegrees();
     int getAngleAbsolute();
     int getAngleRelative();
+    int getMagnitude();
     float getAngleMinMax(float angleMax);
     
     int isMagnetPresent();
+    int sensorState();
+    
     
     void init();
     void setZero();