Permalink
Browse files

Fixed issue where create angle/create distance reading wouldn't be co…

…mpletely reset by the set functions
  • Loading branch information...
1 parent b132ccf commit 32bf72d42eaf95a5e021feb3f1d0f5e507ba0668 @bmcdorman bmcdorman committed Feb 23, 2013
Showing with 7 additions and 3 deletions.
  1. +1 −1 include/kovan/create.hpp
  2. +6 −2 src/create.cpp
@@ -455,7 +455,7 @@ class EXPORT_SYM Create
void updateState();
void updateSensorPacket1();
- void updateSensorPacket2();
+ void updateSensorPacket2(bool forceUpdate = false);
void updateSensorPacket3();
void updateSensorPacket4();
void updateSensorPacket5();
View
@@ -822,11 +822,15 @@ bool Create::setBaudRate(const unsigned char& baudCode)
void Create::setDistance(const int distance)
{
+ // Clear distance on device
+ updateSensorPacket2(true);
m_state.distance = distance;
}
void Create::setAngle(const int angle)
{
+ // Clear angle on device
+ updateSensorPacket2(true);
m_state.angle = angle;
}
@@ -1028,9 +1032,9 @@ void Create::updateSensorPacket1()
endAtomicOperation();
}
-void Create::updateSensorPacket2()
+void Create::updateSensorPacket2(bool forceUpdate)
{
- if(!hasRequiredTimePassed(timestamps[1])) return;
+ if(!forceUpdate && !hasRequiredTimePassed(timestamps[1])) return;
flush();
beginAtomicOperation();
write(OI_SENSORS);

0 comments on commit 32bf72d

Please sign in to comment.