Hi everyone,

I tried to run a lcd-display ST7066 (probably similar to the hd44870) with 
the folowing code:

------------------------------------------------------------------------------------
import Adafruit_BBIO.GPIO as GPIO
import time
 
# Define GPIO to LCD mapping
LCD_RS="P9_15"
LCD_E="P9_16"
LCD_D4="P9_21"
LCD_D5="P9_22"
LCD_D6="P9_23"
LCD_D7="P9_24"

OUT=GPIO.OUT
LOW=GPIO.LOW
HIGH=GPIO.HIGH

# Define some device constants
LCD_WIDTH = 16    # Maximum characters per line
LCD_CHR = True
LCD_CMD = False
 
LCD_LINE_1 = 0x00 # LCD RAM address for the 1st line
LCD_LINE_2 = 0x28 # LCD RAM address for the 2nd line
 
# Timing constants
E_PULSE = 0.00005  
E_DELAY = 0.00005
 
def main():
  # Main program block
  GPIO.setup(LCD_E,OUT)  # E
  GPIO.setup(LCD_RS,OUT) # RS
  GPIO.setup(LCD_D4,OUT) # DB4
  GPIO.setup(LCD_D5,OUT) # DB5
  GPIO.setup(LCD_D6,OUT) # DB6
  GPIO.setup(LCD_D7,OUT) # DB7
 
  # Initialise display
  lcd_init()

def lcd_init():
  # Initialise display
  lcd_byte(0x30,LCD_CMD) # 110011 Initialise
  time.sleep(0.01)
  lcd_byte(0x30,LCD_CMD) # 110010 Initialise
  time.sleep(0.01)
  lcd_byte(0x30,LCD_CMD) # 000110 Cursor move direction
  time.sleep(0.01)
  lcd_byte(0x20,LCD_CMD) # 001100 Display On,Cursor Off, Blink Off
  time.sleep(0.01)
  #lcd_byte(0x1C,LCD_CMD) # 101000 Data length, number of lines, font size
  #  time.sleep(0.01)
  lcd_byte(0x0C,LCD_CMD)
  time.sleep(0.01)
  lcd_byte(0x01,LCD_CMD)
  time.sleep(0.01)
  #lcd_byte(0x06,LCD_CMD) # 000001 Clear display 
  
def lcd_byte(bits, mode):
  # Send byte to data pins
  # bits = data
  # mode = True  for character
  #       False for command
  GPIO.output(LCD_RS, mode) # RS
  GPIO.output(LCD_D4, False)     # High bits
  GPIO.output(LCD_D5, False)
  GPIO.output(LCD_D6, False)
  GPIO.output(LCD_D7, False)
  time.sleep(0.001)
  lcd_toggle_enable()
  if bits&0x10:
    GPIO.output(LCD_D4, True)
  if bits&0x20:
    GPIO.output(LCD_D5, True)
  if bits&0x40:
    GPIO.output(LCD_D6, True)
  if bits&0x80:
    GPIO.output(LCD_D7, True)
  time.sleep(E_PULSE)
  GPIO.output(LCD_E, True)
  time.sleep(E_DELAY) 
  GPIO.output(LCD_E, False)
  time.sleep(E_PULSE)

# lcd_toggle_enable()
  GPIO.output(LCD_D4, False)
  GPIO.output(LCD_D5, False)
  GPIO.output(LCD_D6, False)
  GPIO.output(LCD_D7, False)
  
  if bits&0x01:
    GPIO.output(LCD_D4, True)
  if bits&0x02:
    GPIO.output(LCD_D5, True)
  if bits&0x04:
    GPIO.output(LCD_D6, True)
  if bits&0x08:
    GPIO.output(LCD_D7, True)
  lcd_toggle_enable()
    
def lcd_toggle_enable():
  time.sleep(0.005)
  GPIO.output(LCD_E, False)
  time.sleep(E_PULSE)
  GPIO.output(LCD_E, True)
  time.sleep(E_DELAY) 
  GPIO.output(LCD_E, False)
  time.sleep(0.005) 

def lcd_string(zeile,text):
  if zeile == 1:
      lcd_byte(LCD_LINE_1, LCD_CMD)  
  if zeile == 2:
      lcd_byte(LCD_LINE_1, LCD_CMD)
  message=text.ljust(LCD_WIDTH,'_')
  for i in range(LCD_WIDTH):       
    lcd_byte(ord(message[i]),LCD_CHR)
    
main()
lcd_string(1,'abc')
------------------------------------------------------------

but there is no correct output on the display:


<https://lh3.googleusercontent.com/-s1iECSBCKx0/V3vEFefR3PI/AAAAAAAAADc/mO5u2GQWb28afhb7jkIDuAE1O-YnrcpJwCLcB/s1600/WP_20160705_15_52_27_Rich.jpg>












I think that there is something wrong with the toggle or the waittime of 
the toggle, but I cant find any error. 
Can anybody see an error in the sourcecode?
Thanks for your help.

best regards eyk


-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/d579ae0d-68a3-434d-83d7-51cab5abb81d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to