Skip to content

Commit 485d949

Browse files
committed
Update README.md
1 parent c46c5b4 commit 485d949

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

utils/README.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,47 +18,47 @@ Each button can be in different states depending on how long it has been held do
1818

1919
A Python object that acts as an interface for two buttons and a 16x2 character LCD connected to a Raspberry Pi
2020

21-
Methods:
21+
#### Methods:
2222

2323
**button**(_self, button_)
2424

25-
Get the current state of a button by name
25+
Get the current state of a button by name
2626

2727
**buttons**(_self_)
2828

29-
Return a list of the states of all buttons
29+
Return a list of the states of all buttons
3030

3131
**waitforrelease**(_self, tmin=0_)
3232

33-
Wait for all buttons to be released and at least _tmin_ seconds
33+
Wait for all buttons to be released and at least _tmin_ seconds
3434

3535
**waitfortap**(_self, t_)
3636

37-
Wait _t_ seconds or until a button is tapped. Returns _True_ if tapped, _False_ if not
37+
Wait _t_ seconds or until a button is tapped. Returns _True_ if tapped, _False_ if not
3838

3939
**lcd_clear**(_self_)
4040

41-
Clears the LCD
41+
Clears the LCD
4242

4343
**lcd_write**(_self, text, row=0, col=0_)
4444

45-
Writes _text_ starting on the given _row_ beginning at _col_. If the text is longer than 16 characters, it will scroll.
45+
Writes _text_ starting on the given _row_ beginning at _col_. If the text is longer than 16 characters, it will scroll.
4646

4747
**lcd_blink**(_self, text, row=0, n=3_)
4848

49-
Writes _text_ to _row_ and blinks it _n_ times.
49+
Writes _text_ to _row_ and blinks it _n_ times.
5050

5151
**choose_opt**(_self, opts, row=0, timeout=MENU_TIMEOUT, passlong=False_)
5252

53-
Allows the user to choose between different _opts_ by tapping buttons to scroll through them. Holding right will confirm, blink the choice, and return the index of the option chosen. Holding left or waiting longer than _timeout_ will cancel and return -1. If _passlong_ is _True_, and the user has been holding the button since _choose_opt_ was called, for a total of _LONG_TIME_ seconds, the method returns -1 so this state can be processed by the main loop. If _passlong_ is _False_ long button holds are ignored.
53+
Allows the user to choose between different _opts_ by tapping buttons to scroll through them. Holding right will confirm, blink the choice, and return the index of the option chosen. Holding left or waiting longer than _timeout_ will cancel and return -1. If _passlong_ is _True_, and the user has been holding the button since _choose_opt_ was called, for a total of _LONG_TIME_ seconds, the method returns -1 so this state can be processed by the main loop. If _passlong_ is _False_ long button holds are ignored.
5454

5555
**choose_val**(_self, val, inc, minval, maxval, format="%16s"_)
5656

57-
Lets the user choose a numeric value between _minval_ and _maxval_, with a starting value of _val_. Tapping buttons increases or decreases the value by _inc_, and holding buttons increments the value quickly. The value is displayed according to _format_. The value is returned when the user waits ~5s without pressing a button.
57+
Lets the user choose a numeric value between _minval_ and _maxval_, with a starting value of _val_. Tapping buttons increases or decreases the value by _inc_, and holding buttons increments the value quickly. The value is displayed according to _format_. The value is returned when the user waits ~5s without pressing a button.
5858

5959
**char_input**(_self, text='', row=1, timeout=MENU_TIMEOUT, charset=INPCHARS)
6060

61-
Allows a user to enter text strings charater by character. Tapping buttons changes the current character, and holding a button down moves the cursor. When the user moves the cursor to the end of the string they can also choose the accept and delete characters. Holding right on accept will return the text, and waiting ~5s cancels the text entry.
61+
Allows a user to enter text strings charater by character. Tapping buttons changes the current character, and holding a button down moves the cursor. When the user moves the cursor to the end of the string they can also choose the accept and delete characters. Holding right on accept will return the text, and waiting ~5s cancels the text entry.
6262

6363
### Example
6464

@@ -105,8 +105,7 @@ To use this for your own purposes, import `netlink` in the two scripts that you
105105

106106
Message objects are used by clients and servers to encode requests and replies into text streams that can be sent via sockets. You don't need to create them yourself - they are created internally when you call _Client.request()_ and _Server.reply()_.
107107

108-
Public Attributes:
109-
108+
#### Public Attributes:
110109
- _type_: one of the integer constants defined at the top of _netlink.py_
111110
- _body_: the text of the request or reply
112111
- _id_: Each request has a unique ID - the server tags its responses with the request ID so that the client can match responses with requests
@@ -115,26 +114,30 @@ Public Attributes:
115114

116115
**Server**(_port=DEFAULT_PORT, passkey=DEFAULT_PASSKEY_)
117116

118-
Sets up a server listening on _port_. The _passkey_ must be the same on client and server, and can be up to 7 characters.
117+
Sets up a server listening on _port_. The _passkey_ must be the same on client and server, and can be up to 7 characters.
118+
119+
#### Methods:
119120

120121
**pending**()
121122

122-
Checks to see if any clients have connected and made requests. Returns the current queue of requests as a list of _Message_ objects.
123+
Checks to see if any clients have connected and made requests. Returns the current queue of requests as a list of _Message_ objects.
123124

124125
**reply**(_req, response='', type=REQ_OK_)
125126

126-
Sends a reply to the client that sent _req_, with _response_ as the message body.
127+
Sends a reply to the client that sent _req_, with _response_ as the message body.
127128

128129
### class Client
129130

130131
**Client**(_server='', port=DEFAULT_PORT, passkey=DEFAULT_PASSKEY, timeout=20_)
131132

132-
Starts a client and connects to IP address _server_ on _port_ with _passkey_.
133+
Starts a client and connects to IP address _server_ on _port_ with _passkey_.
134+
135+
#### Methods:
133136

134137
**request**(_type, body='', blocking=1_)
135138

136-
Sends a request to the server, where message _type_ is one of the integer constants defined at the top of the file. If _blocking_ evaluates as **True**, waits until the server responds and returns the response as a _Message_ object.
139+
Sends a request to the server, where message _type_ is one of the integer constants defined at the top of the file. If _blocking_ evaluates as **True**, waits until the server responds and returns the response as a _Message_ object.
137140

138141
**check**()
139142

140-
Checks to see if a reply to any non-blocking requests has arrived. If so, remove the request from the list and return a _Message_ object for the response.
143+
Checks to see if a reply to any non-blocking requests has arrived. If so, remove the request from the list and return a _Message_ object for the response.

0 commit comments

Comments
 (0)