Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Part of #22: Create ADS1115 skeleton class #40

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Software/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@

int main() {
std::array<spartan::PacketType*, 1> dataPackets;
std::array<spartan::Sensor*, 1> sensors;
std::array<spartan::Sensor*, 2> sensors;

// TODO: Initialize Sensors
sensors[0] = new spartan::LSM6DS33(1, 0);
sensors[1] = new spartan::ADS1115(1, 1);

// TODO: Initialize DataPackets
spartan::MasterDataPacket mdp;
Expand Down
23 changes: 18 additions & 5 deletions Software/spartan/src/sensors/ads1115.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
#include "ads1115.h"
/*
spartan::ADS1115::ADS1115(int bus, uint8_t address) {}

int spartan::ADS1115::pollData(spartan::DataPacket &dp) { return 0; }
spartan::ADS1115::ADS1115(int bus, uint8_t address)
: Sensor(bus, address), m_i2c(bus, true)
{}

void spartan::ADS1115::printValues() const {}
*/
const char* spartan::ADS1115::name() const
{
const char * str = "ADS1115";
return str;
};

void spartan::ADS1115::printSensorInfo() {}

int spartan::ADS1115::powerOn() { return 0; }

int spartan::ADS1115::powerOff() { return 0; }

int spartan::ADS1115::pollData(MasterDataPacket &dp) { return 0; }

int spartan::ADS1115::printValues() const {}
12 changes: 11 additions & 1 deletion Software/spartan/src/sensors/ads1115.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,18 @@ namespace spartan
class ADS1115 : public Sensor {
public:
ADS1115(int bus, uint8_t address);
virtual int pollData(spartan::MasterDataPacket &dp);

virtual const char * name() const;
virtual void printSensorInfo();

virtual int powerOn();
virtual int powerOff();
virtual int pollData(MasterDataPacket &dp);

virtual int printValues() const;

private:
mraa::I2c m_i2c;
};
} // namespace spartan

Expand Down