Commit 12a23f390cc337c8c6328bece3a7d90edd3087a5
Committed by
Moritz Wirger
1 parent
1df7e3e8
Fix comparison issue with in SimpleColorHueStrategy
- in setColorXY problem was that hue bridge only returns 4 decimal places, but with setColorRGB or in general more than 4 decimal places are quite common -- fixed issue by truncating floats during comparison by converting to int
Showing
1 changed file
with
2 additions
and
2 deletions
hueplusplus/SimpleColorHueStrategy.cpp
| ... | ... | @@ -238,10 +238,10 @@ bool SimpleColorHueStrategy::setColorXY(float x, float y, uint8_t transistion, H |
| 238 | 238 | if (success && request.isMember("xy")) |
| 239 | 239 | { |
| 240 | 240 | //Check if success was sent and the value was changed |
| 241 | - success = !reply[i].isNull() && reply[i].isMember("success") && reply[i]["success"][path + "xy"][0].asFloat() == request["xy"][0].asFloat(); | |
| 241 | + success = !reply[i].isNull() && reply[i].isMember("success") && static_cast<int>(reply[i]["success"][path + "xy"][0].asFloat() * 10000 + 0.5) == static_cast<int>(request["xy"][0].asFloat() * 10000 + 0.5); | |
| 242 | 242 | if (success) |
| 243 | 243 | { |
| 244 | - success = !reply[i].isNull() && reply[i].isMember("success") && reply[i]["success"][path + "xy"][1].asFloat() == request["xy"][1].asFloat(); | |
| 244 | + success = !reply[i].isNull() && reply[i].isMember("success") && static_cast<int>(reply[i]["success"][path + "xy"][1].asFloat() * 10000 + 0.5) == static_cast<int>(request["xy"][1].asFloat() * 10000 + 0.5); | |
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | return success; | ... | ... |