(&self, key: u8, image_data: &[u8])
| 272 | } |
| 273 | |
| 274 | fn send_image(&self, key: u8, image_data: &[u8]) -> Result<(), StreamDeckError> { |
| 275 | if key >= self.kind.key_count() { |
| 276 | return Err(StreamDeckError::InvalidKeyIndex); |
| 277 | } |
| 278 | |
| 279 | let key = if let Kind::Original = self.kind { flip_key_index(&self.kind, key) } else { key }; |
| 280 | |
| 281 | if !self.kind.is_visual() { |
| 282 | return Err(StreamDeckError::NoScreen); |
| 283 | } |
| 284 | |
| 285 | self.write_image_data_reports( |
| 286 | image_data, |
| 287 | WriteImageParameters::for_key(self.kind, image_data.len()), |
| 288 | |page_number, this_length, last_package| match self.kind { |
| 289 | Kind::Original => vec![0x02, 0x01, (page_number + 1) as u8, 0, if last_package { 1 } else { 0 }, key + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
| 290 | |
| 291 | Kind::Mini | Kind::MiniMk2 | Kind::MiniDiscord | Kind::MiniMk2Module => vec![0x02, 0x01, page_number as u8, 0, if last_package { 1 } else { 0 }, key + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
| 292 | |
| 293 | _ => vec![ |
| 294 | 0x02, |
| 295 | 0x07, |
| 296 | key, |
| 297 | if last_package { 1 } else { 0 }, |
| 298 | (this_length & 0xff) as u8, |
| 299 | (this_length >> 8) as u8, |
| 300 | (page_number & 0xff) as u8, |
| 301 | (page_number >> 8) as u8, |
| 302 | ], |
| 303 | }, |
| 304 | )?; |
| 305 | Ok(()) |
| 306 | } |
| 307 | |
| 308 | /// Writes image data to Stream Deck device, changes must be flushed with `.flush()` before |
| 309 | /// they will appear on the device! |
no test coverage detected