def compress565(r: int, g: int, b: int):
    """Compress an RGB triplet into 565-packed data."""
    # RRRRRGGG GGGBBBBB
    return (
        (r & 0b11111000) | (g >> 5),
        (g << 5) & 0b11100000 | (b >> 3)
    )