DisplayMessage Class

class metlinkpid.DisplayMessage(pages)

A DisplayMessage object represents a single, cohesive set of information displayed over a sequence of Pages. Once the sequence is exhausted, it repeats indefinitely until a new message is sent to the display (or the display times out & clears, which can be avoided by ping()-ing the display).

DisplayMessage objects are typically built from a string using DisplayMessage.from_str() rather than constructed directly.

Parameters

pages – a tuple of Page objects comprising the message.

DisplayMessage.from_str() Class Method

classmethod DisplayMessage.from_str(string: str) → metlinkpid.DisplayMessage

Construct a DisplayMessage object from a string representation.

Parameters

string

a string in one of the following formats:

  • <page_str>

  • <page_str>|<page_str>

  • <page_str>|<page_str>|<page_str>

    (etc.)

where each <page_str> is a string representation of a Page object, as accepted by Page.from_str(), and is separated from other Page representations by |.

For reference, such a string can also be obtained by converting an existing DisplayMessage object to a string using str():

>>> page1 = Page(animate=PageAnimate.VSCROLL, delay=40, text='12:34 FUNKYTOWN~5_Limited Express')
>>> page2 = Page(animate=PageAnimate.HSCROLL, delay=0, text='_Stops all stations except East Richard')
>>> str(DisplayMessage([page1, page2]))
'V40^12:34 FUNKYTOWN~5_Limited Express|H0^_Stops all stations except East Richard'

Where any page string fails to specify an animate or delay value, these defaults will be applied:

  • Animate.VSCROLL & delay=40 for the first page; and

  • Animate.HSCROLL & delay=0 for subsequent pages.

Raises

ValueError – if the text of any page contains unusable characters, or if a valid Animate value is not given, or if the delay is outside the permissible range.

__str__() Method

DisplayMessage.__str__() → str

The string representation of this object.

Passing this string to DisplayMessage.from_str() will yield an equivalent DisplayMessage object to this one.

DisplayMessage.from_bytes() Class Method

classmethod DisplayMessage.from_bytes(bytes_in: bytes) → metlinkpid.DisplayMessage

Construct a DisplayMessage object from a raw byte representation (not including the CRC-checksumming and packet-framing required for transmission).

Parameters

bytes_in – the raw byte representation.

Raises

ValueError – if the bytes could not be understood.

to_bytes() Method

DisplayMessage.to_bytes() → bytes

The raw byte representation of the DisplayMessage as understood by the display (not including the CRC-checksumming and packet-framing required for transmission).