fix(tasoller_v2): LED ordering should be BGR

This commit is contained in:
beerpsi 2024-01-03 17:56:20 +07:00
parent 74e8e2a122
commit 6972b92fa5
2 changed files with 9 additions and 9 deletions

View File

@ -18,7 +18,7 @@
//! ### OUT Bulk (0x03) //! ### OUT Bulk (0x03)
//! - Content length: 240 bytes //! - Content length: 240 bytes
//! - Bytes 0..3: magic bytes [0x42, 0x4C, 0x00] //! - Bytes 0..3: magic bytes [0x42, 0x4C, 0x00]
//! - Bytes 3..96: Slider LED (GRB order, right -> left) //! - Bytes 3..96: Slider LED (BGR order, right -> left)
//! - Bytes 96..168: Left tower LEDs (GRB) //! - Bytes 96..168: Left tower LEDs (GRB)
//! - Bytes 168..240: Right tower LEDs (GRB) //! - Bytes 168..240: Right tower LEDs (GRB)
@ -82,9 +82,9 @@ pub fn set_slider_leds<T: UsbContext>(
rgb: &[u8], rgb: &[u8],
) -> Result<()> { ) -> Result<()> {
for (buf_chunk, state_chunk) in output[3..96].chunks_mut(3).take(31).zip(rgb.chunks(3)) { for (buf_chunk, state_chunk) in output[3..96].chunks_mut(3).take(31).zip(rgb.chunks(3)) {
buf_chunk[0] = state_chunk[1]; buf_chunk[0] = state_chunk[2];
buf_chunk[1] = state_chunk[0]; buf_chunk[1] = state_chunk[1];
buf_chunk[2] = state_chunk[2]; buf_chunk[2] = state_chunk[0];
} }
device.write_bulk(0x03, output, TIMEOUT)?; device.write_bulk(0x03, output, TIMEOUT)?;

View File

@ -43,7 +43,7 @@ cfg_if::cfg_if! {
if #[cfg(any(chuni, chusanapp))] { if #[cfg(any(chuni, chusanapp))] {
type SliderCallbackFn = unsafe extern "C" fn(data: *const u8); type SliderCallbackFn = unsafe extern "C" fn(data: *const u8);
use std::thread::{self, JoinHandle}; use std::{sync::atomic::AtomicBool, thread::{self, JoinHandle}};
use ::log::info; use ::log::info;
use once_cell::sync::OnceCell; use once_cell::sync::OnceCell;
@ -69,7 +69,7 @@ cfg_if::cfg_if! {
use crate::configuration::Configuration; use crate::configuration::Configuration;
static COIN_COUNT: AtomicU16 = AtomicU16::new(0); static COIN_COUNT: AtomicU16 = AtomicU16::new(0);
static mut COIN_PRESSED: bool = false; static COIN_PRESSED: AtomicBool = AtomicBool::new(false);
lazy_static! { lazy_static! {
static ref CONFIGURATION: Configuration = { static ref CONFIGURATION: Configuration = {
@ -182,12 +182,12 @@ pub unsafe extern "C" fn chuni_io_jvs_read_coin_counter(total: *mut u16) {
if con_impl::is_coin_button_pressed(input_shmem.as_slice()) if con_impl::is_coin_button_pressed(input_shmem.as_slice())
|| GetAsyncKeyState(CONFIGURATION.coin_key as c_int) != 0 || GetAsyncKeyState(CONFIGURATION.coin_key as c_int) != 0
{ {
if !COIN_PRESSED { if !COIN_PRESSED.load(Ordering::Relaxed) {
COIN_PRESSED = true; COIN_PRESSED.store(true, Ordering::Relaxed);
COIN_COUNT.fetch_add(1, Ordering::Relaxed); COIN_COUNT.fetch_add(1, Ordering::Relaxed);
} }
} else { } else {
COIN_PRESSED = false; COIN_PRESSED.store(false, Ordering::Relaxed);
} }
*total = COIN_COUNT.load(Ordering::Relaxed); *total = COIN_COUNT.load(Ordering::Relaxed);