1
0
Fork 0

reduce pollution of the global namespace

This commit is contained in:
Kevin Matz 2018-10-25 13:02:59 -04:00
parent 48d8c3ec4f
commit ee08529059
1 changed files with 10 additions and 8 deletions

View File

@ -22,19 +22,19 @@ from time import sleep
logger = logging.getLogger("CommentMacro") logger = logging.getLogger("CommentMacro")
# button state constants
buttonDOWN = 1
buttonUP = 0
class HogDevice(): class HogDevice():
# button state constants
buttonDOWN = 1
buttonUP = 0
def __init__(self, servers): def __init__(self, servers):
self.servers = servers self.servers = servers
def button_press(self, device, path, delay=0.05): def button_press(self, device, path, delay=0.05):
self.send_message(device, path, buttonDOWN) # button down self.send_message(device, path, HogDevice.buttonDOWN) # button down
sleep(delay) sleep(delay)
self.send_message(device, path, buttonUP) # button up self.send_message(device, path, HogDevice.buttonUP) # button up
# utility function to send simple messages with one argument # utility function to send simple messages with one argument
def send_message(self, device, path, arg): def send_message(self, device, path, arg):
@ -160,9 +160,11 @@ class HogDevice():
def _release_all(self, ctx): def _release_all(self, ctx):
logger.info("Release All") logger.info("Release All")
self.osc.send_message(ctx.device, "/hog/hardware/pig", buttonDOWN) self.osc.send_message(ctx.device, "/hog/hardware/pig",
HogDevice.buttonDOWN)
self.osc.button_press(ctx.device, "/hog/hardware/release") self.osc.button_press(ctx.device, "/hog/hardware/release")
self.osc.send_message(ctx.device, "/hog/hardware/pig", buttonUP) self.osc.send_message(ctx.device, "/hog/hardware/pig",
HogDevice.buttonUP)
def _list_go(self, ctx): def _list_go(self, ctx):
for i in ctx.targets: for i in ctx.targets: