home *** CD-ROM | disk | FTP | other *** search
- ' ****************** LCD_Write_Hex_Word '''''******
- ' sendet "value" als Hexzahl $XXXX zum LC-Display *
- ' "i" ist frei als Index *
- ' ***************************************************
-
- DEFINE value WORD[1] ' value wird als $Hex_Zahl zum LC-Display ausgegeben
- DEFINE output WORD[2] ' LCD-Puffer
- define i word[3] ' allgemeiner Index
-
- ' *** LCD-Daten ***
- define lcd_buf byte[7]
- define lcd_param byte[8]
-
- ' *** LCD-Ports ***
- define lcd_port byteport[2]
- define lcd_rs port[14]
- define lcd_rw port[13]
- define lcd_e port[15]
-
- '*** ASCII-Codes ***
- define c_Leer &H20
- define c_Minus &H2D
- define c_0 &H30
- define c_Dollar &H24
-
-
- '*********** TESTPROGRAMM *****************
-
- for value = -10 to 10
- gosub LCD_init
- gosub LCD_Write_Hex_Word : pause 50
- next
-
- end
- '******************************************
-
-
- '*** Output "value" as "$XXXX" to LC-Display ***
- #LCD_Write_Hex_Word
-
- LCD_param = c_Dollar : gosub LCD_WriteChar
-
- '16^3 oder Leerzeichen
- if (value >= 4096) or (value < 0) then gosub LCD_Hoch3 else gosub LCD_Leerzeichen
-
- ' 16^2 oder Leerzeichen
- if (value >= 256) or (value < 0) then gosub LCD_Hoch2 else gosub LCD_Leerzeichen
-
- ' 16^1 oder Leerzeichen
- if (value >= 16) or (value < 0) then gosub LCD_Hoch1 else gosub LCD_Leerzeichen
-
- ' 16^0
- output = value and &H000F : gosub Write_Hex_Nibble
- return
-
- #LCD_Leerzeichen
- lcd_param = c_Leer : gosub LCD_WriteChar
- return
-
- #LCD_Dollar
- lcd_param = c_Dollar : gosub LCD_WriteChar
- return
-
- #Write_Hex_Nibble
- if (output >= 10) then lcd_param = 55 + output else lcd_param = c_0 + output
- gosub LCD_WriteChar
- return
-
- #LCD_Hoch3
- output = value
- output = (output shr 12) and &H000F : gosub Write_Hex_Nibble
- return
-
- #LCD_Hoch2
- output = value
- output = (output shr 8) and &H000F : gosub Write_Hex_Nibble
- return
-
- #LCD_Hoch1
- output = value
- output = (output shr 4) and &H000F: gosub Write_Hex_Nibble
- return
-
-
- '*** LCD_Interface ***
- '( muss in jedes Programm mit LCD-Ausgabe eingefuegt werden)
-
- #LCD_INIT
-
- ' alle ports 0
- lcd_port = OFF
-
- ' 8-Bit-Modus aktivieren
- lcd_param=&H38 : gosub LCD_WRITECMD
-
- ' mit 8-Bit-Command in 4-Bit-Modus umschalten
- lcd_port=&B00000010
- tog lcd_e
- tog lcd_e
-
- ' ab jetzt 4-Bit-Modus
- lcd_param = &H28 : gosub LCD_WRITECMD
- lcd_param = &H0C : gosub LCD_WRITECMD
-
- ' Display loeschen
- #LCD_CLS
- lcd_param = &H02 : gosub LCD_WRITECMD
- lcd_param = &H01 : gosub LCD_WRITECMD
- return
-
- ' Zeilenwechsel
- #LCD_GOTOLINE
- if lcd_param = 1 then lcd_param = &H80
- if lcd_param = 2 then lcd_param = &HC0
- goto LCD_WRITECMD
-
- ' LCD-Kommando
- #LCD_WRITECMD
- lcd_buf = OFF
- goto LCD_WRITE
-
- ' Zeichenausgabe
- #LCD_WRITECHAR
- lcd_buf = &B00100000
-
- ' Kommando oder Zeichen an Display senden
- #LCD_WRITE
- lcd_port = lcd_buf or (lcd_param shr 4) ' Hi-Nibble
- tog lcd_e
- tog lcd_e
- lcd_port = lcd_buf or (lcd_param and &H0F) ' Lo-Nibble
- tog lcd_e
- tog lcd_e
- return
-