rpi gpio
This commit is contained in:
parent
67e617eb61
commit
cef54ac444
788
charlcd.patch
788
charlcd.patch
@ -1,654 +1,3 @@
|
||||
diff --git a/charlcd/demos/lcd_buffered.py b/charlcd/demos/lcd_buffered.py
|
||||
deleted file mode 100644
|
||||
index 9d1cb27..0000000
|
||||
--- a/charlcd/demos/lcd_buffered.py
|
||||
+++ /dev/null
|
||||
@@ -1,144 +0,0 @@
|
||||
-#!/usr/bin/python
|
||||
-# -*- coding: utf-8 -*-
|
||||
-"""test script for buffered lcd"""
|
||||
-
|
||||
-import sys
|
||||
-sys.path.append("../../")
|
||||
-import RPi.GPIO as GPIO # NOQA pylint: disable=I0011,F0401
|
||||
-from charlcd import buffered as lcd # NOQA
|
||||
-from charlcd.drivers.gpio import Gpio # NOQA
|
||||
-from charlcd.drivers.i2c import I2C # NOQA
|
||||
-
|
||||
-GPIO.setmode(GPIO.BCM)
|
||||
-
|
||||
-
|
||||
-def test1():
|
||||
- """demo 20x4 and 16x2"""
|
||||
- lcd_2 = lcd.CharLCD(20, 4, Gpio())
|
||||
- lcd_2.init()
|
||||
- lcd_2.write('- Blarg !')
|
||||
- lcd_2.write('- Grarg !', 0, 1)
|
||||
- lcd_2.write('- ALIVE !!!!', 0, 2)
|
||||
-
|
||||
- lcd_2.flush()
|
||||
-
|
||||
- lcd_2.write('- ALIVE !!!!.', 0, 2)
|
||||
- lcd_2.flush()
|
||||
-
|
||||
- # lcd_1 = lcd.CharLCD(16, 2, I2C(0x20, 1), 0, 0)
|
||||
- # lcd_1.init()
|
||||
- # lcd_1.write('-!Second blarg!')
|
||||
- # lcd_1.write("-second line", 0, 1)
|
||||
- # lcd_1.flush()
|
||||
-
|
||||
-
|
||||
-def test2():
|
||||
- """demo 40x4"""
|
||||
- drv = Gpio()
|
||||
- drv.pins['E2'] = 10
|
||||
- drv.pins['E'] = 24
|
||||
- lcd_1 = lcd.CharLCD(40, 4, drv, 0, 0)
|
||||
- lcd_1.init()
|
||||
- lcd_1.write('- Blarg !')
|
||||
- lcd_1.write('- Grarg !', 0, 1)
|
||||
- lcd_1.write('- ALIVE !!!!', 0, 2)
|
||||
- lcd_1.flush()
|
||||
-
|
||||
- lcd_1.write('/* ', 19, 0)
|
||||
- lcd_1.write('|*|', 19, 1)
|
||||
- lcd_1.write(' */', 19, 2)
|
||||
-
|
||||
- lcd_1.flush()
|
||||
-
|
||||
-
|
||||
-def test3():
|
||||
- """demo 16x2"""
|
||||
- lcd_1 = lcd.CharLCD(16, 2, I2C(0x20, 1), 0, 0)
|
||||
- lcd_1.init()
|
||||
- lcd_1.set_xy(10, 0)
|
||||
- lcd_1.stream("1234567890qwertyuiopasdfghjkl")
|
||||
- lcd_1.flush()
|
||||
-
|
||||
-
|
||||
-def test4():
|
||||
- """demo 2 screens via i2c"""
|
||||
- i2c_20x4 = I2C(0x3b, 1)
|
||||
- #i2c_16x2 = I2C(0x25, 1)
|
||||
-
|
||||
- i2c_20x4.pins = {
|
||||
- 'RS': 6,
|
||||
- 'E': 4,
|
||||
- 'E2': None,
|
||||
- 'DB4': 0,
|
||||
- 'DB5': 1,
|
||||
- 'DB6': 2,
|
||||
- 'DB7': 3
|
||||
- }
|
||||
- # i2c_16x2.pins = {
|
||||
- # 'RS': 6,
|
||||
- # 'E': 4,
|
||||
- # 'E2': None,
|
||||
- # 'DB4': 0,
|
||||
- # 'DB5': 1,
|
||||
- # 'DB6': 2,
|
||||
- # 'DB7': 3
|
||||
- # }
|
||||
- lcd_1 = lcd.CharLCD(20, 4, i2c_20x4)
|
||||
- lcd_1.init()
|
||||
- lcd_1.set_xy(0, 0)
|
||||
- lcd_1.stream("Kab00m")
|
||||
- lcd_1.flush()
|
||||
-
|
||||
- lcd_1.write('siemka', 10, 3)
|
||||
- lcd_1.flush(True)
|
||||
- lcd_1.shutdown()
|
||||
- # lcd_2 = lcd.CharLCD(16, 2, i2c_16x2)
|
||||
- # lcd_2.init()
|
||||
- # lcd_2.set_xy(0, 0)
|
||||
- # lcd_2.stream("1")
|
||||
- # lcd_2.flush()
|
||||
-
|
||||
-
|
||||
-def test5():
|
||||
- """demo 2 screens via i2c"""
|
||||
- i2c_20x4 = I2C(0x3b, 1)
|
||||
- #i2c_16x2 = I2C(0x25, 1)
|
||||
-
|
||||
- i2c_20x4.pins = {
|
||||
- 'RS': 6,
|
||||
- 'E': 4,
|
||||
- 'E2': None,
|
||||
- 'DB4': 0,
|
||||
- 'DB5': 1,
|
||||
- 'DB6': 2,
|
||||
- 'DB7': 3
|
||||
- }
|
||||
-
|
||||
- lcd_1 = lcd.CharLCD(20, 4, i2c_20x4)
|
||||
- lcd_1.init()
|
||||
- lcd_1.add_custom_char(0, [
|
||||
- 0x04, 0x0e, 0x0e, 0x0e, 0x0e, 0x1f, 0x04, 0x04
|
||||
- ])
|
||||
- lcd_1.add_custom_char(1, [
|
||||
- 0b00011, 0b00100, 0b11110, 0b01000, 0b11110, 0b01000, 0b00111
|
||||
- ])
|
||||
- lcd_1.add_custom_char(2, [
|
||||
- 0b00000,
|
||||
- 0b00000,
|
||||
- 0b00000,
|
||||
- 0b01010,
|
||||
- 0b00000,
|
||||
- 0b00100,
|
||||
- 0b10001,
|
||||
- 0b01110
|
||||
- ])
|
||||
- lcd_1.set_xy(0, 0)
|
||||
- lcd_1.stream("Kab00m")
|
||||
- lcd_1.stream(chr(0x00))
|
||||
- lcd_1.stream(chr(0x01))
|
||||
- lcd_1.write(chr(0x02), 9, 2)
|
||||
- lcd_1.flush()
|
||||
- # lcd_1.shutdown()
|
||||
-
|
||||
-
|
||||
-test5()
|
||||
\ No newline at end of file
|
||||
diff --git a/charlcd/demos/lcd_direct.py b/charlcd/demos/lcd_direct.py
|
||||
deleted file mode 100644
|
||||
index ff92c34..0000000
|
||||
--- a/charlcd/demos/lcd_direct.py
|
||||
+++ /dev/null
|
||||
@@ -1,95 +0,0 @@
|
||||
-#!/usr/bin/python
|
||||
-# -*- coding: utf-8 -*-
|
||||
-"""test script for direct lcd input"""
|
||||
-import sys
|
||||
-sys.path.append("../../")
|
||||
-import RPi.GPIO as GPIO # NOQA pylint: disable=I0011,F0401
|
||||
-from charlcd.drivers.gpio import Gpio # NOQA
|
||||
-from charlcd import direct as lcd # NOQA
|
||||
-from charlcd.drivers.i2c import I2C # NOQA pylint: disable=I0011,F0401
|
||||
-
|
||||
-GPIO.setmode(GPIO.BCM)
|
||||
-
|
||||
-
|
||||
-def test1():
|
||||
- """demo 16x2 by i2c and 20x4 by gpio"""
|
||||
- lcd_1 = lcd.CharLCD(16, 2, I2C(0x20, 1))
|
||||
- lcd_1.init()
|
||||
- lcd_1.write('-Second blarg !')
|
||||
- lcd_1.set_xy(0, 1)
|
||||
- lcd_1.write("-second line")
|
||||
-
|
||||
- lcd_2 = lcd.CharLCD(20, 4, Gpio())
|
||||
- lcd_2.init()
|
||||
- lcd_2.write('- Blarg !')
|
||||
- lcd_2.write('- Grarg !', 0, 1)
|
||||
- lcd_2.set_xy(0, 2)
|
||||
- lcd_2.write('- ALIVE !!!!')
|
||||
-
|
||||
-
|
||||
-def test2():
|
||||
- """demo - 20x4 by gpio"""
|
||||
- lcd_2 = lcd.CharLCD(20, 4, Gpio())
|
||||
- lcd_2.init()
|
||||
- lcd_2.write('- Blarg !')
|
||||
- lcd_2.write('- Grarg !', 0, 1)
|
||||
- lcd_2.set_xy(0, 2)
|
||||
- lcd_2.write('- ALIVE !!!!')
|
||||
- lcd_2.stream('1234567890qwertyuiopasdfghjkl')
|
||||
-
|
||||
-
|
||||
-def test3():
|
||||
- """demo 3 - lcd 40x4 by gpio"""
|
||||
- drv = I2C(0x3a, 1)
|
||||
- drv.pins['E2'] = 6
|
||||
- lcd_1 = lcd.CharLCD(40, 4, drv, 0, 0)
|
||||
- lcd_1.init()
|
||||
- lcd_1.write('-First blarg1 !')
|
||||
- lcd_1.write('-Second blarg2 !', 0, 1)
|
||||
- lcd_1.write('-Third blarg3 !', 0, 2)
|
||||
- lcd_1.write('-Fourth blarg4 !', 0, 3)
|
||||
- lcd_1.write('12345678901234567890', 15, 1)
|
||||
- lcd_1.stream('1234567890qwertyuiopasdfghjkl')
|
||||
-
|
||||
-
|
||||
-def test4():
|
||||
- """demo 4 - lcd 40x4 by i2c"""
|
||||
- drv = I2C(0x3a, 1)
|
||||
- drv.pins['E2'] = 6
|
||||
- lcd_1 = lcd.CharLCD(40, 4, drv, 0, 0)
|
||||
- lcd_1.init()
|
||||
- lcd_1.write('-First blarg1 !')
|
||||
- lcd_1.write('-Second blarg2 !', 0, 1)
|
||||
- lcd_1.write('-Third blarg3 !', 0, 2)
|
||||
- lcd_1.write('-Fourth blarg4 !', 0, 3)
|
||||
-
|
||||
-
|
||||
-def test5():
|
||||
- """demo 2 screens via i2c"""
|
||||
- i2c_20x4 = I2C(0x3b, 1)
|
||||
- i2c_20x4.pins = {
|
||||
- 'RS': 6,
|
||||
- 'E': 4,
|
||||
- 'E2': None,
|
||||
- 'DB4': 0,
|
||||
- 'DB5': 1,
|
||||
- 'DB6': 2,
|
||||
- 'DB7': 3
|
||||
- }
|
||||
-
|
||||
- lcd_1 = lcd.CharLCD(20, 4, i2c_20x4)
|
||||
- lcd_1.init()
|
||||
- # lcd_1.set_xy(0, 0)
|
||||
- lcd_1.add_custom_char(0, [
|
||||
- 0x04, 0x0e, 0x0e, 0x0e, 0x0e, 0x1f, 0x04, 0x04
|
||||
- ])
|
||||
- lcd_1.add_custom_char(1, [
|
||||
- 0b00011, 0b00100, 0b11110, 0b01000, 0b11110, 0b01000, 0b00111
|
||||
- ])
|
||||
-
|
||||
- lcd_1.stream("Kab00mek")
|
||||
- lcd_1.stream(chr(0x01))
|
||||
- lcd_1.stream(chr(0x00))
|
||||
-
|
||||
-
|
||||
-test5()
|
||||
diff --git a/charlcd/demos/lcd_handler.py b/charlcd/demos/lcd_handler.py
|
||||
deleted file mode 100644
|
||||
index da92700..0000000
|
||||
--- a/charlcd/demos/lcd_handler.py
|
||||
+++ /dev/null
|
||||
@@ -1,52 +0,0 @@
|
||||
-#!/usr/bin/python
|
||||
-# -*- coding: utf-8 -*-
|
||||
-"""Test script for virtual buffered lcd"""
|
||||
-import sys
|
||||
-sys.path.append("../../")
|
||||
-import RPi.GPIO as GPIO # NOQA pylint: disable=I0011,F0401
|
||||
-from charlcd import buffered as lcd # NOQA
|
||||
-from charlcd.drivers.i2c import I2C # NOQA
|
||||
-from charlcd.handler import Handler # NOQA
|
||||
-
|
||||
-GPIO.setmode(GPIO.BCM)
|
||||
-
|
||||
-
|
||||
-def demo1():
|
||||
- """demo: send message to handler"""
|
||||
- i2c_20x4 = I2C(0x3b, 1)
|
||||
- i2c_20x4.pins = {
|
||||
- 'RS': 6,
|
||||
- 'E': 4,
|
||||
- 'E2': None,
|
||||
- 'DB4': 0,
|
||||
- 'DB5': 1,
|
||||
- 'DB6': 2,
|
||||
- 'DB7': 3
|
||||
- }
|
||||
-
|
||||
- lcd_1 = lcd.CharLCD(20, 4, i2c_20x4)
|
||||
- lcd_1.init()
|
||||
-
|
||||
- message = {
|
||||
- 'protocol': 'iot:1',
|
||||
- 'node': 'computer',
|
||||
- 'chip_id': 'd45656b45afb58b1f0a46',
|
||||
- 'event': 'lcd.content',
|
||||
- 'parameters': {
|
||||
- 'content': [
|
||||
- '12345678901234567890',
|
||||
- 'abcdefghijklmnopqrst',
|
||||
- '12345678901234567890',
|
||||
- 'abcdefghijklmnopqrst',
|
||||
- ]
|
||||
- },
|
||||
- 'targets': [
|
||||
- 'ALL'
|
||||
- ]
|
||||
- }
|
||||
-
|
||||
- handler = Handler(lcd_1)
|
||||
- handler.handle(message)
|
||||
-
|
||||
-
|
||||
-demo1()
|
||||
diff --git a/charlcd/demos/lcd_virtual_buffered.py b/charlcd/demos/lcd_virtual_buffered.py
|
||||
deleted file mode 100644
|
||||
index 6ef33ed..0000000
|
||||
--- a/charlcd/demos/lcd_virtual_buffered.py
|
||||
+++ /dev/null
|
||||
@@ -1,164 +0,0 @@
|
||||
-#!/usr/bin/python
|
||||
-# -*- coding: utf-8 -*-
|
||||
-"""Test script for virtual buffered lcd"""
|
||||
-import sys
|
||||
-sys.path.append("../../")
|
||||
-import RPi.GPIO as GPIO # NOQA pylint: disable=I0011,F0401
|
||||
-from charlcd import buffered as lcd # NOQA
|
||||
-from charlcd.drivers.gpio import Gpio # NOQA
|
||||
-from charlcd.drivers.i2c import I2C # NOQA pylint: disable=I0011,F0401
|
||||
-from charlcd import virtual_buffered as vlcd # NOQA
|
||||
-
|
||||
-GPIO.setmode(GPIO.BCM)
|
||||
-
|
||||
-
|
||||
-def test1():
|
||||
- """demo: 16x2 + 20x4 = 20x6"""
|
||||
- lcd_1 = lcd.CharLCD(16, 2, I2C(0x20, 1))
|
||||
- lcd_2 = lcd.CharLCD(20, 4, Gpio(), 0, 0)
|
||||
-
|
||||
- vlcd_1 = vlcd.CharLCD(20, 6)
|
||||
- vlcd_1.add_display(0, 0, lcd_2)
|
||||
- vlcd_1.add_display(0, 4, lcd_1)
|
||||
- vlcd_1.init()
|
||||
-
|
||||
- vlcd_1.write('First line')
|
||||
- vlcd_1.write('Second line', 0, 1)
|
||||
- vlcd_1.write('Fifth Line', 0, 4)
|
||||
-
|
||||
- vlcd_1.set_xy(4, 2)
|
||||
- vlcd_1.write('third line')
|
||||
-
|
||||
- vlcd_1.flush()
|
||||
-
|
||||
-
|
||||
-def test2():
|
||||
- """demo: 16x2 + 20x4 = 36x4"""
|
||||
- lcd_1 = lcd.CharLCD(16, 2, I2C(0x20, 1))
|
||||
- lcd_2 = lcd.CharLCD(20, 4, Gpio(), 0, 0)
|
||||
-
|
||||
- vlcd_1 = vlcd.CharLCD(36, 4)
|
||||
-
|
||||
- vlcd_1.add_display(0, 0, lcd_2)
|
||||
- vlcd_1.add_display(20, 0, lcd_1)
|
||||
- vlcd_1.init()
|
||||
- vlcd_1.write('test me 123456789qwertyuiopasdfghjkl12')
|
||||
- vlcd_1.flush()
|
||||
-
|
||||
-
|
||||
-def test3():
|
||||
- """demo: 16x2 + 20x4 = 16x6"""
|
||||
- lcd_1 = lcd.CharLCD(16, 2, I2C(0x20, 1))
|
||||
- lcd_2 = lcd.CharLCD(20, 4, Gpio(), 0, 0)
|
||||
-
|
||||
- vlcd_1 = vlcd.CharLCD(16, 6)
|
||||
- vlcd_1.add_display(0, 0, lcd_2, 4, 0)
|
||||
- vlcd_1.add_display(0, 4, lcd_1)
|
||||
- vlcd_1.init()
|
||||
-
|
||||
- vlcd_1.write('1234567890123456')
|
||||
- vlcd_1.set_xy(0, 1)
|
||||
- vlcd_1.write('2')
|
||||
- vlcd_1.write('3', 0, 2)
|
||||
- vlcd_1.write('4', 0, 3)
|
||||
- vlcd_1.write('5', 0, 4)
|
||||
- vlcd_1.write('6', 0, 5)
|
||||
-
|
||||
- vlcd_1.flush()
|
||||
-
|
||||
-
|
||||
-def test4():
|
||||
- """demo: 16x2 + 20x4 = 10x2"""
|
||||
- lcd_1 = lcd.CharLCD(16, 2, I2C(0x20, 1))
|
||||
- lcd_2 = lcd.CharLCD(20, 4, Gpio(), 0, 0)
|
||||
-
|
||||
- vlcd_1 = vlcd.CharLCD(10, 2)
|
||||
- vlcd_1.add_display(0, 0, lcd_1, 11)
|
||||
- vlcd_1.add_display(5, 0, lcd_2)
|
||||
- vlcd_1.init()
|
||||
-
|
||||
- vlcd_1.write('1234567890123456')
|
||||
- vlcd_1.write('-', 0, 0)
|
||||
- vlcd_1.write('/', 0, 1)
|
||||
- vlcd_1.write('*', 9, 1)
|
||||
- vlcd_1.write('#', 9, 0)
|
||||
- vlcd_1.write('!', 5, 1)
|
||||
- vlcd_1.write('+', 4, 1)
|
||||
-
|
||||
- vlcd_1.flush()
|
||||
-
|
||||
-
|
||||
-def test5():
|
||||
- """demo: 16x2 + 20x4 = 10x2 and 8x2"""
|
||||
- lcd_1 = lcd.CharLCD(16, 2, I2C(0x20, 1))
|
||||
- lcd_2 = lcd.CharLCD(20, 4, Gpio(), 0, 0)
|
||||
-
|
||||
- vlcd_1 = vlcd.CharLCD(10, 2)
|
||||
- vlcd_1.add_display(0, 0, lcd_1, 11)
|
||||
- vlcd_1.add_display(5, 0, lcd_2)
|
||||
- vlcd_1.init()
|
||||
-
|
||||
- vlcd_2 = vlcd.CharLCD(8, 2)
|
||||
- vlcd_2.add_display(0, 0, lcd_1)
|
||||
- vlcd_2.init()
|
||||
-
|
||||
- vlcd_1.write('1234567890123456')
|
||||
- vlcd_1.write('-', 0, 0)
|
||||
- vlcd_1.write('/', 0, 1)
|
||||
- vlcd_1.write('*', 9, 1)
|
||||
- vlcd_1.write('#', 9, 0)
|
||||
- vlcd_1.write('!', 5, 1)
|
||||
- vlcd_1.write('+', 4, 1)
|
||||
-
|
||||
- vlcd_2.write("1", 0, 0)
|
||||
- vlcd_2.write("2", 0, 1)
|
||||
- vlcd_2.write("3", 7, 0)
|
||||
- vlcd_2.write("4", 7, 1)
|
||||
-
|
||||
- vlcd_1.flush()
|
||||
- vlcd_2.flush()
|
||||
-
|
||||
-
|
||||
-def test6():
|
||||
- """demo: 40x4 = 20x4 + 20x4"""
|
||||
- drv = I2C(0x3a, 1)
|
||||
- drv.pins['E2'] = 6
|
||||
- lcd_1 = lcd.CharLCD(40, 4, drv, 0, 0)
|
||||
- vlcd_1 = vlcd.CharLCD(20, 4)
|
||||
- vlcd_1.add_display(0, 0, lcd_1)
|
||||
-
|
||||
- vlcd_2 = vlcd.CharLCD(20, 4)
|
||||
- vlcd_2.add_display(0, 0, lcd_1, 20)
|
||||
-
|
||||
- vlcd_1.init()
|
||||
- vlcd_2.init()
|
||||
-
|
||||
- vlcd_1.write('-First blarg1 !')
|
||||
- vlcd_1.write('-Second blarg2 !', 0, 1)
|
||||
- vlcd_1.write('-Third blarg3 !', 0, 2)
|
||||
- vlcd_1.write('-Fourth blarg4 !', 0, 3)
|
||||
-
|
||||
- vlcd_1.flush()
|
||||
-
|
||||
- vlcd_2.write('-First blarg1 !')
|
||||
- vlcd_2.write('-Second blarg2 !', 0, 1)
|
||||
- vlcd_2.write('-Third blarg3 !', 0, 2)
|
||||
- vlcd_2.write('-Fourth blarg4 !', 0, 3)
|
||||
-
|
||||
- vlcd_2.flush()
|
||||
-
|
||||
-
|
||||
-def test7():
|
||||
- """demo: 16x2 + 20x4 = 10x2"""
|
||||
- lcd_1 = lcd.CharLCD(16, 2, I2C(0x20, 1))
|
||||
-
|
||||
- vlcd_1 = vlcd.CharLCD(5, 2)
|
||||
- vlcd_1.add_display(0, 0, lcd_1, 11)
|
||||
- vlcd_1.init()
|
||||
-
|
||||
- vlcd_1.stream('1234567890qwertyui')
|
||||
-
|
||||
- vlcd_1.flush()
|
||||
-
|
||||
-
|
||||
-test7()
|
||||
diff --git a/charlcd/demos/lcd_virtual_direct.py b/charlcd/demos/lcd_virtual_direct.py
|
||||
deleted file mode 100644
|
||||
index 5541d63..0000000
|
||||
--- a/charlcd/demos/lcd_virtual_direct.py
|
||||
+++ /dev/null
|
||||
@@ -1,165 +0,0 @@
|
||||
-#!/usr/bin/python
|
||||
-# -*- coding: utf-8 -*-
|
||||
-"""test script for virtual direct lcd"""
|
||||
-import sys
|
||||
-sys.path.append("../../")
|
||||
-import RPi.GPIO as GPIO # NOQA pylint: disable=I0011,F0401
|
||||
-from charlcd import direct as lcd # NOQA
|
||||
-from charlcd.drivers.gpio import Gpio # NOQA
|
||||
-from charlcd.drivers.i2c import I2C # NOQA pylint: disable=I0011,F0401
|
||||
-from charlcd import virtual_direct as vlcd # NOQA
|
||||
-
|
||||
-GPIO.setmode(GPIO.BCM)
|
||||
-
|
||||
-
|
||||
-def test1():
|
||||
- """demo: 16x2 + 20x4 = 20x6 top, down"""
|
||||
- lcd_1 = lcd.CharLCD(16, 2, I2C(0x20, 1))
|
||||
- lcd_2 = lcd.CharLCD(20, 4, Gpio(), 0, 0)
|
||||
- lcd_1.init()
|
||||
- lcd_2.init()
|
||||
-
|
||||
- vlcd_1 = vlcd.CharLCD(20, 6)
|
||||
- vlcd_1.add_display(0, 0, lcd_2)
|
||||
- vlcd_1.add_display(2, 4, lcd_1)
|
||||
-
|
||||
- vlcd_1.write('test me 123456789qwertyuiop')
|
||||
-
|
||||
- vlcd_1.set_xy(2, 0)
|
||||
- vlcd_1.write('1')
|
||||
- vlcd_1.write('2', 2, 1)
|
||||
- vlcd_1.write('3', 2, 2)
|
||||
- vlcd_1.set_xy(2, 3)
|
||||
- vlcd_1.write('4')
|
||||
- vlcd_1.write('5', 2, 4)
|
||||
- vlcd_1.write('6', 2, 5)
|
||||
-
|
||||
- vlcd_1.set_xy(3, 4)
|
||||
- vlcd_1.write('-Second blarg !')
|
||||
- vlcd_1.set_xy(4, 5)
|
||||
- vlcd_1.write("-second line")
|
||||
-
|
||||
- vlcd_1.set_xy(11, 3)
|
||||
- vlcd_1.stream("two liner and screener")
|
||||
-
|
||||
-
|
||||
-def test2():
|
||||
- """demo: 16x2 + 20x4 = 36x4 left, right"""
|
||||
- lcd_1 = lcd.CharLCD(16, 2, I2C(0x20, 1))
|
||||
- lcd_2 = lcd.CharLCD(20, 4, Gpio(), 0, 0)
|
||||
- lcd_1.init()
|
||||
- lcd_2.init()
|
||||
- vlcd_1 = vlcd.CharLCD(36, 4)
|
||||
- vlcd_1.add_display(0, 0, lcd_2)
|
||||
- vlcd_1.add_display(20, 0, lcd_1)
|
||||
- vlcd_1.write('test me 123456789qwertyuiopasdfghjkl12')
|
||||
-
|
||||
-
|
||||
-def test3():
|
||||
- """demo: 16x2 + 20x4 = 16x6 (offset)"""
|
||||
- lcd_1 = lcd.CharLCD(16, 2, I2C(0x20, 1))
|
||||
- lcd_2 = lcd.CharLCD(20, 4, Gpio(), 0, 0)
|
||||
- lcd_1.init()
|
||||
- lcd_2.init()
|
||||
-
|
||||
- vlcd_1 = vlcd.CharLCD(16, 6)
|
||||
- vlcd_1.add_display(0, 0, lcd_2, 4, 0)
|
||||
- vlcd_1.add_display(0, 4, lcd_1)
|
||||
-
|
||||
- vlcd_1.set_xy(0, 0)
|
||||
- vlcd_1.write('1234567890123456')
|
||||
- vlcd_1.set_xy(0, 1)
|
||||
- vlcd_1.write('2')
|
||||
- vlcd_1.set_xy(0, 2)
|
||||
- vlcd_1.write('3')
|
||||
- vlcd_1.set_xy(0, 3)
|
||||
- vlcd_1.write('4')
|
||||
- vlcd_1.set_xy(0, 4)
|
||||
- vlcd_1.write('5')
|
||||
- vlcd_1.write('6', 0, 5)
|
||||
-
|
||||
-
|
||||
-def test4():
|
||||
- """demo: 16x2 + 20x4 = 10x2 - offset left right """
|
||||
- lcd_1 = lcd.CharLCD(16, 2, I2C(0x20, 1))
|
||||
- lcd_2 = lcd.CharLCD(20, 4, Gpio(), 0, 0)
|
||||
- lcd_1.init()
|
||||
- lcd_2.init()
|
||||
-
|
||||
- vlcd_1 = vlcd.CharLCD(10, 2)
|
||||
- vlcd_1.add_display(0, 0, lcd_1, 11)
|
||||
- vlcd_1.add_display(5, 0, lcd_2)
|
||||
-
|
||||
- vlcd_1.write('1234567890123456')
|
||||
- vlcd_1.write('/', 0, 1)
|
||||
- vlcd_1.write('*', 9, 1)
|
||||
- vlcd_1.write('-', 0, 0)
|
||||
- vlcd_1.write('#', 9, 0)
|
||||
-
|
||||
- vlcd_1.set_xy(5, 1)
|
||||
- vlcd_1.write('!')
|
||||
-
|
||||
- vlcd_1.set_xy(4, 1)
|
||||
- vlcd_1.write('+')
|
||||
-
|
||||
-
|
||||
-def test5():
|
||||
- """demo: 16x2 + 20x4 = 10x2 + 8x2 - offset left right """
|
||||
- lcd_1 = lcd.CharLCD(16, 2, I2C(0x20, 1))
|
||||
- lcd_2 = lcd.CharLCD(20, 4, Gpio(), 0, 0)
|
||||
-
|
||||
- vlcd_1 = vlcd.CharLCD(10, 2)
|
||||
- vlcd_1.add_display(0, 0, lcd_1, 11)
|
||||
- vlcd_1.add_display(5, 0, lcd_2)
|
||||
- vlcd_1.init()
|
||||
-
|
||||
- vlcd_2 = vlcd.CharLCD(8, 2)
|
||||
- vlcd_2.add_display(0, 0, lcd_1)
|
||||
- vlcd_2.init()
|
||||
-
|
||||
- vlcd_1.write('1234567890123456')
|
||||
-
|
||||
- vlcd_1.write('/', 0, 1)
|
||||
- vlcd_1.set_xy(9, 1)
|
||||
- vlcd_1.write('*')
|
||||
- vlcd_1.write('-', 0, 0)
|
||||
- vlcd_1.set_xy(9, 0)
|
||||
- vlcd_1.write('#')
|
||||
- vlcd_1.write('!', 5, 1)
|
||||
- vlcd_1.write('+', 4, 1)
|
||||
-
|
||||
- vlcd_2.set_xy(0, 0)
|
||||
- vlcd_2.write('#')
|
||||
- vlcd_2.write('#', 7, 0)
|
||||
- vlcd_2.write('#', 7, 1)
|
||||
- vlcd_2.write('#', 0, 1)
|
||||
-
|
||||
-
|
||||
-def test6():
|
||||
- """demo: 40x4 = 20x4 + 20x4"""
|
||||
- drv = I2C(0x3a, 1)
|
||||
- drv.pins['E2'] = 6
|
||||
- lcd_1 = lcd.CharLCD(40, 4, drv, 0, 0)
|
||||
- vlcd_1 = vlcd.CharLCD(20, 4)
|
||||
- vlcd_1.add_display(0, 0, lcd_1)
|
||||
-
|
||||
- vlcd_2 = vlcd.CharLCD(20, 4)
|
||||
- vlcd_2.add_display(0, 0, lcd_1, 20)
|
||||
-
|
||||
- vlcd_1.init()
|
||||
- vlcd_2.init()
|
||||
-
|
||||
- vlcd_1.write('-First blarg1 !')
|
||||
- vlcd_1.write('-Second blarg2 !', 0, 1)
|
||||
- vlcd_1.write('-Third blarg3 !', 0, 2)
|
||||
- vlcd_1.write('-Fourth blarg4 !', 0, 3)
|
||||
-
|
||||
- vlcd_2.write('-First blarg1 !')
|
||||
- vlcd_2.write('-Second blarg2 !', 0, 1)
|
||||
- vlcd_2.write('-Third blarg3 !', 0, 2)
|
||||
- vlcd_2.write('-Fourth blarg4 !', 0, 3)
|
||||
- vlcd_1.set_xy(15, 2)
|
||||
- vlcd_1.stream('1234567890qwertyuiopasdfghjkl')
|
||||
-
|
||||
-
|
||||
-test6()
|
||||
diff --git a/charlcd/demos/lcd_wifi_content.py b/charlcd/demos/lcd_wifi_content.py
|
||||
deleted file mode 100644
|
||||
index e27d2ed..0000000
|
||||
@ -736,140 +85,3 @@ index 9382d54..0000000
|
||||
-
|
||||
-
|
||||
-test3()
|
||||
diff --git a/charlcd/drivers/gpio.py b/charlcd/drivers/gpio.py
|
||||
deleted file mode 100644
|
||||
index 08e4337..0000000
|
||||
--- a/charlcd/drivers/gpio.py
|
||||
+++ /dev/null
|
||||
@@ -1,131 +0,0 @@
|
||||
-#!/usr/bin/python
|
||||
-# -*- coding: utf-8 -*-
|
||||
-# pylint: disable=I0011,W0231
|
||||
-"""Driver for lcd. Uses GPIO outputs
|
||||
-Examples:
|
||||
-l = lcd.CharLCD(20, 4, Gpio())
|
||||
-
|
||||
-g = Gpio()
|
||||
-g.pins = {
|
||||
- 'RS': 24,
|
||||
- 'E': 17,
|
||||
- 'E2': None,
|
||||
- 'DB4': 27,
|
||||
- 'DB5': 25,
|
||||
- 'DB6': 23,
|
||||
- 'DB7': 22
|
||||
-}
|
||||
-l = lcd.CharLCD(20, 4, g)
|
||||
-"""
|
||||
-
|
||||
-import time
|
||||
-import RPi.GPIO as GPIO # pylint: disable=I0011,F0401
|
||||
-from charlcd.drivers.base import BaseDriver
|
||||
-
|
||||
-
|
||||
-class Gpio(BaseDriver):
|
||||
- """Gpio LCD driver"""
|
||||
- def __init__(self):
|
||||
- """pins in 4bit mode"""
|
||||
- self.pins = {
|
||||
- 'RS': 25, # 0 ->instruction, 1->data
|
||||
- 'E': 24,
|
||||
- 'E2': None,
|
||||
- 'DB4': 22,
|
||||
- 'DB5': 23,
|
||||
- 'DB6': 27,
|
||||
- 'DB7': 17
|
||||
- }
|
||||
- self.data_pins = [
|
||||
- 'DB4',
|
||||
- 'DB5',
|
||||
- 'DB6',
|
||||
- 'DB7'
|
||||
- ]
|
||||
- self.mode = 8
|
||||
- self.initialized = False
|
||||
-
|
||||
- def init(self):
|
||||
- """Set gpio pins"""
|
||||
- if self.initialized:
|
||||
- return
|
||||
- for pin in self.pins:
|
||||
- if self.pins[pin] is not None:
|
||||
- GPIO.setup(self.pins[pin], GPIO.OUT)
|
||||
- GPIO.output(self.pins[pin], 0)
|
||||
-
|
||||
- self.initialized = True
|
||||
-
|
||||
- def cmd(self, char, enable=0):
|
||||
- """Write output as command. Sets RS to 0
|
||||
- Args:
|
||||
- char: hex to write
|
||||
- """
|
||||
- GPIO.output(self.pins['RS'], 0)
|
||||
- self.write(char, enable)
|
||||
-
|
||||
- def shutdown(self):
|
||||
- """Clean GPIO pins"""
|
||||
- used_pins = [pin for pin in self.pins.values() if pin is not None]
|
||||
- GPIO.cleanup(used_pins)
|
||||
-
|
||||
- def send(self, enable=0):
|
||||
- """Send E signal"""
|
||||
- if enable == 0:
|
||||
- pin = self.pins['E']
|
||||
- elif enable == 1:
|
||||
- pin = self.pins['E2']
|
||||
-
|
||||
- if pin is None:
|
||||
- raise IndexError("Wrong enable index")
|
||||
-
|
||||
- GPIO.output(pin, 1)
|
||||
- time.sleep(0.005)
|
||||
- GPIO.output(pin, 0)
|
||||
-
|
||||
- def _write8(self, char, enable=0):
|
||||
- """Write 8 bits"""
|
||||
- self._write(char)
|
||||
- self.send(enable)
|
||||
-
|
||||
- def _write4(self, char, enable=0):
|
||||
- """Prepare and write 4/4 bits"""
|
||||
- data = (char >> 4)
|
||||
- self._write(data)
|
||||
- self.send(enable)
|
||||
-
|
||||
- data = (char & 0x0F)
|
||||
- self._write(data)
|
||||
- self.send(enable)
|
||||
-
|
||||
- def _write(self, data):
|
||||
- """Write to gpio"""
|
||||
- for i in self.data_pins:
|
||||
- value = data & 0x01
|
||||
- GPIO.output(self.pins[i], value)
|
||||
- data >>= 1
|
||||
-
|
||||
- def write(self, char, enable=0):
|
||||
- """Write char to lcd
|
||||
- Args:
|
||||
- char: hex char to write
|
||||
- """
|
||||
- if self.mode == 4:
|
||||
- self._write4(char, enable)
|
||||
- else:
|
||||
- self._write8(char, enable)
|
||||
-
|
||||
- def char(self, char, enable=0):
|
||||
- """Write char to lcd
|
||||
- Args:
|
||||
- char: char to write
|
||||
- """
|
||||
- GPIO.output(self.pins['RS'], 1)
|
||||
- self.write(ord(char), enable)
|
||||
-
|
||||
- def set_mode(self, mode):
|
||||
- """Set lcd mode
|
||||
- Args:
|
||||
- mode: 4 | 8 bit mode
|
||||
- """
|
||||
- self.mode = mode
|
||||
|
15
default.nix
15
default.nix
@ -1,6 +1,19 @@
|
||||
{ pkgs ? import <nixpkgs> {} }:
|
||||
|
||||
let
|
||||
rpi-gpio = pkgs.python3Packages.buildPythonPackage rec {
|
||||
pname = "RPi.GPIO";
|
||||
version = "0.7.0";
|
||||
|
||||
src = pkgs.python3.pkgs.fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "dCS8bCBUZnZPMPZmwYGHoIJAd9ryCylcQvCK6iy4fT8=";
|
||||
};
|
||||
|
||||
doChceck = false;
|
||||
|
||||
propagatedBuildInputs = with pkgs.python3Packages; [];
|
||||
};
|
||||
smbus = pkgs.python3Packages.buildPythonPackage rec {
|
||||
pname = "smbus";
|
||||
version = "1.1.post2";
|
||||
@ -67,7 +80,7 @@ let
|
||||
|
||||
doChceck = false;
|
||||
|
||||
propagatedBuildInputs = with pkgs.python3Packages; [ future message-listener smbus ];
|
||||
propagatedBuildInputs = with pkgs.python3Packages; [ future message-listener smbus rpi-gpio ];
|
||||
|
||||
meta = {
|
||||
homepage = "https://bitbucket.org/kosci/charlcd/";
|
||||
|
Loading…
x
Reference in New Issue
Block a user