diff --git a/src/backends/tasoller_v2.rs b/src/backends/tasoller_v2.rs index a2a04b1..7789685 100644 --- a/src/backends/tasoller_v2.rs +++ b/src/backends/tasoller_v2.rs @@ -18,7 +18,7 @@ //! ### OUT Bulk (0x03) //! - Content length: 240 bytes //! - 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 168..240: Right tower LEDs (GRB) @@ -82,9 +82,9 @@ pub fn set_slider_leds( rgb: &[u8], ) -> Result<()> { 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[1] = state_chunk[0]; - buf_chunk[2] = state_chunk[2]; + buf_chunk[0] = state_chunk[2]; + buf_chunk[1] = state_chunk[1]; + buf_chunk[2] = state_chunk[0]; } device.write_bulk(0x03, output, TIMEOUT)?; diff --git a/src/lib.rs b/src/lib.rs index 6adf591..17cb0df 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -43,7 +43,7 @@ cfg_if::cfg_if! { if #[cfg(any(chuni, chusanapp))] { 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 once_cell::sync::OnceCell; @@ -69,7 +69,7 @@ cfg_if::cfg_if! { use crate::configuration::Configuration; static COIN_COUNT: AtomicU16 = AtomicU16::new(0); - static mut COIN_PRESSED: bool = false; + static COIN_PRESSED: AtomicBool = AtomicBool::new(false); lazy_static! { 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()) || GetAsyncKeyState(CONFIGURATION.coin_key as c_int) != 0 { - if !COIN_PRESSED { - COIN_PRESSED = true; + if !COIN_PRESSED.load(Ordering::Relaxed) { + COIN_PRESSED.store(true, Ordering::Relaxed); COIN_COUNT.fetch_add(1, Ordering::Relaxed); } } else { - COIN_PRESSED = false; + COIN_PRESSED.store(false, Ordering::Relaxed); } *total = COIN_COUNT.load(Ordering::Relaxed);