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: SDFileSystem USBHost_SAMPLE mbed
Revision 0:9a41b13c220a, committed 2017-11-20
- Comitter:
- overover
- Date:
- Mon Nov 20 05:55:58 2017 +0000
- Commit message:
- timer
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Mon Nov 20 05:55:58 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/SDFileSystem/#8db0d3b02cec
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBHost.lib Mon Nov 20 05:55:58 2017 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/Login10/code/USBHost_SAMPLE/#18e91028dd16
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Nov 20 05:55:58 2017 +0000
@@ -0,0 +1,58 @@
+#include "mbed.h"
+#include "USBHostKeyboard.h"
+#include "SDFileSystem.h"
+DigitalOut led(LED1);
+SDFileSystem sd(p5, p6, p7, p8, "sd");
+
+int i=0;    //カウント用の変数を初期化
+Timer keytime;
+
+
+
+void onKey(uint8_t key) {
+    
+    keytime.stop();
+    
+    printf("Key: 0x%x : %c\r\n", key, key);
+    printf("The time taken was %f seconds\n", keytime.read());
+    keytime.reset();
+
+    ++i;
+    FILE *fp;
+    fp = fopen("/sd/keylog/keylog.csv", "a");
+    fprintf(fp, "Keydata[%d], :,0x%x,:,%c\r\n", i, key, key);//iは押した順番,keyは押したキーのキーコード,keyは押したキーの文字
+    fclose(fp); 
+
+}
+
+void keyboard_task(void const *) {
+    
+    USBHostKeyboard keyboard;
+    
+    while(1) {
+        // try to connect a USB keyboard
+        while(!keyboard.connect())
+            Thread::wait(500);
+    
+        // when connected, attach handler called on keyboard event
+        keyboard.attach(onKey);
+        
+        // wait until the keyboard is disconnected
+        while(keyboard.connected())
+            Thread::wait(500);
+    }
+}
+
+int main() {
+    mkdir("/sd/keylog", 0777);
+    FILE *fp;
+    fp = fopen("/sd/keylog/keylog.csv","w");
+    keytime.start();
+    fclose(fp);
+    
+    Thread keyboardTask(keyboard_task, NULL, osPriorityNormal, 256 * 4);
+    while(1) {
+        led=!led;
+        Thread::wait(500);
+    }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Nov 20 05:55:58 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/5e5da4a5990b \ No newline at end of file