def write_data(self, write_finished_cb):
        """Write the saved LED-ring data to the Crazyflie"""
        self._write_finished_cb = write_finished_cb
        data = bytearray()
        for led in self.leds:
            # In order to fit all the LEDs in one radio packet RGB565 is used
            # to compress the colors. The calculations below converts 3 bytes
            # RGB into 2 bytes RGB565. Then shifts the value of each color to
            # LSB, applies the intensity and shifts them back for correct
            # alignment on 2 bytes.
            R5 = ((int)((((int(led.r) & 0xFF) * 249 + 1014) >> 11) & 0x1F) *
                  led.intensity / 100)
            G6 = ((int)((((int(led.g) & 0xFF) * 253 + 505) >> 10) & 0x3F) *
                  led.intensity / 100)
            B5 = ((int)((((int(led.b) & 0xFF) * 249 + 1014) >> 11) & 0x1F) *
                  led.intensity / 100)
            tmp = (int(R5) << 11) | (int(G6) << 5) | (int(B5) << 0)
            data += bytearray((tmp >> 8, tmp & 0xFF))
        self.mem_handler.write(self, 0x00, data, flush_queue=True)
def write_data ( self , write_finished_cb ) : self . _write_finished_cb = write_finished_cb data = bytearray ( ) for led in self . leds : R5 = ( ( int ) ( ( ( ( int ( led . r ) & 0xFF ) * 249 + 1014 ) >> 11 ) & 0x1F ) * led . intensity / 100 ) G6 = ( ( int ) ( ( ( ( int ( led . g ) & 0xFF ) * 253 + 505 ) >> 10 ) & 0x3F ) * led . intensity / 100 ) B5 = ( ( int ) ( ( ( ( int ( led . b ) & 0xFF ) * 249 + 1014 ) >> 11 ) & 0x1F ) * led . intensity / 100 ) tmp = ( int ( R5 ) << 11 ) | ( int ( G6 ) << 5 ) | ( int ( B5 ) << 0 ) data += bytearray ( ( tmp >> 8 , tmp & 0xFF ) ) self . mem_handler . write ( self , 0x00 , data , flush_queue = True )
Write the saved LED-ring data to the Crazyflie