VLSI Solution Oy VS1103 VLSI Solution Karaoke, MIDI and ADPCM Player Source Code Documentation

Main Page | Class List | File List | Class Members | File Members | Related Pages

lcd.c

Go to the documentation of this file.
00001 #include "board.h"
00002 #include "lcd.h"
00003 #include "lcdfonts.c"
00004 
00011 code const unsigned char lcd_hexchars[17] = "0123456789abcdef";
00012 unsigned char PlayerTaskHandler();
00013 
00017 void LcdPutChar(char c) {
00018   //PlayerTaskHandler();
00019   WaitOutDelay();
00020   LCD_RS = LCD_DATA_MODE;
00021   LCD_DATABUS = c;
00022   LCD_ENABLE = 1; /* Rising edge */
00023   LCD_ENABLE = 1; /* Keep high...*/
00024   LCD_ENABLE = 0; /* Falling edge */
00025   InitiateDelay(84);
00026 }
00027 
00028 
00029 
00030 
00034 void LcdPutCommand(char cmd){
00035   //PlayerTaskHandler();
00036   WaitOutDelay();
00037   LCD_RS = LCD_COMMAND_MODE;
00038   LCD_DATABUS = cmd;
00039   LCD_ENABLE = 1; /* Rising edge */
00040   LCD_ENABLE = 1; /* Keep High */
00041   LCD_ENABLE = 0; /* Falling edge */
00042   InitiateDelay(84);
00043 }
00044 
00045 
00046 
00047 void LcdSelectFont(ROM_CHAR_PTR font){
00048   static ROM_CHAR_PTR loadedFont = 0;
00049   if (loadedFont != font){
00050     loadedFont=font;
00051     
00052     LcdLocateCG();
00053     LcdPutConstantString(font);  
00054     LcdLocateHome();
00055    
00056   }
00057 }
00058 
00060 void LcdReset(){
00061 
00062 
00063   LCD_ENABLE = 0;
00064   InitiateDelay(0); /* Initialize the delay system */
00065 
00066   LcdPutCommand(56); /* 8 data bits, 2 lines */
00067   InitiateDelay(139);
00068 
00069   WaitOutDelay();
00070   LcdPutCommand(56); /* Command 2 times "just in case" */
00071   InitiateDelay(139);
00072 
00073   WaitOutDelay();
00074   LcdPutCommand(12); /* Panel on, no cursor */
00075   InitiateDelay(139);
00076 
00077   WaitOutDelay();
00078   LcdPutCommand(1);  /* Clear screen */
00079   InitiateDelay(2530); /* Start a 1.53 ms delay */
00080 
00081   LcdSelectFont(lcdFont_barchars);
00082 
00083 }
00084 
00085 
00086 
00093 void LcdPutString (char *str) {
00094   while (*str) {
00095     LcdPutChar (*str++);
00096   }
00097 }
00098 
00099 
00100 
00106 void LcdPutConstantString(char code *str){
00107   while (*str)
00108     {
00109       LcdPutChar (*str++);
00110     }
00111 }
00112 
00113 
00114 
00115 void LcdFadeIn(){
00116   unsigned char c,d;
00117   for (c=0; c<254; c++){
00118     for (d=252; d; d-=2){
00119       if (d>c){
00120         LcdPutCommand (8);
00121         InitiateDelay(40);
00122       }else{
00123         LcdPutCommand (12);
00124         InitiateDelay(40);
00125       }
00126     }
00127   }
00128   LcdPutCommand(12);
00129   InitiateDelay(40);
00130 }
00131 
00132 void LcdFadeOut(){
00133   unsigned char c,d;
00134   for (c=0; c<254; c++){
00135     for (d=252; d; d-=2){
00136       if (d<c){
00137         LcdPutCommand (8);
00138         InitiateDelay(40);
00139       }else{
00140         LcdPutCommand (12);
00141         InitiateDelay(40);
00142       }
00143     }
00144   }
00145   LcdPutCommand(8);
00146   InitiateDelay(40);
00147 }
00148 
00149 
00151 void LcdSplashScreen(){
00152     
00153   LcdReset();
00154  
00155   LcdSelectFont(lcdFont_vlsichars);
00156   
00157   LcdLocateHome();
00158   
00159   LcdPutChar(0);
00160   LcdPutConstantString("\1\2\3 Sol");
00161   LcdLocateLine2();
00162   LcdPutConstantString("ution Oy");
00163 
00164  
00165   LcdFadeIn();
00166   LcdFadeOut();
00167  
00168 }
00169 
00170 
00172 void LcdPutHex16 (unsigned int value){
00173   LcdPutChar(lcd_hexchars[value>>12]);
00174   LcdPutChar(lcd_hexchars[(value>>8)&0xf]);
00175   LcdPutChar(lcd_hexchars[(value>>4)&0xf]);
00176   LcdPutChar(lcd_hexchars[(value)&0xf]);
00177 }
00178 
00179 
00181 void LcdPutHex8 (unsigned char value){
00182 
00183   LcdPutChar(lcd_hexchars[(value>>4)&0xf]);
00184   LcdPutChar(lcd_hexchars[(value)&0xf]);
00185 }
00186 
00187 
00189 unsigned char LcdPrintGenericResult (unsigned char errorlevel){
00190   if (!errorlevel){        
00191     LcdPutConstantString ("OK      ");
00192   }else{
00193     LcdPutConstantString ("Error ");
00194     LcdPutChar(lcd_hexchars[(errorlevel>>4)&0xf]);
00195     LcdPutChar(lcd_hexchars[(errorlevel)&0xf]);
00196     ConsoleWrite ("\rSystem error ");
00197     ConsolePutHex8 (errorlevel);
00198     ConsoleWrite (": \"");
00199 
00200     switch (errorlevel){
00201     case 0x01: ConsoleWrite ("No storage"); break;
00202     case 0x02: ConsoleWrite ("Storage powerup"); break;
00203     case 0x03: ConsoleWrite ("Storage init"); break;
00204     case 0x04: ConsoleWrite ("No storage ID"); break;
00205     case 0x05: ConsoleWrite ("Datablock header"); break;
00206     case 0x06: ConsoleWrite ("Storage Data reply failed"); break;
00207     case 0x07: ConsoleWrite ("Generic Storage Command"); break;
00208     case 0x08: ConsoleWrite ("Sector 0 not in recognized format"); break;
00209     case 0x09: ConsoleWrite ("No active partition"); break;
00210     case 0x0a: ConsoleWrite ("Filesystem load"); break;
00211     case 0x0b: ConsoleWrite ("No root directory"); break;
00212     case 0x0c: ConsoleWrite ("File not found"); break;
00213 
00214     };
00215     ConsoleWrite("\" failure.\r");
00216     
00217 
00218     Delay(500);
00219   }
00220   return errorlevel;
00221 }
00222 
00223 
00225 void LcdPutUInt(unsigned long value){
00226   xdata unsigned char valueString[10];
00227   char c;
00228   for (c=0; c<10; c++){
00229     valueString[c]=value % 10;
00230     value = value / 10;
00231   }
00232   c=9;
00233   while ((valueString[c]==0) && (c!=0))
00234     c--;
00235   for (;c!=0;c--)
00236     LcdPutChar('0'+valueString[c]);
00237   LcdPutChar('0'+valueString[0]);
00238 
00239 }
00240 
00241 
00242 
00243 

All software copyright 2000-2004 VLSI Solution OY. Redistribution of these software modules is limited to VLSI Solution Oy chip promotional use only. Free or commercial use of these software modules in MP3 players is ok if the product includes chip(s) from VLSI. You can request the complete (compilable) package from mp3@vlsi.fi. This exampe code is provided with good faith to assist You in code development, but under no circumstances will VLSI offer any guarantees on the usability or functionality of any example software or its fitness for any purpose.