From: Mikko Rasa Date: Mon, 8 Jul 2013 17:17:03 +0000 (+0300) Subject: Support inverted sensors that give low output when active X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=218f194f537dfda55d32ce8d8739e322a3d0c07d;p=r2c2.git Support inverted sensors that give low output when active --- diff --git a/source/libr2c2/sensor.cpp b/source/libr2c2/sensor.cpp index 8a65d3d..47e05f6 100644 --- a/source/libr2c2/sensor.cpp +++ b/source/libr2c2/sensor.cpp @@ -9,6 +9,7 @@ namespace R2C2 { Sensor::Sensor(Layout &l): layout(l), address(0), + invert(false), state(INACTIVE) { if(layout.has_driver()) @@ -43,13 +44,13 @@ void Sensor::event(unsigned a, bool s) { if(a==address) { - if(s && stateMAYBE_INACTIVE) + else if(s==invert && state>MAYBE_INACTIVE) { state = MAYBE_INACTIVE; state_confirm_timeout = 700*Time::msec; diff --git a/source/libr2c2/sensor.h b/source/libr2c2/sensor.h index d3f472d..f1525bf 100644 --- a/source/libr2c2/sensor.h +++ b/source/libr2c2/sensor.h @@ -25,6 +25,7 @@ public: protected: Layout &layout; unsigned address; + bool invert; State state; Msp::Time::TimeDelta state_confirm_timeout;