Skip to content

Commit

Permalink
Add degree symbol to charmap (#158)
Browse files Browse the repository at this point in the history
Fixes #157
* Updated gitignore to cover pytest cache files
* Add degree symbol to charmap
* try unicode in py27
* revert prev change
* Rework segment mapper implementation after unicode fix in luma.core
* Add @petrkr to contributors list
* Additional tests
  • Loading branch information
rm-hull committed Sep 18, 2018
1 parent 8b9323d commit 3af2555
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ htmlcov/
.cache
nosetests.xml
coverage.xml
.pytest_cache/

# Translations
*.mo
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ Contributors
* Qinkang Huang (@pokebox)
* Shawn Woodford (@swoodford)
* Phil Howard (@gadgetoid)
* Petr Kracík (@petrkr)
5 changes: 5 additions & 0 deletions luma/led_matrix/segment_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
' ': 0x00,
'-': 0x01,
'_': 0x08,
u'°': 0x63,
'\xb0': 0x63,
'\'': 0x02,
'0': 0x7e,
'1': 0x30,
Expand Down Expand Up @@ -86,6 +88,9 @@ def regular(text, notfound="_"):


def dot_muncher(text, notfound="_"):
if not text:
return

undefined = _DIGITS[notfound]
iterator = iter(text)
last = _DIGITS.get(next(iterator), undefined)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def find_version(*file_paths):
url="https://github.com/rm-hull/luma.led_matrix",
download_url="https://github.com/rm-hull/luma.led_matrix/tarball/" + version,
packages=["luma", "luma.led_matrix"],
install_requires=["luma.core>=1.2.1"],
install_requires=["luma.core>=1.8.1"],
setup_requires=pytest_runner,
tests_require=test_deps,
extras_require={
Expand Down
18 changes: 18 additions & 0 deletions tests/test_segment_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,21 @@ def test_regular_empty_buf():
buf = mutable_string("")
results = regular(buf)
assert list(results) == []


def test_degrees_string():
buf = mutable_string("29.12\xb0C")
results = dot_muncher(buf)
assert list(results) == [0x6d, 0x7b | 0x80, 0x30, 0x6d, 0x63, 0x4e]


def test_degrees_unicode():
buf = mutable_string(u"29.12°C")
results = dot_muncher(buf)
assert list(results) == [0x6d, 0x7b | 0x80, 0x30, 0x6d, 0x63, 0x4e]


def test_degrees_utf8():
buf = mutable_string(u"29.12\xb0C")
results = dot_muncher(buf)
assert list(results) == [0x6d, 0x7b | 0x80, 0x30, 0x6d, 0x63, 0x4e]

0 comments on commit 3af2555

Please sign in to comment.