7 * - https://blog.inlart.com/post/openrgb-asus-x570/
8 * - https://openrgb-wiki.readthedocs.io/en/latest/asus/ASUS-Aura-USB/
11 const AURA_REQUEST_FIRMWARE_VERSION
: u8 = 0x82;
12 const AURA_REQUEST_CONFIG_TABLE
: u8 = 0xB0;
14 const VID
: u16 = 0x0B05; // Vendor ID: ASUS.
16 const PID_650_E
: u16 = 0x19AF; // Product ID: AURA LED Controller.
17 const PID_CROSSHAIR
: u16 = 0x18F3; // Product ID: AURA LED Controller.
19 pub enum Motherboard
{
21 AsusCrosshairVIIIHero
,
25 device
: hidapi
::HidDevice
,
26 motherboard
: Motherboard
,
30 pub fn new(api
: &hidapi
::HidApi
, motherboard
: Motherboard
) -> Self {
37 Motherboard
::Asus650e
=> PID_650_E
,
38 Motherboard
::AsusCrosshairVIIIHero
=> PID_CROSSHAIR
,
45 device
.set_fixed_mode();
49 pub fn get_firmware_string(&self) -> String
{
50 let mut buffer
= [0u8; 65];
52 buffer
[1] = AURA_REQUEST_FIRMWARE_VERSION
;
53 let n_write
= self.device
.write(&buffer
).unwrap();
54 assert_eq!(n_write
, 65);
57 let n_read
= self.device
.read(&mut buffer
).unwrap();
58 assert_eq!(n_read
, 65);
59 assert_eq!(buffer
[0], 0xEC);
60 assert_eq!(buffer
[1], 0x02);
62 String
::from(str::from_utf8(&buffer
[2..17]).unwrap())
66 Example of configuration table:
67 - Positions 0 and 1 always 1E and 9F.
68 - Value 02 is the number of adressable channels.
80 pub fn get_configuration_table(&self) -> [u8; 60] {
81 let mut buffer
= [0u8; 65];
83 buffer
[1] = AURA_REQUEST_CONFIG_TABLE
;
84 let n_write
= self.device
.write(&buffer
).unwrap();
85 assert_eq!(n_write
, 65);
88 let n_read
= self.device
.read(&mut buffer
).unwrap();
89 assert_eq!(n_read
, 65);
90 assert_eq!(buffer
[0], 0xEC);
91 assert_eq!(buffer
[1], 0x30);
95 .expect("slice with incorrect length")
98 fn set_fixed_mode(&self) {
99 let mut buffer
= [0u8; 65];
101 buffer
[1] = 0x35; // Control mode.
102 buffer
[4] = 0x00; // Shutdown effect.
103 buffer
[5] = 0x01; // Mode id: static.
105 for channel_effect_id
in 0..2 {
106 buffer
[2] = channel_effect_id
; // Channel effect id: Fixed.
107 let n_write
= self.device
.write(&buffer
).unwrap();
108 assert_eq!(n_write
, 65);
112 pub fn set_color(&self, color
: &RGB
) {
113 let mut buffer
= [0u8; 65];
117 let start_led
= 0u32;
118 let nb_of_leds
= 16u32;
119 let mask
= ((1u32 << nb_of_leds
) - 1u32) << start_led
;
121 buffer
[2] = (mask
>> 8) as u8; // 16 bits LED mask: first part.
122 buffer
[3] = (mask
& 0xFF) as u8; // 16 bits LED mask: second part.
124 for n
in start_led
as usize..(start_led
+ nb_of_leds
) as usize {
125 buffer
[5 + 3 * n
] = color
.red
;
126 buffer
[5 + 3 * n
+ 1] = color
.green
;
127 buffer
[5 + 3 * n
+ 2] = color
.blue
;
130 let n_write
= self.device
.write(&buffer
).unwrap();
131 assert_eq!(n_write
, 65);
134 pub fn save_current_color(&self) {
135 let mut buffer
= [0u8; 65];
140 let n_write
= self.device
.write(&buffer
).unwrap();
141 assert_eq!(n_write
, 65);