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
) -> anyhow
::Result
<Self> {
35 Motherboard
::Asus650e
=> PID_650_E
,
36 Motherboard
::AsusCrosshairVIIIHero
=> PID_CROSSHAIR
,
42 device
.set_fixed_mode()?
;
46 pub fn get_firmware_string(&self) -> anyhow
::Result
<String
> {
47 let mut buffer
= [0u8; 65];
49 buffer
[1] = AURA_REQUEST_FIRMWARE_VERSION
;
50 let n_write
= self.device
.write(&buffer
)?
;
51 assert_eq!(n_write
, 65);
54 let n_read
= self.device
.read(&mut buffer
)?
;
55 assert_eq!(n_read
, 65);
56 assert_eq!(buffer
[0], 0xEC);
57 assert_eq!(buffer
[1], 0x02);
59 Ok(String
::from(str::from_utf8(&buffer
[2..17])?
))
63 Example of configuration table:
64 - Positions 0 and 1 always 1E and 9F.
65 - Value 02 is the number of adressable channels.
77 pub fn get_configuration_table(&self) -> anyhow
::Result
<[u8; 60]> {
78 let mut buffer
= [0u8; 65];
80 buffer
[1] = AURA_REQUEST_CONFIG_TABLE
;
81 let n_write
= self.device
.write(&buffer
)?
;
82 assert_eq!(n_write
, 65);
85 let n_read
= self.device
.read(&mut buffer
)?
;
86 assert_eq!(n_read
, 65);
87 assert_eq!(buffer
[0], 0xEC);
88 assert_eq!(buffer
[1], 0x30);
90 Ok(buffer
[4..64].try_into()?
)
93 fn set_fixed_mode(&self) -> anyhow
::Result
<()> {
94 let mut buffer
= [0u8; 65];
96 buffer
[1] = 0x35; // Control mode.
97 buffer
[4] = 0x00; // Shutdown effect.
98 buffer
[5] = 0x01; // Mode id: static.
100 for channel_effect_id
in 0..2 {
101 buffer
[2] = channel_effect_id
; // Channel effect id: Fixed.
102 let n_write
= self.device
.write(&buffer
)?
;
103 assert_eq!(n_write
, 65);
108 pub fn set_color(&self, color
: &RGB
) -> anyhow
::Result
<()> {
109 let mut buffer
= [0u8; 65];
113 let start_led
= 0u32;
114 let nb_of_leds
= 16u32;
115 let mask
= ((1u32 << nb_of_leds
) - 1u32) << start_led
;
117 buffer
[2] = (mask
>> 8) as u8; // 16 bits LED mask: first part.
118 buffer
[3] = (mask
& 0xFF) as u8; // 16 bits LED mask: second part.
120 for n
in start_led
as usize..(start_led
+ nb_of_leds
) as usize {
121 buffer
[5 + 3 * n
] = color
.red
;
122 buffer
[5 + 3 * n
+ 1] = color
.green
;
123 buffer
[5 + 3 * n
+ 2] = color
.blue
;
126 let n_write
= self.device
.write(&buffer
)?
;
127 assert_eq!(n_write
, 65);
131 pub fn save_current_color(&self) -> anyhow
::Result
<()> {
132 let mut buffer
= [0u8; 65];
137 let n_write
= self.device
.write(&buffer
)?
;
138 assert_eq!(n_write
, 65);