Skip to content

Commit

Permalink
Merge pull request #152 from husarion/ros1-fix-coding-style-lights
Browse files Browse the repository at this point in the history
Add floating precision
  • Loading branch information
KmakD authored Jul 24, 2023
2 parents 09a2e86 + 97e8f8c commit 79f5b89
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions panther_lights/src/animation/battery_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def _color_rising(self, battery_percent: float, progress: float) -> np.array:
frame = np.zeros((self._num_led, 3), dtype=np.uint8)
led_to_disp = battery_percent * self._num_led

middle_led = (self._num_led - 1) / 2
middle_led = (self._num_led - 1) / 2.0
ind_1 = int(np.ceil(middle_led - progress * led_to_disp / 2.0))
ind_2 = int(np.floor(middle_led + progress * led_to_disp / 2.0))

Expand All @@ -79,9 +79,9 @@ def _color_rising(self, battery_percent: float, progress: float) -> np.array:
def _fill_frame(self, frame: np.array, battery_percent: float, progress: float) -> np.array:
led_to_disp = battery_percent * self._num_led

middle_led = (self._num_led - 1) / 2
ind_1 = int(np.ceil(middle_led - (1 - progress) * led_to_disp / 2.0))
ind_2 = int(np.floor(middle_led + (1 - progress) * led_to_disp / 2.0))
middle_led = (self._num_led - 1) / 2.0
ind_1 = int(np.ceil(middle_led - (1.0 - progress) * led_to_disp / 2.0))
ind_2 = int(np.floor(middle_led + (1.0 - progress) * led_to_disp / 2.0))

rgb = self._calculate_color(battery_percent)
frame[ind_1] = rgb
Expand Down

0 comments on commit 79f5b89

Please sign in to comment.