| # DM&P LCM DOS Library Reference

LCM Home Page: http://www.dmp.com.tw/tech/lcm | 2003/01/06 Version 0.25

# Graphic LCM

We provide a lot of embedded CPU modules. Besides, we provide graphics/text LCM. Release graphic/text LCM library in order to reduce development time for our user. The library is for M6117D CPU only. It's for large memory model under DOS. If you use Turbo C/C++ to make GrLCM program, you will get some trouble. The compiler we recommend to use our GrLCM library is Borland C++ 3.1.

If you have any problem, mail to tech@dmp.com.tw please.

# Example

Graphic library is easy to use. The sample code is from demo.c of graphic library. Compile and run it, you will see DM&P logo, lines and "Hello" on LCM.

    #include <stdio.h>
    #include "grlcm.h"

    void main()
    {
      char cType;
      int  nLcmType, nLcmSize;
      int  nMaxX, nMaxY;
      /*
      Bitmap buffer to display. One bit to one pixel.
      for this 8x8 buffer:
      10000001
      01000010
      00100100
      00011000
      00011000
      00100100
      01000010
      10000001
      Note: The width of bitmap must be byte boundary.
      If you want to define a 20x15 image. You should define a
      ((20+8)/8)*15 = 3*15 bytes buffer.
      */
      char pcImage[] = { 0x81,0x42,0x24,0x18,0x18,0x24,0x42,0x81 };

      printf("\nDM&P Graphic LCM Library Demo Program, %s %s.\n\n",__DATE__,__TIME__);
      printf("GrLCM Library Version %s\n\n",GrLcm_Version());

      /* Select LCM type */
      printf("1. 122X32 \n");
      printf("2. 128X64 \n");
      printf("3. 320X240\n");
      printf("4. 128X128\n");
      printf("5. 240X128\n");
      printf("6. 240X64 \n");
      printf("Your LCM type: ");
      cType = getch();
      printf("%c\n",cType);
      switch(cType)
      {
        case '1': nLcmSize = LCM_122X32;  break;
        case '2': nLcmSize = LCM_128X64;  break;
        case '3': nLcmSize = LCM_320X240; break;
        case '4': nLcmSize = LCM_128X128; break;
        case '5': nLcmSize = LCM_240X128; break;
        case '6': nLcmSize = LCM_240X64;  break;
      }

      /* Select LCM interface */
      printf("\n");
      printf("1. GPIO\n");
      printf("2. Printer port\n");
      printf("3. VGA emulator\n");
      printf("Your interface type: ");
      cType = getch();
      printf("%c\n",cType);
      switch(cType)
      {
        case '1': nLcmType = LCM_GPIO; break;
        case '2': nLcmType = LCM_PRN;  break;
        case '3': nLcmType = LCM_VGA;  break;
      }

      /* Initialize graphic LCM library */
      if(GrLcm_Init(nLcmType,nLcmSize)==0)
      {
        printf("Unable to initialize LCM library.\n");
        return;
      }

      /* Select font size */
      GrLcm_SetFontType(LCM_FONT_5X7);

      /* Clear LCM. Show DM&P logo and text "Hello" */
      GrLcm_ClearScreen();
      GrLcm_DisplayBitmapFile(0,0,"dmp.bmp");
      GrLcm_printf(70,0,"Hello");

      /* Display bitmap buffer */
      GrLcm_DisplayBitmap(70,10,8,8,pcImage);

      /* Line function test */
      nMaxX = GrLcm_GetMaxX() - 1;
      nMaxY = GrLcm_GetMaxY() - 1;
      GrLcm_DrawLine(    0,    0,nMaxX,    0);
      GrLcm_DrawLine(nMaxX,    0,nMaxX,nMaxY);
      GrLcm_DrawLine(nMaxX,nMaxY,    0,nMaxY);
      GrLcm_DrawLine(    0,nMaxY,    0,    0);
      GrLcm_DrawLine(    0,    0,nMaxX,nMaxY);
      GrLcm_DrawLine(nMaxX,    0,    0,nMaxY);

      getch();

      /* Close GrLCM library */
      GrLcm_Close();
      printf("Program terminated.\n");
    }

# Function Reference

- char *GrLcm_Version();
- int GrLcm_Init(int nIoType,int nLcmType);
- void GrLcm_Close();
- void GrLcm_SetFontType(int nType);
- int GrLcm_GetFontType();
- void GrLcm_SetLanguage(int nType);
- int GrLcm_GetLanguage();
- void GrLcm_printf(int x, int y, char *szFmt, ...);
- void GrLcm_printf2(int x, int y, int nType, char *szFmt, ...);
- void GrLcm_printf3(int x, int y, int nLang, char *szFmt, ...);
- void GrLcm_ClearScreen();
- void GrLcm_ClearRect(int x,int y,int xs,int ys);
- void GrLcm_DisplayBitmapFile(int x,int y,char *szFile);
- void GrLcm_DisplayBitmap(int x,int y,int xs,int ys,char *pcBuf);
- void GrLcm_DrawLine(int x1, int y1, int x2, int y2);
- void GrLcm_DrawDot(int x, int y);
- int GrLcm_GetMaxX();
- int GrLcm_GetMaxY();

### char *GrLcm_Version();

Description: | Get library version string.
Arguments: |
Return | Library version.
Example: |
    /* Show GrLCM version. */
    printf("DM&P GrLCM Library Version %s\n",GrLcm_Version());

### void GrLcm_Close();

Description: | Close graphics LCM.
Arguments: |
N/A
Example: |
    GrLcm_Close();

### int GrLcm_Init(int nIoType,int nLcmType);

Description: | Initialize graphics LCM and set I/O connection mode.
Arguments: |
Return | 0 is error, non-zero is okay.
nIoType | I/O mode: LCM_GPIO,LCM_PRN.
nLcmType | LCM size: LCM_122X32, LCM_128X64, LCM_320X240, LCM_128X128, LCM_240X128.
Example: |
    if(GrLcm_Init(LCM_GPIO,LCM_128X64))
      printf("Unable to initialize LCM library\n");

### void GrLcm_SetFontType(int nType);

Description: | Select font size will be used by GrLcm_printf().
Arguments: |
nType | Font type: LCM_FONT_5X7,LCM_FONT_8X10,LCM_FONT_8X16.
Example: |
    GrLcm_SetFontType(FONT_5X7);

### int GrLcm_GetFontType();

Description: | Get font size used by GrLcm_printf().
Arguments: |
Return | Font size constant, the same as GrLcm_SetFontType() used.
Example: |
    if(GrLcm_GetFontType()==FONT_5X7)
      printf("Font size is 5X7.\n");

### void GrLcm_SetLanguage(int nLang);

Description: | Select language will be used by GrLcm_printf().
Arguments: |
nLang | Font type: LCM_ENGLISH, LCM_CHINESE_BIG5, LCM_CHINESE_GB, LCM_JAPANESE_SJIS, LCM_GREEK, LCM_THAI.
Note: | If you select non-English, you should set font size to 8X16.
Example: |
    GrLcm_SetLanguage(LCM_CHINESE_BIG5);
    GrLcm_SetFontType(FONT_8X16);

### int GrLcm_GetLanguage();

Description: | Get language used by GrLcm_printf().
Arguments: |
Return | Language constant, the same as GrLcm_SetLanguage() used.
Example: |
    if(GrLcm_GetLanguage()==LCM_CHINESE_BIG)
      printf("Trad. Chinses is used.\n");

### void GrLcm_printf(int x, int y, char *szFmt, ...);

Description: | Print format string on LCM.
Arguments: |
x | X coordinate.
y | Y coordinate.
szFmt | Format string, the same as printf().
Example: |
    GrLcm_printf(0,0,"<Mity-Mite Module>\nIP:192.168.0.100");

### void GrLcm_printf2(int x, int y, int nType, char *szFmt, ...);

Description: | Print formated string on LCM and you can select font type.
Arguments: |
x | X coordinate.
y | Y coordinate.
nType | Font size constant, the same as GrLcm_SetFontType() used.
szFmt | Format string, the same as printf().
Example: |
    GrLcm_printf2(0,0,LCM_FONT_5X7,"<Mity-Mite Module>\nIP:192.168.0.100");

### void GrLcm_printf3(int x, int y, int nLang, char *szFmt, ...);

Description: | Print formated string on LCM and you can select language.
Arguments: |
x | X coordinate.
y | Y coordinate.
nLang | Language constant, the same as GrLcm_SetLanguage() used.
szFmt | Format string, the same as printf().
Note: | If you select non-English, you should set font size to 8X16.
Example: |
    GrLcm_SetFontType(FONT_8X16);
    GrLcm_printf3(0,0,LCM_ENGLISH,"<Mity-Mite Module>\nIP:192.168.0.100");

### void GrLcm_ClearScreen();

Description: | Clear LCM.
Arguments: | N/A
Example: |
    GrLcm_ClearScreen();
    GrLcm_printf(0,0,"\nIP:%s",szBuf);

### void GrLcm_ClearRect(int x,int y,int xs,int ys);

Description: | Clear a rectangle range on LCM.
Arguments: |
x | X coordinate.
y | Y coordinate.
xs | horizontal size.
ys | Vertical size.
Example: |
    GrLcm_ClearRect(0,0,100,20);

### void GrLcm_DisplayBitmapFile(int x,int y,char *szFile);

Description: | Show a bitmap on LCM.
Arguments: |
x | X coordinate.
y | Y coordinate.
szFile | Bitmap file name.
Example: |
    GrLcm_DisplayBitmapFile(0,0,"dmp.bmp");

### void GrLcm_DisplayBitmap(int x,int y,int xs,int ys,char *pcBuf);

Description: | Show a bitmap buffer on LCM.
Arguments: |
x | X coordinate.
y | Y coordinate.
xs | size of X coordinate.
ys | size of Y coordinate.
pcBuf | Buffer pointer of bitmap buffer.
Note | The width of bitmap must be byte boundary. If you want to define a 20x15 image. You should define a ((20+8)/8)*15 = 3*15 bytes buffer.
Example: |
    char pcImage[] = { 0x81,0x42,0x24,0x18,0x08,0x04,0x02,0x01 };
    /* Display bitmap buffer */
    GrLcm_DisplayBitmap(70,10,8,8,pcImage);

### void GrLcm_DrawLine(int x1,int y1,int x2,int y2);

Description: | Draw a line on LCM.
Arguments: |
x1 | X coordinate of point 1.
y1 | Y coordinate of point 1.
x2 | X coordinate of point 2.
y2 | Y coordinate of point 2.
Example: |
    GrLcm_DrawLine(0,0,100,50);

### void GrLcm_DrawDot(int x,int y);

Description: | Draw a dot on LCM.
Arguments: |
x | X coordinate.
y1 | Y coordinate.
Example: |
    GrLcm_DrawDot(10,10);

### int GrLcm_GetMaxX();

Description: | Get LCM width.
Arguments: |
Return | Maximum X coordinate on LCM.
Example: |
    int nMaxX = GrLcm_GetMaxX();

### int GrLcm_GetMaxY();

Description: | Get LCM height.
Arguments: |
Return | Maximum Y coordinate on LCM.
Example: |
    int nMaxX = GrLcm_GetMaxX();

Jan Yin Chan Electronics Co., LTD. All rights reserved. | Email us: info@dmp.com.tw