Library mPPP; {***************************************************************************** * * * MPPP.DLL interface for windows 3.1 file: MPPP .LIB * * * ****************************************************************************** * * * Mathijs's Powerfull Parallel Port interface * * expanded with the 2x40 characters LCD display DMC-40218 * * * * * * (C) Copyright 1996 * * ing. Mathijs A. van der Paauw * * * * mathijs@IAEhv.nl * * 21/02/1996 * ****************************************************************************** * * * Ported from Turbo C v2.0 * * to Turbo Pascal for windows v1.0 * * * * Currently this program is for testing/debugging purposes, * * When fully debugged it will be rewritten as a Unit, so that a DLL library * * can be created. * * * * This allows other programming languages as Visual Basic vx.x and * * Microsoft Access to make use of the powerfull capabilities of the MPPP- * * interface. * * * ******************************************************************************} CONST {*****************************************************************************} {* *} {* LCD : DMC-40218 (2 x 40) COMMAND-SET list: *} {* *} {*****************************************************************************} DMC_CLRDISP = $01; {* Clear display RAM and send cursor home to $80 *} DMC_CURHOME = $02; {* Return cursor home, align display with DRAM *} DMC_LDISP = $04; {* Shift left display and cursor *} DMC_RDISPCCP = $05; {* Shift right display from current cursor pos. *} DMC_RDISP = $06; {* Shift right display and cursor *} DMC_LDISPCCP = $07; {* Shift left display from current cursor pos. *} DMC_NODISP = $08; {* Set display and cursor off *} DMC_EDNOCUR = $0C; {* Enable display with no cursor *} DMC_EDBLCUR = $0D; {* Enable display with blinking (full) cursor *} DMC_EDULCUR = $0E; {* Enable display with underline cursor *} DMC_SCLEFT = $10; {* Shift cursor 1 character left *} DMC_SCRIGHT = $14; {* Shift cursor 1 character right *} DMC_SDLEFT = $18; {* Shift display and cursor 1 character left *} DMC_SDRIGHT = $1C; {* Shift display and cursor 1 character right *} DMC_INIT = $38; {* Set 8 bit operation *} DMC_GRAPHIC = $40; {* Start of graphics adress *} {*****************************************************************************} {* *} {* mPPP stuff: *} {* *} {*****************************************************************************} M3P_STROBE = $01; {* DB25 pin 1 *} M3P_AUTOFEED = $02; {* DB25 pin 14 *} M3P_INIT = $04; {* DB25 pin 16 *} M3P_SLCTIN = $08; {* DB25 pin 17 *} M3P_DFLT = $10; {* DISable interrupts on LPT port *} {* select different output mPPP's ports *} M3P_LCD_SELECT = M3P_DFLT + $00; {*} M3P_IC6_SELECT = M3P_DFLT + M3P_AUTOFEED; {*} M3P_IC7_SELECT = M3P_DFLT + M3P_SLCTIN; {*} M3P_NONE_SELECT = M3P_DFLT + M3P_AUTOFEED + M3P_SLCTIN; {*} {*****************************************************************************} {* *} {* LCD DMC-40218 stuff: *} {* *} {*****************************************************************************} LCD_DATAMODE = M3P_DFLT + M3P_INIT; {*} LCD_CTRLMODE = M3P_DFLT + 0; {*} {*****************************************************************************} LCD_NOCURSOR = 0; {*} LCD_BLINKCURSOR = 1; {*} LCD_UNDERLINECURSOR = 2; {*} {*****************************************************************************} LCD_SHIFT_LEFT = 0; {*} LCD_SHIFT_RIGHT = 1; {*} {*****************************************************************************} VAR ticks : Integer; {*****************************************************************************} {* Delay( delayticks ) ***} {* used for timing purposes *} {*****************************************************************************} PROCEDURE Delay( delayticks : integer ); EXPORT; VAR i : integer; BEGIN FOR i := 1 TO ( delayticks * ticks ) DO BEGIN ; { Do actually nothing; just waste some CPU-time } ; END END; {*****************************************************************************} {* LCDclrscr; ***} {* clears the LCD screen *} {*****************************************************************************} PROCEDURE LCDclrscr; EXPORT; BEGIN Port[ $37a ] := LCD_CTRLMODE; Port[ $378 ] := DMC_CLRDISP; Port[ $37a ] := LCD_CTRLMODE + M3P_STROBE; Delay(50); {* timing is critical, should be adjusted by trial and error *} Port[ $37a ] := LCD_CTRLMODE END; {*****************************************************************************} {* LCDcmdCharOut( karakter ); ***} {* Send a command to the DMC-40218 LCD screen *} {*****************************************************************************} PROCEDURE LCDcmdCharOut( karakter : Byte ); BEGIN Port[ $37a ] := LCD_CTRLMODE; Port[ $378 ] := karakter; Port[ $37a ] := LCD_CTRLMODE + M3P_STROBE; Delay(1); Port[ $37a ] := LCD_CTRLMODE; Delay(5); END; {*****************************************************************************} {* LCDdataCharOut( karakter ); ***} {* Send a datacharacter to the DMC-40218 LCD screen *} {*****************************************************************************} PROCEDURE LCDdataCharOut( data : Char ); BEGIN {***************************************************************************} {* deze routine gaat ervanuit dat er een LPT poort is geinstalleerd op *} {* adres 0x378. *} {* *} {* Selecteer de uitvoermode, met een niet actief STROBE signaal, hierdoor *} {* wordt het betreffende latch IC geselecteerd, zonder nog geactiveerd te *} {* worden; *} {***************************************************************************} Port[ $37a ] := LCD_DATAMODE; Port[ $378 ] := Ord( data ); Port[ $37a ] := LCD_DATAMODE + M3P_STROBE; Delay(1); Port[ $37a ] := LCD_DATAMODE END; {*****************************************************************************} {* LCDdisabledisplay() : Disables the display, while it still can be ***} {* updated. *} {*****************************************************************************} PROCEDURE LCDdisabledisplay; EXPORT; BEGIN LCDcmdCharOut( DMC_NODISP ) END; {*****************************************************************************} {* LCDdispchar( character ) ***} {* Displays a character on the LCD-display *} {*****************************************************************************} PROCEDURE LCDdispchar( karakter : Char ); EXPORT; BEGIN LCDdataCharOut( karakter ) END; {*****************************************************************************} {* LCDdispgraphic( charnumber ) : Prints a graphic character at the ***} {* current LCD cursor position. *} {* charnumber = 1 .. 16 *} {*****************************************************************************} PROCEDURE LCDdispgraphic( charnumber : Byte ); EXPORT; BEGIN IF ( ( charnumber > 0 ) AND ( charnumber <= 16 ) ) THEN LCDdataCharOut(Chr( charnumber - 1 ) ) END; {*****************************************************************************} {* LCDdispstr( * outstring ) : Displays a (null terminated) string ***} {* on the LCD display *} {* only the last 80 characters of the string will be displayed *} {* 0 <= len( outstring ) <= 80 *} {*****************************************************************************} PROCEDURE LCDdispstr( outstr : string ); EXPORT; VAR index : byte; BEGIN FOR index := 1 TO Length( outstr ) DO IF outstr[index] <> '' THEN LCDdataCharOut( outstr[ index ] ) END; {*****************************************************************************} {* LCDenabledisplay : Enables the display again, and the internal ***} {* LCD-buffer is displayed. *} {*****************************************************************************} PROCEDURE LCDenabledisplay; EXPORT; BEGIN LCDcmdCharOut( DMC_NODISP ) END; {*****************************************************************************} {* LCDsetgraphic( cn, d1, d2, .. d8 ) : Loads graphic character into ***} {* LCD display's memory. *} {* cn = 1, 2, .. 8 : graphic character number. *} {* d1 = 0, 1, .. 31 : data top line of character. *} {* : : : data x line of character. *} {* d8 = 0, 1, .. 31 : data bottom line of character. *} {*****************************************************************************} PROCEDURE LCDsetgraphic( cnum, d1, d2, d3, d4, d5, d6, d7, d8: Byte); EXPORT; VAR DMCadress : Byte; BEGIN DMCadress := ( (cnum - 1 ) * 8 ) + DMC_GRAPHIC; LCDcmdCharOut( DMCadress ); LCDdataCharOut( Chr(d1) ); LCDdataCharOut( Chr(d2 )); LCDdataCharOut( Chr(d3) ); LCDdataCharOut( Chr(d4 )); LCDdataCharOut( Chr(d5) ); LCDdataCharOut( Chr(d6 )); LCDdataCharOut( Chr(d7) ); LCDdataCharOut( Chr(d8 )) END; {*****************************************************************************} {* LCDgotoxy(x, y); Sets the LCD cursor at the specified position ***} {* y = 0 , 1 x = 0, 1, .. 39 *} {*****************************************************************************} PROCEDURE LCDgotoxy( x, y : Byte ); EXPORT; VAR DMCgoto : Byte; BEGIN IF ( (y >= 0) AND ( y <= 1 ) AND ( x >= 0 ) AND ( x < 40 ) ) THEN BEGIN DMCgoto := $80 + ( y * $40 ) + x; LCDcmdCharOut( DMCgoto ) END ELSE LCDcmdCharOut( DMC_CURHOME ) {* set cursor at home position *} END; {*****************************************************************************} {* LCDsetcursor( cursormode ) : Sets the LCD cursor ***} {* cursormode : 0 LCD_NOCURSOR no cursor *} {* 1 LCD_BLINKCURSOR full blinking cursor *} {* 2 LCD_UNDERLINECURSOR underline cursor *} {*****************************************************************************} PROCEDURE LCDsetcursor( cursormode : Integer ); EXPORT; BEGIN CASE cursormode OF LCD_NOCURSOR : LCDcmdCharOut( DMC_EDNOCUR ); LCD_BLINKCURSOR : LCDcmdCharOut( DMC_EDBLCUR ); LCD_UNDERLINECURSOR : LCDcmdCharOut( DMC_EDULCUR ) END END; {*****************************************************************************} {* LCDintro; ***} {* Displays the intro message on the LCD-screen *} {*****************************************************************************} PROCEDURE LCDintro; EXPORT; CONST str1 = 'M'; str2 = ' interface (c) Copyright 1995, 1996'; str3 = ''; BEGIN LCDclrscr; LCDsetgraphic( $3, 24, 4, 24, 4, 24, 0, 0, 0 ); LCDsetgraphic( $8, 0, 30, 17, 30, 16, 16, 0, 0 ); LCDgotoxy( 0, 0 ); LCDdispstr( 'M' ); LCDdispgraphic( $8 ); LCDdispgraphic( $8 ); LCDdispgraphic( $8 ); LCDdispstr( str2 ); LCDdispstr( ' ing. Mathijs Alexander van der Paauw ' ) END; {*****************************************************************************} {* Initialise DMC40218 LCD-display using the MPPP interface: ***} {* setup for 8 bit communication *} {* clear display and align with DRAM *} {* enable display, with or without cursor *} {* set shift right display and cursor (may not be visible) *} {*****************************************************************************} PROCEDURE LCDinit( tt : Integer ); EXPORT; BEGIN ticks := tt; {* init timerticks *} Port[ $387 ] := $00; Port[ $37a ] := M3P_NONE_SELECT; {* clear all latches *} LCDcmdCharOut( DMC_INIT ); {* init lcd: 8 bit communication *} LCDsetcursor( LCD_NOCURSOR ); {* init lcd: Enable display (no cursor) *} LCDclrscr; LCDcmdCharOut( DMC_RDISP ); {* init lcd: right display and cursor *} LCDintro END; {*****************************************************************************} {* LCDshiftcursor( direction ) ***} {* Shifts the cursor left or right depending on direction *} {* direction = 0: Left *} {* 1: Right *} {*****************************************************************************} PROCEDURE LCDshiftcursor( direction : Integer ); EXPORT; BEGIN CASE direction OF LCD_SHIFT_RIGHT : LCDcmdCharOut( DMC_SCRIGHT ); LCD_SHIFT_LEFT : LCDcmdCharOut( DMC_SCLEFT ) END END; {*****************************************************************************} {* LCDshiftdisplay( direction ) ***} {* Shifts the display left or right depending on direction *} {* direction = 0: Left *} {* 1: Right *} {*****************************************************************************} PROCEDURE LCDshiftdisplay( direction : Integer ); EXPORT; BEGIN CASE direction OF LCD_SHIFT_RIGHT : LCDcmdCharOut( DMC_SDRIGHT ); LCD_SHIFT_LEFT : LCDcmdCharOut( DMC_SDLEFT ) END END; EXPORTS LCDclrscr INDEX 1, LCDdisabledisplay INDEX 2, LCDdispchar INDEX 3, LCDdispgraphic INDEX 4, LCDdispstr INDEX 5, LCDenabledisplay INDEX 6, LCDsetgraphic INDEX 7, LCDgotoxy INDEX 8, LCDsetcursor INDEX 9, LCDintro INDEX 10, LCDinit INDEX 11, LCDshiftcursor INDEX 12, LCDshiftdisplay INDEX 13, Delay INDEX 14; BEGIN END. { End of File : MPPP.LIB }