Demo example on FRDM-64F https://ide.mbed.com/compiler/#nav:/rzr-example-mbed;

Dependencies:   FXOS8700Q

Revision:
3:807a69c34b8b
Parent:
2:15bfd52937dc
diff -r 15bfd52937dc -r 807a69c34b8b main.cpp
--- a/main.cpp	Thu Nov 19 23:07:40 2020 +0000
+++ b/main.cpp	Wed Mar 16 14:41:31 2022 +0000
@@ -1,14 +1,15 @@
 /// SPDX-License-Indentifier: ISC
-/// Copyright: 2020+ Philippe Coval <https://purl.org/rzr>
+/// Copyright: 2020+ Philippe Coval <https://purl.org/rzr/>
 /// URL: https://os.mbed.com/users/rzrfreefr/code/rzr-example-mbed/
 
 #include "mbed.h"
 
-#include "EthernetInterface.h"
-#include "USBKeyboard.h"
-#include "FXOS8700Q.h"
+#include <EthernetInterface.h>
+#include <USBKeyboard.h>
+#include <FXOS8700Q.h>
+#include "Utils.h"
 
-#define CONFIG_LOG 1
+//#define CONFIG_LOG 1
 //#define CONFIG_NET 1
 #define CONFIG_USB 1
 
@@ -26,8 +27,6 @@
     DigitalOut led(LED1);
     led = false; //on
 
-    const float delay = 1000.f / 25;
-
     I2C i2c(PTE25, PTE24);
     motion_data_units_t acc_data;
     motion_data_counts_t acc_raw;
@@ -41,21 +40,30 @@
     float vmin[] = {0, 0, 0};
     float vmax[] = {0, 0, 0};
 
-    float threshold = 1./3.;
+    // cis: 10 < 12 < 13Log < 15 < 20N < 25<  35N < 40 < ~50 < 60 < !75
+    // pin: 12? < 50
+    float threshold = 1./25;
     float vthreshold[] = {threshold, threshold, threshold};
+    const float delay = 1000.f / 25 / len;
 
-#if 1
+#if 0
     int keymap[3][2] = {
-        { LEFT_ARROW, RIGHT_ARROW },
+        { RIGHT_ARROW, LEFT_ARROW },
         { DOWN_ARROW, UP_ARROW },
         { KEY_PAGE_DOWN, KEY_PAGE_UP }
     };
-#else
+#elif 1
     int keymap[3][2] = {
-        { KEY_CTRL, KEY_RCTRL },
+        { KEY_RCTRL, KEY_CTRL },
         { DOWN_ARROW, UP_ARROW },
         { KEY_PAGE_DOWN, KEY_PAGE_UP }
     };
+#elif 0 // https://github.com/ARMmbed/mbed-os/blob/c6094f7b36dc0e90a6a7271870333fbba475286c/drivers/usb/source/USBKeyboard.cpp
+    int keymap[3][2] = {
+        { 0x4f, 0x50 },
+        { 0x51, 0x52 },
+        { 0x4b, 0x4e }
+    };
 #endif
 
 
@@ -108,10 +116,17 @@
             if (key != 0) {
                 led = false; //on
                 logf("# key: %0X\n", key);
+#if 0
+                Thread thread;
+                thread.start(idle);
+#endif
+
                 if (!true) {
                     usb.key_code(key, key);
+                } else if (false) {
+                    usb.key_code(key);
                 } else {
-                    usb.key_code(key);
+                    Utils::keyboard_key_code(usb, key, key);
                 }
             }
             iter=0;