Also ich habe dieses Display, was noch rumlag von einem alten Projekt und damals nicht lief, verwendet.
https://www.reichelt.de/EA-W162-X3LG/3/i...EARCH=oled
Dann hab ich mir die die freien Gpios rausgesucht bei der Cirrus Karte
https://www.element14.com/community/serv...0V1.02.pdf
auf Seite 16
Diese mit dem Multimeter rausgemessen.
Dann hab ich ein script gefunden das auch das Display wieder resetet damit es neu beschrieben werden kann. ansonsten baut es Mist und zeigt nur Kryptische Sachen an.
Code:
#!/usr/bin/python
#
# HD44780 LCD/OLED Test Script for
# Raspberry Pi
#
# Author : Robert Coward/Paul Carpenter (based on driver by Matt Hawkins/)
# Site : http://www.raspberrypi-spy.co.uk
# http://www.pcserviceslectronics.co.uk
#
# Date : 02/03/2014
#
# The wiring for the LCD is as follows:
# 1 : GND
# 2 : 5V
# 3 : Contrast (0-5V)*
# 4 : RS (Register Select)
# 5 : R/W (Read Write) - GROUND THIS PIN
# 6 : Enable or Strobe
# 7 : Data Bit 0 - NOT USED
# 8 : Data Bit 1 - NOT USED
# 9 : Data Bit 2 - NOT USED
# 10: Data Bit 3 - NOT USED
# 11: Data Bit 4
# 12: Data Bit 5
# 13: Data Bit 6
# 14: Data Bit 7
# 15: LCD Backlight +5V**
# 16: LCD Backlight GND
#import
import RPi.GPIO as GPIO
import time
import re
import subprocess
import os
# Define GPIO to LCD mapping (USES BCM MODE NUMBERING scheme)
LCD_RS = 26
LCD_E = 12
LCD_D4 = 16
LCD_D5 = 06
LCD_D6 = 25
LCD_D7 = 05
# Generate an array of pin numbers to write out for the data lines
lcdPins = [LCD_D7, LCD_D6, LCD_D5, LCD_D4]
# Define some device constants
LCD_WIDTH = 16 # Maximum characters per line
LCD_CHR = True
LCD_CMD = False
LCD_LINE_1 = 0x80 # LCD RAM address for the 1st line
LCD_LINE_2 = 0xC0 # LCD RAM address for the 2nd line
# Timing constants for low level write operations
# NOTE: Enable cycle time must be at least 1 microsecond
# NOTE2: Actually, these can be zero and the LCD will typically still work OK
EDEL_TAS = 0.00001 # Address setup time (TAS)
EDEL_PWEH = 0.00001 # Pulse width of enable (PWEH)
EDEL_TAH = 0.00001 # Address hold time (TAH)
# Timing constraints for initialisation steps - IMPORTANT!
# Note that post clear display must be at least 6.2ms for OLEDs, as opposed
# to only 1.4ms for HD44780 LCDs. This has caused confusion in the past.
DEL_INITMID = 0.01 # middle of initial write (min 4.1ms)
DEL_INITNEXT = 0.0002 # post second initial write (min 100ns)
DEL_POSTCLEAR = 0.01 # post clear display step (busy, min 6.2ms)
# ==============================================================================
# LCD Initialisation to setup the two line display using the 4 bit interface
def lcd_init():
# Configure the GPIO to drive the LCD display correctly
GPIO.setmode(GPIO.BCM) # Use BCM GPIO numbers
# setup all output pins for driving LCD display
GPIO.setup(LCD_E, GPIO.OUT) # E
# PC - better safe starting state
GPIO.output(LCD_E, 0) # set low as idle state
GPIO.setup(LCD_RS, GPIO.OUT) # RS
# PC - more maintainable initialisation
for val in lcdPins: # enable DB7 to DB4
GPIO.setup(val, GPIO.OUT)
GPIO.output(val, 0) # set low
# Initialise display into 4 bit mode, using recommended delays
lcd_byte(0x33, LCD_CMD, DEL_INITNEXT, DEL_INITMID)
lcd_byte(0x32, LCD_CMD, DEL_INITNEXT)
# Now perform remainder of display init in 4 bit mode - IMPORTANT!
# These steps MUST be exactly as follows, as OLEDs in particular are rather fussy
lcd_byte(0x28, LCD_CMD, DEL_INITNEXT) # two lines and correct font
lcd_byte(0x08, LCD_CMD, DEL_INITNEXT) # display OFF, cursor/blink off
lcd_byte(0x01, LCD_CMD, DEL_POSTCLEAR) # clear display, waiting for longer delay
lcd_byte(0x06, LCD_CMD, DEL_INITNEXT) # entry mode set
# extra steps required for OLED initialisation (no effect on LCD)
lcd_byte(0x17, LCD_CMD, DEL_INITNEXT) # character mode, power on
# now turn on the display, ready for use - IMPORTANT!
lcd_byte(0x0C, LCD_CMD, DEL_INITNEXT) # display on, cursor/blink off
# ==============================================================================
# Outputs string of characters to the LCD display line, padding as required
# NOTE: Incoming string MUST be a string of simple characters with no complex
# unicode types present, as otherwise incorrect encoding will occur.
def lcd_string(message):
# Send string to display, padding with spaces if required
message = message.ljust(LCD_WIDTH," ")
for i in range(LCD_WIDTH):
# output a single byte value for the incoming character
lcd_byte(ord(message[i]), LCD_CHR)
# ==============================================================================
# Low level routine to output a byte of data to the LCD display
# over the 4 bit interface. Two nybbles are sent, one after the other.
# The post_delay specifies optional delay to cover busy periods
# The mid_delay specifies optional delay between the 4 bit nibbles (special case)
def lcd_byte(byteVal, mode, post_delay = 0, mid_delay = 0):
# convert incoming value into 8 bit array, padding as required
bits = bin(byteVal)[2:].zfill(8)
# set mode = True for character, False for command
GPIO.output(LCD_RS, mode) # RS
# Output the four High bits
for i in range(4):
GPIO.output(lcdPins[i], int(bits[i]))
# Toggle 'Enable' pin, wrapping with minimum delays
time.sleep(EDEL_TAS)
GPIO.output(LCD_E, True)
time.sleep(EDEL_PWEH)
GPIO.output(LCD_E, False)
time.sleep(EDEL_TAH)
# Wait for extra mid delay if specified (special case)
if mid_delay > 0:
time.sleep(mid_delay)
# Output the four Low bits
for i in range(4,8):
GPIO.output(lcdPins[i-4], int(bits[i]))
# Toggle 'Enable' pin, wrapping with minimum delays
time.sleep(EDEL_TAS)
GPIO.output(LCD_E, True)
time.sleep(EDEL_PWEH)
GPIO.output(LCD_E, False)
time.sleep(EDEL_TAH)
# Wait for extra post delay if specified (covers busy period)
if post_delay > 0:
time.sleep(post_delay)
# ==============================================================================
# main routine which initialises the display and outputs text messages to it
def main():
# Initialise GPIO port and display
lcd_init()
# Send some text
lcd_byte(LCD_LINE_1, LCD_CMD)
lcd_string(" BruteFir DSP 1 ")
lcd_byte(LCD_LINE_2, LCD_CMD)
lcd_string(" start Coeff 0 ")
time.sleep(1) # 1 second delay
# Send some more text
lcd_byte(LCD_LINE_1, LCD_CMD)
lcd_string(" BruteFir DSP 1 ")
lcd_byte(LCD_LINE_2, LCD_CMD)
lcd_string(" Dirac Pulse ")
#time.sleep(3) # 3 second delay
# Send some more text
#lcd_byte(LCD_LINE_1, LCD_CMD)
#lcd_string("Modified by")
#lcd_byte(LCD_LINE_2, LCD_CMD)
#lcd_string("Robert Coward")
#time.sleep(3) # 3 second delay
# Send some more text
#lcd_byte(LCD_LINE_1, LCD_CMD)
#lcd_string("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#lcd_byte(LCD_LINE_2, LCD_CMD)
#lcd_string("1234567890!$%^&*()")
# ==============================================================================
# Ensure that the GPIO is cleaned up whichever way the program exits
# This avoids all those annoying "channel already in use" errors
if __name__ == '__main__':
try:
main()
finally: GPIO.cleanup()
# ========================================================================
Es ist eigentlich egal welche von den Gpios man verwendet. es sollte halt im Script angepasst werden.
Stromversogungspins muss man natürlich auch anklemmen!
!Und ganz wichtig bei diesem Display ist den Pin 1 VSS GND Masse
gegen Pin 5 RW kurz zu schließen!!!!
Ansonsten kann das Display auch Daten senden und dieses mit 5 Volt!!
Der Pi verträgt nur 3,3 Volt!!!
Das Script kann man mit Chmod +x /pfad/datei.py ausführbar machen.(braucht man für lirc nicht)
ansonsten startet man es so python /pfad/datei.py
Das ganze kann man dann in sh sripten zusammen mit z.B. Brutefir oder sonst was starten die in Lirc auf die jeweilige Taste gelegt werden.
Code:
#!/bin/sh/py
sudo nohup /usr/bin/brutefir -nodefault /home/pi/brute1 &
echo "cfc 0 0; cfc 1 1;quit" | nc localhost 3000 > /dev/null
python /home/pi/bin/PythonLCD/brute1coeff0.py
das nutze ich um BruteFir mit den ersten beiden Coeffs(0und1) zu starten und um verschiedenen Quellen zu nutzen.
(in der Bruteconfig festgelegt)
Der Groschen ist mir echt erst vor paar tagen gefallen wo ich angefangen habe mich mit den Scripten zu beschäftigen.
So langsam verstehe ich auch was ich überhaupt da mache..
Wenn ich mal die Tage Zeit habe werde ich meine Lösung dazu dokumentieren.