https://github.com/animatedledstrip/client-cpp
Library for connecting to an AnimatedLEDStrip server from clients written in C++
https://github.com/animatedledstrip/client-cpp
Last synced: 7 days ago
JSON representation
Library for connecting to an AnimatedLEDStrip server from clients written in C++
- Host: GitHub
- URL: https://github.com/animatedledstrip/client-cpp
- Owner: AnimatedLEDStrip
- License: mit
- Created: 2020-07-23T01:32:02.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-03T03:05:03.000Z (almost 6 years ago)
- Last Synced: 2025-02-28T23:06:40.183Z (over 1 year ago)
- Language: C++
- Homepage:
- Size: 87.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AnimatedLEDStrip Client Library for C++
[](https://travis-ci.com/AnimatedLEDStrip/client-cpp)
[](https://codecov.io/gh/AnimatedLEDStrip/client-cpp)
This library allows a C++ 11 client to connect to an AnimatedLEDStrip server, allowing the client to send animations to the server and receive currently running animations from the server, among other information.
## Creating an `AnimationSender`
An `AnimationSender` is constructed with two arguments:
- `host`: The IP address of the server (as a c-style string)
- `port`: The port that the client should connect to (as an `int`)
```c++
AnimationSender sender("10.0.0.254", 5);
```
## Starting the `AnimationSender`
An `AnimationSender` is started by calling the `start()` method on the instance.
`start()` will return `0` if the connection is successful, `-1` if there is an error.
```c++
sender.start();
```
## Stopping the `AnimationSender`
To stop the `AnimationSender`, call its `end()` method.
`end()` will return `0` if the disconnection is successful, `-1` if there is an error.
```c++
sender.end();
```
## Sending Data
An animation can be sent to the server by creating an instance of the `AnimationData` struct, then calling `sendAnimation` with the struct as the argument.
```c++
ColorContainer cc;
cc.addColor(0xFF);
cc.addColor(0xFF00);
AnimationData data;
data.addColor(cc);
sender.sendAnimation(data);
```
#### `AnimationData` type notes
The C++ library uses the following values for `continuous` and `direction`:
- `continuous`: `DEFAULT`, `CONTINUOUS`, `NONCONTINUOUS`
- `direction`: `FORWARD`, `BACKWARD`
## Receiving Data
Received animations are saved to `runningAnimations`.
To retrieve an animation, use
```c++
sender.runningAnimations.[ID];
```
where `ID` is the string ID of the animation.