awawa-dev / HyperSerialEsp8266

High speed 2Mb USB serial port LED strip HyperHDR driver using Esp8266 device.
https://hyperhdr.blogspot.com
MIT License
37 stars 67 forks source link

My python program can't work with HyperSerialEsp8266 #32

Closed tihoangyeudau closed 1 year ago

tihoangyeudau commented 1 year ago

I have written a program in which the packet sent to HyperSerialEsp8266 has the following:

def test_packet(data: np.ndarray, color_order: str):
    pixel_length = len(data)
    packet = bytearray([
        ord('A'), ord('w'), ord('a'),
        (pixel_length >> 8), (pixel_length & 0x00FF)
    ])
    packet.append(packet[3] ^ packet[4] ^ 0x55)  # CRC

    byteData = data.astype(np.dtype('B'))

    # Rearrange colors based on the color_order
    # ... (as before)

    # Add color data to the packet
    for color in byteData:
        packet.append(color[0])  # Red
        packet.append(color[1])  # Green
        packet.append(color[2])  # Blue

    # Fletcher checksum
    fletcher1 = sum(packet[6:]) % 255
    fletcher2 = (sum(packet[6:]) + fletcher1) % 255
    packet.append(fletcher1)
    packet.append(fletcher2)

    return packet

however ws2812b shows nothing after running the . Am I wrong somewhere? can you help me fix it?

Im using python 3.11.4, windows 10, wemos d1 mini pinout D4, Led ws2812b, baud 1000000 and works well with HyperHDR

awawa-dev commented 1 year ago

Probably not a valid Fletcher checksum computed this way.