@@ -12,7 +12,7 @@ use std::{
12
12
use uuid:: Uuid ;
13
13
14
14
use super :: { err_str, BoardId , Daemon , DaemonCommand } ;
15
- use crate :: { Hs , Matrix , Rgb } ;
15
+ use crate :: Matrix ;
16
16
17
17
pub struct DaemonServer < R : Read , W : Write > {
18
18
running : Cell < bool > ,
@@ -186,26 +186,16 @@ impl<R: Read, W: Write> Daemon for DaemonServer<R, W> {
186
186
Ok ( Matrix :: new ( rows, cols, data. into_boxed_slice ( ) ) )
187
187
}
188
188
189
- fn color ( & self , board : BoardId , index : u8 ) -> Result < Hs , String > {
189
+ fn color ( & self , board : BoardId , index : u8 ) -> Result < ( u8 , u8 , u8 ) , String > {
190
190
let mut ec = self . board ( board) ?;
191
- let color = unsafe { ec. led_get_color ( index) } . map_err ( err_str) ?;
192
-
193
- if unsafe { ec. access ( ) . is :: < AccessHid > ( ) } && index >= 0xf0 {
194
- Ok ( Hs :: from_ints ( color. 0 , color. 1 ) )
195
- } else {
196
- Ok ( Rgb :: new ( color. 0 , color. 1 , color. 2 ) . to_hs_lossy ( ) )
197
- }
191
+ unsafe { ec. led_get_color ( index) } . map_err ( err_str)
198
192
}
199
193
200
- fn set_color ( & self , board : BoardId , index : u8 , color : Hs ) -> Result < ( ) , String > {
194
+ fn set_color ( & self , board : BoardId , index : u8 , color : ( u8 , u8 , u8 ) ) -> Result < ( ) , String > {
201
195
let mut ec = self . board ( board) ?;
202
-
203
- if unsafe { ec. access ( ) . is :: < AccessHid > ( ) } && index >= 0xf0 {
204
- let ( h, s) = color. to_ints ( ) ;
205
- unsafe { ec. led_set_color ( index, h, s, 0 ) . map_err ( err_str) }
206
- } else {
207
- let Rgb { r, g, b } = color. to_rgb ( ) ;
208
- unsafe { ec. led_set_color ( index, r, g, b) . map_err ( err_str) }
196
+ unsafe {
197
+ ec. led_set_color ( index, color. 0 , color. 1 , color. 2 )
198
+ . map_err ( err_str)
209
199
}
210
200
}
211
201
0 commit comments