Skip to content

Commit e1a939a

Browse files
authored
Merge pull request #3 from mrmcwethy/prepforbundle
Attempt to update readme documents.
2 parents 1817f8a + 0c4552e commit e1a939a

File tree

5 files changed

+103
-55
lines changed

5 files changed

+103
-55
lines changed

README.md

+31-11
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
Introduction
33
============
44

5-
This repo is compatible with standard Character LCDs.
5+
This library is compatible with standard Character LCDs such as:
6+
* [Adafruit Standard LCD 16x2](https://www.adafruit.com/product/181)
7+
* [Adafruit RGB backlight negative LCD 16x2](https://www.adafruit.com/product/399)
8+
* [Adafruit RGB backlight negative LCD 20x4](https://www.adafruit.com/product/498)
69

7-
Compatible with CircuitPython Versions: 1.0.0
10+
Compatible with CircuitPython Versions: 2.x
811

912
Dependencies
1013
=============
1114
This driver depends on:
1215

13-
* [Adafruit CircuitPython](https://github.com/adafruit/circuitpython "cirpyth repo")
16+
* [Adafruit CircuitPython](https://github.com/adafruit/circuitpython "CircuitPython")
1417

1518

1619
Please ensure all dependencies are available on the CircuitPython filesystem.
@@ -20,11 +23,11 @@ This is easily achieved by downloading
2023
Usage Example
2124
=============
2225

23-
The ``LCD`` class interfaces a predefined Character LCD display with CircuitPython.
26+
The ``Character_LCD`` class interfaces a predefined Character LCD display with CircuitPython.
2427

25-
import adafruit_character_lcd as LCD
28+
import adafruit_character_lcd
2629

27-
You must define the data pins (``RS``, ``EN``, ``D4``, ``D5``, ``D6``, ``D7``) in your code before using the ``LCD`` class.
30+
You must define the data pins (``RS``, ``EN``, ``D4``, ``D5``, ``D6``, ``D7``) in your code before using the ``Character_LCD`` class.
2831
If you want to have on/off ``backlight`` functionality, you can also define your backlight as ``lcd_backlight``. Otherwise, the backlight will always remain on. An example of this is below
2932

3033
lcd_rs = digitalio.DigitalInOut(D7)
@@ -38,24 +41,41 @@ If you want to have on/off ``backlight`` functionality, you can also define your
3841
You must also define the size of the CharLCD by specifying its ``lcd_columns`` and ``lcd_rows``:
3942

4043
lcd_columns = 16
41-
lcd_rows = 2
44+
lcd_rows = 2
4245

43-
After you have set up your LCD, we can make the device by calling it
46+
After you have set up your LCD, we can make the device by calling it
4447

45-
lcd = LCD.cirpyth_char_lcd(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight)
48+
lcd = adafruit_character_lcd.Character_LCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight)
4649

4750

4851
To verify that your pins are correct, print a hello message to the CharLCD:
4952

5053
lcd.message('hello\ncircuitpython')
5154

5255

53-
Custom character example with create_char() is provided within /examples/
54-
56+
Custom character example with create_char() is provided within /examples/
5557

5658

5759
Contributing
5860
============
5961

6062
Contributions are welcome! Please read our [Code of Conduct](https://github.com/adafruit/Adafruit_CircuitPython_CircuitPython_CharLCD/blob/master/CODE_OF_CONDUCT.md)
6163
before contributing to help this project stay welcoming.
64+
65+
Installation
66+
============
67+
68+
This library is **NOT** built into CircuitPython to make it easy to update. To
69+
install it either follow the directions below or :ref:`install the library bundle <bundle_installation>`.
70+
71+
To install:
72+
73+
#. Download and unzip the `latest release zip <https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/releases>`_.
74+
#. Copy the unzipped ``adafruit_character_lcd`` to the ``lib`` directory on the ``CIRCUITPY`` or ``MICROPYTHON`` drive.
75+
76+
API
77+
===
78+
.. toctree::
79+
:maxdepth: 3
80+
81+
api

adafruit_character_lcd/character_lcd.py

+31-19
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
`adafruit_CircuitPython_CharLCD`
2424
====================================================
2525
26-
TODO(description)
2726
2827
* Author(s):
2928
-Brent Rubell
@@ -32,7 +31,7 @@
3231
"""
3332

3433
"""
35-
`adafruit_character_lcd` - character lcd module
34+
:mod:`adafruit_character_lcd`
3635
=================================================
3736
module for interfacing with character lcds
3837
"""
@@ -84,19 +83,21 @@
8483

8584
class Character_LCD(object):
8685
""" Interfaces with a character LCD
87-
:param rs: The reset data line
88-
:param en: The enable data line
89-
:param d4, d5, d6, d7: The data lines 4 thru 7
86+
:param ~digitalio.DigitalInOut rs: The reset data line
87+
:param ~digitalio.DigitalInOut en: The enable data line
88+
:param ~digitalio.DigitalInOut d4: The data line 4
89+
:param ~digitalio.DigitalInOut d5: The data line 5
90+
:param ~digitalio.DigitalInOut d6: The data line 6
91+
:param ~digitalio.DigitalInOut d7: The data line 7
9092
:param cols: The columns on the charLCD
9193
:param lines: The lines on the charLCD
92-
:param backlight: The backlight pin, usually the last pin. Check with your datasheet
93-
:param enable_pwm: The PWM CONTROL, TODO
94-
:param initial_backlight: THE initial backlight status (on/off)
94+
:param ~digitalio.DigitalInOut backlight: The backlight pin, usually the last pin. Check with your datasheet
9595
"""
9696
def __init__(self, rs, en, d4, d5, d6, d7, cols, lines,
97-
backlight = None,
98-
enable_pwm = False,
99-
initial_backlight = 1.0):
97+
backlight = None #,
98+
#enable_pwm = False,
99+
#initial_backlight = 1.0
100+
):
100101

101102
self.cols = cols
102103
self.lines = lines
@@ -109,9 +110,7 @@ def __init__(self, rs, en, d4, d5, d6, d7, cols, lines,
109110
self.d7 = d7
110111
# backlight pin
111112
self.backlight = backlight
112-
# save backlight state
113-
self.backlight = backlight
114-
self.pwn_enabled = enable_pwm
113+
# self.pwn_enabled = enable_pwm
115114
# set all pins as outputs
116115
for pin in(rs, en, d4, d5, d6, d7):
117116
pin.direction = digitalio.Direction.OUTPUT
@@ -147,7 +146,9 @@ def clear(self):
147146
time.sleep(0.003)
148147

149148
def show_cursor(self, show):
150-
"""Show or hide the cursor"""
149+
"""Show or hide the cursor
150+
:param show: True to show cursor, False to hide
151+
"""
151152
if show:
152153
self.displaycontrol |= LCD_CURSORON
153154
else:
@@ -166,7 +167,9 @@ def set_cursor(self, col, row):
166167
self._write8(LCD_SETDDRAMADDR | (col + LCD_ROW_OFFSETS[row]))
167168

168169
def blink(self, blink):
169-
"""Blinks the cursor if blink = true."""
170+
"""Blinks the cursor if blink = true.
171+
:param blink: True to blink, False no blink
172+
"""
170173
if blink == True:
171174
self.displaycontrol |= LCD_BLINKON
172175
else:
@@ -192,7 +195,9 @@ def set_right_to_left(self):
192195
self._write8(LCD_ENTRYMODESET | self.displaymode)
193196

194197
def enable_display(self, enable):
195-
"""Enable or disable the display. Set enable to True to enable."""
198+
"""Enable or disable the display.
199+
:param enable: True to enable display, False to disable
200+
"""
196201
if enable:
197202
self.displaycontrol |= LCD_DISPLAYON
198203
else:
@@ -234,15 +239,19 @@ def _pulse_enable(self):
234239
time.sleep(0.0000001)
235240

236241
def set_backlight(self, lighton):
237-
""" Set lighton to turn the charLCD backlight on. """
242+
""" Set lighton to turn the charLCD backlight on.
243+
:param lighton: True to turn backlight on, False to turn off
244+
"""
238245
if lighton:
239246
self.backlight.value = 0
240247
else:
241248
self.backlight.value = 1
242249

243250

244251
def message(self, text):
245-
"""Write text to display, can include \n for newline"""
252+
"""Write text to display, can include \n for newline
253+
:param text: string to display
254+
"""
246255
line = 0
247256
# iterate thru each char
248257
for char in text:
@@ -262,6 +271,9 @@ def create_char(self, location, pattern):
262271
provide an array of 8 bytes containing the pattern. E.g. you can easyly
263272
design your custom character at http://www.quinapalus.com/hd44780udg.html
264273
To show your custom character use eg. lcd.message('\x01')
274+
:param location: integer in range(8) to store the created character
275+
:param ~bytes pattern: len(8) describes created character
276+
265277
"""
266278
# only position 0..7 are allowed
267279
location &= 0x7

adafruit_character_lcd/character_lcd_RGB.py

+32-23
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
`adafruit_CircuitPython_CharLCD`
2424
====================================================
2525
26-
TODO(description)
2726
2827
* Author(s):
2928
-Brent Rubell
@@ -32,7 +31,7 @@
3231
"""
3332

3433
"""
35-
`adafruit_character_lcd_RGB` - RGB character lcd module
34+
:mod:`adafruit_character_lcd_RGB`
3635
=================================================
3736
module for interfacing with RGB character lcds
3837
"""
@@ -86,25 +85,29 @@
8685

8786
class Character_LCD_RGB(object):
8887
""" Interfaces with a character LCD
89-
:param ~microcontroller.Pin rs: The reset data line
90-
:param ~microcontroller.Pin en: The enable data line
91-
:param ~microcontroller.Pin d4, d5, d6, d7: The data lines 4 thru 7
92-
:param ~microcontroller.Pin cols: The columns on the charLCD
93-
:param ~microcontroller.Pin lines: The lines on the charLCD
94-
:param ~microcontroller.Pin red: Red RGB Anode
95-
:param ~microcontroller.Pin green: Green RGB Anode
96-
:param ~microcontroller.Pin blue: Blue RGB Anode
97-
:param ~microcontroller.Pin backlight: The backlight pin, usually the last pin. Consult the datasheet.
98-
:param enable_pwm: PulseIO Control
99-
:param initial_backlight: THE initial backlight status (on/off)
88+
:param ~digitalio.DigitalInOut rs: The reset data line
89+
:param ~digitalio.DigitalInOut en: The enable data line
90+
:param ~digitalio.DigitalInOut d4: The data line 4
91+
:param ~digitalio.DigitalInOut d5: The data line 5
92+
:param ~digitalio.DigitalInOut d6: The data line 6
93+
:param ~digitalio.DigitalInOut d7: The data line 7
94+
:param cols: The columns on the charLCD
95+
:param lines: The lines on the charLCD
96+
:param ~pulseio.PWMOut red: Red RGB Anode
97+
:param ~pulseio.PWMOut green: Green RGB Anode
98+
:param ~pulseio.PWMOut blue: Blue RGB Anode
99+
:param ~digitalio.DigitalInOut backlight: The backlight pin, usually the last pin. Consult the datasheet.
100+
Note that Pin value 0 means blaklight is lit.
101+
100102
"""
101103
def __init__(self, rs, en, d4, d5, d6, d7, cols, lines,
102104
red,
103105
green,
104106
blue,
105-
backlight = None,
106-
enable_pwm = False,
107-
initial_backlight = 1.0):
107+
backlight = None #,
108+
#enable_pwm = False,
109+
#initial_backlight = 1.0
110+
):
108111
# define columns and lines
109112
self.cols = cols
110113
self.lines = lines
@@ -123,9 +126,7 @@ def __init__(self, rs, en, d4, d5, d6, d7, cols, lines,
123126
self.RGBLED = [red, green, blue]
124127
# define backlight pin
125128
self.backlight = backlight
126-
# save backlight state
127-
self.backlight = backlight
128-
self.pwn_enabled = enable_pwm
129+
# self.pwn_enabled = enable_pwm
129130
# set all pins as outputs
130131
for pin in(rs, en, d4, d5, d6, d7):
131132
pin.direction = digitalio.Direction.OUTPUT
@@ -180,7 +181,9 @@ def set_cursor(self, col, row):
180181
self._write8(_LCD_SETDDRAMADDR | (col + LCD_ROW_OFFSETS[row]))
181182

182183
def enable_display(self, enable):
183-
"""Enable or disable the display. Set enable to True to enable."""
184+
"""Enable or disable the display.
185+
:param enable: True to enable display, False to disable
186+
"""
184187
if enable:
185188
self.displaycontrol |= _LCD_DISPLAYON
186189
else:
@@ -222,7 +225,9 @@ def _pulse_enable(self):
222225
time.sleep(0.0000001)
223226

224227
def set_backlight(self, lighton):
225-
""" Set lighton to turn the charLCD backlight on. """
228+
""" Set lighton to turn the charLCD backlight on.
229+
:param lighton: True to turn backlight on, False to turn off
230+
"""
226231
if lighton:
227232
self.backlight.value = 0
228233
else:
@@ -239,13 +244,17 @@ def _map(self, x, in_min, in_max, out_min, out_max):
239244
return max(min(ret, out_min), out_max)
240245

241246
def setColor(self, color):
242-
""" Method to set the duty cycle of the RGB LED """
247+
""" Method to set the duty cycle of the RGB LED
248+
:param color: list of 3 integers in range(100). ``[R,G,B]`` 0 is no color, 100 it maximum color
249+
"""
243250
self.RGBLED[0].duty_cycle = int(self._map(color[0], 0, 100, 65535, 0))
244251
self.RGBLED[1].duty_cycle = int(self._map(color[1], 0, 100, 65535, 0))
245252
self.RGBLED[2].duty_cycle = int(self._map(color[2], 0, 100, 65535, 0))
246253

247254
def message(self, text):
248-
"""Write text to display, can include \n for newline"""
255+
"""Write text to display, can include \n for newline
256+
:param text: string to display
257+
"""
249258
line = 0
250259
# iterate thru each char
251260
for char in text:

api.rst

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11

2-
.. If you created a package, create one automodule per module in the package.
2+
`Character_LCD` - for interfacing with character lcds
3+
+++++++++++++++++++++++++++++++++++++++++++++++++++++
34

4-
.. automodule:: adafruit_circuitpython_charlcd
5+
.. automodule:: adafruit_character_lcd.character_lcd
56
:members:
7+
8+
`Character_LCD_RGB` - for interfacing with RGB character lcds
9+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10+
11+
.. automodule:: adafruit_character_lcd.character_lcd_RGB
12+
:members:

0 commit comments

Comments
 (0)