ready for open house presentation

This commit is contained in:
jpunkt 2021-11-19 16:09:49 +01:00
parent f805379385
commit 1fd975fd66
7 changed files with 17 additions and 7 deletions

View file

@ -98,4 +98,4 @@ SFX_SHUTTER = SfxFile('done')
SFX_REC_AUDIO = SfxFile('countdown') SFX_REC_AUDIO = SfxFile('countdown')
SFX_STOP_REC = SfxFile('done') SFX_STOP_REC = SfxFile('done')
SND_SELECT_LANG = StoryFile(name='01') SND_SELECT_LANG = StoryFile(name='IC-SIBI-00')

View file

@ -198,6 +198,7 @@ def advance(motor: Motor, sensor: ScrollSensor, speed: float=0.3,
@blocking @blocking
def rewind(motor: Motor, sensor: ScrollSensor, direction: bool=True, def rewind(motor: Motor, sensor: ScrollSensor, direction: bool=True,
max_time: float=13.2): max_time: float=13.2):
# TODO fix this
if sensor.is_home: if sensor.is_home:
return return
sensor.eot_callback = motor.off sensor.eot_callback = motor.off

View file

@ -194,7 +194,7 @@ def play_sound(hal: PizzaHAL, sound: Any, **kwargs):
@blocking @blocking
def record_sound(hal: PizzaHAL, filename: Any, duration: int, def record_sound(hal: PizzaHAL, filename: Any, duration: float,
cache: bool = False, **kwargs): cache: bool = False, **kwargs):
""" """
Record sound using the microphone 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), myrecording = sd.rec(int(duration * AUDIO_REC_SR),
samplerate=AUDIO_REC_SR, samplerate=AUDIO_REC_SR,
channels=2) channels=2)
resp = hal.send_cmd(SerialCommands.RECORD, duration).strip() resp = hal.send_cmd(SerialCommands.RECORD, int(duration)).strip()
if resp == b'I': if resp == b'I':
sd.stop() sd.stop()
else: else:

View file

@ -13,7 +13,8 @@ logger = logging.getLogger('pizzactrl.main')
@click.option('--move', is_flag=True) @click.option('--move', is_flag=True)
@click.option('--test', is_flag=True, default=False) @click.option('--test', is_flag=True, default=False)
@click.option('--debug', 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: if debug or test:
logging.basicConfig(level=logging.DEBUG, stream=sys.stdout) logging.basicConfig(level=logging.DEBUG, stream=sys.stdout)
else: else:
@ -21,7 +22,8 @@ def main(move: bool=False, test: bool=False, debug: bool=False):
sm = Statemachine(story_de=sb_de.STORYBOARD, sm = Statemachine(story_de=sb_de.STORYBOARD,
story_en=sb_en.STORYBOARD, story_en=sb_en.STORYBOARD,
move=move) move=move,
loop=loop)
sm.test = test sm.test = test
exitcode = 0 exitcode = 0

View file

@ -16,7 +16,7 @@ STORYBOARD = [
storyboard.Chapter( storyboard.Chapter(
storyboard.Do(storyboard.Activity.PLAY_SOUND, storyboard.Do(storyboard.Activity.PLAY_SOUND,
sound=fs_names.StoryFile('IC-SIBI-03')), 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, storyboard.Do(storyboard.Activity.LIGHT_BACK,
intensity=1.0, fade=0.5), intensity=1.0, fade=0.5),
storyboard.Do(storyboard.Activity.LIGHT_LAYER, storyboard.Do(storyboard.Activity.LIGHT_LAYER,

View file

@ -74,6 +74,7 @@ class Statemachine:
State.POST: self._post, State.POST: self._post,
State.IDLE_START: self._idle_start, State.IDLE_START: self._idle_start,
State.PLAY: self._play, State.PLAY: self._play,
State.REWIND: self._rewind,
State.IDLE_END: self._idle_end State.IDLE_END: self._idle_end
} }
while (self.state is not State.ERROR) and \ while (self.state is not State.ERROR) and \
@ -127,11 +128,13 @@ class Statemachine:
# Callback for start when blue button is held # Callback for start when blue button is held
self.hal.btn_start.when_activated = self._start_or_rewind self.hal.btn_start.when_activated = self._start_or_rewind
logger.debug('start button callback activated')
# play a sound if everything is alright # play a sound if everything is alright
play_sound(self.hal, fs_names.SFX_POST_OK) play_sound(self.hal, fs_names.SFX_POST_OK)
self.state = State.IDLE_START self.state = State.IDLE_START
logger.debug('idle_start')
def _idle_start(self): def _idle_start(self):
""" """
@ -207,11 +210,15 @@ class Statemachine:
Rewind all scrolls, post-process videos Rewind all scrolls, post-process videos
""" """
# postprocessing # postprocessing
logger.debug('Converting video...')
cmdstring = f'MP4Box -add {fs_names.REC_DRAW_CITY} {fs_names.REC_MERGED_VIDEO}' cmdstring = f'MP4Box -add {fs_names.REC_DRAW_CITY} {fs_names.REC_MERGED_VIDEO}'
call([cmdstring], shell=True) call([cmdstring], shell=True)
logger.debug('Rewinding...')
if self.move: if self.move:
rewind(self.hal) rewind(self.hal)
for chapter in self.story:
chapter.rewind()
if self.loop: if self.loop:
self.state = State.IDLE_START self.state = State.IDLE_START

View file

@ -8,7 +8,7 @@ class Activity(Enum):
RECORD_VIDEO = {'duration': 0.0, 'filename': ''} RECORD_VIDEO = {'duration': 0.0, 'filename': ''}
TAKE_PHOTO = {'filename': ''} TAKE_PHOTO = {'filename': ''}
ADVANCE_UP = {'speed': 0.3, 'direction': True, 'steps': 100} 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_LAYER = {'intensity': 1.0, 'fade': 0.0, 'layer': True}
LIGHT_BACK = {'intensity': 1.0, 'fade': 0.0} LIGHT_BACK = {'intensity': 1.0, 'fade': 0.0}