[chronojump] Froce sensor arduino code license updated



commit eca24c666d42afb2378762fcdb96d6c6a5355548
Author: Xavier Padullés <x padulles gmail com>
Date:   Thu Sep 12 12:54:00 2019 +0200

    Froce sensor arduino code license updated

 arduino/ForceSensor/ForceSensor.ino | 128 +++++++++++++++++-------------------
 1 file changed, 59 insertions(+), 69 deletions(-)
---
diff --git a/arduino/ForceSensor/ForceSensor.ino b/arduino/ForceSensor/ForceSensor.ino
index e63d37f8..18f13dbf 100644
--- a/arduino/ForceSensor/ForceSensor.ino
+++ b/arduino/ForceSensor/ForceSensor.ino
@@ -1,34 +1,24 @@
 /*
-  Example using the SparkFun HX711 breakout board with a scale
-  By: Nathan Seidle
-  SparkFun Electronics
-  Date: November 19th, 2014
-  License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware 
license).
+  #
+  #  This file is part of ChronoJump
+  #
+  #  ChronoJump is free software; you can redistribute it and/or modify
+  #   it under the terms of the GNU General Public License as published by
+  #    the Free Software Foundation; either version 2 of the License, or
+  #     (at your option) any later version.
+  #
+  #  ChronoJump is distributed in the hope that it will be useful,
+  #   but WITHOUT ANY WARRANTY; without even the implied warranty of
+  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  #     GNU General Public License for more details.
+  #
+  #  You should have received a copy of the GNU General Public License
+  #   along with this program; if not, write to the Free Software
+  #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+  #
+  #   Copyright (C) 2017     Xavier Padullés <x padulles gmail com>
+  #   Copyright (C) 2017     Xavier de Blas <xaviblas gmail com>
 
-  This is the calibration sketch. Use it to determine the calibration_factor that the main example uses. It 
also
-  outputs the zero_factor useful for projects that have a permanent mass on the scale in between power 
cycles.
-
-  Setup your scale and start the sketch WITHOUT a weight on the scale
-  Once readings are displayed place the weight on the scale
-  Press +/- or a/z to adjust the calibration_factor until the output readings match the known weight
-  Use this calibration_factor on the example sketch
-
-  This example assumes pounds (lbs). If you prefer kilograms, change the Serial.print(" lbs"); line to kg. 
The
-  calibration factor will be significantly different but it will be linearly related to lbs (1 lbs = 
0.453592 kg).
-
-  Your calibration factor may be very positive or very negative. It all depends on the setup of your scale 
system
-  and the direction the sensors deflect from zero state
-  This example code uses bogde's excellent library: https://github.com/bogde/HX711
-  bogde's library is released under a GNU GENERAL PUBLIC LICENSE
-  Arduino pin
-  2 -> HX711 CLK
-  3 -> DOUT
-  5V -> VCC
-  GND -> GND
-
-  Most any pin on the Arduino Uno will be compatible with DOUT/CLK.
-
-  The HX711 board can be powered from 2.7V to 5V so the Arduino 5V power should be fine.
 
 */
 
@@ -72,18 +62,18 @@ void setup() {
 
   long tare = 0;
   EEPROM.get(tareAddress, tare);
-  if(isnan(tare)){
+  if (isnan(tare)) {
     scale.set_scale(10000);// Usual value  in Chronojump strength gauge
     EEPROM.put(tareAddress, 10000);
   } else {
     scale.set_offset(tare);
   }
 
-  
+
   //The factor to convert the units coming from the cell to the units used in the calibration
   float calibration_factor = 0.0f;
   EEPROM.get(calibrationAddress, calibration_factor);
-  if(isnan(calibration_factor)){
+  if (isnan(calibration_factor)) {
     scale.set_scale(915.0);// Usual value  in Chronojump strength gauge
     EEPROM.put(calibrationAddress, 915.0);
   } else {
@@ -118,39 +108,39 @@ void serialEvent()
 {
   String inputString = Serial.readString();
   String commandString = inputString.substring(0, inputString.lastIndexOf(":"));
-//  while (Serial.available())
-//  {
-//    char inChar = (char)Serial.read();
-//    inputString += inChar;
-//    if (inChar == '\n') {
-//       commandString = inputString.substring(0, inputString.lastIndexOf(":"));
-//    }
-
-      if (commandString == "start_capture") {
-        start_capture();
-      } else if (commandString == "end_capture"){
-        end_capture();
-      } else if (commandString == "get_version"){
-        get_version();
-      } else if (commandString == "get_calibration_factor"){
-        get_calibration_factor();
-      } else if (commandString == "set_calibration_factor"){
-        set_calibration_factor(inputString);
-      } else if (commandString == "calibrate"){
-        calibrate(inputString);
-      } else if (commandString == "get_tare"){
-        get_tare();
-      } else if (commandString == "set_tare"){
-        set_tare(inputString);
-      } else if (commandString == "tare"){
-        tare();
-      } else if (commandString == "get_transmission_format"){
-        get_transmission_format();
-      } else {
-        Serial.println("Not a valid command");
-      }
-      inputString = "";
-//  }
+  //  while (Serial.available())
+  //  {
+  //    char inChar = (char)Serial.read();
+  //    inputString += inChar;
+  //    if (inChar == '\n') {
+  //       commandString = inputString.substring(0, inputString.lastIndexOf(":"));
+  //    }
+
+  if (commandString == "start_capture") {
+    start_capture();
+  } else if (commandString == "end_capture") {
+    end_capture();
+  } else if (commandString == "get_version") {
+    get_version();
+  } else if (commandString == "get_calibration_factor") {
+    get_calibration_factor();
+  } else if (commandString == "set_calibration_factor") {
+    set_calibration_factor(inputString);
+  } else if (commandString == "calibrate") {
+    calibrate(inputString);
+  } else if (commandString == "get_tare") {
+    get_tare();
+  } else if (commandString == "set_tare") {
+    set_tare(inputString);
+  } else if (commandString == "tare") {
+    tare();
+  } else if (commandString == "get_transmission_format") {
+    get_transmission_format();
+  } else {
+    Serial.println("Not a valid command");
+  }
+  inputString = "";
+  //  }
 }
 
 void start_capture()
@@ -184,7 +174,7 @@ void set_calibration_factor(String inputString)
   scale.set_scale(calibration_factor.toFloat());
   float stored_calibration = 0.0f;
   EEPROM.get(calibrationAddress, stored_calibration);
-  if(stored_calibration != calibration_factor.toFloat()){
+  if (stored_calibration != calibration_factor.toFloat()) {
     EEPROM.put(calibrationAddress, calibration_factor.toFloat());
   }
   Serial.println("Calibration factor set");
@@ -208,7 +198,7 @@ void calibrate(String inputString)
 void tare()
 {
   scale.tare(255); //Reset the scale to 0 using the mean of 255 raw values
-  EEPROM.put(tareAddress,scale.get_offset());
+  EEPROM.put(tareAddress, scale.get_offset());
   Serial.println("Taring OK");
 }
 
@@ -224,7 +214,7 @@ void set_tare(String inputString)
   scale.set_offset(value);
   long stored_tare = 0;
   EEPROM.get(tareAddress, stored_tare);
-  if(stored_tare != value){
+  if (stored_tare != value) {
     EEPROM.put(tareAddress, value);
     Serial.println("updated");
   }
@@ -233,7 +223,7 @@ void set_tare(String inputString)
 
 String get_command_argument(String inputString)
 {
-  return(inputString.substring(inputString.lastIndexOf(":") + 1, inputString.lastIndexOf(";")));
+  return (inputString.substring(inputString.lastIndexOf(":") + 1, inputString.lastIndexOf(";")));
 }
 
 void get_transmission_format()


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