Skip to content

Commit

Permalink
[hybrisadaptor] Refactor sensor start/stop logic
Browse files Browse the repository at this point in the history
Whether sensors should be started or stopped depends on a number
of state variables. Using case specific conditionals at places
where state variables might change makes the code fragile and
hard to maintain.

Separate sensor hal operations more clearly from logic and forms
dictated by sensorfwd conventions.

Use m_memberName naming convention for member variables, make
all member data private and usable only via accessor functions.

Use a single sensor start/stop policy evaluation function and
call it from each place where relevant state variables might
change.

Use sensorfwd specific logging functions instead of qDebug etc.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Sep 27, 2018
1 parent 4fb1461 commit 8fab553
Show file tree
Hide file tree
Showing 3 changed files with 628 additions and 470 deletions.
2 changes: 1 addition & 1 deletion adaptors/hybrisproximityadaptor/hybrisproximityadaptor.cpp
Expand Up @@ -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

0 comments on commit 8fab553

Please sign in to comment.