-
Notifications
You must be signed in to change notification settings - Fork 52
Update character_lcd.py #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
c7d02b5
d6338ab
a6eb4ef
2516129
2c1a7a4
5bc8ec5
7ef2cc6
3d4340c
4ffe6de
eb8612e
ff1df52
f9d662e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -173,6 +173,7 @@ def __init__(self, rs, en, d4, d5, d6, d7, columns, lines | |
| # itialize to 0,0 | ||
| self.row = 0 | ||
| self.column = 0 | ||
| self._column_align = False | ||
| # pylint: enable-msg=too-many-arguments | ||
|
|
||
| def home(self): | ||
|
|
@@ -201,6 +202,17 @@ def clear(self): | |
| """ | ||
| self._write8(_LCD_CLEARDISPLAY) | ||
| time.sleep(0.003) | ||
|
|
||
| @property | ||
| def column_align(self): | ||
| """If True, message text after '\n' starts directly below start of first | ||
| character in message. If False, text after '\n' starts at column zero. | ||
|
||
| """ | ||
| return self._column_align | ||
|
|
||
| @column_align.setter | ||
| def column_align(self, enable): | ||
| self._column_align = enable | ||
|
||
|
|
||
| @property | ||
| def cursor(self): | ||
|
|
@@ -234,8 +246,9 @@ def cursor(self, show): | |
| self._write8(_LCD_DISPLAYCONTROL | self.displaycontrol) | ||
|
|
||
| def cursor_position(self, column, row): | ||
| """Move the cursor to position ``column``, ``row`` | ||
|
|
||
| """Move the cursor to position ``column``, ``row`` for the next | ||
| message only. Displaying a message resets the cursor position to (0, 0). | ||
|
|
||
| :param column: column location | ||
| :param row: row location | ||
| """ | ||
|
|
@@ -369,6 +382,13 @@ def message(self, message): | |
| # which case start on the opposite side of the display if cursor_position | ||
| # is (0,0) or not set. Start second line at same column as first line when | ||
| # cursor_position is set | ||
| if self.displaymode & _LCD_ENTRYLEFT > 0: | ||
| col = self.column * self._column_align | ||
| else: | ||
| if self._column_align: | ||
| col = self.column | ||
| else: | ||
| col = self.columns - 1 | ||
| self.cursor_position(col, line) | ||
| # Write string to display | ||
| else: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured you mean initialize here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, done