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:
- 38:115875b8cb6c
- Parent:
- 37:4ce71fa47fc3
- Child:
- 39:b7889285c9ef
--- a/main.cpp Fri Aug 26 00:22:05 2016 +0000
+++ b/main.cpp Fri Aug 26 15:22:31 2016 +0000
@@ -172,7 +172,7 @@
enableInterrupt();
}
- void disableInterrupt() {
+ int disableInterrupt() {
int ok;
if (gpio1_ready) {
// Disable interrupt
@@ -189,10 +189,10 @@
0b00000000
);
}
-
+ return ok;
}
- void enableInterrupt() {
+ int enableInterrupt() {
int ok;
if (gpio1_ready) {
// Enable interrupt
@@ -212,6 +212,7 @@
// Clear interrupt
// gpio1.read8(MCP23017::GPIOB, ok);
+ return ok;
}
};
@@ -272,13 +273,18 @@
void updateStatusLed() {
switch (HIDController::status()) {
case TIMEOUT:
- case DISCONNECTED: timeout.attach(updateStatusLed, statusLed ? 3 : 0.1); break;
+ case DISCONNECTED:
+ case CONNECTED:
+ statusLed = 0;
+ updateStatudLedEnabled = false;
+ return;
case ADVERTISING:
- case CONNECTING: timeout.attach(updateStatusLed, statusLed ? 0.5 : 0.1); break;
- case CONNECTED: statusLed = 0; updateStatudLedEnabled = false; return;
+ case CONNECTING:
+ statusLed = !statusLed;
+ updateStatudLedEnabled = true;
+ timeout.attach(updateStatusLed, statusLed ? 0.5 : 0.1);
+ break;
}
- statusLed = !statusLed;
- updateStatudLedEnabled = true;
}
static volatile bool keyIntervalInterrupt = false;
@@ -351,6 +357,7 @@
}
};
+#define is_pressed(keys, row, col) (!!(keys[col] & (1<<row)))
int main(void) {
{
@@ -434,6 +441,18 @@
}
state = !state;
+ if (HIDController::status() == DISCONNECTED ||
+ HIDController::status() == TIMEOUT) {
+
+ if (
+ is_pressed(keysCurr, 0, 0) && // left top 1
+ is_pressed(keysCurr, 1, 0) && // left top 2
+ is_pressed(keysCurr, 0, 15) // right top
+ ) {
+ printf("re-init connection\r\n");
+ HIDController::initializeConnection();
+ }
+ }
if (queue) HIDController::queueCurrentReportData();