Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API mbed-dev nRF51822
Diff: main.cpp
- Revision:
- 49:09ae6fb04a32
- Parent:
- 48:d6938de02f62
- Child:
- 50:c1382a0ff066
--- a/main.cpp Mon Aug 29 14:09:09 2016 +0000
+++ b/main.cpp Mon Aug 29 14:17:12 2016 +0000
@@ -62,10 +62,6 @@
NRF_POWER->SYSTEMOFF = 1;
}
-static void tickerStatus() {
- statusLed = !statusLed;
-}
-
static bool updateStatudLedEnabled = false;
static void updateStatusLed() {
switch (HIDController::status()) {
@@ -79,7 +75,7 @@
case CONNECTING:
statusLed = !statusLed;
updateStatudLedEnabled = true;
- timeout.attach(updateStatusLed, statusLed ? 0.5 : 0.1);
+ timeout.attach(updateStatusLed, statusLed ? 0.1 : 0.5);
break;
}
}
@@ -89,8 +85,6 @@
keyIntervalInterrupt = true;
}
-#define is_pressed(keys, row, col) (!!(keys[col] & (1<<row)))
-
int main(void) {
{
const uint32_t reason = NRF_POWER->RESETREAS;
@@ -99,9 +93,11 @@
serial.printf("init [%x]\r\n", reason);
}
- const float battery = BatteryLevel::readBatteryVoltage();
- if (battery < BatteryLevel::BATTERY_LOW) {
- powerOff();
+ {
+ const float battery = BatteryLevel::readBatteryVoltage();
+ if (battery < BatteryLevel::BATTERY_LOW) {
+ powerOff();
+ }
}
// Enable Pin-reset on DEBUG mode
@@ -260,21 +256,23 @@
} else {
if (!updateStatudLedEnabled) updateStatusLed();
- const float batteryVoltage = BatteryLevel::readBatteryVoltage();
- const uint8_t batteryPercentage = BatteryLevel::readBatteryPercentage(batteryVoltage);
- const bool isLowBattery = batteryVoltage < BatteryLevel::BATTERY_LOW;
-
- DEBUG_PRINTF("%d%% [%d:%s] %s\r\n",
- batteryPercentage,
- HIDController::status(),
- HIDController::statusString(),
- isLowBattery ? "LOWBAT" : "WFE"
- );
-
- HIDController::updateBatteryLevel(batteryPercentage);
-
- if (isLowBattery) {
- powerOff();
+ {
+ const float batteryVoltage = BatteryLevel::readBatteryVoltage();
+ const uint8_t batteryPercentage = BatteryLevel::readBatteryPercentage(batteryVoltage);
+ const bool isLowBattery = batteryVoltage < BatteryLevel::BATTERY_LOW;
+
+ DEBUG_PRINTF("%d%% [%d:%s] %s\r\n",
+ batteryPercentage,
+ HIDController::status(),
+ HIDController::statusString(),
+ isLowBattery ? "LOWBAT" : "WFE"
+ );
+
+ HIDController::updateBatteryLevel(batteryPercentage);
+
+ if (isLowBattery) {
+ powerOff();
+ }
}
if (HIDController::status() == DISCONNECTED) {