From 262fd1e2940498c00d9871a455de21be1c73785f Mon Sep 17 00:00:00 2001 From: tigoe Date: Thu, 3 Dec 2015 23:33:37 -0500 Subject: [PATCH 1/4] Style changes to IMU examples Note: IMU Library API still needs to be standardized. --- .../RawImuDataSerial/RawImuDataSerial.ino | 265 +++++++++--------- .../RawImuDataSerial/RawImuDataSerial.txt | 1 - .../examples/ShockDetect/ShockDetect.ino | 99 ++++--- .../examples/ShockDetect/ShockDetect.txt | 1 - .../CurieImu/examples/StepCount/StepCount.ino | 121 ++++---- .../CurieImu/examples/StepCount/StepCount.txt | 1 - .../CurieImu/examples/TapDetect/TapDetect.ino | 40 +-- .../CurieImu/examples/TapDetect/TapDetect.txt | 1 - 8 files changed, 271 insertions(+), 258 deletions(-) delete mode 100644 libraries/CurieImu/examples/RawImuDataSerial/RawImuDataSerial.txt delete mode 100644 libraries/CurieImu/examples/ShockDetect/ShockDetect.txt delete mode 100644 libraries/CurieImu/examples/StepCount/StepCount.txt delete mode 100644 libraries/CurieImu/examples/TapDetect/TapDetect.txt diff --git a/libraries/CurieImu/examples/RawImuDataSerial/RawImuDataSerial.ino b/libraries/CurieImu/examples/RawImuDataSerial/RawImuDataSerial.ino index a94f7a08..48cc278b 100644 --- a/libraries/CurieImu/examples/RawImuDataSerial/RawImuDataSerial.ino +++ b/libraries/CurieImu/examples/RawImuDataSerial/RawImuDataSerial.ino @@ -1,147 +1,140 @@ /* -=============================================== -Example sketch for CurieImu library for Intel(R) Curie(TM) devices. -Copyright (c) 2015 Intel Corporation. All rights reserved. - -Based on I2C device class (I2Cdev) demonstration Arduino sketch for MPU6050 -class by Jeff Rowberg: https://github.com/jrowberg/i2cdevlib - -=============================================== -I2Cdev device library code is placed under the MIT license -Copyright (c) 2011 Jeff Rowberg - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -=============================================== + =============================================== + Example sketch for CurieImu library for Intel(R) Curie(TM) devices. + Copyright (c) 2015 Intel Corporation. All rights reserved. + + Based on I2C device class (I2Cdev) demonstration Arduino sketch for MPU6050 + class by Jeff Rowberg: https://github.com/jrowberg/i2cdevlib + + =============================================== + I2Cdev device library code is placed under the MIT license + Copyright (c) 2011 Jeff Rowberg + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + =============================================== */ #include "CurieImu.h" -int16_t ax, ay, az; -int16_t gx, gy, gz; +int16_t ax, ay, az; // accelerometer values +int16_t gx, gy, gz; // gyrometer values -// uncomment "OUTPUT_READABLE_ACCELGYRO" if you want to see a tab-separated -// list of the accel X/Y/Z and then gyro X/Y/Z values in decimal. Easy to read, -// not so easy to parse, and slow(er) over UART. -#define OUTPUT_READABLE_ACCELGYRO - -// uncomment "OUTPUT_BINARY_ACCELGYRO" to send all 6 axes of data as 16-bit -// binary, one right after the other. This is very fast (as fast as possible -// without compression or data loss), and easy to parse, but impossible to read -// for a human. -//#define OUTPUT_BINARY_ACCELGYRO - -// uncomment "CALIBRATE_ACCELGRYO_OFFSETS" to perform auto-calibration of all 6 axes during start-up -// This requires the device to be resting in a horizontal position during the start-up phase -//#define CALIBRATE_ACCELGRYO_OFFSETS - - -#define LED_PIN 13 -bool blinkState = false; +const int ledPin = 13; // activity LED pin +boolean blinkState = false; // state of the LED void setup() { - // initialize Serial communication - Serial.begin(115200); - - // initialize device - Serial.println("Initializing IMU device..."); - CurieImu.initialize(); - - // verify connection - Serial.println("Testing device connections..."); - Serial.println(CurieImu.testConnection() ? "CurieImu connection successful" : "CurieImu connection failed"); - -#ifdef CALIBRATE_ACCELGRYO_OFFSETS -// use the code below to calibrate accel/gyro offset values - Serial.println("Internal sensor offsets BEFORE calibration..."); - Serial.print(CurieImu.getXAccelOffset()); Serial.print("\t"); // -76 - Serial.print(CurieImu.getYAccelOffset()); Serial.print("\t"); // -235 - Serial.print(CurieImu.getZAccelOffset()); Serial.print("\t"); // 168 - Serial.print(CurieImu.getXGyroOffset()); Serial.print("\t"); // 0 - Serial.print(CurieImu.getYGyroOffset()); Serial.print("\t"); // 0 - Serial.print(CurieImu.getZGyroOffset()); Serial.print("\t"); // 0 - Serial.println(""); - -// To manually configure offset compensation values, use the following methods instead of the autoCalibrate...() methods below -// CurieImu.setXGyroOffset(220); -// CurieImu.setYGyroOffset(76); -// CurieImu.setZGyroOffset(-85); -// CurieImu.setXAccelOffset(-76); -// CurieImu.setYAccelOffset(--235); -// CurieImu.setZAccelOffset(168); - - // IMU device must be resting in a horizontal position for the following calibration procedure to work correctly! - Serial.print("Starting Gyroscope calibration..."); - CurieImu.autoCalibrateGyroOffset(); - Serial.println(" Done"); - Serial.print("Starting Acceleration calibration..."); - CurieImu.autoCalibrateXAccelOffset(0); - CurieImu.autoCalibrateYAccelOffset(0); - CurieImu.autoCalibrateZAccelOffset(1); - Serial.println(" Done"); - - Serial.println("Internal sensor offsets AFTER calibration..."); - Serial.print(CurieImu.getXAccelOffset()); Serial.print("\t"); // -76 - Serial.print(CurieImu.getYAccelOffset()); Serial.print("\t"); // -2359 - Serial.print(CurieImu.getZAccelOffset()); Serial.print("\t"); // 1688 - Serial.print(CurieImu.getXGyroOffset()); Serial.print("\t"); // 0 - Serial.print(CurieImu.getYGyroOffset()); Serial.print("\t"); // 0 - Serial.print(CurieImu.getZGyroOffset()); Serial.print("\t"); // 0 - Serial.println(""); - - Serial.println("Enabling Gyroscope/Acceleration offset compensation"); - CurieImu.setGyroOffsetEnabled(true); - CurieImu.setAccelOffsetEnabled(true); -#endif - - // configure Arduino LED for - pinMode(LED_PIN, OUTPUT); + Serial.begin(9600); // initialize Serial communication + while (!Serial); // wait for the serial port to open + + // initialize device + Serial.println("Initializing IMU device..."); + CurieImu.initialize(); + + // verify connection + Serial.println("Testing device connections..."); + if (CurieImu.testConnection()) { + Serial.println("CurieImu connection successful"); + } else { + Serial.println("CurieImu connection failed"); + } + + // use the code below to calibrate accel/gyro offset values + Serial.println("Internal sensor offsets BEFORE calibration..."); + Serial.print(CurieImu.getXAccelOffset()); + Serial.print("\t"); // -76 + Serial.print(CurieImu.getYAccelOffset()); + Serial.print("\t"); // -235 + Serial.print(CurieImu.getZAccelOffset()); + Serial.print("\t"); // 168 + Serial.print(CurieImu.getXGyroOffset()); + Serial.print("\t"); // 0 + Serial.print(CurieImu.getYGyroOffset()); + Serial.print("\t"); // 0 + Serial.println(CurieImu.getZGyroOffset()); + + // To manually configure offset compensation values, + // use the following methods instead of the autoCalibrate...() methods below + // CurieImu.setXGyroOffset(220); + // CurieImu.setYGyroOffset(76); + // CurieImu.setZGyroOffset(-85); + // CurieImu.setXAccelOffset(-76); + // CurieImu.setYAccelOffset(-235); + // CurieImu.setZAccelOffset(168); + + Serial.println("About to calibrate. Make sure your board is stable and upright"); + delay(5000); + + // The board must be resting in a horizontal position for + // the following calibration procedure to work correctly! + Serial.print("Starting Gyroscope calibration..."); + CurieImu.autoCalibrateGyroOffset(); + Serial.println(" Done"); + Serial.print("Starting Acceleration calibration..."); + CurieImu.autoCalibrateXAccelOffset(0); + CurieImu.autoCalibrateYAccelOffset(0); + CurieImu.autoCalibrateZAccelOffset(1); + Serial.println(" Done"); + + Serial.println("Internal sensor offsets AFTER calibration..."); + Serial.print(CurieImu.getXAccelOffset()); + Serial.print("\t"); // -76 + Serial.print(CurieImu.getYAccelOffset()); + Serial.print("\t"); // -2359 + Serial.print(CurieImu.getZAccelOffset()); + Serial.print("\t"); // 1688 + Serial.print(CurieImu.getXGyroOffset()); + Serial.print("\t"); // 0 + Serial.print(CurieImu.getYGyroOffset()); + Serial.print("\t"); // 0 + Serial.println(CurieImu.getZGyroOffset()); + + Serial.println("Enabling Gyroscope/Acceleration offset compensation"); + CurieImu.setGyroOffsetEnabled(true); + CurieImu.setAccelOffsetEnabled(true); + + // configure Arduino LED for activity indicator + pinMode(ledPin, OUTPUT); } void loop() { - // read raw accel/gyro measurements from device - CurieImu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); - - // these methods (and a few others) are also available - //CurieImu.getAcceleration(&ax, &ay, &az); - //CurieImu.getRotation(&gx, &gy, &gz); - - #ifdef OUTPUT_READABLE_ACCELGYRO - // display tab-separated accel/gyro x/y/z values - Serial.print("a/g:\t"); - Serial.print(ax); Serial.print("\t"); - Serial.print(ay); Serial.print("\t"); - Serial.print(az); Serial.print("\t"); - Serial.print(gx); Serial.print("\t"); - Serial.print(gy); Serial.print("\t"); - Serial.println(gz); - #endif - - #ifdef OUTPUT_BINARY_ACCELGYRO - Serial.write((uint8_t)(ax >> 8)); Serial.write((uint8_t)(ax & 0xFF)); - Serial.write((uint8_t)(ay >> 8)); Serial.write((uint8_t)(ay & 0xFF)); - Serial.write((uint8_t)(az >> 8)); Serial.write((uint8_t)(az & 0xFF)); - Serial.write((uint8_t)(gx >> 8)); Serial.write((uint8_t)(gx & 0xFF)); - Serial.write((uint8_t)(gy >> 8)); Serial.write((uint8_t)(gy & 0xFF)); - Serial.write((uint8_t)(gz >> 8)); Serial.write((uint8_t)(gz & 0xFF)); - #endif - - // blink LED to indicate activity - blinkState = !blinkState; - digitalWrite(LED_PIN, blinkState); -} \ No newline at end of file + // read raw accel/gyro measurements from device + CurieImu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); + + // these methods (and a few others) are also available + //CurieImu.getAcceleration(&ax, &ay, &az); + //CurieImu.getRotation(&gx, &gy, &gz); + + // display tab-separated accel/gyro x/y/z values + Serial.print("a/g:\t"); + Serial.print(ax); + Serial.print("\t"); + Serial.print(ay); + Serial.print("\t"); + Serial.print(az); + Serial.print("\t"); + Serial.print(gx); + Serial.print("\t"); + Serial.print(gy); + Serial.print("\t"); + Serial.println(gz); + + // blink LED to indicate activity + blinkState = !blinkState; + digitalWrite(ledPin, blinkState); +} diff --git a/libraries/CurieImu/examples/RawImuDataSerial/RawImuDataSerial.txt b/libraries/CurieImu/examples/RawImuDataSerial/RawImuDataSerial.txt deleted file mode 100644 index 07141472..00000000 --- a/libraries/CurieImu/examples/RawImuDataSerial/RawImuDataSerial.txt +++ /dev/null @@ -1 +0,0 @@ -Continuously reads raw accelerometer and gyroscope data values and prints them to the Serial port diff --git a/libraries/CurieImu/examples/ShockDetect/ShockDetect.ino b/libraries/CurieImu/examples/ShockDetect/ShockDetect.ino index e7063b83..9e7e352e 100644 --- a/libraries/CurieImu/examples/ShockDetect/ShockDetect.ino +++ b/libraries/CurieImu/examples/ShockDetect/ShockDetect.ino @@ -1,64 +1,71 @@ /* - * Copyright (c) 2015 Intel Corporation. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + Copyright (c) 2015 Intel Corporation. All rights reserved. - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*/ /* - * This sketch example demonstrates how the BMI160 accelerometer on the - * Intel(R) Curie(TM) module can be used to detect shocks or sudden movements - */ + This sketch example demonstrates how the BMI160 accelerometer on the + Intel(R) Curie(TM) module can be used to detect shocks or sudden movements +*/ #include "CurieImu.h" -static void eventCallback(void) -{ - if (CurieImu.getIntShockStatus()) { - if (CurieImu.getXNegShockDetected()) - Serial.println("Negative shock detected on X-axis"); - if (CurieImu.getXPosShockDetected()) - Serial.println("Positive shock detected on X-axis"); - if (CurieImu.getYNegShockDetected()) - Serial.println("Negative shock detected on Y-axis"); - if (CurieImu.getYPosShockDetected()) - Serial.println("Positive shock detected on Y-axis"); - if (CurieImu.getZNegShockDetected()) - Serial.println("Negative shock detected on Z-axis"); - if (CurieImu.getZPosShockDetected()) - Serial.println("Positive shock detected on Z-axis"); - } -} +boolean blinkState = false; // state of the LED void setup() { - Serial.begin(115200); + Serial.begin(9600); - /* Initialise the IMU */ - CurieImu.initialize(); - CurieImu.attachInterrupt(eventCallback); + /* Initialise the IMU */ + CurieImu.initialize(); + CurieImu.attachInterrupt(eventCallback); - /* Enable Shock Detection */ - CurieImu.setShockDetectionThreshold(192); // 1.5g - CurieImu.setShockDetectionDuration(11); // 30ms - CurieImu.setIntShockEnabled(true); + /* Enable Shock Detection */ + CurieImu.setShockDetectionThreshold(192); // 1.5g + CurieImu.setShockDetectionDuration(11); // 30ms + CurieImu.setIntShockEnabled(true); - /* Enable Interrupts Notifications */ - CurieImu.setIntEnabled(true); + /* Enable Interrupts Notifications */ + CurieImu.setIntEnabled(true); - Serial.println("IMU initialisation complete, waiting for events..."); + Serial.println("IMU initialisation complete, waiting for events..."); } void loop() { + // blink the LED in the main loop: + digitalWrite(13, blinkState); + blinkState = !blinkState; + delay(1000); +} + + +static void eventCallback(void) +{ + if (CurieImu.getIntShockStatus()) { + if (CurieImu.getXNegShockDetected()) + Serial.println("Negative shock detected on X-axis"); + if (CurieImu.getXPosShockDetected()) + Serial.println("Positive shock detected on X-axis"); + if (CurieImu.getYNegShockDetected()) + Serial.println("Negative shock detected on Y-axis"); + if (CurieImu.getYPosShockDetected()) + Serial.println("Positive shock detected on Y-axis"); + if (CurieImu.getZNegShockDetected()) + Serial.println("Negative shock detected on Z-axis"); + if (CurieImu.getZPosShockDetected()) + Serial.println("Positive shock detected on Z-axis"); + } } diff --git a/libraries/CurieImu/examples/ShockDetect/ShockDetect.txt b/libraries/CurieImu/examples/ShockDetect/ShockDetect.txt deleted file mode 100644 index fdd8ccae..00000000 --- a/libraries/CurieImu/examples/ShockDetect/ShockDetect.txt +++ /dev/null @@ -1 +0,0 @@ -Configures the Intel Curie IMU to detect shock events and prints notifications to the Serial port when they occur diff --git a/libraries/CurieImu/examples/StepCount/StepCount.ino b/libraries/CurieImu/examples/StepCount/StepCount.ino index 9585dda3..9686d6b6 100644 --- a/libraries/CurieImu/examples/StepCount/StepCount.ino +++ b/libraries/CurieImu/examples/StepCount/StepCount.ino @@ -1,74 +1,89 @@ /* - * Copyright (c) 2015 Intel Corporation. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + Copyright (c) 2015 Intel Corporation. All rights reserved. - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*/ /* - * This sketch example demonstrates how the BMI160 accelerometer on the - * Intel(R) Curie(TM) module can be used as a Step Counter (pedometer) - */ + This sketch example demonstrates how the BMI160 accelerometer on the + Intel(R) Curie(TM) module can be used as a Step Counter (pedometer) +*/ #include "CurieImu.h" -/* To get an interrupt notification for every step detected, uncomment the line below. - * Note that, by design, the step counter does not immediately update on every step detected. - * Please refer to Section 2.7 of the BMI160 Data Sheet for more information on this feature - */ -//#define ENABLE_STEP_DETECTION_EVENTS - -uint16_t lastStepCount = 0; +/* To get an interrupt notification for every step detected, + set stepEventsEnabeled to true. Otherwise, the main loop will + poll for the current step count. -static void updateStepCount() -{ - uint16_t stepCount = CurieImu.getStepCount(); - if (stepCount != lastStepCount) { - Serial.print("Step count: "); Serial.println(stepCount); - lastStepCount = stepCount; - } -} + By design, the step counter does not immediately update on every step detected. + Please refer to Section 2.7 of the BMI160 IMU SensorData Sheet + for more information on this feature. +*/ +const int ledPin = 13; -static void eventCallback(void) -{ - if (CurieImu.getIntStepStatus()) - updateStepCount(); -} +boolean stepEventsEnabeled = true; // whether you're polling or using events +long lastStepCount = 0; // step count on previous polling check +boolean blinkState = false; // state of the LED void setup() { - Serial.begin(115200); - - CurieImu.initialize(); + Serial.begin(9600); + // pinMode(13, OUTPUT); + // intialize the sensor: + CurieImu.initialize(); + // turn on step detection mode: + CurieImu.setStepDetectionMode(BMI160_STEP_MODE_NORMAL); + // enable step counting: + CurieImu.setStepCountEnabled(true); - CurieImu.setStepDetectionMode(BMI160_STEP_MODE_NORMAL); - CurieImu.setStepCountEnabled(true); - -#ifdef ENABLE_STEP_DETECTION_EVENTS + if (stepEventsEnabeled) { + // attach the eventCallback function as the + // step event handler: CurieImu.attachInterrupt(eventCallback); - CurieImu.setIntStepEnabled(true); - CurieImu.setIntEnabled(true); -#endif + CurieImu.setIntStepEnabled(true); // turn on step detection + CurieImu.setIntEnabled(true); // enable interrupts Serial.println("IMU initialisation complete, waiting for events..."); + } } void loop() { -#ifndef ENABLE_STEP_DETECTION_EVENTS - /* Instead of using step detection event notifications, - * we can check the step count periodically */ + /* Instead of using step detection event notifications, + we can check the step count periodically */ + if (!stepEventsEnabeled) { + updateStepCount(); + } + digitalWrite(13, blinkState); + blinkState = !blinkState; + delay(1000); +} + +static void updateStepCount() { + // get the step count: + int stepCount = CurieImu.getStepCount(); + + // if the step count has changed, print it: + if (stepCount != lastStepCount) { + Serial.print("Step count: "); + Serial.println(stepCount); + // save the current count for comparison next check: + lastStepCount = stepCount; + } +} + +static void eventCallback(void) { + if (CurieImu.getIntStepStatus()) updateStepCount(); - delay(1000); -#endif } diff --git a/libraries/CurieImu/examples/StepCount/StepCount.txt b/libraries/CurieImu/examples/StepCount/StepCount.txt deleted file mode 100644 index fb1f4f27..00000000 --- a/libraries/CurieImu/examples/StepCount/StepCount.txt +++ /dev/null @@ -1 +0,0 @@ -Configures the Intel Curie IMU as a step counter (pedometer) and prints notifications to the Serial port when the count changes diff --git a/libraries/CurieImu/examples/TapDetect/TapDetect.ino b/libraries/CurieImu/examples/TapDetect/TapDetect.ino index 80258a9e..ce56ea0b 100644 --- a/libraries/CurieImu/examples/TapDetect/TapDetect.ino +++ b/libraries/CurieImu/examples/TapDetect/TapDetect.ino @@ -24,26 +24,8 @@ #include "CurieImu.h" -static void eventCallback(void) -{ - if (CurieImu.getIntDoubleTapStatus()) { - if (CurieImu.getXNegTapDetected()) - Serial.println("Double Tap detected on negative X-axis"); - if (CurieImu.getXPosTapDetected()) - Serial.println("Double Tap detected on positive X-axis"); - if (CurieImu.getYNegTapDetected()) - Serial.println("Double Tap detected on negative Y-axis"); - if (CurieImu.getYPosTapDetected()) - Serial.println("Double Tap detected on positive Y-axis"); - if (CurieImu.getZNegTapDetected()) - Serial.println("Double Tap detected on negative Z-axis"); - if (CurieImu.getZPosTapDetected()) - Serial.println("Double Tap detected on positive Z-axis"); - } -} - void setup() { - Serial.begin(115200); + Serial.begin(9600); // Initialise the IMU CurieImu.initialize(); @@ -68,4 +50,24 @@ void setup() { } void loop() { + // nothing happens in the loop because all the action happens + // in the callback function. +} + +static void eventCallback() +{ + if (CurieImu.getIntDoubleTapStatus()) { + if (CurieImu.getXNegTapDetected()) + Serial.println("Double Tap detected on negative X-axis"); + if (CurieImu.getXPosTapDetected()) + Serial.println("Double Tap detected on positive X-axis"); + if (CurieImu.getYNegTapDetected()) + Serial.println("Double Tap detected on negative Y-axis"); + if (CurieImu.getYPosTapDetected()) + Serial.println("Double Tap detected on positive Y-axis"); + if (CurieImu.getZNegTapDetected()) + Serial.println("Double Tap detected on negative Z-axis"); + if (CurieImu.getZPosTapDetected()) + Serial.println("Double Tap detected on positive Z-axis"); + } } diff --git a/libraries/CurieImu/examples/TapDetect/TapDetect.txt b/libraries/CurieImu/examples/TapDetect/TapDetect.txt deleted file mode 100644 index 70ed6326..00000000 --- a/libraries/CurieImu/examples/TapDetect/TapDetect.txt +++ /dev/null @@ -1 +0,0 @@ -Configures the Intel Curie IMU to detect tap events and prints notifications to the Serial port when they occur From d8618b23ede8b769ecfe8cafee0695c2eea60956 Mon Sep 17 00:00:00 2001 From: hbisby Date: Fri, 4 Dec 2015 17:02:10 +0100 Subject: [PATCH 2/4] adding keywords.txt for CurieImu library --- libraries/CurieImu/keywords.txt | 261 ++++++++++++++++++++++++++++++++ 1 file changed, 261 insertions(+) create mode 100644 libraries/CurieImu/keywords.txt diff --git a/libraries/CurieImu/keywords.txt b/libraries/CurieImu/keywords.txt new file mode 100644 index 00000000..58ef5c83 --- /dev/null +++ b/libraries/CurieImu/keywords.txt @@ -0,0 +1,261 @@ +####################################### +# Syntax Coloring Map For CureImu +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +CurieImuClass KEYWORD1 +BMI160Class KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +initialize KEYWORD2 +testConnection KEYWORD2 +getGyroRate KEYWORD2 +setGyroRate KEYWORD2 +getAccelRate KEYWORD2 +setAccelRate KEYWORD2 + +getGyroDLPFMode KEYWORD2 +setGyroDLPFMode KEYWORD2 + +getAccelDLPFMode KEYWORD2 +setAccelDLPFMode KEYWORD2 + +getFullScaleGyroRange KEYWORD2 +setFullScaleGyroRange KEYWORD2 +getFullScaleAccelRange KEYWORD2 +setFullScaleAccelRange KEYWORD2 + +autoCalibrateGyroOffset KEYWORD2 +getGyroOffsetEnabled KEYWORD2 +setGyroOffsetEnabled KEYWORD2 + +getXGyroOffset KEYWORD2 +setXGyroOffset KEYWORD2 +getYGyroOffset KEYWORD2 +setYGyroOffset KEYWORD2 +getZGyroOffset KEYWORD2 +setZGyroOffset KEYWORD2 + +autoCalibrateXAccelOffset KEYWORD2 +autoCalibrateYAccelOffset KEYWORD2 +autoCalibrateZAccelOffset KEYWORD2 +getAccelOffsetEnabled KEYWORD2 +setAccelOffsetEnabled KEYWORD2 + +getXAccelOffset KEYWORD2 +setXAccelOffset KEYWORD2 +getYAccelOffset KEYWORD2 +setYAccelOffset KEYWORD2 +getZAccelOffset KEYWORD2 +setZAccelOffset KEYWORD2 + +getFreefallDetectionThreshold KEYWORD2 +setFreefallDetectionThreshold KEYWORD2 + +getFreefallDetectionDuration KEYWORD2 +setFreefallDetectionDuration KEYWORD2 + +getShockDetectionThreshold KEYWORD2 +setShockDetectionThreshold KEYWORD2 + +getShockDetectionDuration KEYWORD2 +setShockDetectionDuration KEYWORD2 + +getMotionDetectionThreshold KEYWORD2 +setMotionDetectionThreshold KEYWORD2 + +getMotionDetectionDuration KEYWORD2 +setMotionDetectionDuration KEYWORD2 + +getZeroMotionDetectionThreshold KEYWORD2 +setZeroMotionDetectionThreshold KEYWORD2 + +getZeroMotionDetectionDuration KEYWORD2 +setZeroMotionDetectionDuration KEYWORD2 + +getTapDetectionThreshold KEYWORD2 +setTapDetectionThreshold KEYWORD2 + +getTapShockDuration KEYWORD2 +setTapShockDuration KEYWORD2 + +getTapQuietDuration KEYWORD2 +setTapQuietDuration KEYWORD2 + +getDoubleTapDetectionDuration KEYWORD2 +setDoubleTapDetectionDuration KEYWORD2 + +setStepDetectionMode KEYWORD2 +getStepCountEnabled KEYWORD2 +setStepCountEnabled KEYWORD2 +getStepCount KEYWORD2 +resetStepCount KEYWORD2 + +getIntFreefallEnabled KEYWORD2 +setIntFreefallEnabled KEYWORD2 +getIntShockEnabled KEYWORD2 +setIntShockEnabled KEYWORD2 +getIntStepEnabled KEYWORD2 +setIntStepEnabled KEYWORD2 +getIntMotionEnabled KEYWORD2 +setIntMotionEnabled KEYWORD2 +getIntZeroMotionEnabled KEYWORD2 +setIntZeroMotionEnabled KEYWORD2 +getIntTapEnabled KEYWORD2 +setIntTapEnabled KEYWORD2 +getIntDoubleTapEnabled KEYWORD2 +setIntDoubleTapEnabled KEYWORD2 + +getGyroFIFOEnabled KEYWORD2 +setGyroFIFOEnabled KEYWORD2 +getAccelFIFOEnabled KEYWORD2 +setAccelFIFOEnabled KEYWORD2 + +getIntFIFOBufferFullEnabled KEYWORD2 +setIntFIFOBufferFullEnabled KEYWORD2 +getIntDataReadyEnabled KEYWORD2 +setIntDataReadyEnabled KEYWORD2 + +getIntStatus0 KEYWORD2 +getIntStatus1 KEYWORD2 +getIntStatus2 KEYWORD2 +getIntStatus3 KEYWORD2 +getIntFreefallStatus KEYWORD2 +getIntShockStatus KEYWORD2 +getIntStepStatus KEYWORD2 +getIntMotionStatus KEYWORD2 +getIntZeroMotionStatus KEYWORD2 +getIntTapStatus KEYWORD2 +getIntDoubleTapStatus KEYWORD2 +getIntFIFOBufferFullStatus KEYWORD2 +getIntDataReadyStatus KEYWORD2 + +getMotion6 KEYWORD2 +getAcceleration KEYWORD2 +getAccelerationX KEYWORD2 +getAccelerationY KEYWORD2 +getAccelerationZ KEYWORD2 + +getTemperature KEYWORD2 +getRotation KEYWORD2 +getRotationX KEYWORD2 +getRotationY KEYWORD2 +getRotationZ KEYWORD2 + +getXNegShockDetected KEYWORD2 +getXPosShockDetected KEYWORD2 +getYNegShockDetected KEYWORD2 +getYPosShockDetected KEYWORD2 +getZNegShockDetected KEYWORD2 +getZPosShockDetected KEYWORD2 +getZeroShockDetected KEYWORD2 + +getXNegMotionDetected KEYWORD2 +getXPosMotionDetected KEYWORD2 +getYNegMotionDetected KEYWORD2 +getYPosMotionDetected KEYWORD2 +getZNegMotionDetected KEYWORD2 +getZPosMotionDetected KEYWORD2 +getZeroMotionDetected KEYWORD2 + +getXNegTapDetected KEYWORD2 +getXPosTapDetected KEYWORD2 +getYNegTapDetected KEYWORD2 +getYPosTapDetected KEYWORD2 +getZNegTapDetected KEYWORD2 +getZPosTapDetected KEYWORD2 + +getFIFOHeaderModeEnabled KEYWORD2 +setFIFOHeaderModeEnabled KEYWORD2 +resetFIFO KEYWORD2 + +getFIFOCount KEYWORD2 +getFIFOBytes KEYWORD2 +getDeviceID KEYWORD2 +getRegister KEYWORD2 +setRegister KEYWORD2 + +getIntEnabled KEYWORD2 +setIntEnabled KEYWORD2 +getInterruptMode KEYWORD2 +setInterruptMode KEYWORD2 +getInterruptDrive KEYWORD2 +setInterruptDrive KEYWORD2 +getInterruptLatch KEYWORD2 +setInterruptLatch KEYWORD2 +resetInterrupt KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### + +BMI160_ZERO_MOTION_DURATION_1_28S LITERAL1 +BMI160_ZERO_MOTION_DURATION_2_56S LITERAL1 +BMI160_ZERO_MOTION_DURATION_3_84S LITERAL1 +BMI160_ZERO_MOTION_DURATION_5_12S LITERAL1 +BMI160_ZERO_MOTION_DURATION_6_40S LITERAL1 +BMI160_ZERO_MOTION_DURATION_7_68S LITERAL1 +BMI160_ZERO_MOTION_DURATION_8_96S LITERAL1 +BMI160_ZERO_MOTION_DURATION_10_24S LITERAL1 +BMI160_ZERO_MOTION_DURATION_11_52S LITERAL1 +BMI160_ZERO_MOTION_DURATION_12_80S LITERAL1 +BMI160_ZERO_MOTION_DURATION_14_08S LITERAL1 +BMI160_ZERO_MOTION_DURATION_15_36S LITERAL1 +BMI160_ZERO_MOTION_DURATION_16_64S LITERAL1 +BMI160_ZERO_MOTION_DURATION_17_92S LITERAL1 +BMI160_ZERO_MOTION_DURATION_19_20S LITERAL1 +BMI160_ZERO_MOTION_DURATION_20_48S LITERAL1 +BMI160_ZERO_MOTION_DURATION_25_60S LITERAL1 +BMI160_ZERO_MOTION_DURATION_30_72S LITERAL1 +BMI160_ZERO_MOTION_DURATION_35_84S LITERAL1 +BMI160_ZERO_MOTION_DURATION_40_96S LITERAL1 +BMI160_ZERO_MOTION_DURATION_46_08S LITERAL1 +BMI160_ZERO_MOTION_DURATION_51_20S LITERAL1 +BMI160_ZERO_MOTION_DURATION_56_32S LITERAL1 +BMI160_ZERO_MOTION_DURATION_61_44S LITERAL1 +BMI160_ZERO_MOTION_DURATION_66_56S LITERAL1 +BMI160_ZERO_MOTION_DURATION_71_68S LITERAL1 +BMI160_ZERO_MOTION_DURATION_76_80S LITERAL1 +BMI160_ZERO_MOTION_DURATION_81_92S LITERAL1 +BMI160_ZERO_MOTION_DURATION_87_04S LITERAL1 +BMI160_ZERO_MOTION_DURATION_92_16S LITERAL1 +BMI160_ZERO_MOTION_DURATION_97_28S LITERAL1 +BMI160_ZERO_MOTION_DURATION_102_40S LITERAL1 +BMI160_ZERO_MOTION_DURATION_112_64S LITERAL1 +BMI160_ZERO_MOTION_DURATION_122_88S LITERAL1 +BMI160_ZERO_MOTION_DURATION_133_12S LITERAL1 +BMI160_ZERO_MOTION_DURATION_143_36S LITERAL1 +BMI160_ZERO_MOTION_DURATION_153_60S LITERAL1 +BMI160_ZERO_MOTION_DURATION_163_84S LITERAL1 +BMI160_ZERO_MOTION_DURATION_174_08S LITERAL1 +BMI160_ZERO_MOTION_DURATION_184_32S LITERAL1 +BMI160_ZERO_MOTION_DURATION_194_56S LITERAL1 +BMI160_ZERO_MOTION_DURATION_204_80S LITERAL1 +BMI160_ZERO_MOTION_DURATION_215_04S LITERAL1 +BMI160_ZERO_MOTION_DURATION_225_28S LITERAL1 +BMI160_ZERO_MOTION_DURATION_235_52S LITERAL1 +BMI160_ZERO_MOTION_DURATION_245_76S LITERAL1 +BMI160_ZERO_MOTION_DURATION_256_00S LITERAL1 +BMI160_ZERO_MOTION_DURATION_266_24S LITERAL1 +BMI160_ZERO_MOTION_DURATION_276_48S LITERAL1 +BMI160_ZERO_MOTION_DURATION_286_72S LITERAL1 +BMI160_ZERO_MOTION_DURATION_296_96S LITERAL1 +BMI160_ZERO_MOTION_DURATION_307_20S LITERAL1 +BMI160_ZERO_MOTION_DURATION_317_44S LITERAL1 +BMI160_ZERO_MOTION_DURATION_327_68S LITERAL1 +BMI160_ZERO_MOTION_DURATION_337_92S LITERAL1 +BMI160_ZERO_MOTION_DURATION_348_16S LITERAL1 +BMI160_ZERO_MOTION_DURATION_358_40S LITERAL1 +BMI160_ZERO_MOTION_DURATION_368_64S LITERAL1 +BMI160_ZERO_MOTION_DURATION_378_88S LITERAL1 +BMI160_ZERO_MOTION_DURATION_389_12S LITERAL1 +BMI160_ZERO_MOTION_DURATION_399_36S LITERAL1 +BMI160_ZERO_MOTION_DURATION_409_60S LITERAL1 +BMI160_ZERO_MOTION_DURATION_419_84S LITERAL1 +BMI160_ZERO_MOTION_DURATION_430_08S LITERAL1 \ No newline at end of file From 3642f44a88069e89cd644faabae8c72da78a2bfd Mon Sep 17 00:00:00 2001 From: hbisby Date: Fri, 4 Dec 2015 17:40:59 +0100 Subject: [PATCH 3/4] added defines and classes to keywords.txt --- libraries/CurieImu/keywords.txt | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/libraries/CurieImu/keywords.txt b/libraries/CurieImu/keywords.txt index 58ef5c83..562bcc10 100644 --- a/libraries/CurieImu/keywords.txt +++ b/libraries/CurieImu/keywords.txt @@ -8,6 +8,8 @@ CurieImuClass KEYWORD1 BMI160Class KEYWORD1 +CurieImu KEYWORD1 +BMI160 KEYWORD1 ####################################### # Methods and Functions (KEYWORD2) @@ -195,6 +197,31 @@ resetInterrupt KEYWORD2 # Constants (LITERAL1) ####################################### +BMI160_GYRO_RANGE_2000 LITERAL1 +BMI160_GYRO_RANGE_1000 LITERAL1 +BMI160_GYRO_RANGE_500 LITERAL1 +BMI160_GYRO_RANGE_250 LITERAL1 +BMI160_GYRO_RANGE_125 LITERAL1 + +BMI160_ACCEL_RANGE_2G LITERAL1 +BMI160_ACCEL_RANGE_4G LITERAL1 +BMI160_ACCEL_RANGE_8G LITERAL1 +BMI160_ACCEL_RANGE_16G LITERAL1 + +BMI160_STEP_MODE_NORMAL LITERAL1 +BMI160_STEP_MODE_SENSITIVE LITERAL1 +BMI160_STEP_MODE_ROBUST LITERAL1 + +BMI160_DOUBLE_TAP_DURATION_50MS LITERAL1 +BMI160_DOUBLE_TAP_DURATION_100MS LITERAL1 +BMI160_DOUBLE_TAP_DURATION_150MS LITERAL1 +BMI160_DOUBLE_TAP_DURATION_200MS LITERAL1 +BMI160_DOUBLE_TAP_DURATION_250MS LITERAL1 +BMI160_DOUBLE_TAP_DURATION_375MS LITERAL1 +BMI160_DOUBLE_TAP_DURATION_500MS LITERAL1 +BMI160_DOUBLE_TAP_DURATION_700MS LITERAL1 + + BMI160_ZERO_MOTION_DURATION_1_28S LITERAL1 BMI160_ZERO_MOTION_DURATION_2_56S LITERAL1 BMI160_ZERO_MOTION_DURATION_3_84S LITERAL1 From f6c59c14f95772fa3d6de4b8dfdc697cf8867b0d Mon Sep 17 00:00:00 2001 From: Sandeep Mistry Date: Fri, 4 Dec 2015 11:53:02 -0500 Subject: [PATCH 4/4] Change CurieImu and BMI160 to KEYWORD2 --- libraries/CurieImu/keywords.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libraries/CurieImu/keywords.txt b/libraries/CurieImu/keywords.txt index 562bcc10..913434a1 100644 --- a/libraries/CurieImu/keywords.txt +++ b/libraries/CurieImu/keywords.txt @@ -8,8 +8,6 @@ CurieImuClass KEYWORD1 BMI160Class KEYWORD1 -CurieImu KEYWORD1 -BMI160 KEYWORD1 ####################################### # Methods and Functions (KEYWORD2) @@ -193,6 +191,13 @@ getInterruptLatch KEYWORD2 setInterruptLatch KEYWORD2 resetInterrupt KEYWORD2 +####################################### +# Instances (KEYWORD2) +####################################### + +CurieImu KEYWORD2 +BMI160 KEYWORD2 + ####################################### # Constants (LITERAL1) #######################################