Skip to content
Merged
10 changes: 0 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,6 @@ Contributing
Contributions are welcome! Please read our `Code of Conduct
<https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/blob/master/CODE_OF_CONDUCT.md>`_ before contributing to help this project stay welcoming.

Installation
============

This library is **NOT** built into CircuitPython to make it easy to update. To
install it either follow the directions below or :ref:`install the library bundle <bundle_installation>`.

To install:

#. Download and unzip the `latest release zip <https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/releases>`_.
#. Copy the unzipped ``adafruit_character_lcd`` to the ``lib`` directory on the ``CIRCUITPY`` or ``MICROPYTHON`` drive.

Building locally
================
Expand Down
16 changes: 13 additions & 3 deletions adafruit_character_lcd/character_lcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ def __init__(self, rs, en, d4, d5, d6, d7, columns, lines
self._message = None
self._enable = None
self._direction = None
# track row and column used in cursor_position
# itialize to 0,0
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, done

self.row = 0
self.column = 0
# pylint: enable-msg=too-many-arguments

def home(self):
Expand Down Expand Up @@ -243,6 +247,9 @@ def cursor_position(self, column, row):
column = self.columns - 1
# Set location
self._write8(_LCD_SETDDRAMADDR | (column + _LCD_ROW_OFFSETS[row]))
# Update self.row and self.column to match setter
self.row = row
self.column = column

@property
def blink(self):
Expand Down Expand Up @@ -331,7 +338,8 @@ def message(self):
@message.setter
def message(self, message):
self._message = message
line = 0
# Set line to match self.row from cursor_position()
line = self.row
# Track times through iteration, to act on the initial character of the message
initial_character = 0
# iterate through each character
Expand All @@ -340,15 +348,17 @@ def message(self, message):
if initial_character == 0:
# Start at (1, 1) unless direction is set right to left, in which case start
# on the opposite side of the display.
col = 0 if self.displaymode & _LCD_ENTRYLEFT > 0 else self.columns - 1
# start at self.column instead of 0
col = self.column if self.displaymode & _LCD_ENTRYLEFT > 0 else self.columns - 1
self.cursor_position(col, line)
initial_character += 1
# If character is \n, go to next line
if character == '\n':
line += 1
# Start the second line at (1, 1) unless direction is set right to left in which
# case start on the opposite side of the display.
col = 0 if self.displaymode & _LCD_ENTRYLEFT > 0 else self.columns - 1
# start at self.column instead of 0
col = self.column if self.displaymode & _LCD_ENTRYLEFT > 0 else self.columns - 1
self.cursor_position(col, line)
# Write string to display
else:
Expand Down