Page Class¶
-
class
metlinkpid.Page(animate: metlinkpid.PageAnimate, delay: int, text: str)¶ A
Pageobject represents one “screen” of information in aDisplayMessage.Each
Pageobject 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.Pageobjects are not typically constructed directly. Instead, they usually come to exist through construction ofDisplayMessageobjects.- Parameters
animate – the type of animation to take place on page entry, given as a
PageAnimateconstant.delay – the length of time (in approximately quarter-seconds) to delay display of the next page after animation completes, given as an
intbetween0and255inclusive.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&DisplayMessagestring methods to enable compact, easily-typed, pure-string representations containing all attributes.
- Raises
ValueError – if the text contains unusable characters, or if a valid
PageAnimatevalue 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
Pageobject 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 desiredAnimatevalue (e.g.NforAnimate.NONE);<delay>is the desireddelayvalue; and<text>is the desiredtextvalue.
For reference, such a string can also be obtained by converting an existing
Pageobject 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
animatevalue to use if one is not provided in the string. Defaults toPageAnimate.NONE.default_delay – the
delayvalue to use if one is not provided in the string. Defaults to20.
- Raises
ValueError – if the text contains unusable characters, or if a valid
Animatevalue 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 equivalentPageobject to this one.
Page.from_bytes() Class Method¶
-
classmethod
Page.from_bytes(bytes_in: bytes) → metlinkpid.Page¶ Construct a
Pageobject from a raw byte representation.Typically used by
DisplayMessage.from_bytes()when attempting to construct aDisplayMessagefrombytes.- Parameters
bytes_in – the
bytesrelating 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
Pageas understood by the display.Used by
DisplayMessage.to_bytes()when preparing tosend()a completeDisplayMessageto the display.