Пример #1
0
async def _check(data: ScreenShot, iter: int):
    pix = data.pixel(POSLIST[iter], 0)

    trigger = False

    if iter == 0:  # green
        if pix[1] > LIMITLIST[iter] and pix[1] == max(pix):
            trigger = True
        elif pix[1] > LIMITLIST[iter] + 30:
            trigger = True

    elif iter == 1:  # red
        if pix[0] > LIMITLIST[iter] and pix[0] == max(pix):
            trigger = True
        elif pix[0] > LIMITLIST[iter] + 30:
            trigger = True

    elif iter == 2:  # yellow
        if any(x > LIMITLIST[iter] for x in pix):
            trigger = True
    else:
        return

    if trigger:
        #if any(x > LIMITLIST[iter] for x in pix):
        await _triggerButton(iter)
        global resultList
        print(KEYMAPPING[iter], pix)
        resultList.append(max(pix))
Пример #2
0
async def _check(data: ScreenShot, iter: int):
    pix = data.pixel(POSLIST[iter], 8)

    trigger = False
    """
    if iter == 0: # green
        color = "green"import json
import sys
        if pix[1] > LIMITLIST[iter] and pix[1] == max(pix):
            trigger = True
        elif pix[1] > LIMITLIST[iter] + 30:
            trigger = True
            
    elif iter == 1: # red
        color = "red"
        if pix[0] > LIMITLIST[iter] and pix[0] == max(pix):
            trigger = True
        elif pix[0] > LIMITLIST[iter] + 30:
            trigger = True

    elif iter == 2: # yellow
        color = "yellow"
        if any(x > LIMITLIST[iter] for x in pix):
            trigger = True
    else:
        return
    """

    #if trigger:
    if any(x > LIMITLIST[iter] for x in pix):
        await _triggerButton(iter)
        await _saveImage(data, CATLIST[iter])

        global resultList
        print(KEYMAPPING[iter], pix)
        resultList.append(max(pix))
    else:
        if random.randint(0, 100) <= 1:
            #pass
            await _saveImage(data, CATLIST[-1])
Пример #3
0
def test_bad_length():
    data = bytearray(b"789c626001000000ffff030000060005")
    image = ScreenShot.from_size(data, 1024, 768)
    with pytest.raises(ValueError):
        image.rgb
Пример #4
0
def test_good_types(raw):
    image = ScreenShot.from_size(bytearray(raw), 1024, 768)
    assert isinstance(image.raw, bytearray)
    assert isinstance(image.rgb, bytes)