Hiroh Satoh / keyboard Featured

Dependencies:   BLE_API mbed-dev nRF51822

Revision:
58:64df960619ce
Parent:
50:c1382a0ff066
Child:
59:2d6c0bff2151
--- a/main.cpp	Tue Aug 30 14:17:14 2016 +0000
+++ b/main.cpp	Tue Aug 30 14:44:24 2016 +0000
@@ -245,6 +245,7 @@
 				if (queue) HIDController::queueCurrentReportData();
 
 				// use timer to use wait 5ms
+				timeout.detach();
 				keyIntervalInterrupt = false;
 				timeout.attach_us(wakeupKeyIntervalSleep, 5000);
 				while (!keyIntervalInterrupt) HIDController::waitForEvent();
@@ -264,7 +265,7 @@
 					isLowBattery ? "LOWBAT" : "WFE"
 				);
 	
-				HIDController::updateBatteryLevel(batteryPercentage);
+				HIDController::updateBatteryLevel(batteryPercentage, batteryVoltage * 1000);
 	
 				if (isLowBattery) {
 					powerOff();
@@ -274,30 +275,8 @@
 			if (HIDController::status() == DISCONNECTED) {
 				HIDController::initializeConnection(false);
 			}
-
-			if (DEBUG_BLE_INTERRUPT) {
-				HIDController::waitForEvent();
-			} else {
-				// disable internal HFCLK RC Clock surely. It consume 1mA constantly
-				// TWI / SPI / UART must be disabled and boot without debug mode
-				while (NRF_UART0->EVENTS_TXDRDY != 1);
-
-				const uint32_t tx = NRF_UART0->PSELTXD;
-
-				NRF_UART0->TASKS_STOPTX = 1;
-				NRF_UART0->ENABLE = (UART_ENABLE_ENABLE_Disabled << UART_ENABLE_ENABLE_Pos);
-
-				HIDController::waitForEvent();
-
-				NRF_UART0->ENABLE = (UART_ENABLE_ENABLE_Enabled << UART_ENABLE_ENABLE_Pos);
-				NRF_UART0->TASKS_STARTTX = 1;
-				// dummy send to wakeup...
-				NRF_UART0->PSELTXD = 0xFFFFFFFF;
-				NRF_UART0->EVENTS_TXDRDY = 0;
-				NRF_UART0->TXD = 0;
-				while (NRF_UART0->EVENTS_TXDRDY != 1);
-				NRF_UART0->PSELTXD = tx;
-			}
+			
+			HIDController::waitForEvent();
 		}
 	}
 }