test code

Dependencies:   HX711_weight

Revision:
80:167f8aabffca
Parent:
76:a3df66cb69e6
Child:
81:883a1a95f20b
--- a/source/main.cpp	Mon Feb 11 15:05:13 2019 +0000
+++ b/source/main.cpp	Mon Jun 24 03:57:20 2019 +0000
@@ -22,7 +22,7 @@
 #include "hx711.h"
 
 HX711 scale(D5, D4);
-float calibration_factor = 20;
+float calibration_factor = 100;
 
 Serial pc(USBTX, USBRX);    // USB Serial Terminal
 
@@ -61,13 +61,15 @@
             return;
         }
 
-        _weight_service = new WEIGHTService(_ble, _current_weight);
+        _weight_service = new WEIGHTService(_ble, _initial_weight);
 
 //        _ble.gattServer().onDataWritten(this, &WEIGHTDemo::on_data_written);
 
         print_mac_address();
         
         pc.printf("HX711 Demo\n");
+        pc.printf("Ensure that there is no weight on the floor.\n");
+
         
         scale.tare(); 
 
@@ -124,12 +126,18 @@
         {
                 scale.setScale(calibration_factor);
                 _current_weight = scale.getGram();
-                //if(_current_weight <= 0.00)
+                WeightType_t *weight;
+                weight->integer = (uint16_t)_current_weight;
+                float f_decimal = _current_weight - weight->integer;
+                weight->decimal = (uint8_t)(f_decimal* 100.0f);
+//                if(_current_weight <= 0.00f)
 //                {
 //                    _current_weight = 0.00;
 //                }
                 _weight_service->updateWeight(_current_weight);
                 pc.printf("Reading: %.2f\n", _current_weight);
+                pc.printf("Reading: %d.%d\n", weight->integer,weight->decimal);
+
          }
     }
 
@@ -147,6 +155,7 @@
     UUID _weight_uuid;
     
     float _current_weight;
+    WeightType_t _initial_weight;
     WEIGHTService *_weight_service;
 
     uint8_t _adv_buffer[ble::LEGACY_ADVERTISING_MAX_SIZE];