19.April 2024    
   homeProjekteSoftwareAdafruit_CharLCD: createChar

 

Hobby 234x60
reichelt elektronik – Elektronik und PC-Technik
Seite zuletzt geändert: 09.11.2012 14:38

createChar-Patch für Adafruit_CharLCD.py

Im Python-Code für die Adafruit-LCD-Ansteuerung fehlt aktuell (2012-11-09) das "createChar"-Äquivalent, welches es in der C-Library gibt. Hier wäre der entsprechende Patch dafür:

 

--- Adafruit_CharLCD.py.org     2012-11-07 15:14:45.000000000 +0100
+++ Adafruit_CharLCD.py 2012-11-09 14:16:01.724124462 +0100
@@ -200,6 +200,13 @@
        self.write4bits(self.LCD_ENTRYMODESET | self.displaymode)


+    def createChar(self, location, charmap):
+        location &= 0x7
+        self.write4bits(self.LCD_SETCGRAMADDR | (location << 3), False)
+        for i in range(8):
+            self.write4bits(charmap[i], True)
+
+
     def write4bits(self, bits, char_mode=False):
         """ Send command to LCD """


Hier auch zum Herunterladen

Anwenden des Patches auf die herkömmliche Weise:

  • Kopieren der Datei Adafruit_CharLCD.createChar.diff in das Verzeichnis, in dem sich die Adafruit_CharLCD.py befindet
  • Sichern der Adafruit_CharLCD.py
  • Ausführen von
    patch < Adafruit_CharLCD.createChar.diff

Die Benutzung von createChar erfolgt äquivalent wie bei der C-Library:

 

from Adafruit_CharLCD import Adafruit_CharLCD

char_Auml = [
    0b01010,
    0b01110,
    0b10001,
    0b11111,
    0b10001,
    0b10001,
    0b10001,
    0b00000
]

lcd = Adafruit_CharLCD()
lcd.begin(20,4)
lcd.clear()
lcd.createChar(0,char_Auml)
lcd.message(chr(0))

 

Keine Kommentare
Kommentar hinzufügen

* - Pflichtfeld

*



*
Copyright © 2008-2017