stefanbode / Sonoff-Tasmota

Provide ESP8266 based itead Sonoff with Web, MQTT and OTA firmware using Arduino IDE, enhanced with I2C options
GNU General Public License v3.0
126 stars 40 forks source link

Erratic Behaviour when Slow Blinds - includes fix #202

Closed kabongsteve closed 4 years ago

kabongsteve commented 4 years ago

I have blinds that take ~50+ seconds to open/close. These were not operating correctly and moving on odd directions when using slider in Web interface. Once past a certain percent open, would start moving in opposite direction. My open_max value is 114600.

Issue found in ShutterPercentToRealPosition() where uint16_t is used for realpos calculation, even thou result is int32_t.

this was causing numeric overflow and high values rolling over to lower values.

Line94: from uint16_t realpos; to int32_t realpos;

Corrects this issue and solves the problem, now working as expected.

stefanbode commented 4 years ago

Uhh, thanks for bringing this up. You are 100% right.