Skip to content

Commit

Permalink
autodetect varibright (thanks @dinchak)
Browse files Browse the repository at this point in the history
  • Loading branch information
artfwo committed Feb 27, 2015
1 parent 35f9446 commit 986028a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions monome.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import asyncio
import aiosc
import itertools

import re

def pack_row(row):
return row[7] << 7 | row[6] << 6 | row[5] << 5 | row[4] << 4 | row[3] << 3 | row[2] << 2 | row[1] << 1 | row[0]
Expand All @@ -42,13 +42,13 @@ def unpack_row(val):


class Monome(aiosc.OSCProtocol):
def __init__(self, prefix='/python', varibright=True):
def __init__(self, prefix='/python'):
self.prefix = prefix.strip('/')
self.id = None
self.width = None
self.height = None
self.rotation = None
self.varibright = varibright
self.varibright = False

super().__init__(handlers={
'/sys/disconnect': lambda *args: self.disconnect,
Expand Down Expand Up @@ -84,6 +84,8 @@ def sys_info(self, addr, path, *args):
# in case rotation, etc. changes
# Note: arc will report 0, 0 for its size
if all(x is not None for x in [self.id, self.width, self.height, self.rotation]):
if re.match('^m\d+$', self.id):
self.varibright = True
self.ready()

def ready(self):
Expand Down

0 comments on commit 986028a

Please sign in to comment.