Move tests in a separate module
[temp2RGB.git] / src / b650_e.rs
diff --git a/src/b650_e.rs b/src/b650_e.rs
deleted file mode 100644 (file)
index b571675..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-use std::str;
-
-use crate::rgb::RGB;
-
-/*
- * Doc:
- *  - https://blog.inlart.com/post/openrgb-asus-x570/
- *  - https://openrgb-wiki.readthedocs.io/en/latest/asus/ASUS-Aura-USB/
- */
-
-const AURA_REQUEST_FIRMWARE_VERSION: u8 = 0x82;
-const AURA_REQUEST_CONFIG_TABLE: u8 = 0xB0;
-
-const VID: u16 = 0x0B05; // Vendor ID: ASUS.
-const PID: u16 = 0x19AF; // Product ID: AURA LED Controller.
-
-pub fn get_device(api: &hidapi::HidApi) -> hidapi::HidDevice {
-    api.open(VID, PID).unwrap()
-}
-
-pub fn get_firmware_string(device: &hidapi::HidDevice) -> String {
-    let mut buffer = [0u8; 65];
-    buffer[0] = 0xEC;
-    buffer[1] = AURA_REQUEST_FIRMWARE_VERSION;
-    let n_write = device.write(&buffer).unwrap();
-    assert_eq!(n_write, 65);
-
-    buffer.fill(0);
-    let n_read = device.read(&mut buffer).unwrap();
-    assert_eq!(n_read, 65);
-    assert_eq!(buffer[0], 0xEC);
-    assert_eq!(buffer[1], 0x02);
-
-    String::from(str::from_utf8(&buffer[2..17]).unwrap())
-}
-
-pub fn get_configuration_table(device: &hidapi::HidDevice) -> [u8; 60] {
-    let mut buffer = [0u8; 65];
-    buffer[0] = 0xEC;
-    buffer[1] = AURA_REQUEST_CONFIG_TABLE;
-    let n_write = device.write(&buffer).unwrap();
-    assert_eq!(n_write, 65);
-
-    buffer.fill(0);
-    let n_read = device.read(&mut buffer).unwrap();
-    assert_eq!(n_read, 65);
-    assert_eq!(buffer[0], 0xEC);
-    assert_eq!(buffer[1], 0x30);
-
-    buffer[4..64]
-        .try_into()
-        .expect("slice with incorrect length")
-}
-
-// TODO: it seems this doesn't work.
-// The mode is set by OpenRGB prior launching temp2RGB for the moment.
-pub fn set_fixed_mode(device: &hidapi::HidDevice) {
-    let mut buffer = [0u8; 65];
-    buffer[0] = 0xEC;
-    buffer[1] = 0x35;
-    buffer[2] = 0x00; // Channel effect id = Fixed.
-    buffer[5] = 0x01; // Mode id = static.
-
-    let n_write = device.write(&buffer).unwrap();
-    assert_eq!(n_write, 65);
-}
-
-pub fn set_color(device: &hidapi::HidDevice, color: &RGB) {
-    let mut buffer = [0u8; 65];
-    buffer[0] = 0xEC;
-    buffer[1] = 0x36;
-    buffer[2] = 0x00; // 16 bits LED mask: first part.
-    buffer[3] = 0x02; // 16 bits LED mask: second part.
-
-    // Don't know why the first LED isn't used.
-    // buffer[5] = color.red;
-    // buffer[6] = color.green;
-    // buffer[7] = color.blue;
-
-    // // Set second LED.
-    buffer[8] = color.red;
-    buffer[9] = color.green;
-    buffer[10] = color.blue;
-
-    let n_write = device.write(&buffer).unwrap();
-    assert_eq!(n_write, 65);
-}
-
-pub fn save_current_color(device: &hidapi::HidDevice) {
-    let mut buffer = [0u8; 65];
-    buffer[0] = 0xEC;
-    buffer[1] = 0x3F;
-    buffer[2] = 0x55;
-
-    let n_write = device.write(&buffer).unwrap();
-    assert_eq!(n_write, 65);
-}