PiStorms
4.012
PiStorms Library Reference by mindsensors.com
|
mindsensorsUI: this class provides functions for touchscreen LCD on mindsensors.com products for read and write operations. More...
Public Member Functions | |
def | __init__ |
Initialize the UI device. More... | |
def | dumpTerminal |
Dumps the screen buffer. More... | |
def | setMode |
Sets the mode (Experienced users) More... | |
def | getMode |
Returns the value of the mode (Experienced users) More... | |
def | calibrateTouched |
Sets the expected X,Y when the screen is not touched to their current values (Experienced users) More... | |
def | fillRoundRect |
Draw a rectangle with rounded edges on the screen (rotated to screen) More... | |
def | screenXFromImageCoords |
Calculates the x-coordinate of the screen upon rotation (INTERNAL USE ONLY) More... | |
def | screenYFromImageCoords |
Calculates the y-coordinate of the screen upon rotation(INTERNAL USE ONLY) More... | |
def | TS_To_ImageCoords_X |
Calculates display x-coordinate from touchscreen values, adjusted for rotation (INTERNAL USE ONLY) More... | |
def | TS_To_ImageCoords_Y |
Calculates display y-coordinate from touchscreen values, adjusted for rotation (INTERNAL USE ONLY) More... | |
def | draw_rotated_text |
Displays rotated text (INTERNAL USE ONLY) More... | |
def | screenWidth |
Determines the width of the screen based on rotation (Experienced users) More... | |
def | screenHeight |
Determines the height of the screen based on rotation (Experienced users) More... | |
def | drawDisplay |
Prints the name text on the screen, intended for terminal mode. More... | |
def | drawArrows |
Draw forward and back arrows on the screen. More... | |
def | checkArrows |
Determine if either on screen arrow button is pressed. More... | |
def | hideArrows |
Hide the on screen arrow buttons. More... | |
def | showArrows |
Show the on screen arrow buttons. More... | |
def | calculateButton |
Determines if button in a pop-up window is pressed (Experienced users) More... | |
def | getTouchscreenValues |
Returns a tuple of the x and y touchscreen coordinates, or (0,0) if the screen is not touched. More... | |
def | TS_X |
Reads the x-coordinate of the touchscreen press. More... | |
def | TS_Y |
Reads the y-coordinate of the touchscreen press. More... | |
def | RAW_X |
Reads the raw touchscreen x-value (INTERNAL USE ONLY) More... | |
def | RAW_Y |
Reads the raw touchscreen y-value (INTERNAL USE ONLY) More... | |
def | isTouched |
Detects touchscreen presses and prevents false positives. More... | |
def | clearScreen |
Clears the LCD screen to defualt black. More... | |
def | fillRect |
Draw a rectangle on the screen (rotated to screen) More... | |
def | fillCircle |
Draw a circle on the screen (rotated to screen) More... | |
def | fillBmp |
Draw a bitmap image on the screen (.png files rcommended) More... | |
def | fillImgArray |
Draw a image on the screen using supplied image data. More... | |
def | rotateRight |
Rotates the screen orientation 90 degrees to the right (-90 degrees) More... | |
def | rotateLeft |
Rotates the screen orientation 90 degrees to the left (90 degrees) More... | |
def | drawAutoText |
Displays text on the screen with adjusted position and rotation. More... | |
def | termGotoLine |
Set the cursor to a specific line of the of the screen. More... | |
def | termCheckCursorValid |
Check if a cursor position (or the current cursor position) is valid. More... | |
def | termClearLine |
Clear a terminal line. More... | |
def | termPrintAt |
Print to a specific line of the screen. More... | |
def | termPrint |
Print to the current line of the screen. More... | |
def | termPrintln |
Print to the current line and then go to the next line. More... | |
def | termReplaceLastLine |
Print new text in place of last line. More... | |
def | refreshLine |
Draw a terminal text line to the screen. More... | |
def | drawButton |
Draw a labeled button on the screen (INTERNAL USE ONLY) More... | |
def | refresh |
Refresh the screen (Slow) More... | |
def | checkButton |
Determine if an on screen button is pressed. More... | |
def | askQuestion |
Display pop-up of a question on the screen. More... | |
def | askYesOrNoQuestion |
Display Pop-up of 'Yes' or 'No' question on the screen, returning True or False. More... | |
def | showMessage |
Display pop-up of a message on the screen with a single option "OK". More... | |
def | forceMessage |
Display pop-up of a message on the screen with no exit options. More... | |
def | drawLine |
Draw a line on the screen (rotated to screen) More... | |
def | drawPolyLine |
Draw a polyline on the screen (rotated to screen) More... | |
Public Attributes | |
PS_ADDRESS | |
PS_TSX | |
PS_TSY | |
i2c | |
mutex | |
touchIgnoreX | |
touchIgnoreY | |
currentRotation | |
myname | |
ts_cal | |
terminalBuffer | |
terminalCursor | |
currentMode | |
drawArrowsbool | |
popupText | |
buttonText | |
Static Public Attributes | |
int | PS_ADDRESS = 0x34 |
Default Device I2C Address. | |
int | PS_TSX = 0xE3 |
Touchscreen X-axis Register. More... | |
int | PS_TSY = 0xE5 |
Touchscreen Y-axis Register. More... | |
int | PS_RAWX = 0xE7 |
Touchscreen Y-axis Raw Register. More... | |
int | PS_RAWY = 0xE9 |
Touchscreen Y-axis Raw Register. More... | |
tuple | PS_BLACK = (0,0,0) |
Constant to specify black color. | |
tuple | PS_BLUE = (0,0,255) |
Constant to specify blue color. | |
tuple | PS_RED = (255,0,0) |
Constant to specify red color. | |
tuple | PS_GREEN = (0,255,0) |
Constant to specify green color. | |
tuple | PS_CYAN = (0,255,255) |
Constant to specify cyan color. | |
tuple | PS_MAGENTA = (255,0,255) |
Constant to specify magenta color. | |
tuple | PS_YELLOW = (255,255,0) |
Constant to specify yellow color. | |
tuple | PS_WHITE = (255,255,255) |
Constant to specify white color. | |
int | PS_SCREENWIDTH = 240 |
Constant to defualt screen width. | |
int | PS_SCREENHEIGHT = 320 |
Constant to defualt screen height. | |
mindsensorsUI: this class provides functions for touchscreen LCD on mindsensors.com products for read and write operations.
There is no need to initialize this class unless using the LCD screen alone. Normal initialization will be performed automatically with initialization of the Device on which the screen is used.
def mindsensorsUI.mindsensorsUI.__init__ | ( | self, | |
name = "PiStorms" , |
|||
rotation = 3 , |
|||
device = Dev_PiStorms |
|||
) |
Initialize the UI device.
self | The object pointer. |
name | The display title that will appear at the top of the LCD touchscreen. Optional, defaults to "PiStorms" (unused). |
rotation | The rotation of the LCD touchscreen. Optional, defaults to 3 (standard rotation). |
device | The device on which the LCD touchscreen is used. Optional, defaults to PiStorms. |
def mindsensorsUI.mindsensorsUI.askQuestion | ( | self, | |
question, | |||
options, | |||
touch = True , |
|||
goBtn = False |
|||
) |
Display pop-up of a question on the screen.
self | The object pointer. |
question | The question that will pop-up on the screen. The first string will be the titlebar. |
options | The possible answers to the question. |
touch | Whether to check if the on screen buttons are pressed. Optional, defaults to True. |
goBtn | Whether to check for the GO button to close the question. Optional, defaults to False. |
def mindsensorsUI.mindsensorsUI.askYesOrNoQuestion | ( | self, | |
question, | |||
touch = True , |
|||
goBtn = False |
|||
) |
Display Pop-up of 'Yes' or 'No' question on the screen, returning True or False.
self | The object pointer. |
question | The question that will pop-up on the screen. |
touch | Whether to check if on screen buttons are pressed. Optional, defaults to True. |
goBtn | Whether to check for the GO button to close the question. Optional, defaults to False. |
def mindsensorsUI.mindsensorsUI.calculateButton | ( | self, | |
xbuff, | |||
ybuff, | |||
buttHeight | |||
) |
Determines if button in a pop-up window is pressed (Experienced users)
self | The object pointer. |
xbuff | The x-coordinate buffer. |
ybuff | The y-coordinate buffer. |
buttHeight | The height of the button. |
def mindsensorsUI.mindsensorsUI.calibrateTouched | ( | self | ) |
Sets the expected X,Y when the screen is not touched to their current values (Experienced users)
self | The object pointer. |
def mindsensorsUI.mindsensorsUI.checkArrows | ( | self | ) |
Determine if either on screen arrow button is pressed.
self | The object pointer. |
def mindsensorsUI.mindsensorsUI.checkButton | ( | self, | |
x, | |||
y, | |||
width = 150 , |
|||
height = 50 |
|||
) |
Determine if an on screen button is pressed.
self | The object pointer. |
x | The upper left x-coordinate of the button. |
y | The upper left y-coordinate of the button. |
width | The width of the button. Optional, defaults to 150. |
height | The height of the button. Optional, defaults to 50. |
def mindsensorsUI.mindsensorsUI.clearScreen | ( | self, | |
display = True |
|||
) |
def mindsensorsUI.mindsensorsUI.draw_rotated_text | ( | self, | |
image, | |||
text, | |||
position, | |||
angle, | |||
font, | |||
fill = (255,255 , |
|||
display = True |
|||
) |
Displays rotated text (INTERNAL USE ONLY)
self | The object pointer. |
image | The image used for creating text |
text | The text to display on the screen |
position | The position of the text as a set of x and y-coordinates |
angle | The angle at which to rotate the text |
font | The font of the text |
fill | The color of the text. Optional, defaults to white. |
display | Choose to immediately push the drawing to the screen. Optional, defaults to True. |
def mindsensorsUI.mindsensorsUI.drawArrows | ( | self, | |
display = True |
|||
) |
Draw forward and back arrows on the screen.
self | The object pointer. |
display | Choose to immediately push the drawing to the screen. Optional, defaults to True. |
def mindsensorsUI.mindsensorsUI.drawAutoText | ( | self, | |
text, | |||
x, | |||
y, | |||
fill = (255,255 , |
|||
size = 20 , |
|||
align = "left" , |
|||
display = True |
|||
) |
Displays text on the screen with adjusted position and rotation.
self | The object pointer. |
text | The text to display on the screen |
x | The upper left x coordinate of the text. Optional, defaults to "left". Irrelevant if align is "center" |
y | The upper left y coordinate of the text. |
fill | The color of the text. Optional, defaults to white. |
size | The pixel size of the text. Optional, defaults to 20. |
align | The text alignment, "left" or "center" or "right". Optional, defaults to "left". |
display | Choose to immediately push the drawing to the screen. Optional, defaults to True. |
def mindsensorsUI.mindsensorsUI.drawButton | ( | self, | |
x, | |||
y, | |||
width, | |||
height, | |||
prefix = "btns_" , |
|||
text = "OK" , |
|||
display = True , |
|||
align = "left" , |
|||
image = None , |
|||
imageX = None , |
|||
imageY = None |
|||
) |
Draw a labeled button on the screen (INTERNAL USE ONLY)
self | The object pointer. |
x | The upper left x coordinate of the rectangle. |
y | The upper left y coordinate of the rectangle. |
width | The width of the button. |
height | The height of the button. |
prefix | The button images filename prefix. Optional, defaults to "btns_" |
text | The button label. Defaults to "OK" |
display | Choose to immediately push the drawing to the screen. Optional, defaults to True. |
align | The alignment for the button's text label. |
image | An optional image to be included on the button, should be 32x32. |
imageX | The x-coordinate of the optional image icon. |
imageY | The y-coordinate of the optional image icon. |
def mindsensorsUI.mindsensorsUI.drawDisplay | ( | self, | |
name, | |||
display = True |
|||
) |
Prints the name text on the screen, intended for terminal mode.
self | The object pointer. |
name | The display title that will appear at the top of the LCD touchscreen. |
display | Choose to immediately push the drawing to the screen. Optional, defaults to True. |
def mindsensorsUI.mindsensorsUI.drawLine | ( | self, | |
x1, | |||
y1, | |||
x2, | |||
y2, | |||
width = 0 , |
|||
fill = (255,255 , |
|||
display = True |
|||
) |
Draw a line on the screen (rotated to screen)
self | The object pointer. |
x1,y1,x2,y2 | The x and y coordinates of each endpoint of the line. |
width | The width of the line. Optional, defaults to 0. |
fill | The color of line. Optional, defaults to white. |
display | Choose to immediately push the drawing to the screen. Optional, defaults to True. |
def mindsensorsUI.mindsensorsUI.drawPolyLine | ( | self, | |
endpoints, | |||
width = 0 , |
|||
fill = (255,255 , |
|||
display = True |
|||
) |
Draw a polyline on the screen (rotated to screen)
self | The object pointer. |
endpoints | [x1, y1, x2, y2...] The x and y coordinates of each endpoint of the polyline. |
width | The width of the polyline. Optional, defaults to 0. |
fill | The color of polyline. Optional, defaults to white. |
display | Choose to immediately push the drawing to the screen. Optional, defaults to True. |
def mindsensorsUI.mindsensorsUI.dumpTerminal | ( | self, | |
display = True |
|||
) |
Dumps the screen buffer.
self | The object pointer. |
display | Choose to immediately push the drawing to the screen. Optional, defaults to True. |
def mindsensorsUI.mindsensorsUI.fillBmp | ( | self, | |
x, | |||
y, | |||
width, | |||
height, | |||
path = "/usr/local/mindsensors/images/Pane1.png" , |
|||
display = True |
|||
) |
Draw a bitmap image on the screen (.png files rcommended)
self | The object pointer. |
x | The upper left x coordinate of the image. |
y | The upper left y coordinate of the image. |
width | The width of the image. |
height | The width of the image. |
path | The image file path. Optional, defaults to the popup background image. |
display | Choose to immediately push the drawing to the screen. Optional, defaults to True. |
def mindsensorsUI.mindsensorsUI.fillCircle | ( | self, | |
x, | |||
y, | |||
radius, | |||
fill = (255,255 , |
|||
display = True |
|||
) |
Draw a circle on the screen (rotated to screen)
self | The object pointer. |
x | The center x coordinate of the circle. |
y | The center y coordinate of the circle. |
radius | The radius of the circle. |
fill | The color of the inside of the circle. Optional, defaults to white. |
display | Choose to immediately push the drawing to the screen. Optional, defaults to True. |
def mindsensorsUI.mindsensorsUI.fillImgArray | ( | self, | |
x, | |||
y, | |||
width, | |||
height, | |||
image, | |||
display = True |
|||
) |
Draw a image on the screen using supplied image data.
self | The object pointer. |
x | The upper left x coordinate of the image. |
y | The upper left y coordinate of the image. |
width | The width of the image. |
height | The width of the image. |
image | data |
display | Choose to immediately push the drawing to the screen. Optional, defaults to True. |
def mindsensorsUI.mindsensorsUI.fillRect | ( | self, | |
x, | |||
y, | |||
width, | |||
height, | |||
fill = (255,255 , |
|||
outline = None , |
|||
display = True |
|||
) |
Draw a rectangle on the screen (rotated to screen)
self | The object pointer. |
x | The upper left x coordinate of the rectangle. |
y | The upper left y coordinate of the rectangle. |
width | The width of the rectangle. |
height | The height of the rectangle. |
fill | The color of inside of the rectangle. Optional, defaults to white. |
outline | The color of the outer edge of the rectangle. Optional, defaults to no outline. |
display | Choose to immediately push the drawing to the screen. Optional, defaults to True. |
def mindsensorsUI.mindsensorsUI.fillRoundRect | ( | self, | |
x, | |||
y, | |||
width, | |||
height, | |||
radius, | |||
fill = (255,255 , |
|||
display = True |
|||
) |
Draw a rectangle with rounded edges on the screen (rotated to screen)
self | The object pointer. |
x | The upper left x coordinate of the rectangle. |
y | The upper left y coordinate of the rectangle. |
width | The width of the rectangle. |
height | The height of the rectangle. |
radius | The arc of the rectangle corners. |
fill | The color of the inside of the rectangle. Optional, defaults to white. |
display | Choose to immediately push the drawing to the screen. Optional, defaults to True. |
def mindsensorsUI.mindsensorsUI.forceMessage | ( | self, | |
message | |||
) |
Display pop-up of a message on the screen with no exit options.
This function will return right away. You may need to call screen.setMode(screen.PS_MODE_TERMINAL)
to stop the popup later.
self | The object pointer. |
message | The message that will pop-up on the screen. |
def mindsensorsUI.mindsensorsUI.getMode | ( | self | ) |
Returns the value of the mode (Experienced users)
self | The object pointer. |
def mindsensorsUI.mindsensorsUI.getTouchscreenValues | ( | self | ) |
def mindsensorsUI.mindsensorsUI.hideArrows | ( | self, | |
refresh = True |
|||
) |
Hide the on screen arrow buttons.
self | The object pointer. |
refresh | Choose to immediately refresh screen. |
def mindsensorsUI.mindsensorsUI.isTouched | ( | self | ) |
def mindsensorsUI.mindsensorsUI.RAW_X | ( | self | ) |
Reads the raw touchscreen x-value (INTERNAL USE ONLY)
self | The object pointer. |
def mindsensorsUI.mindsensorsUI.RAW_Y | ( | self | ) |
Reads the raw touchscreen y-value (INTERNAL USE ONLY)
self | The object pointer. |
def mindsensorsUI.mindsensorsUI.refresh | ( | self | ) |
def mindsensorsUI.mindsensorsUI.refreshLine | ( | self, | |
lineNum, | |||
display = True |
|||
) |
def mindsensorsUI.mindsensorsUI.rotateLeft | ( | self | ) |
def mindsensorsUI.mindsensorsUI.rotateRight | ( | self | ) |
def mindsensorsUI.mindsensorsUI.screenHeight | ( | self | ) |
Determines the height of the screen based on rotation (Experienced users)
self | The object pointer. |
def mindsensorsUI.mindsensorsUI.screenWidth | ( | self | ) |
Determines the width of the screen based on rotation (Experienced users)
self | The object pointer. |
def mindsensorsUI.mindsensorsUI.screenXFromImageCoords | ( | self, | |
x = 0 , |
|||
y = 0 |
|||
) |
Calculates the x-coordinate of the screen upon rotation (INTERNAL USE ONLY)
self | The object pointer. |
x | The x-coordinate. |
y | The y-coordinate. |
def mindsensorsUI.mindsensorsUI.screenYFromImageCoords | ( | self, | |
x = 0 , |
|||
y = 0 |
|||
) |
Calculates the y-coordinate of the screen upon rotation(INTERNAL USE ONLY)
self | The object pointer. |
x | The x-coordinate. |
y | The y-coordinate. |
def mindsensorsUI.mindsensorsUI.setMode | ( | self, | |
mode = 0 |
|||
) |
Sets the mode (Experienced users)
self | The object pointer. |
mode | The new mode: PS_MODE_TERMINAL, PS_MODE_POPUP, or PS_MODE_DEAD. Optional, defaults to PS_MODE_TERMINAL. |
def mindsensorsUI.mindsensorsUI.showArrows | ( | self, | |
refresh = True |
|||
) |
Show the on screen arrow buttons.
self | The object pointer. |
refresh | Choose to immediately refresh screen. |
def mindsensorsUI.mindsensorsUI.showMessage | ( | self, | |
message, | |||
touch = True , |
|||
goBtn = True |
|||
) |
Display pop-up of a message on the screen with a single option "OK".
self | The object pointer. |
message | The message that will pop-up on the screen. |
touch | Whether to check if on screen buttons are pressed. Optional, defaults to True. |
goBtn | Whether to check for the GO button to close the question. Optional, defaults to True. |
def mindsensorsUI.mindsensorsUI.termCheckCursorValid | ( | self, | |
lineno = None |
|||
) |
Check if a cursor position (or the current cursor position) is valid.
lineno | Which line to check if is is valid. If no argument is provided, check the current cursor position. |
def mindsensorsUI.mindsensorsUI.termClearLine | ( | self, | |
lineno, | |||
visualOnly = False , |
|||
display = True |
|||
) |
Clear a terminal line.
lineno | The line number at which to clear. |
visualOnly | Choose to clear the space on screen but not modify the terminal buffer. Optional, defaults to False. |
display | Choose to immediately push the drawing to the screen. Optional, defaults to True. |
def mindsensorsUI.mindsensorsUI.termGotoLine | ( | self, | |
lineno | |||
) |
def mindsensorsUI.mindsensorsUI.termPrint | ( | self, | |
text, | |||
display = True |
|||
) |
def mindsensorsUI.mindsensorsUI.termPrintAt | ( | self, | |
lineno, | |||
text, | |||
display = True |
|||
) |
Print to a specific line of the screen.
This will not affect the current cursor position.
self | The object pointer. |
lineno | The line number at which to set the cursor. |
text | The text to print to the screen. |
display | Choose to immediately push the drawing to the screen. Optional, defaults to True. |
def mindsensorsUI.mindsensorsUI.termPrintln | ( | self, | |
text, | |||
display = True |
|||
) |
Print to the current line and then go to the next line.
self | The object pointer. |
text | The text to print to the screen. |
display | Choose to immediately push the drawing to the screen. Optional, defaults to True. |
def mindsensorsUI.mindsensorsUI.termReplaceLastLine | ( | self, | |
text, | |||
display = True |
|||
) |
Print new text in place of last line.
This will not affect the current cursor position.
self | The object pointer. |
text | The text to print to the screen. |
display | Choose to immediately push the drawing to the screen. Optional, defaults to True. |
def mindsensorsUI.mindsensorsUI.TS_To_ImageCoords_X | ( | self, | |
x, | |||
y | |||
) |
Calculates display x-coordinate from touchscreen values, adjusted for rotation (INTERNAL USE ONLY)
self | The object pointer. |
x | The x-coordinate. |
y | The y-coordinate. |
def mindsensorsUI.mindsensorsUI.TS_To_ImageCoords_Y | ( | self, | |
x, | |||
y | |||
) |
Calculates display y-coordinate from touchscreen values, adjusted for rotation (INTERNAL USE ONLY)
self | The object pointer. |
x | The x-coordinate. |
y | The y-coordinate. |
def mindsensorsUI.mindsensorsUI.TS_X | ( | self | ) |
def mindsensorsUI.mindsensorsUI.TS_Y | ( | self | ) |
|
static |
Touchscreen Y-axis Raw Register.
|
static |
Touchscreen Y-axis Raw Register.
|
static |
Touchscreen X-axis Register.
Will return an unsigned integer reading (0-340)
|
static |
Touchscreen Y-axis Register.
Will return an unsigned integer reading (0-440)