Skip to content
This repository was archived by the owner on Dec 20, 2018. It is now read-only.

Commit 513307d

Browse files
committed
Merge pull request #5 from rodrigodiez/issue_4
Move create_char from Adafruit_CharLCDPlate to Adafruit_CharLCD
2 parents f1d0723 + 848187e commit 513307d

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

Adafruit_CharLCD/Adafruit_CharLCD.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,18 @@ def write8(self, value, char_mode=False):
280280
self._d7: ((value >> 3) & 1) > 0 })
281281
self._pulse_enable()
282282

283+
def create_char(self, location, pattern):
284+
"""Fill one of the first 8 CGRAM locations with custom characters.
285+
The location parameter should be between 0 and 7 and pattern should
286+
provide an array of 8 bytes containing the pattern. E.g. you can easyly
287+
design your custom character at http://www.quinapalus.com/hd44780udg.html
288+
To show your custom character use eg. lcd.message('\x01')
289+
"""
290+
# only position 0..7 are allowed
291+
location &= 0x7
292+
self.write8(LCD_SETCGRAMADDR | (location << 3))
293+
for i in range(8):
294+
self.write8(pattern[i], char_mode=True)
283295

284296
def _delay_microseconds(self, microseconds):
285297
# Busy wait in loop because delays are generally very short (few microseconds).
@@ -404,20 +416,6 @@ def set_backlight(self, backlight):
404416
"""
405417
self.set_color(backlight, backlight, backlight)
406418

407-
def create_char(self, location, pattern):
408-
"""Fill one of the first 8 CGRAM locations with custom characters.
409-
The location parameter should be between 0 and 7 and pattern should
410-
provide an array of 8 bytes containing the pattern. E.g. you can easyly
411-
design your custom character at http://www.quinapalus.com/hd44780udg.html
412-
To show your custom character use eg. lcd.message('\x01')
413-
"""
414-
# only position 0..7 are allowed
415-
location &= 0x7
416-
self.write8(LCD_SETCGRAMADDR | (location << 3))
417-
for i in range(8):
418-
self.write8(pattern[i], char_mode=True)
419-
420-
421419

422420

423421
class Adafruit_CharLCDPlate(Adafruit_RGBCharLCD):

0 commit comments

Comments
 (0)