| 44 | } |
| 45 | |
| 46 | void PhilipsHueController::SetColor(unsigned char red, unsigned char green, unsigned char blue) |
| 47 | { |
| 48 | hueplusplus::RGB rgb; |
| 49 | rgb.r = red; |
| 50 | rgb.g = green; |
| 51 | rgb.b = blue; |
| 52 | |
| 53 | if((red == 0) && (green == 0) && (blue == 0)) |
| 54 | { |
| 55 | if(!dark) |
| 56 | { |
| 57 | try |
| 58 | { |
| 59 | light.setColorRGB(rgb, 0); |
| 60 | } |
| 61 | catch(const std::exception& e) |
| 62 | { |
| 63 | LOG_ERROR("[PhilipsHueController] An error occured while setting the colors: %s", e.what()); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | dark = true; |
| 68 | } |
| 69 | else |
| 70 | { |
| 71 | dark = false; |
| 72 | |
| 73 | try |
| 74 | { |
| 75 | light.setColorRGB(rgb, 0); |
| 76 | } |
| 77 | catch(std::exception& e) |
| 78 | { |
| 79 | LOG_ERROR("[PhilipsHueController] An error occured while setting the colors: %s", e.what()); |
| 80 | } |
| 81 | } |
| 82 | } |
no test coverage detected