class BaseMessageInterface:

    def __init__(self, default_led_count=32):
        self.led = Strand(default_led_count) # long-lived stateful LEDStrip instance

    def issue_start_build_step(self, pixel, r, g, b):
        self.led.set(pixel, r, g, b)

    def issue_update_segment(self, tokens):
        start_idx = int(tokens[0])
        segment_width = int(tokens[1])
        seg_start_idx = (int(tokens[2]) - 1) * segment_width + start_idx
        seg_end_idx = seg_start_idx + segment_width
        seg_colour = colours[tokens[3].lower()]
        self.led.fill(seg_colour.R, seg_colour.G, seg_colour.B, seg_start_idx, seg_end_idx)
        self.led.update()

    def issue_update(self, tokens):
        start_idx = int(tokens[0])
        segment_count = int(tokens[1])
        segment_width = int(tokens[2])

        for i in range(segment_count):
            seg_colour = colours[tokens[i + 3].lower()]
            seg_start_idx = i * segment_width + start_idx
            seg_end_idx = seg_start_idx + segment_width
            self.led.fill(seg_colour.R, seg_colour.G, seg_colour.B, seg_start_idx, seg_end_idx)
            self.led.update()
 def __init__(self, default_led_count=32):
     self.led = Strand(default_led_count) # long-lived stateful LEDStrip instance