test code

Dependencies:   HX711_weight

Revision:
82:d40c223b65f9
Parent:
81:883a1a95f20b
Child:
83:dc516d289cc0
--- a/source/main.cpp	Mon Jun 24 14:17:40 2019 +0000
+++ b/source/main.cpp	Tue Jun 25 10:05:54 2019 +0000
@@ -26,7 +26,7 @@
 
 Serial pc(USBTX, USBRX);    // USB Serial Terminal
 
-const static char DEVICE_NAME[] = "WEIGHT";
+const static char DEVICE_NAME[] = "TH2G_WEIGHT";
 
 static EventQueue event_queue(/* event count */ 16 * EVENTS_EVENT_SIZE);
 
@@ -61,6 +61,8 @@
             printf("Ble initialization failed.");
             return;
         }
+        
+        initialWeightReading(&_initial_weight);
 
         _weight_service = new WEIGHTService(_ble, _initial_weight);
 
@@ -138,8 +140,8 @@
 //                    _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);
+                pc.printf("Reading of float: %.2f\n", _current_weight);
+                pc.printf("Reading of structure: %d.%d\n", weight.integer,weight.decimal);
 
          }
     }
@@ -150,6 +152,10 @@
     void onDisconnectionComplete(const ble::DisconnectionCompleteEvent&) {
         _ble.gap().startAdvertising(ble::LEGACY_ADVERTISING_HANDLE);
     }
+    void initialWeightReading(WeightType_t *newValue){
+        newValue->integer = 0;
+        newValue->decimal = 0;    
+    }
 
 private:
     BLE &_ble;