Allows the user to input text using the LCD.
To change mode from moving and editing press switch 5 (navigation switch in). Move the navigation switch side to side (switches 6 and 7) to change character.
The available character set is specified using a format string similar to printf. Supported character specifiers are:
c: Characters
C: Capital Characters
i: Integers
d: Integers
x: Hexadecimal
X: Capital Hexadecimal
.: Punctuation
m: Custom (specifed by ``custom_values`` in init args)
r: Return (switch 5 to submit string)
You must prefix them with a % symbol and you can also specify a number argument. Each specifier is returned as an element in a list.
For example:
>>> scanner = pifacecad.tools.LCDScanf("Text: %c%2i%.%r")
>>> print(scanner.scan()) # user enters things on PiFaceCAD
['a', '13', '!']
You can also specify custom values:
>>> scanner = pifacecad.tools.LCDScanf(
... "Animal: %m%r",
... custom_values=('cat', 'dog', 'fish')
... )
>>> print(scanner.scan())
['fish']
move cursor left, roll around string, scroll screen. Only place cursor on ValueSelect, ignore plain text.
move cursor right, roll around string, scroll screen. Only place cursor on ValueSelect, ignore plain text.
A list of ValueSelects representing a single value.
A character in a specified range
Return the length of the longest value in this list. Example:
ValueSelect(["one", "two", "three"]).longest_len() == 5
A list of ValueSelect’s and characters, representing a string.
Returns the first index of an instance of instance_type
Returns a list of currently selected values.
Returns the ValueSelect or character at the string index. The string index is the index of this ValueSelectString as if it is being treated as a string.
Example:
cs0 == CustomValueSelect == ["bb", "cc"]
cs1 == CustomValueSelect == ["dd", "ee"]
vss == ValueSelectString == ["a", cs0, cs1, "f"]
vss == ["a", ["bb", "cc"], ["dd", "ee"], "f"]
str(vss) == "abbddf"
vss.value_at(0) == "a"
vss.value_at(1) == cs0
vss.value_at(2) == cs0
vss.value_at(3) == cs1
vss.value_at(5) == "f"
str(vss.value_at(2)) == "bb"
Generates the characters from c1 to c2, inclusive.
Returns True if given character is a number, False otherwise.
Returns True if the character can be selected