Module pytell :: Class PyTell
[hide private]
[frames] | no frames]

Class PyTell

source code


 Abstraction of the 4 digit 7-segment display PyTell from Didel (http://www.didel.com) attached to the I2C port.
 If no display is found, all display methods return immediately. The static variable SharedConstants.PATTERN defines a dictionary
 that maps ASCII characters to display patterns and can be modified by the user program.

 Default:

 The 7 segments have the following binary weights
        1
        -
  32 |     |2

       64
        -
  16 |     |4
        -
        8

The decimal points has weight 128.

 

Instance Methods [hide private]
 
__init__(self, i2c_address=0x20)
Creates a display instance with display set to given i2c address (default: 0x20).
source code
 
getId(self)
Returns the Id number of the display (default: 0xA0).
source code
 
readByte(self)
Send the I2C address without a command and returns the byte received.
source code
 
readData(self, cmd)
Sends a command and returns the block of data received.
source code
 
writeData(self, data)
Sends 4 data bytes to the display @param data list or tuple of integers whose lower byte are used (higher bytes are ignored).
source code
 
clear(self)
Clears the display (all digits are turned off).
source code
 
showText(self, text, pos=0, dp=[0,0,0,0])
Displays 4 characters of the given text.
source code
 
scrollToLeft(self)
Scrolls the current text one step to the left by increasing the text pointer.
source code
 
scrollToRight(self)
Scrolls the current text one step to the left by decreasing the text pointer.
source code
 
setToStart(self)
Shows the scrollable text at the start position by setting the text pointer to its start value.
source code
 
showTicker(self, text, count=1, speed=2, blocking=False)
Shows a ticker text that scroll to the left until the last 4 characters are displayed.
source code
 
stopTicker(self)
Stops a running ticker.
source code
 
isTickerAlive(self)
Returns: True, if the ticker is displaying; otherwise False
source code
 
showBlinker(self, text, dp=[0,0,0,0], count=3, speed=1, blocking=False)
Shows a ticker text that scroll to the left until the last 4 characters are displayed.
source code
 
stopBlinker(self)
Stops a running blinker.
source code
 
isBlinkerAlive(self)
Returns: True, if the blinker is displaying; otherwise False
source code
 
showVersion(self)
Displays current version.
source code
 
isAvailable(self)
Check if device is available.
source code
 
_getData(self, pos) source code
Static Methods [hide private]
 
debug(msg) source code
 
getVersion() source code
 
getDisplayableChars()
Returns a string with all displayable characters taken from PATTERN dictionary.
source code
 
toHex(intValue)
Returns a string with hex digits from given number (>0, any size).
source code
 
toBytes(intValue)
Returns a list of four byte values [byte#24-#31, byte#16-#23, byte#8-#15, byte#0-#7] of given integer.
source code
 
toInt(hexValue)
Returns an integer from given hex string
source code
 
delay(timeout) source code
Class Variables [hide private]
  DEBUG = False
  VERSION = "1.01 - April 2016"
Character to binary value mapping for 4 digit 7 segment display
  PATTERN = {' ': 0, '!': 134, '"': 34, '#': 0, '$': 0, '%': 0, ...
Method Details [hide private]

getDisplayableChars()
Static Method

source code 

Returns a string with all displayable characters taken from PATTERN dictionary.

Returns:
The character set that can be displayed

toHex(intValue)
Static Method

source code 

Returns a string with hex digits from given number (>0, any size).

Parameters:
  • number - the number to convert (must be positive)
Returns:
string of hex digits (uppercase), e.g. 0xFE

toBytes(intValue)
Static Method

source code 

Returns a list of four byte values [byte#24-#31, byte#16-#23, byte#8-#15, byte#0-#7] of given integer.

Parameters:
  • number - an integer
Returns:
list with integers of 4 bytes [MSB,..., LSB]

toInt(hexValue)
Static Method

source code 

Returns an integer from given hex string

Parameters:
  • number - a string with the number to convert, e.g. "FE" or "fe" or "0xFE" or "0XFE"
Returns:
integer number

__init__(self, i2c_address=0x20)
(Constructor)

source code 

Creates a display instance with display set to given i2c address (default: 0x20). Then the display is cleared.

Parameters:
  • i2c_address - the i2c address (default: 0x20)

getId(self)

source code 

Returns the Id number of the display (default: 0xA0).

Returns:
the display's id; None if display is not ready or I2C transfer failed

readByte(self)

source code 

Send the I2C address without a command and returns the byte received.

Returns:
one byte reply; None if display not ready or I2C transfer failed

readData(self, cmd)

source code 

Sends a command and returns the block of data received.

Parameters:
  • cmd - the command to send
Returns:
reply as list; None if display not ready or I2C transfer failed

showText(self, text, pos=0, dp=[0,0,0,0])

source code 

Displays 4 characters of the given text. The text is considered to be prefixed and postfixed by spaces and the 4 character window is selected by the text pointer pos that determines the character displayed at the leftmost digit, e.g. (_: empty): showText("AbCdEF") -> AbCd showText("AbCdEF", 1) -> bCdE showText("AbCdEF", -1) ->_AbC showText("AbCdEF", 4) -> EF__

Parameters:
  • text - the text to display (list, tuple, string or integer)
  • pos - the start value of the text pointer (character index positioned a leftmost digit)
  • dp - a list with one to four 1 or 0, if the decimal point is shown or not. For compatibility with the 4tronix display, the following mapping is used: The first element in list corresponds to dp at second digit from the right, the second element to dp at third digit from the right, the third element to dp at leftmost digit, the forth element to the dp at rightmost digit. More than 4 elements are ignored
Returns:
True, if successful; False, if the display is not available, text or dp has illegal type or one of the characters can't be displayed

scrollToLeft(self)

source code 

Scrolls the current text one step to the left by increasing the text pointer.

Returns:
the number of characters hidden, but remaining to be displayed at the right (>=0); -1, if error

scrollToRight(self)

source code 

Scrolls the current text one step to the left by decreasing the text pointer.

Returns:
the number of characters hidden, but remaining to be displayed at the left (>=0); -1, if error

setToStart(self)

source code 

Shows the scrollable text at the start position by setting the text pointer to its start value.

Returns:
0, if successful; -1, if error

showTicker(self, text, count=1, speed=2, blocking=False)

source code 

Shows a ticker text that scroll to the left until the last 4 characters are displayed. The method blocks until the ticker thread is successfully started and isTickerAlive() returns True.

Parameters:
  • text - the text to display, if short than 4 characters, scrolling is disabled
  • count - the number of repetitions (default: 1). For count = 0, infinite duration, may be stopped by calling stopTicker().
  • speed - the speed number of scrolling operations per sec (default: 2)
  • blocking - if True, the method blocks until the ticker has finished; otherwise it returns immediately (default: False)

stopTicker(self)

source code 

Stops a running ticker. The method blocks until the ticker thread is finished and isTickerAlive() returns False.

isTickerAlive(self)

source code 
Returns:
True, if the ticker is displaying; otherwise False

showBlinker(self, text, dp=[0,0,0,0], count=3, speed=1, blocking=False)

source code 

Shows a ticker text that scroll to the left until the last 4 characters are displayed. The method blocks until the ticker thread is successfully started and isTickerAlive() returns True.

Parameters:
  • text - the text to display, if short than 4 characters, scrolling is disabled
  • count - the number of repetitions (default: 2). For count = 0, infinite duration, may be stopped by calling stopBlinker().
  • speed - the speed number of blinking operations per sec (default: 1)
  • blocking - if True, the method blocks until the blinker has finished; otherwise it returns immediately (default: False)

stopBlinker(self)

source code 

Stops a running blinker. The method blocks until the blinker thread is finished and isBlinkerAlive() returns False.

isBlinkerAlive(self)

source code 
Returns:
True, if the blinker is displaying; otherwise False

showVersion(self)

source code 

Displays current version. Format X (three horz bars) + n.nn

isAvailable(self)

source code 

Check if device is available.

Returns:
True, if device can be accessed

Class Variable Details [hide private]

PATTERN

Value:
{' ': 0, '!': 134, '"': 34, '#': 0, '$': 0, '%': 0, '&': 0, '\'': 2, '\
(': 0, ')': 0, '*': 0, '+': 0, ',': 4, '-': 64, '.': 128, '/': 82, '0'\
: 63, '1': 6, '2': 91, '3': 79, '4': 102, '5': 109, '6': 125, '7': 7, \
'8': 127, '9': 111, ':': 0, ';': 0, '<': 0, '=': 72, '>': 0, '?': 0, '\
@': 93, 'A': 119, 'B': 124, 'C': 57, 'D': 94, 'E': 121, 'F': 113, 'G':\
 61, 'H': 118, 'I': 48, 'J': 14, 'K': 112, 'L': 56, 'M': 85, 'N': 84, \
'O': 63, 'P': 115, 'Q': 103, 'R': 80, 'S': 45, 'T': 120, 'U': 62, 'V':\
 54, 'W': 106, 'X': 73, 'Y': 110, 'Z': 27, '[': 57, '\\': 100, ']': 15\
...