mirror of
https://github.com/cosmic-pi-deprecated/cosmicpi-arduino_V1.6.git
synced 2026-05-12 16:09:25 +00:00
Compiles, but doesn't run. Left to do: Fix serial output Verify GPS Verify ADC + HV settings Swap accelerometer library Sort out timers (software for now) Confirm serial output format.
50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
#ifndef __SENSORS__
|
|
#define __SENSORS__
|
|
|
|
#include <Arduino.h>
|
|
#include "asyncSerial.h"
|
|
// LPS lib from here: https://github.com/pololu/lps-arduino
|
|
#include "src/LPS.h"
|
|
// LSM303 lib from here: https://github.com/pololu/lsm303-arduino
|
|
#include "src/LSM303.h"
|
|
// HTU21D lib from here: https://github.com/sparkfun/SparkFun_HTU21D_Breakout_Arduino_Library
|
|
#include "src/SparkFunHTU21D.h"
|
|
|
|
class Sensors {
|
|
// object for the pressure sensor
|
|
LPS baro;
|
|
// object for the accel and magnetometer
|
|
LSM303 accelMagneto;
|
|
// object for humidity sensor
|
|
HTU21D humidity;
|
|
|
|
// vars for checking if a sensor initilized correctly
|
|
bool baroOK;
|
|
bool accelMagnetoOK;
|
|
bool humidOK;
|
|
|
|
// cute class for printing and the needed char array
|
|
AsyncSerial *aSer;
|
|
static const int TXTLEN = 512;
|
|
char txt[TXTLEN]; // For writing to serial
|
|
|
|
public:
|
|
Sensors(AsyncSerial *aS);
|
|
// initilize sensors
|
|
bool init();
|
|
// different ways of printing data
|
|
void printBaro();
|
|
void printAccel();
|
|
void printMagneto();
|
|
void printHumid();
|
|
void printTempAvg();
|
|
void printAll();
|
|
|
|
private:
|
|
float AclToMs2(int16_t val);
|
|
float MagToGauss(int16_t val);
|
|
|
|
};
|
|
|
|
|
|
#endif
|