From 010175d7b93ddfdff25ee37af42a1f3f17d31659 Mon Sep 17 00:00:00 2001 From: shrkey Date: Sun, 9 Oct 2016 18:51:41 +0100 Subject: [PATCH] remove unneeded --- examples/ADC/ADC.cpp | 51 ------- examples/ADC/Makefile | 9 -- examples/AHRS/AHRS.cpp | 190 ------------------------ examples/AHRS/AHRS.hpp | 243 ------------------------------- examples/AHRS/Makefile | 9 -- examples/Barometer/Barometer.cpp | 45 ------ examples/Barometer/Makefile | 9 -- examples/FRAM/Navio+/FRAM.cpp | 66 --------- examples/FRAM/Navio+/Makefile | 9 -- examples/FRAM/Navio/FRAM.cpp | 66 --------- examples/FRAM/Navio/Makefile | 9 -- examples/GPS/gps.cpp | 133 ----------------- examples/GPS/makefile | 22 --- examples/LED/LED.cpp | 86 ----------- examples/LED/Makefile | 9 -- 15 files changed, 956 deletions(-) delete mode 100644 examples/ADC/ADC.cpp delete mode 100644 examples/ADC/Makefile delete mode 100644 examples/AHRS/AHRS.cpp delete mode 100644 examples/AHRS/AHRS.hpp delete mode 100644 examples/AHRS/Makefile delete mode 100644 examples/Barometer/Barometer.cpp delete mode 100644 examples/Barometer/Makefile delete mode 100644 examples/FRAM/Navio+/FRAM.cpp delete mode 100644 examples/FRAM/Navio+/Makefile delete mode 100644 examples/FRAM/Navio/FRAM.cpp delete mode 100644 examples/FRAM/Navio/Makefile delete mode 100644 examples/GPS/gps.cpp delete mode 100644 examples/GPS/makefile delete mode 100644 examples/LED/LED.cpp delete mode 100644 examples/LED/Makefile diff --git a/examples/ADC/ADC.cpp b/examples/ADC/ADC.cpp deleted file mode 100644 index dd2902b..0000000 --- a/examples/ADC/ADC.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* -Provided to you by Emlid Ltd (c) 2014. -twitter.com/emlidtech || www.emlid.com || info@emlid.com - -Example: Control ADS1115 connected to PCA9685 driver onboard of Navio shield for Rapspberry Pi. - -Connect a wire to P1 and the ADC will measure its voltage and display it. -Be careful, do not connect high-voltage circuits, for acceptable range check the datasheet for ADS1115. - -To run this example navigate to the directory containing it and run following commands: -make -./ADC -*/ - -#include -#include - -#include "Navio/ADS1115.h" -#include "Navio/Util.h" - -int main() { - - ADS1115 adc; - - if (check_apm()) { - return 1; - } - - adc.setMode(ADS1115_MODE_SINGLESHOT); - adc.setRate(ADS1115_RATE_860); - - uint16_t muxes[] = {ADS1115_MUX_P0_NG, ADS1115_MUX_P1_NG, ADS1115_MUX_P2_NG, ADS1115_MUX_P3_NG}; - float results[ARRAY_SIZE(muxes)] = {0.0f}; - int i = 0; - - while (true) { - adc.setMultiplexer(muxes[i]); - - float conversion = adc.getMilliVolts(); - results[i] = conversion; - - i = (i + 1) % ARRAY_SIZE(muxes); - - for (int j = 0; j < ARRAY_SIZE(muxes); j++) { - printf("A%d: %.4fV ", j, results[j] / 1000); - } - printf("\n"); - } - - return 0; -} diff --git a/examples/ADC/Makefile b/examples/ADC/Makefile deleted file mode 100644 index 72f1cd8..0000000 --- a/examples/ADC/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -CC = g++ -NAVIO = ../../Navio -INCLUDES = -I ../.. - -all: - $(CC) $(INCLUDES) ADC.cpp $(NAVIO)/ADS1115.cpp $(NAVIO)/I2Cdev.cpp $(NAVIO)/Util.cpp -o ADC - -clean: - rm ADC diff --git a/examples/AHRS/AHRS.cpp b/examples/AHRS/AHRS.cpp deleted file mode 100644 index 85f7f7a..0000000 --- a/examples/AHRS/AHRS.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/* -This code is provided under the BSD license. -Copyright (c) 2014, Emlid Limited. All rights reserved. -Written by Igor Vereninov and Mikhail Avkhimenia -twitter.com/emlidtech || www.emlid.com || info@emlid.com - -Application: Mahory AHRS algorithm supplied with data from MPU9250. -Outputs roll, pitch and yaw in the console and sends quaternion -over the network - it can be used with 3D IMU visualizer located in -Navio/Applications/3D IMU visualizer. - -To run this app navigate to the directory containing it and run following commands: -make -sudo ./AHRS - -If you want to visualize IMU data on another machine pass it's address and port -sudo ./AHRS ipaddress portnumber - -To achieve stable loop you need to run this application with a high priority -on a linux kernel with real-time patch. Raspbian distribution with real-time -kernel is available at emlid.com and priority can be set with chrt command: -chrt -f -p 99 PID -*/ - -#include -#include -#include -#include -#include -#include -#include -#include "Navio/MPU9250.h" -#include "AHRS.hpp" -#include "Navio/Util.h" - -#define G_SI 9.80665 -#define PI 3.14159 - -// Objects - -MPU9250 imu; // MPU9250 -AHRS ahrs; // Mahony AHRS - -// Sensor data - -float ax, ay, az; -float gx, gy, gz; -float mx, my, mz; - -// Orientation data - -float roll, pitch, yaw; - -// Timing data - -float offset[3]; -struct timeval tv; -float dt, maxdt; -float mindt = 0.01; -unsigned long previoustime, currenttime; -float dtsumm = 0; -int isFirst = 1; - -// Network data - -int sockfd; -struct sockaddr_in servaddr = {0}; -char sendline[80]; - -//============================= Initial setup ================================= - -void imuSetup() -{ - //----------------------- MPU initialization ------------------------------ - - imu.initialize(); - - //------------------------------------------------------------------------- - - printf("Beginning Gyro calibration...\n"); - for(int i = 0; i<100; i++) - { - imu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); - gx *= 180 / PI; - gy *= 180 / PI; - gz *= 180 / PI; - offset[0] += (-gx*0.0175); - offset[1] += (-gy*0.0175); - offset[2] += (-gz*0.0175); - usleep(10000); - } - offset[0]/=100.0; - offset[1]/=100.0; - offset[2]/=100.0; - - printf("Offsets are: %f %f %f\n", offset[0], offset[1], offset[2]); - ahrs.setGyroOffset(offset[0], offset[1], offset[2]); -} - -//============================== Main loop ==================================== - -void imuLoop() -{ - //----------------------- Calculate delta time ---------------------------- - - gettimeofday(&tv,NULL); - previoustime = currenttime; - currenttime = 1000000 * tv.tv_sec + tv.tv_usec; - dt = (currenttime - previoustime) / 1000000.0; - if(dt < 1/1300.0) usleep((1/1300.0-dt)*1000000); - gettimeofday(&tv,NULL); - currenttime = 1000000 * tv.tv_sec + tv.tv_usec; - dt = (currenttime - previoustime) / 1000000.0; - - //-------- Read raw measurements from the MPU and update AHRS -------------- - - // Accel + gyro. - imu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); - ax /= G_SI; - ay /= G_SI; - az /= G_SI; - gx *= 180 / PI; - gy *= 180 / PI; - gz *= 180 / PI; - ahrs.updateIMU(ax, ay, az, gx*0.0175, gy*0.0175, gz*0.0175, dt); - - // Accel + gyro + mag. - // Soft and hard iron calibration required for proper function. - /* - imu.getMotion9(&ax, &ay, &az, &gx, &gy, &gz, &mx, &my, &mz); - ahrs.update(ax, ay, az, gx*0.0175, gy*0.0175, gz*0.0175, my, mx, -mz, dt); - */ - - //------------------------ Read Euler angles ------------------------------ - - ahrs.getEuler(&roll, &pitch, &yaw); - - //------------------- Discard the time of the first cycle ----------------- - - if (!isFirst) - { - if (dt > maxdt) maxdt = dt; - if (dt < mindt) mindt = dt; - } - isFirst = 0; - - //------------- Console and network output with a lowered rate ------------ - - dtsumm += dt; - if(dtsumm > 0.05) - { - // Console output - printf("ROLL: %+05.2f PITCH: %+05.2f YAW: %+05.2f PERIOD %.4fs RATE %dHz \n", roll, pitch, yaw * -1, dt, int(1/dt)); - - // Network output - sprintf(sendline,"%10f %10f %10f %10f %dHz\n", ahrs.getW(), ahrs.getX(), ahrs.getY(), ahrs.getZ(), int(1/dt)); - sendto(sockfd, sendline, strlen(sendline), 0, (struct sockaddr *)&servaddr, sizeof(servaddr)); - - dtsumm = 0; - } -} - -//============================================================================= - -int main(int argc, char *argv[]) -{ - if (check_apm()) { - return 1; - } - - //--------------------------- Network setup ------------------------------- - - sockfd = socket(AF_INET,SOCK_DGRAM,0); - servaddr.sin_family = AF_INET; - - if (argc == 3) { - servaddr.sin_addr.s_addr = inet_addr(argv[1]); - servaddr.sin_port = htons(atoi(argv[2])); - } else { - servaddr.sin_addr.s_addr = inet_addr("127.0.0.1"); - servaddr.sin_port = htons(7000); - } - - //-------------------- IMU setup and main loop ---------------------------- - - imuSetup(); - - while(1) - imuLoop(); -} diff --git a/examples/AHRS/AHRS.hpp b/examples/AHRS/AHRS.hpp deleted file mode 100644 index ae01288..0000000 --- a/examples/AHRS/AHRS.hpp +++ /dev/null @@ -1,243 +0,0 @@ -/* -Mahony AHRS algorithm implemented by Madgwick -See: http://www.x-io.co.uk/node/8#open_source_ahrs_and_imu_algorithms - -Adapted by Igor Vereninov (igor.vereninov@emlid.com) -Provided to you by Emlid Ltd (c) 2014. -twitter.com/emlidtech || www.emlid.com || info@emlid.com -*/ - -#ifndef AHRS_HPP -#define AHRS_HPP - -#include -#include - -class AHRS{ -private: - float q0, q1, q2, q3; - float gyroOffset[3]; - float twoKi; - float twoKp; - float integralFBx, integralFBy, integralFBz; -public: - AHRS(float q0 = 1, float q1 = 0, float q2 = 0, float q3 = 0) - : q0(q0), q1(q1), q2(q2), q3(q3), twoKi(0), twoKp(2) {;} - - void update(float ax, float ay, float az, float gx, float gy, float gz, float mx, float my, float mz, float dt) - { - float recipNorm; - float q0q0, q0q1, q0q2, q0q3, q1q1, q1q2, q1q3, q2q2, q2q3, q3q3; - float hx, hy, bx, bz; - float halfvx, halfvy, halfvz, halfwx, halfwy, halfwz; - float halfex, halfey, halfez; - float qa, qb, qc; - - // Use IMU algorithm if magnetometer measurement invalid (avoids NaN in magnetometer normalisation) - if((mx == 0.0f) && (my == 0.0f) && (mz == 0.0f)) { - updateIMU(gx, gy, gz, ax, ay, az, dt); - return; - } - - // Compute feedback only if accelerometer measurement valid (avoids NaN in accelerometer normalisation) - if(!((ax == 0.0f) && (ay == 0.0f) && (az == 0.0f))) { - - // Normalise accelerometer measurement - recipNorm = invSqrt(ax * ax + ay * ay + az * az); - ax *= recipNorm; - ay *= recipNorm; - az *= recipNorm; - - // Normalise magnetometer measurement - recipNorm = invSqrt(mx * mx + my * my + mz * mz); - mx *= recipNorm; - my *= recipNorm; - mz *= recipNorm; - - // Auxiliary variables to avoid repeated arithmetic - q0q0 = q0 * q0; - q0q1 = q0 * q1; - q0q2 = q0 * q2; - q0q3 = q0 * q3; - q1q1 = q1 * q1; - q1q2 = q1 * q2; - q1q3 = q1 * q3; - q2q2 = q2 * q2; - q2q3 = q2 * q3; - q3q3 = q3 * q3; - - // Reference direction of Earth's magnetic field - hx = 2.0f * (mx * (0.5f - q2q2 - q3q3) + my * (q1q2 - q0q3) + mz * (q1q3 + q0q2)); - hy = 2.0f * (mx * (q1q2 + q0q3) + my * (0.5f - q1q1 - q3q3) + mz * (q2q3 - q0q1)); - bx = sqrt(hx * hx + hy * hy); - bz = 2.0f * (mx * (q1q3 - q0q2) + my * (q2q3 + q0q1) + mz * (0.5f - q1q1 - q2q2)); - - // Estimated direction of gravity and magnetic field - halfvx = q1q3 - q0q2; - halfvy = q0q1 + q2q3; - halfvz = q0q0 - 0.5f + q3q3; - halfwx = bx * (0.5f - q2q2 - q3q3) + bz * (q1q3 - q0q2); - halfwy = bx * (q1q2 - q0q3) + bz * (q0q1 + q2q3); - halfwz = bx * (q0q2 + q1q3) + bz * (0.5f - q1q1 - q2q2); - - // Error is sum of cross product between estimated direction and measured direction of field vectors - halfex = (ay * halfvz - az * halfvy) + (my * halfwz - mz * halfwy); - halfey = (az * halfvx - ax * halfvz) + (mz * halfwx - mx * halfwz); - halfez = (ax * halfvy - ay * halfvx) + (mx * halfwy - my * halfwx); - - // Compute and apply integral feedback if enabled - if(twoKi > 0.0f) { - integralFBx += twoKi * halfex * dt; // integral error scaled by Ki - integralFBy += twoKi * halfey * dt; - integralFBz += twoKi * halfez * dt; - gx += integralFBx; // apply integral feedback - gy += integralFBy; - gz += integralFBz; - } - else { - integralFBx = 0.0f; // prevent integral windup - integralFBy = 0.0f; - integralFBz = 0.0f; - } - - // Apply proportional feedback - gx += twoKp * halfex; - gy += twoKp * halfey; - gz += twoKp * halfez; - } - - // Integrate rate of change of quaternion - gx *= (0.5f * dt); // pre-multiply common factors - gy *= (0.5f * dt); - gz *= (0.5f * dt); - qa = q0; - qb = q1; - qc = q2; - q0 += (-qb * gx - qc * gy - q3 * gz); - q1 += (qa * gx + qc * gz - q3 * gy); - q2 += (qa * gy - qb * gz + q3 * gx); - q3 += (qa * gz + qb * gy - qc * gx); - - // Normalise quaternion - recipNorm = invSqrt(q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3); - q0 *= recipNorm; - q1 *= recipNorm; - q2 *= recipNorm; - q3 *= recipNorm; - } - - void updateIMU(float ax, float ay, float az, float gx, float gy, float gz, float dt) - { - float recipNorm; - float halfvx, halfvy, halfvz; - float halfex, halfey, halfez; - float qa, qb, qc; - - gx -= gyroOffset[0]; - gy -= gyroOffset[1]; - gz -= gyroOffset[2]; - - // Compute feedback only if accelerometer measurement valid (avoids NaN in accelerometer normalisation) - if(!((ax == 0.0f) && (ay == 0.0f) && (az == 0.0f))) { - - // Normalise accelerometer measurement - recipNorm = invSqrt(ax * ax + ay * ay + az * az); - ax *= recipNorm; - ay *= recipNorm; - az *= recipNorm; - - // Estimated direction of gravity and vector perpendicular to magnetic flux - halfvx = q1 * q3 - q0 * q2; - halfvy = q0 * q1 + q2 * q3; - halfvz = q0 * q0 - 0.5f + q3 * q3; - - // Error is sum of cross product between estimated and measured direction of gravity - halfex = (ay * halfvz - az * halfvy); - halfey = (az * halfvx - ax * halfvz); - halfez = (ax * halfvy - ay * halfvx); - - // Compute and apply integral feedback if enabled - if(twoKi > 0.0f) { - integralFBx += twoKi * halfex * dt; // integral error scaled by Ki - integralFBy += twoKi * halfey * dt; - integralFBz += twoKi * halfez * dt; - gx += integralFBx; // apply integral feedback - gy += integralFBy; - gz += integralFBz; - } - else { - integralFBx = 0.0f; // prevent integral windup - integralFBy = 0.0f; - integralFBz = 0.0f; - } - - // Apply proportional feedback - gx += twoKp * halfex; - gy += twoKp * halfey; - gz += twoKp * halfez; - } - - // Integrate rate of change of quaternion - gx *= (0.5f * dt); // pre-multiply common factors - gy *= (0.5f * dt); - gz *= (0.5f * dt); - qa = q0; - qb = q1; - qc = q2; - q0 += (-qb * gx - qc * gy - q3 * gz); - q1 += (qa * gx + qc * gz - q3 * gy); - q2 += (qa * gy - qb * gz + q3 * gx); - q3 += (qa * gz + qb * gy - qc * gx); - - // Normalise quaternion - recipNorm = invSqrt(q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3); - q0 *= recipNorm; - q1 *= recipNorm; - q2 *= recipNorm; - q3 *= recipNorm; - } - - void setGyroOffset(float offsetX, float offsetY, float offsetZ) - { - gyroOffset[0] = offsetX; - gyroOffset[1] = offsetY; - gyroOffset[2] = offsetZ; - } - - void getEuler(float* roll, float* pitch, float* yaw) - { - *roll = atan2(2*(q0*q1+q2*q3), 1-2*(q1*q1+q2*q2)) * 180.0/M_PI; - *pitch = asin(2*(q0*q2-q3*q1)) * 180.0/M_PI; - *yaw = atan2(2*(q0*q3+q1*q2), 1-2*(q2*q2+q3*q3)) * 180.0/M_PI; - } - - float invSqrt(float x) - { - float halfx = 0.5f * x; - float y = x; - long i = *(long*)&y; - i = 0x5f3759df - (i>>1); - y = *(float*)&i; - y = y * (1.5f - (halfx * y * y)); - return y; - } - float getW() - { - return q0; - } - float getX() - { - return q1; - } - float getY() - { - return q2; - } - float getZ() - { - return q3; - } - -}; - -#endif // AHRS_hpp diff --git a/examples/AHRS/Makefile b/examples/AHRS/Makefile deleted file mode 100644 index ecb9198..0000000 --- a/examples/AHRS/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -CC = g++ -NAVIO = ../../Navio -INCLUDES = -I ../.. - -all: - $(CC) $(INCLUDES) AHRS.cpp $(NAVIO)/MPU9250.cpp $(NAVIO)/Util.cpp -o AHRS -lrt -lpthread - -clean: - rm AHRS diff --git a/examples/Barometer/Barometer.cpp b/examples/Barometer/Barometer.cpp deleted file mode 100644 index 3ac5f8b..0000000 --- a/examples/Barometer/Barometer.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* -Provided to you by Emlid Ltd (c) 2014. -twitter.com/emlidtech || www.emlid.com || info@emlid.com - -Example: Get pressure from MS5611 barometer onboard of Navio shield for Raspberry Pi - -To run this example navigate to the directory containing it and run following commands: -make -./Barometer -*/ - -#include "Navio/MS5611.h" -#include "Navio/Util.h" -#include -#include - -int main() -{ - MS5611 barometer; - - if (check_apm()) { - return 1; - } - - barometer.initialize(); - - while (true) { - barometer.refreshPressure(); - usleep(10000); // Waiting for pressure data ready - barometer.readPressure(); - - barometer.refreshTemperature(); - usleep(10000); // Waiting for temperature data ready - barometer.readTemperature(); - - barometer.calculatePressureAndTemperature(); - - printf("Temperature(C): %f Pressure(millibar): %f\n", - barometer.getTemperature(), barometer.getPressure()); - - sleep(1); - } - - return 0; -} diff --git a/examples/Barometer/Makefile b/examples/Barometer/Makefile deleted file mode 100644 index b6aca17..0000000 --- a/examples/Barometer/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -CC = g++ -NAVIO = ../../Navio -INCLUDES = -I ../.. - -all: - $(CC) $(INCLUDES) Barometer.cpp $(NAVIO)/MS5611.cpp $(NAVIO)/I2Cdev.cpp $(NAVIO)/Util.cpp -o Barometer - -clean: - rm Barometer diff --git a/examples/FRAM/Navio+/FRAM.cpp b/examples/FRAM/Navio+/FRAM.cpp deleted file mode 100644 index 6d5a833..0000000 --- a/examples/FRAM/Navio+/FRAM.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include -#include "Navio/I2Cdev.h" -#include "Navio/MB85RC256.h" -#include "Navio/Util.h" - -// 32768 bytes >> 0x8000 >> 15 bit address - -int main() -{ - - uint8_t dev_address = 0b1010000; - uint16_t reg_address = 0; - uint8_t data = 0xCC; - bool flag = true; - - if (check_apm()) { - return 1; - } - - printf("Fram memory Write/Read test!\nWe will write value 0xCC to the address 0 of fram memory, and then read it:\n"); - - MB85RC256 fram; - - printf("Writing data...\n"); - - fram.writeByte(reg_address, data); - - data = 0x00; - - printf("Reading data...\n"); - - fram.readByte(reg_address, &data); - - printf("Data, read from address 0 is %x\n", data); - - if (data != 0xCC) flag = false; - - // multiple write and read functionality test - - printf("Multiple read/write functionality test!\nWe will write values 0xAA, 0xBB, 0xCC to the addresses 0, 1, 2 of the fram memory \nand then read it:\n"); - - uint8_t a[3] = {0xAA, 0xBB, 0xCC}; - - printf("Writing data...\n"); - - fram.writeBytes(reg_address, 3, a); - - for (int i=0; i<3; i++) a[i] = 0; - - printf("Reading data...\n"); - - fram.readBytes(reg_address, 3, a); - - printf("Data, read from the addresses 0, 1, 2:\n%x %x %x\n", a[0], a[1], a[2]); - - if ((a[0] != 0xAA) || (a[1] != 0xBB) || (a[2] != 0xCC)) flag = false; - - if (flag == true) { - printf("Memory test passed succesfully\n"); - } else { - printf("Memory test not passed\n"); - } - - return 0; -} diff --git a/examples/FRAM/Navio+/Makefile b/examples/FRAM/Navio+/Makefile deleted file mode 100644 index 880f071..0000000 --- a/examples/FRAM/Navio+/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -CC = g++ -NAVIO = ../../../Navio -INCLUDES = -I ../../.. - -all: - $(CC) $(INCLUDES) FRAM.cpp $(NAVIO)/MB85RC256.cpp $(NAVIO)/I2Cdev.cpp $(NAVIO)/Util.cpp -o FRAM - -clean: - rm FRAM diff --git a/examples/FRAM/Navio/FRAM.cpp b/examples/FRAM/Navio/FRAM.cpp deleted file mode 100644 index 05708a0..0000000 --- a/examples/FRAM/Navio/FRAM.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include -#include "Navio/I2Cdev.h" -#include "Navio/MB85RC04.h" -#include "Navio/Util.h" - -// 512 bytes >> 0b1000000000 max >> 9 bit address - -int main() -{ - - uint8_t dev_address = 0b1010000; - uint16_t reg_address = 0; - uint8_t data = 0xCC; - bool flag = true; - - if (check_apm()) { - return 1; - } - - printf("Fram memory Write/Read test!\nWe will write value 0xCC to the address 0 of fram memory, and then read it:\n"); - - MB85RC04 fram; - - printf("Writing data...\n"); - - fram.writeByte(reg_address, data); - - data = 0x00; - - printf("Reading data...\n"); - - fram.readByte(reg_address, &data); - - printf("Data, read from address 0 is %x\n", data); - - if (data != 0xCC) flag = false; - - // multiple write and read functionality test - - printf("Multiple read/write functionality test!\nWe will write values 0xAA, 0xBB, 0xCC to the addresses 0, 1, 2 of the fram memory \nand then read it:\n"); - - uint8_t a[3] = {0xAA, 0xBB, 0xCC}; - - printf("Writing data...\n"); - - fram.writeBytes(reg_address, 3, a); - - for (int i=0; i<3; i++) a[i] = 0; - - printf("Reading data...\n"); - - fram.readBytes(reg_address, 3, a); - - printf("Data, read from the addresses 0, 1, 2:\n%x %x %x\n", a[0], a[1], a[2]); - - if ((a[0] != 0xAA) || (a[1] != 0xBB) || (a[2] != 0xCC)) flag = false; - - if (flag == true) { - printf("Memory test passed succesfully\n"); - } else { - printf("Memory test not passed\n"); - } - - return 0; -} diff --git a/examples/FRAM/Navio/Makefile b/examples/FRAM/Navio/Makefile deleted file mode 100644 index 07fa3a7..0000000 --- a/examples/FRAM/Navio/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -CC = g++ -NAVIO = ../../../Navio -INCLUDES = -I ../../.. - -all: - $(CC) $(INCLUDES) FRAM.cpp $(NAVIO)/MB85RC04.cpp $(NAVIO)/I2Cdev.cpp $(NAVIO)/Util.cpp -o FRAM - -clean: - rm FRAM diff --git a/examples/GPS/gps.cpp b/examples/GPS/gps.cpp deleted file mode 100644 index 424fdbe..0000000 --- a/examples/GPS/gps.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* -Provided to you by Emlid Ltd (c) 2014. -twitter.com/emlidtech || www.emlid.com || info@emlid.com - -Example: Receive position information with GPS driver onboard of Navio shield for Raspberry Pi. - -Ublox GPS receiver is connected as an SPI device 0.0(/dev/spidev0.0). -The receiver sends information over SPI in an endless stream, -this program is intended to show, how to capture ubx protocol messages -from the stream and extract useful information from them. - -To run this example navigate to the directory containing it and run following commands: -make -./ublox -*/ - -//#define _XOPEN_SOURCE 600 -#include "Navio/Ublox.h" -#include "Navio/Util.h" - -using namespace std; - -int main(int argc, char *argv[]){ - - // This vector is used to store location data, decoded from ubx messages. - // After you decode at least one message successfully, the information is stored in vector - // in a way described in function decodeMessage(vector& data) of class UBXParser(see ublox.h) - - std::vector pos_data; - - - // create ublox class instance - Ublox gps; - - // check if APM is launched - if (check_apm()) { - return 1; - } - - // Here we test connection with the receiver. Function testConnection() waits for a ubx protocol message and checks it. - // If there's at least one correct message in the first 300 symbols the test is passed - if(gps.testConnection()) - { - printf("Ublox test OK\n"); - - // gps.decodeMessages(); - // You can use this function to decode all messages, incoming from the GPS receiver. The function starts an infinite loop. - // In this example we can only decode NAV-POSLLH messages, the others are simply ignored. - // You can add new message types in function decodeMessage() of class UBXParser(see ublox.h) - - - // Here, however we use a different approach. Instead of trying to extract info from every message(as done in decodeMessages()), - // this function waits for a message of a specified type and gets you just the information you need - // In this example we decode NAV-POSLLH messages, adding new types, however is quite easy - - while (true) - { - - if (gps.decodeSingleMessage(Ublox::NAV_POSLLH, pos_data) == 1) - { - // after desired message is successfully decoded, we can use the information stored in pos_data vector - // right here, or we can do something with it from inside decodeSingleMessage() function(see ublox.h). - // the way, data is stored in pos_data vector is specified in decodeMessage() function of class UBXParser(see ublox.h) - printf("GPS Millisecond Time of Week: %.0lf s\n", pos_data[0]/1000); - printf("Longitude: %lf\n", pos_data[1]/10000000); - printf("Latitude: %lf\n", pos_data[2]/10000000); - printf("Height above Ellipsoid: %.3lf m\n", pos_data[3]/1000); - printf("Height above mean sea level: %.3lf m\n", pos_data[4]/1000); - printf("Horizontal Accuracy Estateimate: %.3lf m\n", pos_data[5]/1000); - printf("Vertical Accuracy Estateimate: %.3lf m\n", pos_data[6]/1000); - - } else { - // printf("Message not captured\n"); - // use this to see, how often you get the right messages - // to increase the frequency you can turn off the undesired messages or tweak ublox settings - // to increase internal receiver frequency - } - - if (gps.decodeSingleMessage(Ublox::NAV_STATUS, pos_data) == 1) - { - printf("Current GPS status:\n"); - printf("gpsFixOk: %d\n", ((int)pos_data[1] & 0x01)); - - printf("gps Fix status: "); - switch((int)pos_data[0]){ - case 0x00: - printf("no fix\n"); - break; - - case 0x01: - printf("dead reckoning only\n"); - break; - - case 0x02: - printf("2D-fix\n"); - break; - - case 0x03: - printf("3D-fix\n"); - break; - - case 0x04: - printf("GPS + dead reckoning combined\n"); - break; - - case 0x05: - printf("Time only fix\n"); - break; - - default: - printf("Reserved value. Current state unknown\n"); - break; - - } - - printf("\n"); - - } else { - // printf("Status Message not captured\n"); - } - - - usleep(200); - } - - } else { - - printf("Ublox test not passed\nAbort program!\n"); - - } - - return 0; -} diff --git a/examples/GPS/makefile b/examples/GPS/makefile deleted file mode 100644 index c405026..0000000 --- a/examples/GPS/makefile +++ /dev/null @@ -1,22 +0,0 @@ -CC=g++ -CFLAGS=-c -Wall -NAVIO = ../../Navio -INCLUDES = -I ../.. - -all: gps - -gps: gps.o Ublox.o Util.o - $(CC) gps.o Ublox.o Util.o -o gps - rm -rf *.o - -gps.o: gps.cpp - $(CC) $(INCLUDES) $(CFLAGS) gps.cpp - -Ublox.o: $(NAVIO)/Ublox.cpp - $(CC) $(INCLUDES) $(CFLAGS) $(NAVIO)/Ublox.cpp - -Util.o: $(NAVIO)/Util.cpp - $(CC) $(INCLUDES) $(CFLAGS) $(NAVIO)/Util.cpp - -clean: - rm -rf *.o gps diff --git a/examples/LED/LED.cpp b/examples/LED/LED.cpp deleted file mode 100644 index 6df8965..0000000 --- a/examples/LED/LED.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* -Provided to you by Emlid Ltd (c) 2014. -twitter.com/emlidtech || www.emlid.com || info@emlid.com - -Example: Control RGB LED with PCA9685 driver onboard of Navio shield for Raspberry Pi. - -RGB LED is connected to 0,1,2 channels of PWM controller PCA9685. -As channels are connected to LED's cathodes the logic is inverted, -that means that 0 value sets max brightness and 4095 sets min brightness. - -To run this example navigate to the directory containing it and run following commands: -make -./LED -*/ - -#include -#include "Navio/Util.h" -#include "Navio/PCA9685.h" - -using namespace Navio; - -int main() -{ - static const uint8_t outputEnablePin = RPI_GPIO_27; - - if (check_apm()) { - return 1; - } - - Pin pin(outputEnablePin); - - if (pin.init()) { - pin.setMode(Pin::GpioModeOutput); - pin.write(0); /* drive Output Enable low */ - } else { - fprintf(stderr, "Output Enable not set. Are you root?\n"); - return 1; - } - - PCA9685 pwm; - - pwm.initialize(); - - uint16_t R = 0, G = 0, B = 4095; - - pwm.setPWM(2, R); - pwm.setPWM(1, G); - pwm.setPWM(0, B); - printf("LED is yellow\n"); - sleep(1); - - while (true) { - for (R = 0; R < 4095; R++) - pwm.setPWM(2, R); - printf("LED is green\n"); - sleep(1); - - for (B = 4095; B > 0; B--) - pwm.setPWM(0, B); - printf("LED is cyan\n"); - sleep(1); - - for (G = 0; G < 4095; G++) - pwm.setPWM(1, G); - printf("LED is blue\n"); - sleep(1); - - for (R = 4095; R > 0; R--) - pwm.setPWM(2, R); - printf("LED is magneta\n"); - sleep(1); - - for (B = 0; B < 4095; B++) - pwm.setPWM(0, B); - printf("LED is red\n"); - sleep(1); - - for (G = 4095; G > 0; G--) - pwm.setPWM(1, G); - printf("LED is yellow\n"); - sleep(1); - - } - - return 0; -} diff --git a/examples/LED/Makefile b/examples/LED/Makefile deleted file mode 100644 index 5b05a49..0000000 --- a/examples/LED/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -CC = g++ -NAVIO = ../../Navio -INCLUDES = -I ../.. - -all: - $(CC) $(INCLUDES) LED.cpp $(NAVIO)/PCA9685.cpp $(NAVIO)/I2Cdev.cpp $(NAVIO)/gpio.cpp $(NAVIO)/Util.cpp -o LED - -clean: - rm LED