Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'jb43020_initial_state' into 'master'
Refactor sensor start/stop logic and tune als/ps default values

See merge request mer-core/sensorfw!27
  • Loading branch information
spiiroin committed Sep 28, 2018
2 parents 8bd068f + a997710 commit 09dbf90
Show file tree
Hide file tree
Showing 11 changed files with 726 additions and 510 deletions.
9 changes: 4 additions & 5 deletions adaptors/hybrisaccelerometer/hybrisaccelerometeradaptor.cpp
Expand Up @@ -44,20 +44,19 @@ HybrisAccelerometerAdaptor::~HybrisAccelerometerAdaptor()

bool HybrisAccelerometerAdaptor::startSensor()
{
if(!powerStatePath.isEmpty())
writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;

if (isRunning() && !powerStatePath.isEmpty())
writeToFile(powerStatePath, "1");
sensordLogD() << "Hybris AccelAdaptor start\n";
return true;
}

void HybrisAccelerometerAdaptor::stopSensor()
{
if(!powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
if (!isRunning() && !powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
sensordLogD() << "Hybris AccelAdaptor stop\n";
}

Expand Down
9 changes: 4 additions & 5 deletions adaptors/hybrisalsadaptor/hybrisalsadaptor.cpp
Expand Up @@ -52,11 +52,10 @@ HybrisAlsAdaptor::~HybrisAlsAdaptor()

bool HybrisAlsAdaptor::startSensor()
{
if(!powerStatePath.isEmpty())
writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;

if (isRunning() && !powerStatePath.isEmpty())
writeToFile(powerStatePath, "1");
sensordLogD() << "Hybris HybrisAlsAdaptor start\n";
return true;
}
Expand Down Expand Up @@ -120,9 +119,9 @@ void HybrisAlsAdaptor::sendInitialData()

void HybrisAlsAdaptor::stopSensor()
{
if(!powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
if (!isRunning() && !powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
sensordLogD() << "Hybris HybrisAlsAdaptor stop\n";
}

Expand Down
9 changes: 4 additions & 5 deletions adaptors/hybrisgyroscopeadaptor/hybrisgyroscopeadaptor.cpp
Expand Up @@ -51,20 +51,19 @@ HybrisGyroscopeAdaptor::~HybrisGyroscopeAdaptor()

bool HybrisGyroscopeAdaptor::startSensor()
{
if(!powerStatePath.isEmpty())
writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;

if (isRunning() && !powerStatePath.isEmpty())
writeToFile(powerStatePath, "1");
sensordLogD() << "HybrisGyroscopeAdaptor start\n";
return true;
}

void HybrisGyroscopeAdaptor::stopSensor()
{
if(!powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
if (!isRunning() &&!powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
sensordLogD() << "HybrisGyroscopeAdaptor stop\n";
}

Expand Down
Expand Up @@ -48,20 +48,19 @@ HybrisMagnetometerAdaptor::~HybrisMagnetometerAdaptor()

bool HybrisMagnetometerAdaptor::startSensor()
{
if(!powerStatePath.isEmpty())
writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;

if (isRunning() &&!powerStatePath.isEmpty())
writeToFile(powerStatePath, "1");
sensordLogD() << "HybrisMagnetometerAdaptor start\n";
return true;
}

void HybrisMagnetometerAdaptor::stopSensor()
{
if(!powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
if (!isRunning() && !powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
sensordLogD() << "HybrisMagnetometerAdaptor stop\n";
}

Expand Down
Expand Up @@ -64,20 +64,19 @@ HybrisOrientationAdaptor::~HybrisOrientationAdaptor()

bool HybrisOrientationAdaptor::startSensor()
{
if(!powerStatePath.isEmpty())
writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;

if (isRunning() && !powerStatePath.isEmpty())
writeToFile(powerStatePath, "1");
sensordLogD() << "Hybris OrientationAdaptor start\n";
return true;
}

void HybrisOrientationAdaptor::stopSensor()
{
if(!powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
if (!isRunning() && !powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
sensordLogD() << "Hybris OrientationAdaptor stop\n";
}

Expand Down
9 changes: 4 additions & 5 deletions adaptors/hybrispressureadaptor/hybrispressureadaptor.cpp
Expand Up @@ -50,20 +50,19 @@ HybrisPressureAdaptor::~HybrisPressureAdaptor()

bool HybrisPressureAdaptor::startSensor()
{
if(!powerStatePath.isEmpty())
writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;

if (isRunning() && !powerStatePath.isEmpty())
writeToFile(powerStatePath, "1");
sensordLogD() << "Hybris HybrisPressureAdaptor start\n";
return true;
}

void HybrisPressureAdaptor::stopSensor()
{
if(!powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
if (!isRunning() && !powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
sensordLogD() << "Hybris HybrisPressureAdaptor stop\n";
}

Expand Down
10 changes: 5 additions & 5 deletions adaptors/hybrisproximityadaptor/hybrisproximityadaptor.cpp
Expand Up @@ -57,10 +57,10 @@ HybrisProximityAdaptor::~HybrisProximityAdaptor()

bool HybrisProximityAdaptor::startSensor()
{
if(!powerStatePath.isEmpty())
writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;
if (isRunning() && !powerStatePath.isEmpty())
writeToFile(powerStatePath, "1");
sensordLogD() << "HybrisProximityAdaptor start\n";
return true;
}
Expand Down Expand Up @@ -127,9 +127,9 @@ void HybrisProximityAdaptor::sendInitialData()

void HybrisProximityAdaptor::stopSensor()
{
if(!powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
if (!isRunning() && !powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
sensordLogD() << "HybrisProximityAdaptor stop\n";
}

Expand All @@ -138,7 +138,7 @@ void HybrisProximityAdaptor::processSample(const sensors_event_t& data)
ProximityData *d = buffer->nextSlot();
d->timestamp_ = quint64(data.timestamp * .001);
bool near = false;
if (data.distance < maxRange) {
if (data.distance < maxRange()) {
near = true;
}
d->withinProximity_ = near;
Expand Down
Expand Up @@ -56,11 +56,10 @@ HybrisStepCounterAdaptor::~HybrisStepCounterAdaptor()

bool HybrisStepCounterAdaptor::startSensor()
{
if(!powerStatePath.isEmpty())
writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;

if (isRunning() && !powerStatePath.isEmpty())
writeToFile(powerStatePath, "1");
sensordLogD() << "Hybris HybrisStepCounterAdaptor start\n";
return true;
}
Expand All @@ -72,9 +71,9 @@ void HybrisStepCounterAdaptor::sendInitialData()

void HybrisStepCounterAdaptor::stopSensor()
{
if(!powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
if (!isRunning() && !powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
sensordLogD() << "Hybris HybrisStepCounterAdaptor stop\n";
}

Expand Down

0 comments on commit 09dbf90

Please sign in to comment.