test

Dependencies:   BLE_API nRF51822 mbed

Fork of KS7 by masaaki makabe

Revision:
8:32be16b1eaf2
Parent:
7:9ebf125e405f
Child:
9:a7bd5ae66d6d
--- a/main.cpp	Fri Nov 06 03:45:16 2015 +0000
+++ b/main.cpp	Tue Nov 24 03:46:06 2015 +0000
@@ -14,7 +14,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.001@rev0007" // Firmware Revision String - shall represent the firmware revision for the firmware within the device.
+#define FIRMWARE_REVISION_STRING        "v1.00.002@rev0008" // Firmware Revision String - shall represent the firmware revision for the firmware within the device.
 
 // Weight Scale Service (Original)
 #define UUID_WEIGHT_SCALE_SERVICE       (0x181D)
@@ -111,11 +111,9 @@
 
 void ticker_callback()
 {
-    bool pushing = check_joystick();
-    
     switch(led_mode){
         case MODE_OFF:
-            if(pushing){
+            if(check_joystick()){
                 io.display_value = 0;
                 led_mode = MODE_START;
             }
@@ -129,7 +127,7 @@
             }
         break;
         case MODE_ON:
-            if(!pushing){
+            if(!check_joystick()){
                 io.display_value = (uint16_t)(io.get_weight() * 9999.0); // dummy display
                 if(++update_counter >= 5){
                     io.analog_pow(1); // turn analog power on
@@ -141,10 +139,12 @@
                     update_counter = 0;
                 }   
             }else{
+                led_mode = MODE_END;
                 if(ble.getGapState().connected){
                     ble.disconnect(Gap::REMOTE_USER_TERMINATED_CONNECTION);
+                }else{
+                    ble.stopAdvertising();
                 }
-                led_mode = MODE_END;
                 update_counter = 0;
             }
         break;