From 74fe42acafa0b21250ca9c8ef264cb7fbeeebf89 Mon Sep 17 00:00:00 2001 From: mumpf Date: Sat, 17 Aug 2019 21:14:46 +0200 Subject: [PATCH] corrected float with DPT9 (#27) * corrected float with DPT9 * Switch Programming-LED also via Bus/ETS * Again: Prog-LED switchable from bus/ETS --- src/knx/knx_value.cpp | 2 ++ src/knx_facade.cpp | 41 +++++++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/knx/knx_value.cpp b/src/knx/knx_value.cpp index 4985085..7b6f93a 100644 --- a/src/knx/knx_value.cpp +++ b/src/knx/knx_value.cpp @@ -532,6 +532,8 @@ struct tm KNXValue::timeValue() const KNXValue::KNXValue(float value) { + _value.doubleValue = value; + _type = DoubleType; } KNXValue& KNXValue::operator=(const float value) diff --git a/src/knx_facade.cpp b/src/knx_facade.cpp index 1e93ce8..34ae0dc 100644 --- a/src/knx_facade.cpp +++ b/src/knx_facade.cpp @@ -17,11 +17,13 @@ Bau57B0 bau(platform); #endif bool _toogleProgMode = false; +bool _progLedState = false; + #ifndef __linux__ KnxFacade knx(bau); ICACHE_RAM_ATTR void buttonUp() { - _toogleProgMode = true; + _toogleProgMode = true; } #endif @@ -48,17 +50,6 @@ bool KnxFacade::progMode() void KnxFacade::progMode(bool value) { - if (value) - { - println("progmode on"); - digitalWrite(knx.ledPin(), _ledPinActiveOn); - } - else - { - println("progmode off"); - digitalWrite(knx.ledPin(), HIGH - _ledPinActiveOn); - } - _bau.deviceObject().progMode(value); } @@ -109,11 +100,25 @@ void KnxFacade::writeMemory() void KnxFacade::loop() { - if(_toogleProgMode) - { - progMode(!progMode()); - _toogleProgMode = false; - } + if (progMode() != _progLedState) + { + _progLedState = progMode(); + if (_progLedState) + { + println("progmode on"); + digitalWrite(knx.ledPin(), _ledPinActiveOn); + } + else + { + println("progmode off"); + digitalWrite(knx.ledPin(), HIGH - _ledPinActiveOn); + } + } + if (_toogleProgMode) + { + progMode(!progMode()); + _toogleProgMode = false; + } _bau.loop(); } @@ -150,7 +155,7 @@ void KnxFacade::version(uint16_t value) void KnxFacade::start() { pinMode(_ledPin, OUTPUT); - + digitalWrite(_ledPin, HIGH - _ledPinActiveOn); pinMode(_buttonPin, INPUT_PULLUP);