From 26444c9c5f29e4cb03bd41c31c99c690765d87f0 Mon Sep 17 00:00:00 2001 From: penrods Date: Thu, 18 Jan 2018 14:44:53 -0600 Subject: [PATCH] Tweak UI for NTP checking Withe the NTP checks in place, the sequence of visual and audio queues was a little clunky. This refines it slightly for normal use and to play better with the pairing process. --- mycroft/client/enclosure/__init__.py | 11 ++--------- mycroft/client/enclosure/api.py | 5 +++++ .../res/text/en-us/message_synching.clock.dialog | 2 +- mycroft/res/text/en-us/message_updating.dialog | 1 + mycroft/skills/main.py | 16 ++++++++++++---- 5 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 mycroft/res/text/en-us/message_updating.dialog diff --git a/mycroft/client/enclosure/__init__.py b/mycroft/client/enclosure/__init__.py index ee0ec19026..b2d9d507a4 100644 --- a/mycroft/client/enclosure/__init__.py +++ b/mycroft/client/enclosure/__init__.py @@ -144,14 +144,13 @@ class EnclosureReader(Thread): self.ws.emit(Message("system.wifi.setup", {'lang': self.lang})) if "unit.factory-reset" in data: - self.ws.emit(Message("enclosure.eyes.spin")) + self.ws.emit(Message("speak", { + 'utterance': mycroft.dialog.get("reset to factory defaults")})) subprocess.call( 'rm ~/.mycroft/identity/identity2.json', shell=True) self.ws.emit(Message("system.wifi.reset")) self.ws.emit(Message("system.ssh.disable")) - self.ws.emit(Message("speak", { - 'utterance': mycroft.dialog.get("reset to factory defaults")})) wait_while_speaking() self.ws.emit(Message("enclosure.mouth.reset")) self.ws.emit(Message("enclosure.eyes.spin")) @@ -298,9 +297,6 @@ class Enclosure(object): # receive the "speak". This was sometimes happening too # quickly and the user wasn't notified what to do. Timer(5, self._do_net_check).start() - else: - # Indicate we are checking for updates from the internet now... - self.writer.write("mouth.text=< < < UPDATING < < < ") Timer(60, self._hack_check_for_duplicates).start() @@ -425,9 +421,6 @@ class Enclosure(object): # Kick off wifi-setup automatically data = {'allow_timeout': False, 'lang': self.lang} self.ws.emit(Message('system.wifi.setup', data)) - else: - # Indicate we are checking for updates from the internet now... - self.writer.write("mouth.text=< < < UPDATING < < < ") def _hack_check_for_duplicates(self): # TEMPORARY HACK: Look for multiple instance of the diff --git a/mycroft/client/enclosure/api.py b/mycroft/client/enclosure/api.py index bf91853ed6..2f13ca56f8 100644 --- a/mycroft/client/enclosure/api.py +++ b/mycroft/client/enclosure/api.py @@ -128,6 +128,11 @@ class EnclosureAPI: """Restore the eyes to their default (ready) state.""" self.ws.emit(Message("enclosure.eyes.reset")) + def eyes_spin(self): + """Make the eyes 'roll' + """ + self.ws.emit(Message("enclosure.eyes.spin")) + def eyes_timed_spin(self, length): """Make the eyes 'roll' for the given time. Args: diff --git a/mycroft/res/text/en-us/message_synching.clock.dialog b/mycroft/res/text/en-us/message_synching.clock.dialog index 61cc47cad9..8aeb858b47 100644 --- a/mycroft/res/text/en-us/message_synching.clock.dialog +++ b/mycroft/res/text/en-us/message_synching.clock.dialog @@ -1 +1 @@ -SYNC CLOCK... \ No newline at end of file +< < < SYNC < < < \ No newline at end of file diff --git a/mycroft/res/text/en-us/message_updating.dialog b/mycroft/res/text/en-us/message_updating.dialog new file mode 100644 index 0000000000..6d5a6b2fc7 --- /dev/null +++ b/mycroft/res/text/en-us/message_updating.dialog @@ -0,0 +1 @@ +< < < UPDATING < < < \ No newline at end of file diff --git a/mycroft/skills/main.py b/mycroft/skills/main.py index e0098badfa..64cf199095 100644 --- a/mycroft/skills/main.py +++ b/mycroft/skills/main.py @@ -105,10 +105,13 @@ def check_connection(): if connected(): enclosure = EnclosureAPI(ws) + if is_paired(): + # Skip the sync message when unpaired because the prompt to go to + # home.mycrof.ai will be displayed by the pairing skill + enclosure.mouth_text(mycroft.dialog.get("message_synching.clock")) # Force a sync of the local clock with the internet - enclosure.mouth_text(mycroft.dialog.get("message_synching.clock")) ws.emit(Message("system.ntp.sync")) - time.sleep(10) # TODO: Generate/listen for a message response... + time.sleep(15) # TODO: Generate/listen for a message response... # Check if the time skewed significantly. If so, reboot skew = abs((monotonic.monotonic() - start_ticks) - @@ -124,10 +127,10 @@ def check_connection(): # provide visual indicators of the reboot enclosure.mouth_text(mycroft.dialog.get("message_rebooting")) enclosure.eyes_color(70, 65, 69) # soft gray - enclosure.eyes_timed_spin(None) + enclosure.eyes_spin() # give the system time to finish processing enclosure messages - time.sleep(0.5) + time.sleep(1.0) # reboot ws.emit(Message("system.reboot")) @@ -143,6 +146,11 @@ def check_connection(): } ws.emit(Message("recognizer_loop:utterance", payload)) else: + if is_paired(): + # Skip the message when unpaired because the prompt to go + # to home.mycrof.ai will be displayed by the pairing skill + enclosure.mouth_text(mycroft.dialog.get("message_updating")) + from mycroft.api import DeviceApi api = DeviceApi() api.update_version()