X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fsensor.cpp;h=c31c795f12986e32fbd4f23e95c885e03d1aff2f;hb=0c1214ad0680c3bf65c1ee5f366dbafabc9d188d;hp=8a65d3dedf20f52419d130bfd1612f5bb3cc2a30;hpb=eb9c7f5200da4f3f31b41233be8cee397cb6abb9;p=r2c2.git diff --git a/source/libr2c2/sensor.cpp b/source/libr2c2/sensor.cpp index 8a65d3d..c31c795 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()) @@ -22,6 +23,13 @@ Sensor::~Sensor() layout.remove(*this); } +void Sensor::set_address(unsigned a) +{ + address = a; + if(layout.has_driver()) + layout.get_driver().add_sensor(address); +} + void Sensor::tick(const Time::TimeDelta &dt) { if(state_confirm_timeout) @@ -43,13 +51,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;