11# -*- coding: UTF-8 -*-
2- #brailleDisplayDrivers/seika.py
3- #A part of NonVisual Desktop Access (NVDA)
4- #This file is covered by the GNU General Public License.
5- #See the file COPYING for more details.
6- #Copyright (C) 2012 Ulf Beckmann <beckmann@flusoft.de>
7-
8- # Parts of this code are inherited from the baum braille driver
9- # written by James Teh <jamie@jantrid.net>
10-
2+ # brailleDisplayDrivers/seika.py
3+ # A part of NonVisual Desktop Access (NVDA)
4+ # This file is covered by the GNU General Public License.
5+ # See the file COPYING for more details.
6+ # Copyright (C) 2012/20 Ulf Beckmann <beckmann@flusoft.de>
7+
8+ # A redesign was made for Python V3.7 in 2020
9+ #
1110# This file represents the braille display driver for
12- # Seika3 V2.00 , Seika80, a product from Nippon Telesoft
11+ # Seika3/5 V1.x/2.0 , Seika80, a product from Nippon Telesoft
1312# see www.seika-braille.com for more details
14- # 18.08.2012 13:54
13+ # 24.07.2020 17:03
1514
1615from typing import List
17-
1816import wx
1917import serial
2018import braille
2119import inputCore
2220import hwPortUtils
21+ from hwIo import intToByte
2322from logHandler import log
2423
2524TIMEOUT = 0.2
2928class BrailleDisplayDriver (braille .BrailleDisplayDriver ):
3029 name = "seika"
3130 # Translators: Names of braille displays.
32- description = _ ("Seika braille displays " )
31+ description = _ ("Seika Braille Displays " )
3332 numCells = 0
3433
3534 @classmethod
3635 def check (cls ):
3736 return True
38-
3937 def __init__ (self ):
4038 super (BrailleDisplayDriver , self ).__init__ ()
41-
4239 for portInfo in hwPortUtils .listComPorts (onlyAvailable = True ):
4340 port = portInfo ["port" ]
4441 hwID = portInfo ["hardwareID" ]
@@ -52,18 +49,22 @@ def __init__(self):
5249 except serial .SerialException :
5350 continue
5451 log .debug ("serial port open {port}" .format (port = port ))
52+ # get the version infos
5553 self ._ser .write (b"\xFF \xFF \x1C " )
5654 self ._ser .flush ()
5755 # Read out the input buffer
5856 versionS = self ._ser .read (13 )
5957 log .debug ("receive {p}" .format (p = versionS ))
60- if versionS .startswith ("seika80" ):
58+ if versionS .startswith (b "seika80" ):
6159 log .info ("Found Seika80 connected via {port} Version {versionS}" .format (port = port , versionS = versionS ))
6260 self .numCells = 80
61+ # Handshake data for seika 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
67+ # Handshake data for v3, v5
6768 self .s40 = b"\xFF \xFF \x73 \x65 \x69 \x6B \x61 \x00 "
6869 break
6970 # is it a old Seika3?
@@ -96,18 +97,18 @@ def terminate(self):
9697 self ._ser .close ()
9798
9899 def display (self , cells : List [int ]):
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 ) + cellPadding
111+ # log.info("senden....{p}".format(p=len(lineBytes)))
111112 self ._ser .write (lineBytes )
112113
113114 def handleResponses (self ):
0 commit comments