Repository: rm-hull/luma.led_matrix

Issue:
Add degree symbol to charmap
Add degree symbol to charmap, so we can use this library to show temperature.

```diff
diff --git a/luma/led_matrix/segment_mapper.py b/luma/led_matrix/segment_mapper.py
index 91c3447..d6a8e5f 100644
--- a/luma/led_matrix/segment_mapper.py
+++ b/luma/led_matrix/segment_mapper.py
@@ -6,6 +6,7 @@ _DIGITS = {
     ' ': 0x00,
     '-': 0x01,
     '_': 0x08,
+    '°': 0x63,
     '\'': 0x02,
     '0': 0x7e,
     '1': 0x30,
```

![image](https://user-images.githubusercontent.com/6428351/43455412-004f493c-94c0-11e8-9d43-a35c2d056474.png)


Discussion:
rm-hull: py27 build fails because of different unicode/utf-8 handling .. any ideas @thijstriemstra ?
thijstriemstra: oh the (co-)author should be added to contributors?
thijstriemstra: > py27 build fails because of different unicode/utf-8 handling 

let me check.
thijstriemstra: Took another look but can't figure it out, since I'm not sure what 'dot_muncher' does. Perhaps you can comment it line by line in this PR and it'll become more clear.
rm-hull: ### Notes

Seems like python2 doesn't properly iterate over unicode characters (but python 3 does), and this is the root cause of the problem.

* https://stackoverflow.com/questions/46711888/how-to-properly-iterate-over-unicode-characters-in-python

```python
Python 2.7.15 (default, Jun 17 2018, 12:46:58) 
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x = "29.12°C"
>>> len(x)
8
>>> list(x)
['2', '9', '.', '1', '2', '\xc2', '\xb0', 'C'] 
>>> y = u"29.12°C"
>>> len(y)
7
>>> list(y)
[u'2', u'9', u'.', u'1', u'2', u'\xb0', u'C']
```

vs.

```python3
Python 3.7.0 (default, Jun 29 2018, 20:13:13) 
[Clang 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x = "29.12°C"
>>> len(x)
7
>>> list(x)
['2', '9', '.', '1', '2', '°', 'C']
```

Patch:
diff --git a/.gitignore b/.gitignore
index 04ce1c3..92614be 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,6 +42,7 @@ htmlcov/
 .cache
 nosetests.xml
 coverage.xml
+.pytest_cache/
 
 # Translations
 *.mo
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index 3f474bb..f86c1c5 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -22,3 +22,4 @@ Contributors
 * Qinkang Huang (@pokebox)
 * Shawn Woodford (@swoodford)
 * Phil Howard (@gadgetoid)
+* Petr Kracík (@petrkr)
diff --git a/luma/led_matrix/segment_mapper.py b/luma/led_matrix/segment_mapper.py
index 91c3447..f8e22cf 100644
--- a/luma/led_matrix/segment_mapper.py
+++ b/luma/led_matrix/segment_mapper.py
@@ -6,6 +6,8 @@ _DIGITS = {
     ' ': 0x00,
     '-': 0x01,
     '_': 0x08,
+    u'°': 0x63,
+    '\xb0': 0x63,
     '\'': 0x02,
     '0': 0x7e,
     '1': 0x30,
@@ -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)
diff --git a/setup.py b/setup.py
index 60a671d..84fb47a 100644
--- a/setup.py
+++ b/setup.py
@@ -50,7 +50,7 @@ setup(
     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={


Test patch:
diff --git a/tests/test_segment_mapper.py b/tests/test_segment_mapper.py
index c32cf19..7ef4e20 100644
--- a/tests/test_segment_mapper.py
+++ b/tests/test_segment_mapper.py
@@ -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]