Skip to content

Commit

Permalink
Rename stuff to pixels instead of leds
Browse files Browse the repository at this point in the history
  • Loading branch information
MaliaLabor committed Sep 3, 2024
1 parent be045b6 commit 22a6846
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions demos/applications/apa102.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -34,11 +34,11 @@ void update_single(hal::display::apa102_pixel& p_rgb,
hal::display::apa102_frame<PixelCount>& 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;
}
}

Expand Down
16 changes: 8 additions & 8 deletions include/libhal-display/apa102.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::size_t led_count>
template<std::size_t pixel_count>
struct apa102_frame
{
std::array<apa102_pixel, led_count> data;
std::array<apa102_pixel, pixel_count> pixels;
};

/**
Expand All @@ -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<std::size_t LedCount>
void update(apa102_frame<LedCount>& p_spi_frame)
template<std::size_t pixel_count>
void update(apa102_frame<pixel_count>& p_spi_frame)
{
update(p_spi_frame.data);
update(p_spi_frame.pixels);
}

private:
Expand Down
4 changes: 2 additions & 2 deletions src/apa102.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ apa102::apa102(hal::spi& p_spi, hal::output_pin& p_chip_select)
}

// public
void apa102::update(std::span<apa102_pixel> p_data)
void apa102::update(std::span<apa102_pixel> p_pixels)
{
m_chip_select->level(false);
hal::write(*m_spi, std::array<hal::byte, 4>{ 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<hal::byte, 4>{ 0xFF, 0xFF, 0xFF, 0xFF });
m_chip_select->level(true);
}
Expand Down

0 comments on commit 22a6846

Please sign in to comment.