Skip to content

Commit

Permalink
[vl53l0] Add strings to RangeErrorCode
Browse files Browse the repository at this point in the history
  • Loading branch information
strongly-typed committed Sep 15, 2018
1 parent 71c0c59 commit 67a8e6a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/modm/driver/position/vl53l0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,32 @@ modm::accessor::Flash<BinaryConfiguration> configuration(configurationFlash);
} // namespace vl53l0_private

} // namespace modm

// ----------------------------------------------------------------------------
modm::IOStream&
modm::operator << (modm::IOStream& s, const vl53l0::RangeErrorCode& c)
{
// s.printf("%.3f", (double)c.getTemperatureFloat());
// s << " C " << c.getStatus();

switch(c)
{
case vl53l0::RangeErrorCode::NoError: s << "NoError"; break;
case vl53l0::RangeErrorCode::VCSEL_ContinuityTest: s << "VCSEL_ContinuityTest"; break;
case vl53l0::RangeErrorCode::VCSEL_WatchdogTest: s << "VCSEL_WatchdogTest"; break;
case vl53l0::RangeErrorCode::VHV_NoValueFound: s << "VHV_NoValueFound"; break;
case vl53l0::RangeErrorCode::MSRC_NoTarget: s << "MSRC_NoTarget"; break;
case vl53l0::RangeErrorCode::SNR_Check: s << "SNR_Check"; break;
case vl53l0::RangeErrorCode::RangePhaseCheck: s << "RangePhaseCheck"; break;
case vl53l0::RangeErrorCode::SigmaThresholdCheck: s << "SigmaThresholdCheck"; break;
case vl53l0::RangeErrorCode::TCC: s << "TCC"; break;
case vl53l0::RangeErrorCode::PhaseConsistency: s << "PhaseConsistency"; break;
case vl53l0::RangeErrorCode::MinClip: s << "MinClip"; break;
case vl53l0::RangeErrorCode::RangeComplete: s << "RangeComplete"; break;
case vl53l0::RangeErrorCode::RangingAlgoUnderflow: s << "RangingAlgoUnderflow"; break;
case vl53l0::RangeErrorCode::RangingAlgoOverflow: s << "RangingAlgoOverflow"; break;
case vl53l0::RangeErrorCode::RangeIgnoreThreshold: s << "RangeIgnoreThreshold"; break;
}

return s;
}
4 changes: 4 additions & 0 deletions src/modm/driver/position/vl53l0.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@ struct vl53l0
};
}; // struct vl53l0

// Output operators
IOStream&
operator << (IOStream& os, const vl53l0::RangeErrorCode& c);

/**
* VL53L0X: Proximity sensor module
*
Expand Down

0 comments on commit 67a8e6a

Please sign in to comment.