diff --git a/demos/applications/apa102.cpp b/demos/applications/apa102.cpp index 94d4aec..97b42e9 100644 --- a/demos/applications/apa102.cpp +++ b/demos/applications/apa102.cpp @@ -18,7 +18,7 @@ #include "../resource_list.hpp" -hal::byte build_brightness_byte(int p_brightness) +hal::byte build_brightness_byte(unsigned p_brightness) { hal::byte starting_bits = 0b11100000; if (p_brightness > 31) { @@ -34,11 +34,11 @@ void update_single(hal::display::apa102_pixel& p_rgb, hal::display::apa102_frame& p_led_frames) { if (p_led_number < PixelCount) { - p_led_frames.data[p_led_number].brightness = + p_led_frames.pixels[p_led_number].brightness = build_brightness_byte(p_brightness); - p_led_frames.data[p_led_number].blue = p_rgb.blue; - p_led_frames.data[p_led_number].green = p_rgb.green; - p_led_frames.data[p_led_number].red = p_rgb.red; + p_led_frames.pixels[p_led_number].blue = p_rgb.blue; + p_led_frames.pixels[p_led_number].green = p_rgb.green; + p_led_frames.pixels[p_led_number].red = p_rgb.red; } } diff --git a/include/libhal-display/apa102.hpp b/include/libhal-display/apa102.hpp index d95f1ec..20404be 100644 --- a/include/libhal-display/apa102.hpp +++ b/include/libhal-display/apa102.hpp @@ -38,12 +38,12 @@ static_assert(4U == sizeof(apa102_pixel), * @brief Contains data to send over SPI and information about size of the data * to send over * - * @tparam LedCount - Number of LEDs to control + * @tparam pixel_count - Number of pixels to control */ -template +template struct apa102_frame { - std::array data; + std::array pixels; }; /** @@ -66,14 +66,14 @@ class apa102 /** * @brief Update the state of the LEDs * - * @tparam LedCount - Number of LEDs to control is set implicitly, user should - * not set it manually + * @tparam pixel_count - Number of pixels to control is set implicitly, user + * should not set it manually * @param p_spi_frame spi frame to send to control LEDs */ - template - void update(apa102_frame& p_spi_frame) + template + void update(apa102_frame& p_spi_frame) { - update(p_spi_frame.data); + update(p_spi_frame.pixels); } private: diff --git a/src/apa102.cpp b/src/apa102.cpp index f16f58a..653a80a 100644 --- a/src/apa102.cpp +++ b/src/apa102.cpp @@ -15,11 +15,11 @@ apa102::apa102(hal::spi& p_spi, hal::output_pin& p_chip_select) } // public -void apa102::update(std::span p_data) +void apa102::update(std::span p_pixels) { m_chip_select->level(false); hal::write(*m_spi, std::array{ 0x00, 0x00, 0x00, 0x00 }); - hal::write(*m_spi, hal::as_bytes(p_data)); + hal::write(*m_spi, hal::as_bytes(p_pixels)); hal::write(*m_spi, std::array{ 0xFF, 0xFF, 0xFF, 0xFF }); m_chip_select->level(true); }