[chronojump] Force platform. Added get_transmission_format function



commit 79b64e8fd541b1b0aba5f541401e807f80c8e589
Author: Xavier Padullés <x padulles gmail com>
Date:   Mon Feb 18 17:27:27 2019 +0100

    Force platform. Added get_transmission_format function

 arduino/ForceSensor4Binary/ForceSensor4Binary.ino | 28 ++++++++++++++++++-----
 1 file changed, 22 insertions(+), 6 deletions(-)
---
diff --git a/arduino/ForceSensor4Binary/ForceSensor4Binary.ino 
b/arduino/ForceSensor4Binary/ForceSensor4Binary.ino
index a1aa4fd5..296875cd 100644
--- a/arduino/ForceSensor4Binary/ForceSensor4Binary.ino
+++ b/arduino/ForceSensor4Binary/ForceSensor4Binary.ino
@@ -37,6 +37,9 @@ unsigned long totalTime = 0;
 //Wether the sensor has to capture or not
 boolean capturing = false;
 
+//wether the tranmission is in binary format or not
+boolean binaryFormat = false;
+
 void setup(void)
 {
 
@@ -64,18 +67,18 @@ void loop(void)
     int nReadings = 10;
     int nsensors = 1;
     for (int i = 1; i <= nReadings; i++)
-   {
+    {
       //Reading each of the 4 sensors
-      for (int sensor = 0; sensor <= nsensors -1; sensor++)
+      for (int sensor = 0; sensor <= nsensors - 1; sensor++)
       {
         offsettedData[sensor] = readOffsetedData(sensor);
         total[sensor] += offsettedData[sensor];
       }
     }
-      for (int sensor = 0; sensor <= nsensors -1; sensor++)
-      {
-        offsettedData[sensor] = total[sensor]/nReadings;
-      }
+    for (int sensor = 0; sensor <= nsensors - 1; sensor++)
+    {
+      offsettedData[sensor] = total[sensor] / nReadings;
+    }
 
 
     //Managing the timer overflow
@@ -206,6 +209,8 @@ void serialEvent()
     //        set_tare(inputString);
   } else if (commandString == "tare") {
     tare();
+  } else if (commandString == "get_transmission_format") {
+    get_transmission_format();
   } else {
     Serial.println("Not a valid command");
   }
@@ -230,3 +235,14 @@ void get_version()
 {
   Serial.println(version);
 }
+
+void get_transmission_format()
+{
+  if (binaryFormat)
+  {
+    Serial.println("binary");
+  } else
+  {
+    Serial.println("text");
+  }
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]