Skip to content

Commit

Permalink
chore(release): 0.2.1 [skip ci]
Browse files Browse the repository at this point in the history
### [0.2.1](v0.2.0...v0.2.1) (2022-05-22)

### Documentation

* inline example to lib docs ([862c04d](862c04d))

### Build System

* add env usage to build script ([0137cfb](0137cfb))

### Continuous Integration

* fix publish ([dc2d883](dc2d883))
* fixup changes to lock file after publish ([4b03592](4b03592))
* run tests with all features ([ea9bc64](ea9bc64))
  • Loading branch information
semantic-release-bot committed May 22, 2022
1 parent dc2d883 commit 3419ebd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 122 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
### [0.2.1](https://github.com/meskill/mystic-light-sdk/compare/v0.2.0...v0.2.1) (2022-05-22)


### Documentation

* inline example to lib docs ([862c04d](https://github.com/meskill/mystic-light-sdk/commit/862c04d45dbe3632b2708203c62797c350ca949c))


### Build System

* add env usage to build script ([0137cfb](https://github.com/meskill/mystic-light-sdk/commit/0137cfb21665bc929987ca58b403532fdd5e0e89))


### Continuous Integration

* fix publish ([dc2d883](https://github.com/meskill/mystic-light-sdk/commit/dc2d883ca2f5ec965aa9ad4a92b3f17fd8b8d110))
* fixup changes to lock file after publish ([4b03592](https://github.com/meskill/mystic-light-sdk/commit/4b035924d0a434d2759d5c4fbd44fec8cb88a4e7))
* run tests with all features ([ea9bc64](https://github.com/meskill/mystic-light-sdk/commit/ea9bc64baf946c71afa63bb1295d283e7772253b))

## [0.2.0](https://github.com/meskill/mystic-light-sdk/compare/v0.1.5...v0.2.0) (2022-05-22)


Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mystic_light_sdk"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
authors = ["meskill"]
description = "A Rust wrapper for the MysticLight SDK (MSI hardware and peripherals)"
Expand Down
120 changes: 0 additions & 120 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,125 +14,5 @@ Rust SDK wrapper for the [Mystic Light SDK](https://www.msi.com/Landing/mystic-l
## Examples

```rust
use mystic_light_sdk::{Color, CommonError, DeviceLedState, MysticLightSDK};
use std::thread;
use std::time::Duration;

const LIB_PATH: &str = if cfg!(target_arch = "x86_64") {
"sdk/MysticLight_SDK_x64.dll"
} else {
"sdk/MysticLight_SDK.dll"
};

fn main() -> Result<(), CommonError> {
let sdk = MysticLightSDK::new(LIB_PATH)?;

let devices = sdk.get_devices()?;

println!("{:#?}", devices);

let mut keyboard_leds = devices[2].leds()?;

println!("{:#?}", keyboard_leds);

let state = keyboard_leds[0].get_state()?.to_owned();

println!("Current device state: {:#?}", state);

println!("Disable lightning!");

let new_state = DeviceLedState {
color: Color {
red: 0,
green: 0,
blue: 0,
},
style: String::from("NoAnimation"),
..state.clone()
};

keyboard_leds[0].set_state(&new_state)?;

thread::sleep(Duration::from_secs(5));

println!("Enable lightning");

keyboard_leds[0].set_state(&state)?;

Ok(())
}
```

### Pass right dll file

It depends on the os architecture you are building the program to and the os architecture for the end users.

Currently, most of the PC's are 64 bit architecture so you may just use MysticLight_SDK_x64.dll

Or if you are targetting both architecture you may use code below

```rust
const LIB_PATH: &str = if cfg!(target_arch = "x86_64") {
"sdk/MysticLight_SDK_x64.dll" // path to the dll file that must be available in runtime
} else {
"sdk/MysticLight_SDK.dll"
};
```

### Copy dll files to the output dir

As sdk dll is required in runtime you must provide these files somehow in the runtime.

You may use build script below in order to copy sdk files to the output dir. In this case dll files must reside in the `<path-to-your-project>/sdk` directory

```rust
use std::env;
use std::path::Path;

fn main() -> std::io::Result<()> {
println!("cargo:rerun-if-changed=sdk");

let current_dir = env::current_dir()?;
let out_dir = env::var("OUT_DIR").unwrap();

let from_path = current_dir.join("sdk");

let dest_path = Path::new(&out_dir)
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.join("sdk");

if !dest_path.exists() {
copy_dir::copy_dir(from_path, dest_path)?;
}

Ok(())
}
```

## Panics

- in case of any problems with conversion from and into WinApi types

## Features

### serde

Enables [serde](https://crates.io/crates/serde) serialization/deserialization for some of the sdk structs

## Troubleshooting

### Timeout error on initialization

Make sure you have been fulfilled [requirements](#requirements) and you running the result program with the admin rights

### NotSupported error when trying to set color

Some of the device's styles do not support colors. In this case this kind of error will be generated.


License: Apache-2.0

0 comments on commit 3419ebd

Please sign in to comment.