Skip to content

Commit

Permalink
Fixing colorperiod message, small formatting changes for led cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
danilo-pejovic committed Jan 4, 2024
1 parent f578b2b commit 71d790d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
10 changes: 5 additions & 5 deletions rae_bringup/scripts/led_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ def listener_callback(self, msg):
# Set LEDs based on battery level
# Define colors for LEDs
colors = {
"white": ColorPeriod(r=1.0, g=1.0, b=1.0, a=1.0, f =2.0),
"yellow": ColorPeriod(r=1.0, g=1.0, b=0.0, a=1.0, f =8.0),
"red": ColorPeriod(r=1.0, g=0.0, b=0.0, a=1.0, f =0.0),
"blue": ColorPeriod(r=0.0, g=0.0, b=1.0, a=1.0, f =0.0)
"white": ColorPeriod(r=1.0, g=1.0, b=1.0, a=1.0, frequency =2.0),
"yellow": ColorPeriod(r=1.0, g=1.0, b=0.0, a=1.0, frequency =8.0),
"red": ColorPeriod(r=1.0, g=0.0, b=0.0, a=1.0, frequency =0.0),
"blue": ColorPeriod(r=0.0, g=0.0, b=1.0, a=1.0, frequency =0.0)
}



# Create and publish LEDControl message for each LED
led_msg = LEDControl()
led_msg.header.stamp = self.get_clock().now().to_msg()
led_msg.data = [ColorPeriod(r=0.0, g=0.0, b=0.0, a=0.0, f =0.0)]*40
led_msg.data = [ColorPeriod(r=0.0, g=0.0, b=0.0, a=0.0, frequency =0.0)]*40

for i in range(39):
led_msg.single_led_n = 0
Expand Down
12 changes: 6 additions & 6 deletions rae_hw/src/peripherals/led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace rae_hw

setAllPixels(150, 10, 150, 0);
transmitSPI();

timer_ = this->create_wall_timer(std::chrono::milliseconds(50), std::bind(&LEDNode::timer_callback, this));
RCLCPP_INFO(this->get_logger(), "LED node running!");
}
Expand All @@ -104,28 +104,28 @@ namespace rae_hw
uint8_t r = convertColor(currentData_->data[0].r);
uint8_t g = convertColor(currentData_->data[0].g);
uint8_t b = convertColor(currentData_->data[0].b);
setAllPixels(r, g, b, currentData_-> data[0].f);
setAllPixels(r, g, b, currentData_-> data[0].frequency);
}
else if (currentData_->control_type == currentData_->CTRL_TYPE_SINGLE)
{
uint8_t r = convertColor(currentData_->data[0].r);
uint8_t g = convertColor(currentData_->data[0].g);
uint8_t b = convertColor(currentData_->data[0].b);
setSinglePixel(currentData_->single_led_n, r, g, b, currentData_-> data[0].f);
setSinglePixel(currentData_->single_led_n, r, g, b, currentData_-> data[0].frequency);
}
else if (currentData_->control_type == currentData_->CTRL_TYPE_SPINNER)
{
uint8_t r = convertColor(currentData_->data[0].r);
uint8_t g = convertColor(currentData_->data[0].g);
uint8_t b = convertColor(currentData_->data[0].b);
spinner(r, g, b, currentData_ -> animation_size, currentData_ -> animation_quantity, currentData_-> data[0].f);
spinner(r, g, b, currentData_ -> animation_size, currentData_ -> animation_quantity, currentData_-> data[0].frequency);
}
else if (currentData_->control_type == currentData_->CTRL_TYPE_FAN)
{
uint8_t r = convertColor(currentData_->data[0].r);
uint8_t g = convertColor(currentData_->data[0].g);
uint8_t b = convertColor(currentData_->data[0].b);
fan(r, g, b, true, currentData_ -> animation_quantity, currentData_-> data[0].f);
fan(r, g, b, true, currentData_ -> animation_quantity, currentData_-> data[0].frequency);
}
else
{
Expand All @@ -134,7 +134,7 @@ namespace rae_hw
uint8_t r = convertColor(currentData_->data[i].r);
uint8_t g = convertColor(currentData_->data[i].g);
uint8_t b = convertColor(currentData_->data[i].b);
setSinglePixel(i, r, g, b, currentData_-> data[i].f);
setSinglePixel(i, r, g, b, currentData_-> data[i].frequency);
}
}
transmitSPI();
Expand Down
7 changes: 2 additions & 5 deletions rae_msgs/msg/ColorPeriod.msg
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
float32 r
float32 g
float32 b
float32 a
float32 f
std_msgs/ColorRGBA color
float32 frequency

0 comments on commit 71d790d

Please sign in to comment.