tingbot / tingbot-python

🔩 Python APIs to write apps for Tingbot
Other
18 stars 9 forks source link

Old button notation API issue #29

Closed WhistleMaster closed 8 years ago

WhistleMaster commented 8 years ago

With the old notation @button.press('left'): buttons press are taken into account multiple times (score counter increase 2 by 2 as an example).

import tingbot
from tingbot import *
import random

state = {'score': 0}

@button.press('left')
def next():
    state['score'] += 1

@button.press('right')
def next():
    state['score'] -= 1

@button.press('midleft')
def next():
    state['score'] += 10

@button.press('midright')
def next():
    state['score'] -= 10

def loop():
    screen.fill(
        color='black')
    screen.text(
        state['score'],
        align='center',
        color=(random.randint(0, 255), random.randint(0, 255), 0))

tingbot.run(loop)
joerick commented 8 years ago

Hey @WhistleMaster, this might be caused by a change to the GPIO code (79c9f87e9acfed84c7eb96cf400eced53d5529c8). I made a branch without this to test - could you try with this issue-29 branch? Here's the zipball link: https://github.com/tingbot/tingbot-python/archive/issue-29.zip