julianschill / klipper-led_effect

LED effects plugin for klipper
GNU General Public License v3.0
643 stars 116 forks source link

Simulator only showing line #208

Open kevinkhill opened 2 weeks ago

kevinkhill commented 2 weeks ago

I got the simulator up and running, but was saddened when the layout did not switch to circle.

I have a 16 pixel ring and want to experiment, but the only layout that works in the simulator for me is line. Circle, Triangle and Voron all do not work for me.

kevinkhill commented 2 weeks ago

I think I might have found the issue! The difference between the x,y in Rectangle vs all the others, is that they were int

I tried adding a method like this

def _push_led_coordinates(self, x, y, size, round_xy=False):
    if round_xy is True:
        self.led_coordinates += [(round(x), round(y), size)]
    else:
        self.led_coordinates += [(x, y, size)]

Then switched out self.led_coordinates += [(x, y, size)] in _calc_coordinates() to use that method. With rectangle, I didn't use the 4th param to round, but enabling it in Circle worked!

elif self.m_cbLayout.GetValue() == "Circle":
    self.m_spinLines.Enable(False)
    r = distance * self.led_count / (2 * math.pi)
    for i in range(self.led_count):
        a = 2 * math.pi / self.led_count * i
        x = r * math.sin(a)
        y = r * math.cos(a)
        self._push_led_coordinates(x, y, size, round_xy=True)

image

(Triangle seems to have a slight issue in the algorithm leaving gaps at certain counts) image image