Skip to content

Commit a9d35d0

Browse files
authored
Merge 900e9e9 into 2d73010
2 parents 2d73010 + 900e9e9 commit a9d35d0

1 file changed

Lines changed: 20 additions & 18 deletions

File tree

source/brailleDisplayDrivers/seika.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
#A part of NonVisual Desktop Access (NVDA)
44
#This file is covered by the GNU General Public License.
55
#See the file COPYING for more details.
6-
#Copyright (C) 2012 Ulf Beckmann <beckmann@flusoft.de>
6+
#Copyright (C) 2012/20 Ulf Beckmann <beckmann@flusoft.de>
77

88
# Parts of this code are inherited from the baum braille driver
99
# written by James Teh <jamie@jantrid.net>
1010

1111
# This file represents the braille display driver for
1212
# Seika3 V2.00, Seika80, a product from Nippon Telesoft
1313
# see www.seika-braille.com for more details
14-
# 18.08.2012 13:54
14+
# 2020-02-15 11:46
1515

1616
from typing import List
1717

@@ -21,6 +21,7 @@
2121
import inputCore
2222
import hwPortUtils
2323
from logHandler import log
24+
from hwIo import intToByte
2425

2526
TIMEOUT = 0.2
2627
BAUDRATE = 9600
@@ -29,16 +30,14 @@
2930
class BrailleDisplayDriver(braille.BrailleDisplayDriver):
3031
name = "seika"
3132
# Translators: Names of braille displays.
32-
description = _("Seika braille displays")
33+
description = _("Seika Braille V3/5/80")
3334
numCells = 0
3435

3536
@classmethod
3637
def check(cls):
3738
return True
38-
3939
def __init__(self):
4040
super(BrailleDisplayDriver, self).__init__()
41-
4241
for portInfo in hwPortUtils.listComPorts(onlyAvailable=True):
4342
port = portInfo["port"]
4443
hwID = portInfo["hardwareID"]
@@ -57,12 +56,13 @@ def __init__(self):
5756
# Read out the input buffer
5857
versionS = self._ser.read(13)
5958
log.debug("receive {p}".format(p=versionS))
60-
if versionS.startswith("seika80"):
59+
if versionS.startswith(b"seika80"):
6160
log.info("Found Seika80 connected via {port} Version {versionS}".format(port=port, versionS=versionS))
6261
self.numCells = 80
62+
self.s40 = b"\xff\xff\x73\x38\x30\x00\x00\x00"
6363
break
64-
if versionS.startswith("seika3"):
65-
log.info("Found Seika40 connected via {port} Version {versionS}".format(port=port, versionS=versionS))
64+
if versionS.startswith(b"seika3"):
65+
log.info("Found Seika3/5 connected via {port} Version {versionS}".format(port=port, versionS=versionS))
6666
self.numCells = 40
6767
self.s40 = b"\xFF\xFF\x73\x65\x69\x6B\x61\x00"
6868
break
@@ -83,7 +83,7 @@ def __init__(self):
8383
break
8484
self._ser.close()
8585
else:
86-
raise RuntimeError("No SEIKA40/80 display found")
86+
raise RuntimeError("No SEIKA3/5/80 display found")
8787
self._readTimer = wx.PyTimer(self.handleResponses)
8888
self._readTimer.Start(READ_INTERVAL)
8989

@@ -96,18 +96,19 @@ def terminate(self):
9696
self._ser.close()
9797

9898
def display(self, cells: List[int]):
99+
100+
# add padding so total length is 1 + numberOfStatusCells + numberOfRegularCells
101+
cellPadding: bytes = bytes(self.numCells - len(cells))
102+
writeBytes: List[bytes] = [self.s40, ]
99103
# every transmitted line consists of the preamble SEIKA_SENDHEADER and the Cells
100104
if self.numCells==80:
101-
lineBytes = b"".join([
102-
b"\xff\xff\x73\x38\x30\x00\x00\x00",
103-
bytes(cells)
104-
])
105+
lineBytes : bytes = self.s40 + bytes(cells) + cellPadding
105106
else:
106-
lineBytes = b"".join([
107-
self.s40,
108-
b"\0",
109-
bytes(cells)
110-
])
107+
for cell in cells:
108+
writeBytes.append(b"\x00")
109+
writeBytes.append(intToByte(cell))
110+
lineBytes = b"".join(writeBytes)
111+
# + cellPadding self._ser.write(lineBytes)
111112
self._ser.write(lineBytes)
112113

113114
def handleResponses(self):
@@ -195,3 +196,4 @@ def __init__(self, index):
195196

196197
self.id = "routing"
197198
self.routingIndex = index
199+

0 commit comments

Comments
 (0)