fixes Makefile

This commit is contained in:
Brendan Haines 2015-02-12 15:16:53 -07:00
parent 0b82600552
commit c99551a422
3 changed files with 18 additions and 15 deletions

View File

@ -1,12 +1,13 @@
all: pid.o I2Cdev.o MPU6050.o PCA9685.o PCA9685tester pidTest MPU6050dmp_tester all: pid.o I2Cdev.o MPU6050.o PCA9685.o PCA9685tester pidTest
#pidTest MPU6050dmp_tester PCA9685tester
HDRS = pid.h helper_3dmath.h I2Cdev.h MPU6050_6Axis_MotionApps20.h MPU6050.h PCA9685.h PCA9685_Addresses.h HDRS = pid.h helper_3dmath.h I2Cdev.h MPU6050_6Axis_MotionApps20.h MPU6050.h PCA9685.h PCA9685_Addresses.h
CXXFLAGS = -DDMP_FIFO_RATE=9 -Wall -lwiringPi CXXFLAGS = -DDMP_FIFO_RATE=9 -Wall -lwiringPi
pid.o pidTest.o I2Cdev.o MPU6050.o MPU6050dmp_tester.o PCA9685.o PCA9685tester.o: $(HDRS) pid.o pidTest.o I2Cdev.o MPU6050.o MPU6050dmp_tester.o PCA9685.o PCA9685tester.o: $(HDRS)
pidTest: pidTest.o pid.o pidTest: pidTest.o pid.o PCA9685.o I2Cdev.o MPU6050.o
$(CXX) $^ -o $@ $(CXX) $^ -lwiringPi -o $@
MPU6050dmp_tester: I2Cdev.o MPU6050.o MPU6050dmp_tester.o MPU6050dmp_tester: I2Cdev.o MPU6050.o MPU6050dmp_tester.o
$(CXX) $^ -lm `pkg-config gtkmm-3.0 --cflags --libs` -lwiringPi -o $@ $(CXX) $^ -lm `pkg-config gtkmm-3.0 --cflags --libs` -lwiringPi -o $@
@ -15,4 +16,4 @@ PCA9685tester: PCA9685.o PCA9685tester.o
$(CXX) $^ -lwiringPi -o $@ $(CXX) $^ -lwiringPi -o $@
clean: clean:
rm I2Cdev.o MPU6050.o MPU6050dmp.o MPU6050dmp_tester.o MPU6050dmp_tester pid.o pidTest.o pidTest rm I2Cdev.o MPU6050.o MPU6050dmp.o MPU6050dmp_tester.o MPU6050dmp_tester pid.o pidTest.o pidTest PCA9685tester

View File

@ -32,6 +32,8 @@ THE SOFTWARE.
#ifndef _HELPER_3DMATH_H_ #ifndef _HELPER_3DMATH_H_
#define _HELPER_3DMATH_H_ #define _HELPER_3DMATH_H_
#include "math.h"
class Quaternion { class Quaternion {
public: public:
float w; float w;

View File

@ -1,4 +1,5 @@
#include <iostream> #include <iostream>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
@ -28,15 +29,15 @@ MPU6050 mpu;
#define SERVO_FREQ 60 #define SERVO_FREQ 60
PCA9685 servo; PCA9685 servo;
void setupTCP( portno ) void setupTCP( int portno )
{ {
struct sockaddr_in serv_addr, cli_addr; struct sockaddr_in serv_addr, cli_addr;
socklen_t clilen; socklen_t clilen;
std::cout << "setting up TCP on port " << portno << std::endl; std::cout << "setting up TCP on port " << portno << std::endl;
sockfd = socket( AF_INET, SOCKET_STREAM, 0 ); sockfd = socket( AF_INET, SOCK_STREAM, 0 );
if( sockfd < 0 ) if( sockfd < 0 )
cerror << "ERROR opening socket" << std::endl; std::cerr << "ERROR opening socket" << std::endl;
bzero( (char*) &serv_addr, sizeof(serv_addr) ); bzero( (char*) &serv_addr, sizeof(serv_addr) );
serv_addr.sin_family = AF_INET; serv_addr.sin_family = AF_INET;
@ -45,7 +46,7 @@ void setupTCP( portno )
std::cout << "binding socket to portno" << std::endl; std::cout << "binding socket to portno" << std::endl;
if( bind( sockfd, (struct sockaddr*) &serv_addr, sizeof(serv_addr) ) ) if( bind( sockfd, (struct sockaddr*) &serv_addr, sizeof(serv_addr) ) )
cerror << "ERROR binding socket to portno" << std::endl; std::cerr << "ERROR binding socket to portno" << std::endl;
std::cout << "listening to socket" << std::endl; std::cout << "listening to socket" << std::endl;
listen( sockfd, 5 ); listen( sockfd, 5 );
@ -54,11 +55,11 @@ void setupTCP( portno )
std::cout << "waiting for connection..." << std::endl; std::cout << "waiting for connection..." << std::endl;
newsockfd = accept( sockfd, (struct sockaddr *) &cli_addr, &clilen ); newsockfd = accept( sockfd, (struct sockaddr *) &cli_addr, &clilen );
if( newsockfd < 0 ) if( newsockfd < 0 )
cerror << "ERROR on accept" << std::endl; std::cerr << "ERROR on accept" << std::endl;
std::cout << "connection established" << std::endl; std::cout << "connection established" << std::endl;
bzero( buffer, 256 ); bzero( buffer, 256 );
fcntl( newsockfd, F_SETFL, 0_NONBLOCK ); fcntl( newsockfd, F_SETFL, O_NONBLOCK );
} }
void setupPCA() void setupPCA()
@ -90,7 +91,7 @@ int setupMPU()
} }
else else
{ {
cerror << "MPU6050 connection failed" << std::endl; std::cerr << "MPU6050 connection failed" << std::endl;
return -1; return -1;
} }
@ -107,7 +108,7 @@ int setupMPU()
} }
else else
{ {
cerror << "DMP initialization failed" << std::endl; std::cerr << "DMP initialization failed" << std::endl;
return -1; return -1;
} }
return 0; return 0;
@ -143,14 +144,13 @@ void loop()
close( newsockfd ); close( newsockfd );
close( sockfd ); close( sockfd );
exit;
} }
} }
fifoCount = mpu.getFIFOCount(); fifoCount = mpu.getFIFOCount();
if( fifoCount == 1024) if( fifoCount == 1024)
{ {
cerror << "FIFO overflow" << std::endl; std::cerr << "FIFO overflow" << std::endl;
} }
if( fifoCount >= 42 ) if( fifoCount >= 42 )
{ {
@ -167,7 +167,7 @@ void loop()
int main( int argc, char* argv[] ) int main( int argc, char* argv[] )
{ {
setup(); setup();
while true while( true )
{ {
loop(); loop();
} }