Use hexiwear as a GPSIMU-AHRS for Nikon DSLR cameras
Dependencies: FXOS8700CQ FXAS21000 MBed_Adafruit-GPS-Library Hexi_OLED_SSD1351 Hexi_KW40Z Madgwick
Fork of Hexi_Blinky_Example by
Revision 15:b5a3e22d706b, committed 2016-08-15
- Comitter:
- whatnick
- Date:
- Mon Aug 15 06:42:19 2016 +0000
- Parent:
- 14:9885c8536437
- Child:
- 16:2e42284011d9
- Commit message:
- Added GPS and OLED libraries
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FXAS21000.lib Mon Aug 15 06:42:19 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/JimCarver/code/FXAS21000/#a8f83b52f4df
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MBed_Adafruit-GPS-Library.lib Mon Aug 15 06:42:19 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/whatnick/code/MBed_Adafruit-GPS-Library/#857102793de1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NeatGUI.lib Mon Aug 15 06:42:19 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/neilt6/code/NeatGUI/#a8f72d4864e6
--- a/main.cpp Sat Aug 13 23:08:18 2016 +0000
+++ b/main.cpp Mon Aug 15 06:42:19 2016 +0000
@@ -1,10 +1,15 @@
#include "mbed.h"
#include "FXOS8700Q.h"
+#include "FXAS21000.h"
+#include "MBed_Adafruit_GPS.h"
+#include "NeatGUI.h"
DigitalOut myled(LED3);
Serial gps(PTD3,PTD2);
Serial pc(USBTX, USBRX);
+SSD1351_SPI OLED128(PTB22,PTB23,PTB21,PTB20,PTD15); //Hexiwear pins for SPI bus OLED (MOSI, MISO, SCK, CS, DC)
+
FXOS8700Q_acc acc( PTC11, PTC10, FXOS8700CQ_SLAVE_ADDR0); // Proper Ports and I2C Address for Hexiwear
FXOS8700Q_mag mag( PTC11, PTC10, FXOS8700CQ_SLAVE_ADDR0); // Proper Ports and I2C Address for Hexiwear
MotionSensorDataUnits mag_data;
@@ -13,18 +18,49 @@
MotionSensorDataCounts mag_raw;
MotionSensorDataCounts acc_raw;
+FXAS21000 gyro( PTC11, PTC10); // Proper Ports for Hexiwear
+
int main() {
float faX, faY, faZ;
float fmX, fmY, fmZ;
int16_t raX, raY, raZ;
int16_t rmX, rmY, rmZ;
+float gyro_data[3];
+
+Adafruit_GPS myGPS(&gps);
+char c; //when read via Adafruit_GPS::read(), the class returns single character stored here
+myGPS.begin(115200);
+//Turn off all sentences except GGA and RMC
+//For MTK GPS
+myGPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
+
+//FOR UBLOX GPS
+myGPS.sendCommand(UBX_DISABLE_ZDA);
+myGPS.sendCommand(UBX_DISABLE_GLL);
+myGPS.sendCommand(UBX_DISABLE_VTG);
+myGPS.sendCommand(UBX_DISABLE_GSV);
+myGPS.sendCommand(UBX_DISABLE_GSA);
+
+
+
+pc.baud(115200);
+
acc.enable();
pc.printf("\r\n\nFXOS8700Q Who Am I= %X\r\n", acc.whoAmI());
+pc.printf("\r\n\nFXAS21000 Who Am I= %X\r\n", gyro.getWhoAmI());
+
+OLED128.open();
+OLED128.state(Display::DISPLAY_ON);
+OLED128.drawCircle(10,10,5,0xff345463);
+OLED128.flush();
+
while (true) {
acc.getAxis(acc_data);
mag.getAxis(mag_data);
+ gyro.ReadXYZ(gyro_data);
pc.printf("FXOS8700Q ACC: X=%1.4f Y=%1.4f Z=%1.4f ", acc_data.x, acc_data.y, acc_data.z);
pc.printf(" MAG: X=%4.1f Y=%4.1f Z=%4.1f\r\n", mag_data.x, mag_data.y, mag_data.z);
+ pc.printf("FXAS21000 X=%4.2f Y=%4.2f Z=%4.1f\r\n", gyro_data[0], gyro_data[1], gyro_data[2]);
acc.getX(&faX);
acc.getY(&faY);
acc.getZ(&faZ);
@@ -44,7 +80,24 @@
mag.getY(&rmY);
mag.getZ(&rmZ);
pc.printf("FXOS8700Q ACC: X=%d Y=%d Z=%d ", raX, raY, raZ);
- pc.printf(" MAG: X=%d Y=%d Z=%d\r\n\n", rmX, rmY, rmZ);
- wait(1.0);
+ pc.printf(" MAG: X=%d Y=%d Z=%d\r\n\n", rmX, rmY, rmZ);
+
+ while(gps.readable())
+ {
+ c = myGPS.read(); //queries the GPS
+
+ if (c) {
+ pc.printf("%c", c); //this line will echo the GPS data if not paused
+ }
+ }
+
+ //check if we recieved a new message from GPS, if so, attempt to parse it,
+ if ( myGPS.newNMEAreceived() ) {
+ if ( !myGPS.parse(myGPS.lastNMEA()) ) {
+ continue;
+ }
+ }
+
+ wait(0.1);
}
}
