Mercurial > code > home > repos > light9
changeset 253:a92b6d1ac072
SubClient created, keyboardcomposer and gyrocontroller use it now
Plus some minor cleanups in keyboardcomposer and gyrocontroller
author | David McClosky <dmcc@bigasterisk.com> |
---|---|
date | Wed, 15 Jun 2005 04:28:16 +0000 |
parents | 40e7d08e0123 |
children | 1546c423b467 |
files | bin/gyrocontroller bin/keyboardcomposer light9/subclient.py |
diffstat | 3 files changed, 30 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/gyrocontroller Wed Jun 15 04:14:18 2005 +0000 +++ b/bin/gyrocontroller Wed Jun 15 04:28:16 2005 +0000 @@ -1,10 +1,9 @@ #!/usr/bin/env python # vi: syntax=python -from __future__ import division import run_local from light9.Submaster import combine_subdict -from light9 import dmxclient, showconfig +from light9.subclient import SubClient class circcycle: """Like itertools.cycle, but with a prev() method too. You lose @@ -27,7 +26,7 @@ self._change_index(-1) return ret -class AbstractSimpleController: +class AbstractSimpleController(SubClient): """Simple controller with minimal input and output: Input is 4 directions and 3 buttons. @@ -38,6 +37,7 @@ B3: toggle keep/solo mode Double-B3: clear kept levels""" def __init__(self, subnames): + SubClient.__init__(self) self.subnames = subnames self.refresh() def refresh(self): @@ -60,20 +60,15 @@ self.kept_levels[self.current_sub] = self.current_level self.current_sub = self.submasters.get_sub_by_name(self.all_subs.prev()) + def get_levels_as_sub(self): if self.keep_solo_mode == 'keep': # send all levels in self.kept_levels - levels = combine_subdict(self.kept_levels) + levelsub = combine_subdict(self.kept_levels) else: - levels = {self.current_sub : self.current_level} + levelsub = self.current_sub * self.current_level - return levels - def get_dmx_list(self): - maxes = self.get_levels_as_sub() - return maxes.get_dmx_list() - def send_levels(self): - levels = self.get_dmx_list() - dmxclient.outputlevels(levels) + return levelsub if __name__ == "__main__": if 0:
--- a/bin/keyboardcomposer Wed Jun 15 04:14:18 2005 +0000 +++ b/bin/keyboardcomposer Wed Jun 15 04:28:16 2005 +0000 @@ -6,7 +6,7 @@ from twisted.internet import reactor,tksupport from twisted.web import xmlrpc, server from Tix import * -import math, atexit, pickle +import pickle import run_local from light9.Fadable import Fadable @@ -53,11 +53,11 @@ levellabel.pack(side=TOP) self.scale.pack(side=BOTTOM, expand=1, fill=BOTH) -class KeyboardComposer(Frame): - def __init__(self, root, submasters, current_sub_levels=None, dmxdummy=0): +class KeyboardComposer(Frame, SubClient): + def __init__(self, root, submasters, current_sub_levels=None): Frame.__init__(self, root, bg='black') + SubClient.__init__(self) self.submasters = submasters - self.dmxdummy = dmxdummy self.current_sub_levels = {} if current_sub_levels: @@ -226,17 +226,6 @@ self.send_levels() self.after(10, self.send_frequent_updates) - def get_dmx_list(self): - maxes = self.get_levels_as_sub() - return maxes.get_dmx_list() - def send_levels(self): - if not self.dmxdummy: - levels = self.get_dmx_list() - dmxclient.outputlevels(levels) - # print "sending levels", levels - def send_levels_loop(self): - self.send_levels() - self.after(1000, self.send_levels_loop) def refresh(self): self.save() self.submasters = Submasters() @@ -267,7 +256,7 @@ root = Tk() tl = toplevelat("Keyboard Composer", existingtoplevel=root) - kc = KeyboardComposer(tl, s, dmxdummy=0) + kc = KeyboardComposer(tl, s) kc.pack(fill=BOTH, expand=1) ls = LevelServer(kc.name_to_subtk)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/light9/subclient.py Wed Jun 15 04:28:16 2005 +0000 @@ -0,0 +1,18 @@ +from light9 import dmxclient + +# later, this stuff will talk to a SubServer +class SubClient: + def get_levels_as_sub(self): + """Subclasses must implement this method and return a Submaster + object.""" + def get_dmx_list(self): + maxes = self.get_levels_as_sub() + return maxes.get_dmx_list() + def send_levels(self): + levels = self.get_dmx_list() + dmxclient.outputlevels(levels) + def send_levels_loop(self, delay=1000): + """This function assumes that we are an instance of a Tk object + (or at least that we have an 'after' method)""" + self.send_levels() + self.after(delay, self.send_levels_loop, delay)