Page
Class¶
-
class
metlinkpid.
Page
(animate: metlinkpid.PageAnimate, delay: int, text: str)¶ A
Page
object represents one “screen” of information in aDisplayMessage
.Each
Page
object holds the text to be displayed, how the text animates on entry, and how long the page should “pause” between completion of the animation and display of the next page.Page
objects are not typically constructed directly. Instead, they usually come to exist through construction ofDisplayMessage
objects.- Parameters
animate – the type of animation to take place on page entry, given as a
PageAnimate
constant.delay – the length of time (in approximately quarter-seconds) to delay display of the next page after animation completes, given as an
int
between0
and255
inclusive.text –
the text to display on the page. All ASCII letters & numbers, the ASCII space character, and these other printable ASCII characters can be used freely:
(+) (0)(1)(2)(3)(4)(5)(6)(7)(8)(9)(A)(B)(C)(D)(E)(F) (0x20) ! # $ & ' ( ) * + , - . / (0x30) : ; < = > ? (0x50) \
as well as some Unicode characters:
(+) (0)(1)(2)(3)(4)(5)(6)(7)(8)(9)(A)(B)(C)(D)(E)(F) (0x00B0) · (0x2020) • (0x2500) ─ ━ (0x2580) █ (0x2590) ▔
Notably, some printable ASCII characters cannot be used:
(+) (0)(1)(2)(3)(4)(5)(6)(7)(8)(9)(A)(B)(C)(D)(E)(F) (0x20) " % (0x40) @ (0x50) [ ] ^ _ (0x60) ` (0x70) { | } ~
Some of these unusable characters are instead utilised for other purposes:
Use
~
to right-justify the remaining text on the line.Use
_
to advance to the next line of the display.
A few more of these characters are utilised by the various
Page
&DisplayMessage
string methods to enable compact, easily-typed, pure-string representations containing all attributes.
- Raises
ValueError – if the text contains unusable characters, or if a valid
PageAnimate
value is not given, or if the delay is outside the permissible range.
Page.from_str()
Class Method¶
-
classmethod
Page.
from_str
(string: str, default_animate: metlinkpid.PageAnimate = <PageAnimate.NONE: 'N'>, default_delay: int = 20) → metlinkpid.Page¶ Construct a
Page
object from a string representation.- Parameters
string –
a string in one of the following formats:
<text>
^<text>
<animate>^<text>
<delay>^<text>
<animate><delay>^<text>
where:
<animate>
is the string value of the desiredAnimate
value (e.g.N
forAnimate.NONE
);<delay>
is the desireddelay
value; and<text>
is the desiredtext
value.
For reference, such a string can also be obtained by converting an existing
Page
object to a string usingstr()
:>>> str(Page(animate=PageAnimate.VSCROLL, delay=40, text='12:34 FUNKYTOWN~5_Limited Express')) 'V40^12:34 FUNKYTOWN~5_Limited Express'
default_animate – the
animate
value to use if one is not provided in the string. Defaults toPageAnimate.NONE
.default_delay – the
delay
value to use if one is not provided in the string. Defaults to20
.
- Raises
ValueError – if the text contains unusable characters, or if a valid
Animate
value is not given, or if the delay is outside the permissible range.
__str__()
Method¶
-
Page.
__str__
() → str¶ The string representation of this object.
Passing this string to
Page.from_str()
will yield an equivalentPage
object to this one.
Page.from_bytes()
Class Method¶
-
classmethod
Page.
from_bytes
(bytes_in: bytes) → metlinkpid.Page¶ Construct a
Page
object from a raw byte representation.Typically used by
DisplayMessage.from_bytes()
when attempting to construct aDisplayMessage
frombytes
.- Parameters
bytes_in – the
bytes
relating to one page.- Raises
ValueError – if the bytes could not be understood.
to_bytes()
Method¶
-
Page.
to_bytes
() → bytes¶ The raw byte representation of the
Page
as understood by the display.Used by
DisplayMessage.to_bytes()
when preparing tosend()
a completeDisplayMessage
to the display.