From 2859a23b1e0b3e284b5ea4854d7ce3593b10febb Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Fri, 6 Aug 2021 23:32:04 -0400 Subject: [PATCH] Rename WS28xx* to Ws28xx* --- .../src/adapter_gen.rs | 12 ++++++------ .../src/adapter_spi.rs | 18 +++++++++--------- src/strip.rs | 8 ++++---- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib-ws2818-rgb-led-spi-driver/src/adapter_gen.rs b/lib-ws2818-rgb-led-spi-driver/src/adapter_gen.rs index 232bf15..90f39a8 100644 --- a/lib-ws2818-rgb-led-spi-driver/src/adapter_gen.rs +++ b/lib-ws2818-rgb-led-spi-driver/src/adapter_gen.rs @@ -9,7 +9,7 @@ pub trait HardwareDev { fn write_all(&mut self, encoded_data: &[u8]) -> Result<(), String>; } -pub trait WS28xxAdapter { +pub trait Ws28xxAdapter { /// Returns a reference to the hardware device. /// This function only needs to be implemented once in the generic adapter. fn get_hw_dev(&mut self) -> &mut Box; @@ -18,7 +18,7 @@ pub trait WS28xxAdapter { /// is the number of LEDs you want to write to. *Note* that if you have performance critical /// applications (like you need a signal on the LEDS on a given time) it's a better idea /// to encode the data earlier by yourself using `crate::encoding`-module and calling - /// `WS28xxAdapter::write_encoded_rgb`. Otherwise and if your device is slow the encoding + /// `Ws28xxAdapter::write_encoded_rgb`. Otherwise and if your device is slow the encoding /// could cost a few microseconds to milliseconds - depending on your amount of data and machine. fn write_rgb(&mut self, rgb_data: &[(u8, u8, u8)]) -> Result<(), String> { let encoded_data = encode_rgb_slice(rgb_data); @@ -47,13 +47,13 @@ pub trait WS28xxAdapter { } /// Platform agnostic (generic) adapter that connects your application via your specified -/// hardware interface to your WS28xx LEDs. *Handle this as something like an abstract class +/// hardware interface to your Ws28xx LEDs. *Handle this as something like an abstract class /// for concrete implementations!* This works in `#[no-std]`-environments. -pub struct WS28xxGenAdapter { +pub struct Ws28xxGenAdapter { hw: Box, } -impl WS28xxGenAdapter { +impl Ws28xxGenAdapter { /// Constructor that stores the hardware device in the adapter. pub fn new(hw: Box) -> Self { Self { hw } @@ -61,7 +61,7 @@ impl WS28xxGenAdapter { } // Implement the getter for the hardware device. -impl WS28xxAdapter for WS28xxGenAdapter { +impl Ws28xxAdapter for Ws28xxGenAdapter { fn get_hw_dev(&mut self) -> &mut Box { &mut self.hw } diff --git a/lib-ws2818-rgb-led-spi-driver/src/adapter_spi.rs b/lib-ws2818-rgb-led-spi-driver/src/adapter_spi.rs index aec5754..84e7fb9 100644 --- a/lib-ws2818-rgb-led-spi-driver/src/adapter_spi.rs +++ b/lib-ws2818-rgb-led-spi-driver/src/adapter_spi.rs @@ -1,6 +1,6 @@ //! Adapter for SPI-dev on Linux-systems. This requires std. -use crate::adapter_gen::{HardwareDev, WS28xxAdapter, WS28xxGenAdapter}; +use crate::adapter_gen::{HardwareDev, Ws28xxAdapter, Ws28xxGenAdapter}; use crate::timings::PI_SPI_HZ; use alloc::boxed::Box; use alloc::string::{String, ToString}; @@ -28,7 +28,7 @@ impl HardwareDev for SpiHwAdapterDev { impl SpiHwAdapterDev { /// Connects your application with the SPI-device of your device. /// This uses the `spidev`-crate. Returns a new adapter object - /// for the WS28xx LEDs. + /// for the Ws28xx LEDs. /// /// * `dev` - Device name. Probably "/dev/spidev0.0" if available. /// @@ -46,17 +46,17 @@ impl SpiHwAdapterDev { } } -/// Adapter that connects your application via SPI to your WS28xx LEDs. +/// Adapter that connects your application via SPI to your Ws28xx LEDs. /// This requires an SPI device on your machine. This doesn't work /// with `#[no-std]`. -pub struct WS28xxSpiAdapter { - gen: WS28xxGenAdapter, +pub struct Ws28xxSpiAdapter { + gen: Ws28xxGenAdapter, } -impl WS28xxSpiAdapter { +impl Ws28xxSpiAdapter { /// Connects your application with the SPI-device of your device. /// This uses the `spidev`-crate. Returns a new adapter object - /// for the WS28xx LEDs. + /// for the Ws28xx LEDs. /// /// * `dev` - Device name. Probably "/dev/spidev0.0" if available. /// @@ -64,12 +64,12 @@ impl WS28xxSpiAdapter { pub fn new(dev: &str) -> Result { let spi = SpiHwAdapterDev::new(dev).map_err(|err| err.to_string())?; let spi = Box::from(spi); - let gen = WS28xxGenAdapter::new(spi); + let gen = Ws28xxGenAdapter::new(spi); Ok(Self { gen }) } } -impl WS28xxAdapter for WS28xxSpiAdapter { +impl Ws28xxAdapter for Ws28xxSpiAdapter { fn get_hw_dev(&mut self) -> &mut Box { // forward to generic adapter // todo this is not the best code design because this requires diff --git a/src/strip.rs b/src/strip.rs index f8afdb2..a66d39f 100644 --- a/src/strip.rs +++ b/src/strip.rs @@ -5,8 +5,8 @@ use std::ops::Add; use std::process; use std::sync::mpsc::Receiver; use std::time::{Duration, Instant}; -use ws2818_rgb_led_spi_driver::adapter_gen::WS28xxAdapter; -use ws2818_rgb_led_spi_driver::adapter_spi::WS28xxSpiAdapter; +use ws2818_rgb_led_spi_driver::adapter_gen::Ws28xxAdapter; +use ws2818_rgb_led_spi_driver::adapter_spi::Ws28xxSpiAdapter; /// Maximum number of lights allowed const MAX_NUM_LIGHTS: u16 = 128; @@ -37,7 +37,7 @@ pub enum Message { #[allow(clippy::module_name_repetitions)] pub struct LEDStrip { - pub adapter: Box, + pub adapter: Box, pub config: Config, pub pattern: Box, } @@ -45,7 +45,7 @@ pub struct LEDStrip { impl LEDStrip { pub fn new(config: Config) -> Self { let adapter = Box::new( - WS28xxSpiAdapter::new("/dev/spidev0.0").expect("Cannot locate device /dev/spidev0.0!"), + Ws28xxSpiAdapter::new("/dev/spidev0.0").expect("Cannot locate device /dev/spidev0.0!"), ); let pattern = Box::new(pattern::Solid::new(color::BLACK)); let num_lights = config.num_lights;