Skip to content
This repository has been archived by the owner on Jan 18, 2020. It is now read-only.

Latest commit

 

History

History
136 lines (97 loc) · 3.83 KB

talalib.md

File metadata and controls

136 lines (97 loc) · 3.83 KB

talalib.py

talalib.py is a small python module that allows easy interaction with the sensors used on the Tala project, without the need to know GPIO commands, PIL, etc..

Supported Modules

Setup

import talalib
tala = talalib.Tala()

Methods

menu(items[List of String]) [Screen, Keypad]

Get the user to select from a list of items. The first parameter of the function is the list of strings to ask the user to select, the output of the function will be one of the items in the list as a string.

tala.menu(["Item 1", "Item 2", "Item 3"])
# -> "Item 1"

message(title[String], body[String]) [Screen, Keypad]

This shows a message to the user. The first parameter of the function is the title of the message as a string and the second parameter is the body of the message, if the body is too long to fit on screen, the user can scroll using the up and down keys. The user needs to manually dismiss a message!

tala.message("Example", "This is an example popup!")

Input a title then a body.

popup(title[String], body[String]) [Screen]

This is similar to the above message method, but does not require user input to be dismissed (the screen needs to be cleared to remove it). The title parameter is optional but body is required. After calling this function, you might want tala.singlebutton() to get user input.

tala.popup("Popup", "You have mail!")
tala.popup(body="You have mail!")

yn(question[String]) [Screen, Keypad]

This uses the above popup method and combines it with singlebutton to ask the user a yes/no question. The question parameter is required and needs to be a string.

tala.yn("Do you like ice cream")

singlebutton() [Keypad]

This waits for a button on the keypad to be pressed, then returns the button as a string (0-9, #, *).

tala.singlebutton()
# -> "1"

type(wait[Integer]{optional}) [Screen, Keypad]

This allows the user to type on the keypad by holding a key to cycle through the letters and unpressing to type the letter that is currently on the screen. The user can then press the # button to enter the text. An optional parameter is wait which is how fast move onto the next letter in the sequence when the button is held down in seconds (the default is 0.5). The function returns the message as a string.

tala.type()
# -> "Hello World!"

send(message[String]) [Radio]

This sends a message via the HC-12 module. The first and only parameter is the message to send as a string, there is no output.

tala.send("Hello World!")

waitForReceive() [Radio]

This waits for a message to be received via the HC-12 module. There are no parameters and the output is the message received as a string.

tala.waitForReceive()
# -> "Hello World!"

receive() [Radio]

This receives a message from the HC-12 module. There are no parameters and the output will be the message as a string. The string may be empty, in which case no message has been received. waitForReceive() is the output of this command, but in a loop.

tala.receive()
# -> "Hello World!"

cleanup() [Keypad]

This cleans up the GPIO pins. This should be run when the program quits.

tala.cleanup()

clear() [Screen]

This clears the screen.

tala.clear()