Skip to content

Commit

Permalink
Feat/seperate mk1 (#53)
Browse files Browse the repository at this point in the history
* first try

* clean up logs

* fix tests?

* fix tests?

* fix logging

coderabbit suggestions

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix tests?

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
builderjer and coderabbitai[bot] authored Oct 23, 2024
1 parent 3e81e17 commit 664bc55
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 59 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
uses: neongeckocom/.github/.github/workflows/python_build_tests.yml@master
with:
test_manifest: true
manifest_ignored: "test/**,scripts/**,CHANGELOG.md"
manifest_ignored: "test/**,scripts/**,CHANGELOG.md,translations/**"
pip_audit:
strategy:
max-parallel: 2
Expand All @@ -36,3 +36,4 @@ jobs:
ignore-vulns: |
GHSA-r9hx-vwmv-q579
GHSA-fpfv-jqm9-f5jm
PYSEC-2022-43012
66 changes: 8 additions & 58 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
from timezonefinder import TimezoneFinder

from ovos_utils import classproperty
from ovos_utils.log import LOG
from ovos_utils.process_utils import RuntimeRequirements
from ovos_utils.time import now_local, get_next_leap_year
from ovos_workshop.decorators import intent_handler
from ovos_workshop.intents import IntentBuilder
from ovos_workshop.skills import OVOSSkill
from ovos_bus_client.message import Message


def speakable_timezone(tz):
Expand Down Expand Up @@ -444,14 +446,9 @@ def show_date(self, dt: datetime.datetime, location: str):

def show_date_mark1(self, dt: datetime.datetime):
show = self.get_display_date(anchor_date=dt)
# TODO - move to mk1 plugin
#self.bus.emit(Message("ovos.mk1.display_date",
# {"text": show}))
self.enclosure.deactivate_mouth_events()
self.enclosure.mouth_text(show)
time.sleep(10)
self.enclosure.mouth_reset()
self.enclosure.activate_mouth_events()
LOG.debug(f"sending date to mk1 {show}")
self.bus.emit(Message("ovos.mk1.display_date",
{"text": show}))

def show_date_gui(self, dt: datetime.datetime, location: str):
self.gui.clear()
Expand All @@ -473,56 +470,9 @@ def show_time(self, display_time: str):
self.show_time_mark1(display_time)

def show_time_mark1(self, display_time: str):
# TODO - move to mk1 plugin
#self.bus.emit(Message("ovos.mk1.display_time",
# {"text": display_time}))
self.enclosure.deactivate_mouth_events()
# Map characters to the display encoding for a Mark 1
# (4x8 except colon, which is 2x8)
code_dict = {
':': 'CIICAA',
'0': 'EIMHEEMHAA',
'1': 'EIIEMHAEAA',
'2': 'EIEHEFMFAA',
'3': 'EIEFEFMHAA',
'4': 'EIMBABMHAA',
'5': 'EIMFEFEHAA',
'6': 'EIMHEFEHAA',
'7': 'EIEAEAMHAA',
'8': 'EIMHEFMHAA',
'9': 'EIMBEBMHAA',
}

# clear screen (draw two blank sections, numbers cover rest)
if len(display_time) == 4:
# for 4-character times, 9x8 blank
self.enclosure.mouth_display(img_code="JIAAAAAAAAAAAAAAAAAA",
refresh=False)
self.enclosure.mouth_display(img_code="JIAAAAAAAAAAAAAAAAAA",
x=22, refresh=False)
else:
# for 5-character times, 7x8 blank
self.enclosure.mouth_display(img_code="HIAAAAAAAAAAAAAA",
refresh=False)
self.enclosure.mouth_display(img_code="HIAAAAAAAAAAAAAA",
x=24, refresh=False)

# draw the time, centered on display
xoffset = (32 - (4 * (len(display_time)) - 2)) / 2
for c in display_time:
if c in code_dict:
self.enclosure.mouth_display(img_code=code_dict[c],
x=xoffset, refresh=False)
if c == ":":
xoffset += 2 # colon is 1 pixels + a space
else:
xoffset += 4 # digits are 3 pixels + a space

self.enclosure.mouth_display(img_code="CIAAAA", x=29,
refresh=False)
time.sleep(5)
self.enclosure.mouth_reset()
self.enclosure.activate_mouth_events()
LOG.debug(f"Emitting ovos.mk1.display_time with time: {display_time}")
self.bus.emit(Message("ovos.mk1.display_time",
{"text": display_time}))

def show_time_gui(self, display_time):
""" Display time on the GUI. """
Expand Down

0 comments on commit 664bc55

Please sign in to comment.