Commit 086d7d37c7b5555873c120edfac02bd46de0855c
1 parent
eebaaa9d
update README
Showing
1 changed file
with
55 additions
and
0 deletions
README.md
| @@ -8,5 +8,60 @@ A simple and easy to use library for Philips Hue Lights | @@ -8,5 +8,60 @@ A simple and easy to use library for Philips Hue Lights | ||
| 8 | * extended alert() function, which alerts in a specific color | 8 | * extended alert() function, which alerts in a specific color |
| 9 | * documented with doxygen | 9 | * documented with doxygen |
| 10 | 10 | ||
| 11 | +## How to use | ||
| 12 | +### <a name="findingBridges"></a>Finding Bridges | ||
| 13 | +If you want to find a Hue Bridge make a HueFinder object and call FindBridges() | ||
| 14 | +it will return a vector containing the ip and mac adress of all found Bridges. | ||
| 15 | +If no Bridges were found the vector is empty, so make sure that in that case you provide an ip and mac address. | ||
| 16 | +```C++ | ||
| 17 | +HueFinder finder; | ||
| 18 | +std::vector<HueFinder::HueIdentification> bridges = finder.FindBridges(); | ||
| 19 | +if (bridges.empty()) | ||
| 20 | +{ | ||
| 21 | + bridges.push_back({ "<ip address>", "<mac address>" }); | ||
| 22 | +} | ||
| 23 | +``` | ||
| 24 | + | ||
| 25 | +### Using Bridges | ||
| 26 | +If you have found the Bridge you were looking for, you can then move on with the authentication process. | ||
| 27 | +To get a new username from the Bridge (for now) you simply call GetBridge(bridges[<index>]), | ||
| 28 | +where index is your preferred Bridge from the part [Finding Bridges](findingBridges). | ||
| 29 | +```C++ | ||
| 30 | +Hue bridge = finder.GetBridge(bridges[0]); | ||
| 31 | +``` | ||
| 32 | +If you on the other hand already have a username you can add you bridge like so | ||
| 33 | +```C++ | ||
| 34 | +finder.AddUsername(bridges[0].mac, "<username>"); | ||
| 35 | +Hue bridge = finder.GetBridge(bridges[0]); | ||
| 36 | +``` | ||
| 37 | + | ||
| 38 | +### Controlling lights | ||
| 39 | +If you have your Bridge all set up now you can get and control its lights. | ||
| 40 | +For that create a pointer of the specific light type you want to use. | ||
| 41 | +You can choose from | ||
| 42 | +* HueLight | ||
| 43 | +* HueDimmableLight | ||
| 44 | +* HueTemperatureLight | ||
| 45 | +* HueColorLight | ||
| 46 | +* HueExtendedColorLight | ||
| 47 | +Then call getLight(<id>) from you bridge object to get the specific light, where id | ||
| 48 | +is the id of the light set internally by the Hue Bridge. | ||
| 49 | +```C++ | ||
| 50 | +HueExtendedColorLight* lamp1 = static_cast<HueExtendedColorLight*>(bridge.getLight(1)); | ||
| 51 | +``` | ||
| 52 | +If you now want to control the light you just call the specific function of the light. | ||
| 53 | +```C++ | ||
| 54 | +lamp1->On(); | ||
| 55 | +lamp1->setBrightness(120); | ||
| 56 | +lamp1->alertHueSaturation(25500, 255); | ||
| 57 | +lamp1->setColorLoop(true); | ||
| 58 | +lamp1->setColorRGB(255, 128, 0); | ||
| 59 | +``` | ||
| 60 | + | ||
| 11 | ## Copyright | 61 | ## Copyright |
| 12 | Copyright (c) 2017 Jan Rogall & Moritz Wirger. See LICENSE for further details. | 62 | Copyright (c) 2017 Jan Rogall & Moritz Wirger. See LICENSE for further details. |
| 63 | + | ||
| 64 | + | ||
| 65 | +```C++ | ||
| 66 | + | ||
| 67 | +``` | ||
| 13 | \ No newline at end of file | 68 | \ No newline at end of file |