]> Repositories - hackapet/Adafruit_Blinka_Displayio.git/blob - terminalio.py
Divide by zero and speed up bug fixes
[hackapet/Adafruit_Blinka_Displayio.git] / terminalio.py
1 # The MIT License (MIT)
2 #
3 # Copyright (c) 2020 Melissa LeBlanc-Williams for Adafruit Industries
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to deal
7 # in the Software without restriction, including without limitation the rights
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 # copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 # THE SOFTWARE.
22
23 """
24 `terminalio`
25 ================================================================================
26
27 terminalio for Blinka
28
29 **Software and Dependencies:**
30
31 * Adafruit Blinka:
32   https://github.com/adafruit/Adafruit_Blinka/releases
33
34 * Author(s): Melissa LeBlanc-Williams
35
36 """
37
38 import sys  # pylint: disable=unused-import
39 import fontio
40 from displayio.tilegrid import TileGrid
41
42 __version__ = "0.0.0-auto.0"
43 __repo__ = "https://github.com/adafruit/Adafruit_Blinka_displayio.git"
44
45 FONT = fontio.BuiltinFont()
46
47 # TODO: Tap into stdout to get the REPL
48 # sys.stdout = open('out.dat', 'w')
49 # sys.stdout.close()
50
51
52 class Terminal:
53     """Displays text in a TileGrid
54
55     The terminalio module contains classes to display a character stream on a display. The built in font is available as terminalio.FONT.
56     """
57
58     def __init__(self, tilegrid, font):
59         if not isinstance(tilefrid, TileGrid):
60             raise TypeError("Expected a TileGrid")
61         self._tilegrid = tilegrid
62         if not isinstance(font, fontio.BuiltinFont):
63             raise TypeError("Expected a BuiltinFont")
64         self._font = font
65         self._cursor_x = 0
66         self._curcor_y = 0
67         self._first_row = 0
68         for x in range(self._tilegrid.width):
69             for y in range(self._tilegrid.height):
70                 self._tilegrid[x, y] = 0
71
72     def write(self, buf):
73         """Write the buffer of bytes to the bus."""
74         pass