diff --git a/pizzactrl/fs_names.py b/pizzactrl/fs_names.py index 6cfbf7c..1eb8ab7 100644 --- a/pizzactrl/fs_names.py +++ b/pizzactrl/fs_names.py @@ -98,4 +98,4 @@ SFX_SHUTTER = SfxFile('done') SFX_REC_AUDIO = SfxFile('countdown') SFX_STOP_REC = SfxFile('done') -SND_SELECT_LANG = StoryFile(name='01') +SND_SELECT_LANG = StoryFile(name='IC-SIBI-00') diff --git a/pizzactrl/hal.py b/pizzactrl/hal.py index 4cd08b6..57a6e58 100644 --- a/pizzactrl/hal.py +++ b/pizzactrl/hal.py @@ -198,6 +198,7 @@ def advance(motor: Motor, sensor: ScrollSensor, speed: float=0.3, @blocking def rewind(motor: Motor, sensor: ScrollSensor, direction: bool=True, max_time: float=13.2): + # TODO fix this if sensor.is_home: return sensor.eot_callback = motor.off diff --git a/pizzactrl/hal_serial.py b/pizzactrl/hal_serial.py index 36c9402..3144065 100644 --- a/pizzactrl/hal_serial.py +++ b/pizzactrl/hal_serial.py @@ -194,7 +194,7 @@ def play_sound(hal: PizzaHAL, sound: Any, **kwargs): @blocking -def record_sound(hal: PizzaHAL, filename: Any, duration: int, +def record_sound(hal: PizzaHAL, filename: Any, duration: float, cache: bool = False, **kwargs): """ Record sound using the microphone @@ -207,7 +207,7 @@ def record_sound(hal: PizzaHAL, filename: Any, duration: int, myrecording = sd.rec(int(duration * AUDIO_REC_SR), samplerate=AUDIO_REC_SR, channels=2) - resp = hal.send_cmd(SerialCommands.RECORD, duration).strip() + resp = hal.send_cmd(SerialCommands.RECORD, int(duration)).strip() if resp == b'I': sd.stop() else: diff --git a/pizzactrl/main.py b/pizzactrl/main.py index c1507bb..895522f 100644 --- a/pizzactrl/main.py +++ b/pizzactrl/main.py @@ -13,7 +13,8 @@ logger = logging.getLogger('pizzactrl.main') @click.option('--move', is_flag=True) @click.option('--test', is_flag=True, default=False) @click.option('--debug', is_flag=True, default=False) -def main(move: bool=False, test: bool=False, debug: bool=False): +@click.option('--loop', is_flag=True, default=False) +def main(move: bool=False, test: bool=False, debug: bool=False, loop: bool=False): if debug or test: logging.basicConfig(level=logging.DEBUG, stream=sys.stdout) else: @@ -21,7 +22,8 @@ def main(move: bool=False, test: bool=False, debug: bool=False): sm = Statemachine(story_de=sb_de.STORYBOARD, story_en=sb_en.STORYBOARD, - move=move) + move=move, + loop=loop) sm.test = test exitcode = 0 diff --git a/pizzactrl/sb_en.py b/pizzactrl/sb_en.py index 31baa24..2a9986d 100644 --- a/pizzactrl/sb_en.py +++ b/pizzactrl/sb_en.py @@ -16,7 +16,7 @@ STORYBOARD = [ storyboard.Chapter( storyboard.Do(storyboard.Activity.PLAY_SOUND, sound=fs_names.StoryFile('IC-SIBI-03')), - # storyboard.Do(storyboard.Activity.ADVANCE_UP), # VERT02down + # storyboard.Do(storyboard.Activity.ADVANCE_UP, steps=90), # VERT02down storyboard.Do(storyboard.Activity.LIGHT_BACK, intensity=1.0, fade=0.5), storyboard.Do(storyboard.Activity.LIGHT_LAYER, diff --git a/pizzactrl/statemachine.py b/pizzactrl/statemachine.py index b18f0c5..04031b9 100644 --- a/pizzactrl/statemachine.py +++ b/pizzactrl/statemachine.py @@ -74,6 +74,7 @@ class Statemachine: State.POST: self._post, State.IDLE_START: self._idle_start, State.PLAY: self._play, + State.REWIND: self._rewind, State.IDLE_END: self._idle_end } while (self.state is not State.ERROR) and \ @@ -127,11 +128,13 @@ class Statemachine: # Callback for start when blue button is held self.hal.btn_start.when_activated = self._start_or_rewind + logger.debug('start button callback activated') # play a sound if everything is alright play_sound(self.hal, fs_names.SFX_POST_OK) self.state = State.IDLE_START + logger.debug('idle_start') def _idle_start(self): """ @@ -207,11 +210,15 @@ class Statemachine: Rewind all scrolls, post-process videos """ # postprocessing + logger.debug('Converting video...') cmdstring = f'MP4Box -add {fs_names.REC_DRAW_CITY} {fs_names.REC_MERGED_VIDEO}' call([cmdstring], shell=True) + logger.debug('Rewinding...') if self.move: rewind(self.hal) + for chapter in self.story: + chapter.rewind() if self.loop: self.state = State.IDLE_START diff --git a/pizzactrl/storyboard.py b/pizzactrl/storyboard.py index 2ddd151..c3fe930 100644 --- a/pizzactrl/storyboard.py +++ b/pizzactrl/storyboard.py @@ -8,7 +8,7 @@ class Activity(Enum): RECORD_VIDEO = {'duration': 0.0, 'filename': ''} TAKE_PHOTO = {'filename': ''} ADVANCE_UP = {'speed': 0.3, 'direction': True, 'steps': 100} - ADVANCE_LEFT = {'speed': 0.3, 'direction': True, 'steps': 180} # TODO set right number of steps + ADVANCE_LEFT = {'speed': 0.3, 'direction': True, 'steps': 200} # TODO set right number of steps LIGHT_LAYER = {'intensity': 1.0, 'fade': 0.0, 'layer': True} LIGHT_BACK = {'intensity': 1.0, 'fade': 0.0}