diff --git a/Makefile.local b/Makefile.local index 5aeb27c..415f80e 100644 --- a/Makefile.local +++ b/Makefile.local @@ -1,7 +1,7 @@ -CXX_FLAGS = -O0 -g3 -Wall -std=c++11 +CXX_FLAGS = -O2 -Wall -std=c++11 CXX_INCL = -I ../TinkerforgeCPPsimple/include -I ../TinkerforgeCPPsimple/third-party/tinkerforge/include -I ../TinkerforgeCPPsimple/third-party/log4cpp/include -I /usr/include LD_FLAGS = -pthread diff --git a/src/GrowControl.cpp b/src/GrowControl.cpp index c928eb1..67fc76c 100644 --- a/src/GrowControl.cpp +++ b/src/GrowControl.cpp @@ -186,7 +186,7 @@ void GrowControl::newDeviceCallback(TfConnection& conn, TfDevice& device) { io16ConnectFlag = true; io16MissingFlag = false; io16Bricklet->addListener(*this); - setFan1Level(fan1Level); + setFan1Level(fan1Level, true); logger << log4cpp::Priority::INFO << "Added io16 device " << device.getDeviceName(true) << "."; } break; @@ -367,11 +367,11 @@ bool GrowControl::isFan1Connected() { return (io16Bricklet != nullptr && io16Bricklet->getDeviceState() == TfDeviceState::CONNECTED); } -void GrowControl::setFan1Level(unsigned level) { +void GrowControl::setFan1Level(unsigned level, bool force) { if (level > fan1UpperLimit) { level = fan1UpperLimit; } - if (level != fan1Level) { + if (level != fan1Level || force) { fan1Level = level; if (isFan1Connected()) { if (fan1Level <= 0) { diff --git a/src/GrowControl.h b/src/GrowControl.h index e68167a..f30273b 100644 --- a/src/GrowControl.h +++ b/src/GrowControl.h @@ -112,7 +112,7 @@ public: bool isFan1Connected(); unsigned getFan1Level(bool force = false); - void setFan1Level(unsigned level); + void setFan1Level(unsigned level, bool force = false); unsigned getFan1UpperLimit(); void setFan1UpperLimit(unsigned limit); unsigned getFan1Max();