masaaki makabe / Mbed 2 deprecated KS7

Dependencies:   BLE_API nRF51822 mbed

Fork of KS7 by masaaki makabe

Branch:
KS3
Revision:
28:d8c652994988
Parent:
27:8c3c29b3f704
Child:
29:09406be35ef4
diff -r 8c3c29b3f704 -r d8c652994988 main.cpp
--- a/main.cpp	Mon Apr 04 03:39:08 2016 +0000
+++ b/main.cpp	Tue Apr 05 12:56:59 2016 +0000
@@ -19,7 +19,7 @@
 #define MANUFACTURER_NAME_STRING        "Hacarus" // Manufacturer Name String - shall represent the name of the manufacturer of the device.
 #define MODEL_NUMBER_STRING             "0001" // Model Number String - shall represent the model number that is assigned by the device vendor.
 #define SERIAL_NUMBER_STRING            "000780c0ffeef00d"  // Serial Number String - shall represent the serial number for a particular instance of the device.
-#define FIRMWARE_REVISION_STRING        "v1.00.009@rev0023" // Firmware Revision String - shall represent the firmware revision for the firmware within the device.
+#define FIRMWARE_REVISION_STRING        "v1.00.009@rev0028" // Firmware Revision String - shall represent the firmware revision for the firmware within the device.
 
 // Weight Scale Service (Original)
 #define UUID_WEIGHT_SCALE_SERVICE       (0x181D)
@@ -148,13 +148,13 @@
 
 #ifdef PCB_VER3
     // check XTALFREQ for TaiyoYuden module in PCB_VER3
-/*
-        if(NRF_UICR->XTALFREQ == 0xFFFFFF00){
-            io.display_value = 3232;
-        }else if(NRF_UICR->XTALFREQ == 0xFFFFFFFF){
-            io.display_value = 1616;
-        }
-*/
+    /*
+            if(NRF_UICR->XTALFREQ == 0xFFFFFF00){
+                io.display_value = 3232;
+            }else if(NRF_UICR->XTALFREQ == 0xFFFFFFFF){
+                io.display_value = 1616;
+            }
+    */
 #endif
 }
 
@@ -230,18 +230,18 @@
     int sample = 0;
 #ifdef UART_DEBUG
     pc.baud(UART_BAUD_RATE);
-/*
-    pc.printf("SPI->PSELSCK  = %x\r\n", NRF_SPI0->PSELSCK);  // will be 15 (P0_15)
-    pc.printf("SPI->PSELMISO = %x\r\n", NRF_SPI0->PSELMISO); // will be 13 (P0_13)
-    pc.printf("SPI->PSELMOSI = %x\r\n", NRF_SPI0->PSELMOSI); // will be 14 (P0_14): dummy
-    pc.printf("SPI->PSELSCK  = %x\r\n", NRF_SPI1->PSELSCK);  // will be 15 (P0_15)
-    pc.printf("SPI->PSELMISO = %x\r\n", NRF_SPI1->PSELMISO); // will be 13 (P0_13)
-    pc.printf("SPI->PSELMOSI = %x\r\n", NRF_SPI1->PSELMOSI); // will be 14 (P0_14): dummy
-    io.analog_pow(1);
-    while(1){
-        pc.printf("%x\r\n", io._get_adc_raw(0));
-    }
-*/
+    /*
+        pc.printf("SPI->PSELSCK  = %x\r\n", NRF_SPI0->PSELSCK);  // will be 15 (P0_15)
+        pc.printf("SPI->PSELMISO = %x\r\n", NRF_SPI0->PSELMISO); // will be 13 (P0_13)
+        pc.printf("SPI->PSELMOSI = %x\r\n", NRF_SPI0->PSELMOSI); // will be 14 (P0_14): dummy
+        pc.printf("SPI->PSELSCK  = %x\r\n", NRF_SPI1->PSELSCK);  // will be 15 (P0_15)
+        pc.printf("SPI->PSELMISO = %x\r\n", NRF_SPI1->PSELMISO); // will be 13 (P0_13)
+        pc.printf("SPI->PSELMOSI = %x\r\n", NRF_SPI1->PSELMOSI); // will be 14 (P0_14): dummy
+        io.analog_pow(1);
+        while(1){
+            pc.printf("%x\r\n", io._get_adc_raw(0));
+        }
+    */
 #endif
 #ifdef PCB_VER3
     // set XTAL=32MHz for TaiyoYuden's module
@@ -251,7 +251,7 @@
 
     BleInitialize();
     AppInit();
-    
+
     led_mode = MODE_OFF;
 #ifdef DISPLAY_DEMO
     uint16_t d = 0;
@@ -298,9 +298,13 @@
                 io.analog_pow(1);
 #ifdef DISPLAY_DEMO
                 demo_count++;
-                if (demo_count == 10){
+                if (demo_count == 10) {
                     demo_count = 0;
                     io.display_value = d++; // increment display value for every 1s in demo mode
+                    weight_data = quick_ieee11073_from_float(d);
+                    ble.updateCharacteristicValue(WeightMeasurement.getValueAttribute().getHandle(),
+                                                  (uint8_t *)&weight_data,
+                                                  sizeof(weight_data));
                 }
 #else
                 if(io.get_switch()) {
@@ -318,7 +322,7 @@
 
                     weight_s += io.get_weight();
                     sample++;
-                    if (sample == Navg){
+                    if (sample == Navg) {
                         weight = weight_s / (float)Navg;
                         io.display_value = (uint16_t)weight;
                         weight_s = 0.0;