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: mbed TSI USBDevice
Revision 2:4097fa431680, committed 2021-04-12
- Comitter:
- Fratink
- Date:
- Mon Apr 12 15:12:41 2021 +0000
- Parent:
- 1:b5afa5af13d5
- Commit message:
- Working version
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Apr 11 05:21:23 2021 +0000
+++ b/main.cpp Mon Apr 12 15:12:41 2021 +0000
@@ -2,6 +2,8 @@
#include "USBKeyboard.h"
#include "TSISensor.h"
+#define SWITCH_TIMEOUT 10
+
USBKeyboard keyboard;
typedef enum
@@ -51,8 +53,7 @@
int main(void)
{
-// rled.period(0.001);
-// TSISensor tsi;
+ int switchTime = 0;
up.mode(PullUp);
down.mode(PullUp);
left.mode(PullUp);
@@ -60,13 +61,38 @@
while(1)
{
-// rled = 1.0 - tsi.readPercentage();
+ if (switchTime == 0)
+ {
+ if(!up)
+ {
+ switchTime = SWITCH_TIMEOUT;
+ sendKeyboardCommand(TOGGLE_MUTE);
+// keyboard.keyCode(UP_ARROW);
+ }
+ if(!down)
+ {
+ switchTime = SWITCH_TIMEOUT;
+ sendKeyboardCommand(DECLINE_CALL);
+// keyboard.keyCode(DOWN_ARROW);
+ }
+ if(!left)
+ {
+ switchTime = SWITCH_TIMEOUT;
+ sendKeyboardCommand(ACCEPT_VIDEO_CALL);
+// keyboard.keyCode(LEFT_ARROW);
+ }
+ if(!right)
+ {
+ switchTime = SWITCH_TIMEOUT;
+ sendKeyboardCommand(ACCCEPT_AUDIO_CALL);
+// keyboard.keyCode(RIGHT_ARROW);
+ }
+ }
+ else
+ {
+ switchTime--;
+ }
wait(0.1);
- if(!up)
- keyboard.printf("Hello World\r\n");
-// wait(1);
-// keyboard.printf("Hello World\r\n");
-
};
}
\ No newline at end of file