Keyboard based response box for E-prime Psychopy. This box has a certain latency determinated by os and debounce function delay.

Files at this revision

API Documentation at this revision

Comitter:
kanatronics
Date:
Tue Nov 14 12:53:28 2017 +0000
Commit message:
Response box for E-Prime Psychopy experiments. Based on Standard keyboard with latency.

Changed in this revision

keyTrigger.cpp Show annotated file Show diff for this revision Revisions of this file
keyTrigger.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r c1b31c5bc2cb keyTrigger.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keyTrigger.cpp	Tue Nov 14 12:53:28 2017 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+#include "USBKeyboard.h"
+#include "keyTrigger.h"
+
+
+USBKeyboard keyboard;            //USBKeyboard
+bool toggleLED=true;
+/*
+ This function has 3 input parameters
+ char key
+ DigitalIn GPIO
+ delayms for debouncing
+
+*/
+
+
+      void keyTrigger (char key,  DigitalIn pinio, int delayms)
+    
+    {
+        
+
+        DigitalOut Blue(led_blue);
+        
+        
+        if (!pinio)                      //pinio pull up
+           {                
+             wait_ms(delayms);           // keypress debounce  
+              if (!pinio)
+              {
+                    toggleLED=!toggleLED; 
+                     keyboard.keyCode(key);
+                     Blue=toggleLED;
+                     wait_ms(delayms);
+                    //keyboard.keyCode(0x0a);      // Enter    
+                  
+              }
+           }  
+          
+    
+    }
\ No newline at end of file
diff -r 000000000000 -r c1b31c5bc2cb keyTrigger.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keyTrigger.h	Tue Nov 14 12:53:28 2017 +0000
@@ -0,0 +1,13 @@
+#ifndef MBED_keyTrigger_H
+#define MBED_keyTrigger_H
+#include "mbed.h"
+
+void keyTrigger(char , DigitalIn, int);             //function declaration
+
+
+#define pin_1 PTD4
+#define pin_2 PTA12
+#define led_blue PTD1 
+
+#endif
+