From: pin Date: Mon, 7 Jun 2010 14:21:02 +0000 (+0000) Subject: Configuration de la position de la barre de diodes dans le fichier de configuration. X-Git-Url: https://scm.cri.ensmp.fr/git/minwii.git/commitdiff_plain/11a91fe04d1d980af4c65414e73b5c3048c72cad?ds=sidebyside Configuration de la position de la barre de diodes dans le fichier de configuration. git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@222 fe552daf-6dbe-4428-90eb-1537e0879342 --- diff --git a/src/minwii/app.py b/src/minwii/app.py index f9385f6..ad2e382 100755 --- a/src/minwii/app.py +++ b/src/minwii/app.py @@ -39,7 +39,8 @@ class MinWii(object): def initWiimotes(self) : if self.wiimoteSupport : from pywiiuse import pygame_wiimouse - pygame_wiimouse.init(4, 5, self.screenResolution) # look for 4, wait 5 seconds + from minwii.config import IR_POSITION + pygame_wiimouse.init(4, 5, self.screenResolution, IR_POSITION) # look for 4, wait 5 seconds self.nwiimotes = nwiimotes = pygame_wiimouse.get_count() console.debug('wiimotes found : %d', nwiimotes) self.WT = WT = pygame_wiimouse.WT diff --git a/src/minwii/config.py b/src/minwii/config.py index 4a36201..14ec709 100755 --- a/src/minwii/config.py +++ b/src/minwii/config.py @@ -40,6 +40,7 @@ conf.set('playingscreen', 'FONT_COLOR', '(0,0,0)') conf.set('playingscreen', 'MIDI_VELOCITY_RANGE', '(64, 127)') conf.set('playingscreen', 'MIDI_PAN_RANGE', '(32, 96)') conf.set('playingscreen', 'MIDI_VELOCITY_WRONG_NOTE_ATTN', '0.5') +conf.set('playingscreen', 'IR_POSITION', 'ABOVE') conf.add_section('locations') conf.set('locations', 'notes_font_file', _computePath('fonts/Arial Unicode.ttf')) @@ -63,6 +64,7 @@ FONT_COLOR = str2IntTuple(conf.get('playingscreen', 'FONT_COLOR')) MIDI_VELOCITY_RANGE = str2IntTuple(conf.get('playingscreen', 'MIDI_VELOCITY_RANGE')) MIDI_PAN_RANGE = str2IntTuple(conf.get('playingscreen', 'MIDI_PAN_RANGE')) MIDI_VELOCITY_WRONG_NOTE_ATTN = conf.getfloat('playingscreen', 'MIDI_VELOCITY_WRONG_NOTE_ATTN') +IR_POSITION = conf.get('playingscreen', 'IR_POSITION') SONG_FILE_PATH = conf.get('locations', 'SONG_FILE_PATH') LOGS_DIR = conf.get('locations', 'LOGS_DIR') diff --git a/src/pywiiuse/pygame_wiimouse.py b/src/pywiiuse/pygame_wiimouse.py index 55a9c99..f77856c 100755 --- a/src/pywiiuse/pygame_wiimouse.py +++ b/src/pywiiuse/pygame_wiimouse.py @@ -127,18 +127,26 @@ class wiimote_thread(Thread): WT = None -def init(nmotes, timeout, screenResolution=(660, 370)): +def init(nmotes, timeout, screenResolution=(660, 370), position='ABOVE'): '''Initialize the module.''' global WT if WT: return WT = wiimote_thread(nmotes, timeout) + if position == 'ABOVE' : + position = wiiuse.IR_ABOVE + elif position == 'BELOW' : + position = wiiuse.IR_BELOW + else : + position = wiiuse.IR_ABOVE + + nmotes = get_count() for i in range(nmotes) : wm = Wiimote(i) # access the wiimote object wm.enable_accels(0) # turn off acceleration reporting - wm.enable_ir(1, vres = screenResolution, position=wiiuse.IR_ABOVE) + wm.enable_ir(1, vres = screenResolution, position=position) def get_count():