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

/* external strings */
extern char *_szChineseBig5;
extern char *_szChineseGb;
extern char *_szJapaneseSjis;

void main()
{
  char cType;
  int  nLcmType, nLcmSize;
  int  nMaxX, nMaxY;
  int  x,y;

  printf("\nDM&P Graphic LCM Library Multi-Language 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;
  }

  /* You should select 8X16 font for non-English characters */
  GrLcm_SetFontType(LCM_FONT_8X16);

  /* Show languages supported */
  GrLcm_ClearScreen();

  nMaxX = GrLcm_GetMaxX() - 1;
  nMaxY = GrLcm_GetMaxY() - 1;
  x = y = 0;

	GrLcm_printf3(x,y++*16,LCM_CHINESE_BIG5 ,_szChineseBig5);
  if(y*16>nMaxY) y=0,x=nMaxX/2;
	GrLcm_printf3(x,y++*16,LCM_CHINESE_GB,_szChineseGb);
  if(y*16>nMaxY) y=0,x=nMaxX/2;
 	GrLcm_printf3(x,y++*16,LCM_JAPANESE_SJIS,_szJapaneseSjis);
  if(y*16>nMaxY) y=0,x=nMaxX/2;
 	GrLcm_printf3(x,y++*16,LCM_ENGLISH,"German");
  if(y*16>nMaxY) y=0,x=nMaxX/2;
 	GrLcm_printf3(x,y++*16,LCM_ENGLISH,"Français");
  if(y*16>nMaxY) y=0,x=nMaxX/2;
 	GrLcm_printf3(x,y++*16,LCM_ENGLISH,"Dutch");
  if(y*16>nMaxY) y=0,x=nMaxX/2;
 	GrLcm_printf3(x,y++*16,LCM_ENGLISH,"Svenska");
  if(y*16>nMaxY) y=0,x=nMaxX/2;
 	GrLcm_printf3(x,y++*16,LCM_ENGLISH,"Español");
  if(y*16>nMaxY) y=0,x=nMaxX/2;
 	GrLcm_printf3(x,y++*16,LCM_GREEK,"ÅëëÜäáò");
  if(y*16>nMaxY) y=0,x=nMaxX/2;
 	GrLcm_printf3(x,y++*16,LCM_THAI,"ä·Â");
  if(y*16>nMaxY) y=0,x=nMaxX/2;

  getch();

  /* Default language is English, you can not see Chinese */
  GrLcm_ClearScreen();
 	GrLcm_printf(0, 0,"English & ¤¤¤å");

  /* Set laguage to Chinese and you can see Chinese */
 	GrLcm_SetLanguage(LCM_CHINESE_BIG5);
 	GrLcm_printf(0,16,"English & ¤¤¤å");
  getch();

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

