From 218f194f537dfda55d32ce8d8739e322a3d0c07d Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 8 Jul 2013 20:17:03 +0300 Subject: [PATCH] Support inverted sensors that give low output when active --- source/libr2c2/sensor.cpp | 5 +++-- source/libr2c2/sensor.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) 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; -- 2.43.0