Skip to content

Commit a810e9d

Browse files
committed
Refactor to CircuitPython library conventions.
1 parent 058c626 commit a810e9d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+99
-14976
lines changed

.travis.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Travis CI configuration for automated .mpy file generation.
2+
# Version: 2.0 (support for both .mpy and packages)
3+
# Author: Tony DiCola
4+
# License: Public Domain
5+
# This configuration will work with Travis CI (travis-ci.org) to automacially
6+
# build .mpy files and packages for MicroPython when a new tagged release is
7+
# created. This file is relatively generic and can be shared across multiple
8+
# repositories by following these steps:
9+
# 1. Copy this file into a .travis.yml file in the root of the repository.
10+
# 2. Change the deploy > file section below to list each of the .mpy files or
11+
# package .zip files that should be generated.
12+
# For each .mpy file listed the config will automatically look for .py files
13+
# with the same name as the source for generating the .mpy files. Note that
14+
# the .mpy extension should be lower case!
15+
# For each .zip file listed the config will assume a folder with the same
16+
# name exists (minus the .zip extension) and will recursively walk the folder
17+
# to generate .mpy versions of all .py files EXCEPT __init__.py (not supported
18+
# right now because of a bug). Then a zip of the directory will be generated
19+
# with just the .mpy and __init__.py files.
20+
# 3. Commit the .travis.yml file and push it to GitHub.
21+
# 4. Go to travis-ci.org and find the repository (it needs to be setup to access
22+
# your github account, and your github account needs access to write to the
23+
# repo). Flip the 'ON' switch on for Travis and the repo, see the Travis
24+
# docs for more details: https://docs.travis-ci.com/user/getting-started/
25+
# 5. Get a GitHub 'personal access token' which has at least 'public_repo' or
26+
# 'repo' scope: https://help.github.com/articles/creating-an-access-token-for-command-line-use/
27+
# Keep this token safe and secure! Anyone with the token will be able to
28+
# access and write to your GitHub repositories. Travis will use the token
29+
# to attach the .mpy files to the release.
30+
# 6. In the Travis CI settings for the repository that was enabled find the
31+
# environment variable editing page: https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings
32+
# Add an environment variable named GITHUB_TOKEN and set it to the value
33+
# of the GitHub personal access token above. Keep 'Display value in build
34+
# log' flipped off.
35+
# 7. That's it! Tag a release and Travis should go to work to add .mpy files
36+
# to the release. It takes about a 2-3 minutes for a worker to spin up,
37+
# build mpy-cross, and add the binaries to the release.
38+
language: generic
39+
40+
sudo: true
41+
42+
deploy:
43+
provider: releases
44+
api_key: $GITHUB_TOKEN
45+
file:
46+
- adafruit_character_lcd.zip
47+
skip_cleanup: true
48+
on:
49+
tags: true
50+
51+
before_install:
52+
- wget https://raw.githubusercontent.com/adafruit/MicroPython_TravisCI_Deploy/master/install_dependencies.sh
53+
- chmod +x install_dependencies.sh
54+
- source install_dependencies.sh
55+
56+
before_deploy:
57+
- wget https://raw.githubusercontent.com/adafruit/MicroPython_TravisCI_Deploy/master/build_release.sh
58+
- chmod +x build_release.sh
59+
- ./build_release.sh

adafruit_character_lcd.mpy

-4.57 KB
Binary file not shown.

adafruit_character_lcd/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from adafruit_character_lcd.character_lcd import Character_LCD
2+
from adafruit_character_lcd.character_lcd_RGB import Character_LCD_RGB
4.47 KB
Binary file not shown.

src/adafruit_character_lcd.py renamed to adafruit_character_lcd/character_lcd.py

+21-21
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@
2525
2626
TODO(description)
2727
28-
* Author(s):
28+
* Author(s):
2929
-Brent Rubell
30-
-Asher Lieber
31-
-Tony DiCola for the original python charLCD library
30+
-Asher Lieber
31+
-Tony DiCola for the original python charLCD library
3232
"""
3333

3434
"""
35-
`adafruit_character_lcd` - character lcd module
35+
`adafruit_character_lcd` - character lcd module
3636
=================================================
3737
module for interfacing with character lcds
38-
"""
39-
import time
38+
"""
39+
import time
4040
import math
4141
import digitalio
4242
from board import *
@@ -82,7 +82,7 @@
8282
# Offset for up to 4 rows.
8383
LCD_ROW_OFFSETS = (0x00, 0x40, 0x14, 0x54)
8484

85-
class cirpyth_char_lcd(object):
85+
class Character_LCD(object):
8686
""" Interfaces with a character LCD
8787
:param rs: The reset data line
8888
:param en: The enable data line
@@ -93,13 +93,13 @@ class cirpyth_char_lcd(object):
9393
:param enable_pwm: The PWM CONTROL, TODO
9494
:param initial_backlight: THE initial backlight status (on/off)
9595
"""
96-
def __init__(self, rs, en, d4, d5, d6, d7, cols, lines,
96+
def __init__(self, rs, en, d4, d5, d6, d7, cols, lines,
9797
backlight = None,
9898
enable_pwm = False,
9999
initial_backlight = 1.0):
100100

101101
self.cols = cols
102-
self.lines = lines
102+
self.lines = lines
103103
# save pin numbers
104104
self.rs = rs
105105
self.en = en
@@ -111,22 +111,22 @@ def __init__(self, rs, en, d4, d5, d6, d7, cols, lines,
111111
self.backlight = backlight
112112
# save backlight state
113113
self.backlight = backlight
114-
self.pwn_enabled = enable_pwm
114+
self.pwn_enabled = enable_pwm
115115
# set all pins as outputs
116116
for pin in(rs, en, d4, d5, d6, d7):
117117
pin.direction = digitalio.Direction.OUTPUT
118-
# Setup backlight
118+
# Setup backlight
119119
if backlight is not None:
120120
self.backlight.direction = digitalio.Direction.OUTPUT
121121
self.backlight.value = 0 # turn backlight on
122-
# initialize the display
122+
# initialize the display
123123
self._write8(0x33)
124124
self._write8(0x32)
125125
# init. display control
126126
self.displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF
127127
# init display function
128128
self.displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_2LINE | LCD_5x8DOTS
129-
# init display mode
129+
# init display mode
130130
self.displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT
131131
# write to display control
132132
self._write8(LCD_DISPLAYCONTROL | self.displaycontrol)
@@ -157,11 +157,11 @@ def show_cursor(self, show):
157157
def set_cursor(self, col, row):
158158
"""Sets the cursor to ``row`` and ``col``
159159
:param col: column location
160-
:param row: row location
160+
:param row: row location
161161
"""
162162
# Clamp row to the last row of the display
163163
if row > self.lines:
164-
row = self.lines - 1
164+
row = self.lines - 1
165165
# Set location
166166
self._write8(LCD_SETDDRAMADDR | (col + LCD_ROW_OFFSETS[row]))
167167

@@ -180,7 +180,7 @@ def move_left(self):
180180
def move_right(self):
181181
"""Moves display right one position"""
182182
self._write8(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT)
183-
183+
184184
def set_left_to_right(self):
185185
"""Set direction of text to read from left to right"""
186186
self.displaymode |= LCD_ENTRYLEFT
@@ -202,7 +202,7 @@ def enable_display(self, enable):
202202
def _write8(self,value, char_mode = False):
203203
"""Sends 8b ``value`` in ``char_mode``.
204204
:param value: bytes
205-
:param char_mode: character/data mode selector. False (default) for
205+
:param char_mode: character/data mode selector. False (default) for
206206
data only, True for character bits.
207207
"""
208208
# one ms delay to prevent writing too quickly.
@@ -216,7 +216,7 @@ def _write8(self,value, char_mode = False):
216216
self.d7.value = ((value >> 7) & 1) > 0
217217
# send command
218218
self._pulse_enable()
219-
# WRITE lower 4 bits
219+
# WRITE lower 4 bits
220220
self.d4.value = (value & 1) > 0
221221
self.d5.value = ((value >> 1) & 1) > 0
222222
self.d6.value = ((value >> 2) & 1) > 0
@@ -225,7 +225,7 @@ def _write8(self,value, char_mode = False):
225225

226226
def _pulse_enable(self):
227227
""" Pulses (lo->hi->lo) to send commands. """
228-
self.en.value = False
228+
self.en.value = False
229229
# 1microsec pause
230230
time.sleep(0.0000001)
231231
self.en.value = True
@@ -240,7 +240,7 @@ def set_backlight(self, lighton):
240240
else:
241241
self.backlight.value = 1
242242

243-
243+
244244
def message(self, text):
245245
"""Write text to display, can include \n for newline"""
246246
line = 0
@@ -252,7 +252,7 @@ def message(self, text):
252252
# move to left/right depending on text direction
253253
col = 0 if self.displaymode & LCD_ENTRYLEFT > 0 else self.cols-1
254254
self.set_cursor(col, line)
255-
# Write character to display
255+
# Write character to display
256256
else:
257257
self._write8(ord(char), True)
258258

src/adafruit_character_lcd_RGB.py renamed to adafruit_character_lcd/character_lcd_RGB.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
# Offset for up to 4 rows.
8585
LCD_ROW_OFFSETS = (0x00, 0x40, 0x14, 0x54)
8686

87-
class cirpyth_char_lcd_RGB(object):
87+
class Character_LCD_RGB(object):
8888
""" Interfaces with a character LCD
8989
:param ~microcontroller.Pin rs: The reset data line
9090
:param ~microcontroller.Pin en: The enable data line
3.65 KB
Binary file not shown.

adafruit_character_lcd_RGB.mpy

-4.32 KB
Binary file not shown.

docs/Makefile

-20
This file was deleted.
-4.13 KB
Binary file not shown.

docs/_build/doctrees/index.doctree

-5.33 KB
Binary file not shown.

docs/_build/html/.buildinfo

-4
This file was deleted.

docs/_build/html/_sources/index.rst.txt

-20
This file was deleted.
-673 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)