library for m3Dpi robot, based on the Pololu 3pi and m3pi. m3Dpi has multiple distance sensors, gyroscope, compass and accelerometer sensor to be fully aware of its environment. With the addition of xbee or nrf24n01 module it has wireless communication capabilities.
Dependencies: m3pi ADXL345_I2C HMC5583L ITG3200 PCA9547 TLC59116 VL6180x RGB-fun xbee
Diff: M3Dpi.cpp
- Revision:
- 4:b2fe3a2545bf
- Parent:
- 0:9f02ae958e20
- Child:
- 6:b60a3c005d3c
- Child:
- 10:4200a8140b10
--- a/M3Dpi.cpp Thu Dec 03 08:19:42 2015 +0000 +++ b/M3Dpi.cpp Thu Dec 03 16:34:59 2015 +0000 @@ -45,37 +45,40 @@ leds.setAll(colors); } -int* M3Dpi::getDistance(int data[]) +m3dpi::Distance M3Dpi::getDistance() { - return distance.getAllDistance(data);; + return distance.getAllDistance(); } -int* M3Dpi::getDirection(int data[]) +m3dpi::Direction M3Dpi::getDirection() { + m3dpi::Direction direction; coord c; c = compass.getCompass(); - data[0] = c.x; - data[1] = c.y; - data[2] = c.z; - return data; + direction.x = c.x; + direction.y = c.y; + direction.z = c.z; + return direction; } -int* M3Dpi::getRotation(int data[]) +m3dpi::Rotation M3Dpi::getRotation() { - data[0] = gyro.getGyroX(); - data[1] = gyro.getGyroY(); - data[2] = gyro.getGyroZ(); - return data; + m3dpi::Rotation rotation; + rotation.x = gyro.getGyroX(); + rotation.y = gyro.getGyroY(); + rotation.z = gyro.getGyroZ(); + return rotation; } -int* M3Dpi::getAcceleration(int data[]) +m3dpi::Acceleration M3Dpi::getAcceleration() { + m3dpi::Acceleration acc; int values[3] = {0}; accelerometer.getOutput(values); - data[0] = (int16_t) values[0]; - data[1] = (int16_t) values[1]; - data[2] = (int16_t) values[2]; - return data; + acc.x = (int16_t) values[0]; + acc.y = (int16_t) values[1]; + acc.z = (int16_t) values[2]; + return acc; } int M3Dpi::_putc(int c) @@ -88,9 +91,7 @@ return xbee.getc(); } -char* M3Dpi::getTime(char buffer[]) +time_t M3Dpi::getTime() { - time_t seconds = time(NULL); - strftime(buffer, 32, "%d-%m-%Y %T", localtime(&seconds)); - return buffer; + return time(NULL); } \ No newline at end of file