9. API - LCD Module
9.1. Regular Classes
The following classes are intended for general use with the devices they represent. All classes in this section are concrete (not abstract).
9.1.1. LCM
- class lannerpsp.LCM(check_platform: bool = False)[source]
LCD Module.
- Parameters:
check_platform (bool) – Set to
True
to check if the platform supports this feature. Defaults toFalse
for better compatibility.- Raises:
PSPNotSupport – This function is not supported (when
check_platform
is set toTrue
).NotImplementedError – It has not been verified to run on this platform (when
check_platform
is set toTrue
).
- search_port() str [source]
Get the LCM current connected port and speed.
- Returns:
the port and speed the LCM is currently connected to
- Return type:
- Raises:
PSPNotOpened – The library is not ready or opened yet.
PSPNotSupport – This function is not supported.
PSPNotExist – This function is not enabled or does not exist.
PSPError – General PSP functional error.
- reset() None [source]
Reset the LCD module.
Note
Support only UART type.
- Raises:
PSPNotOpened – The library is not ready or opened yet.
PSPNotSupport – This function is not supported.
PSPError – General PSP functional error.
- set_backlight(enable: bool) None [source]
Set LCD module light on/off status.
Example:
>>> lcm = LCM() >>> lcm.set_backlight(True)
- Parameters:
enable (bool) – set
True
to enable backlight, otherwiseFalse
- Raises:
TypeError – The input parameters type error.
PSPNotOpened – The library is not ready or opened yet.
PSPNotSupport – This function is not supported.
PSPError – General PSP functional error.
- set_cursor(row: int, column: int = 1) None [source]
Set LCM cursor.
Example:
>>> lcm = LCM() >>> lcm.set_cursor(2, 6)
- Parameters:
- Raises:
TypeError – The input parameters type error.
PSPInvalid – The input parameter is out of range.
PSPNotOpened – The library is not ready or opened yet.
PSPNotSupport – This function is not supported.
PSPError – General PSP functional error.
- write(msg: str) None [source]
Write string to LCD module.
Note
The maximum string length depends on the LCD module, normally 40 characters.
Example:
>>> lcm = LCM() >>> lcm.write("Hello World")
- Parameters:
msg (str) – message string to LCM display
- Raises:
TypeError – The input parameters type error.
PSPNotOpened – The library is not ready or opened yet.
PSPNotSupport – This function is not supported.
PSPError – General PSP functional error.
- clear() None [source]
Clear LCM display.
Example:
>>> lcm = LCM() >>> lcm.clear()
- Raises:
PSPNotOpened – The library is not ready or opened yet.
PSPNotSupport – This function is not supported.
PSPError – General PSP functional error.
- get_keys_status() int [source]
Get LCM keys status.
bit 0 means Key 1, bit 1 means Key2, bit 2 means Key 3, bit 3 means Key4
1: pressed , 0: released
0 (0000): key1 -> off, key2 -> off, key3 -> off, key4 -> off
1 (0001): key1 -> on, key2 -> off, key3 -> off, key4 -> off
2 (0010): key1 -> off, key2 -> on, key3 -> off, key4 -> off
4 (0100): key1 -> off, key2 -> off, key3 -> on, key4 -> off
8 (1000): key1 -> off, key2 -> off, key3 -> off, key4 -> on
Example:
>>> lcm = LCM() >>> lcm.get_keys_status() 2
- Returns:
LCM keys status
- Return type:
- Raises:
PSPNotOpened – The library is not ready or opened yet.
PSPNotSupport – This function is not supported.
PSPError – No key is pressed.
- exec_callback() None [source]
Use callback function to detect LCM Keys status.
Example:
>>> lcm = LCM() >>> lcm.exec_callback() ----> hook LCM Keys Callback OK <---- ===> pause !!! hit <enter> to end <=== <Callback> LCM Item = 0x08, Status = 0x08, time is 2022/08/02 16:48:28 <Callback> LCM Item = 0x08, Status = 0x00, time is 2022/08/02 16:48:28 <Callback> LCM Item = 0x04, Status = 0x04, time is 2022/08/02 16:48:29 <Callback> LCM Item = 0x04, Status = 0x00, time is 2022/08/02 16:48:29 <Callback> LCM Item = 0x08, Status = 0x08, time is 2022/08/02 16:48:30 <Callback> LCM Item = 0x08, Status = 0x00, time is 2022/08/02 16:48:30 <Callback> LCM Item = 0x02, Status = 0x02, time is 2022/08/02 16:48:31 <Callback> LCM Item = 0x02, Status = 0x00, time is 2022/08/02 16:48:31 <Callback> LCM Item = 0x01, Status = 0x01, time is 2022/08/02 16:48:31 <Callback> LCM Item = 0x01, Status = 0x00, time is 2022/08/02 16:48:31 <Callback> LCM Item = 0x08, Status = 0x08, time is 2022/08/02 16:48:32 <Callback> LCM Item = 0x08, Status = 0x00, time is 2022/08/02 16:48:32 ----> hook LCM Keys Callback Disable OK <----
9.2. Supported Platforms
The following platforms have been verified and confirmed to be supported: