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

display.c

Go to the documentation of this file.
00001 
00005 #include "display.h"
00006 #include "lcd.h"
00007 #include "board.h"
00008 #include "string.h"
00009 #include "ui.h"
00010 #include "vs10xx.h"
00011 
00012 xdata unsigned char displayTimeCount;
00013 xdata struct displayItemStruct {
00014   char style;
00015   char title[12];
00016   char text[12];
00017 } displayItem[DISPLAY_ITEMS];
00018 
00019 void SetDisplayTitle(char n, char *s){
00020   char c; 
00021   for (c=0; c<12; c++) displayItem[n].title[c] = s[c];
00022 }
00023 
00024 void SetDisplaySignedValue(char n, int i){
00025   bit negative;
00026   char c;
00027   negative = 0;
00028   if (i<0){
00029     negative = 1;
00030     i = -i;
00031   }
00032   for (c=0; c<12; c++) displayItem[n].text[c] = ' ';
00033   c=2;
00034   if (i>99) c=3;
00035   if (i>999) c=6;
00036   do {
00037     displayItem[n].text[c--] = '0' + (i % 10);
00038     i /= 10; 
00039   }  while (i);
00040   if (negative){
00041     displayItem[n].text[c] = '-';
00042   } else {
00043     displayItem[n].text[c] = '+';
00044   }      
00045 }
00046 
00047 void SetDisplayText(char n, char *s){
00048   char c;
00049   for (c=0; c<12; c++) displayItem[n].text[c] = s[c];
00050 }
00051 
00052 void SetDisplayPercent (char n, char displayValue){
00053     unsigned char temp,majorp, minorp;
00054     if (displayValue>100){
00055       displayValue=100;
00056     }
00057     majorp = (displayValue-4) / 12;
00058     minorp = ((displayValue-4) % 12) >> 1;
00059     for (temp=0; temp<8; temp++){
00060       if (majorp>temp){
00061         displayItem[n].text[temp] = 4;
00062       }else{
00063         if (majorp<temp){
00064           displayItem[n].text[temp] = ' ';
00065         }else{
00066           switch(minorp){
00067           case 0:
00068             displayItem[n].text[temp] = ' ';
00069             break;
00070           case 1:
00071             displayItem[n].text[temp] = 0;
00072             break;
00073           case 2:
00074             displayItem[n].text[temp] = 1;
00075             break;
00076           case 3:
00077             displayItem[n].text[temp] = 2;
00078             break;
00079           case 4:
00080             displayItem[n].text[temp] = 3;
00081             break;
00082           case 5:
00083             displayItem[n].text[temp] = 4;
00084             break;
00085           }//switch
00086         }
00087       }
00088     }       
00089     displayItem[n].text[8] = ' ';
00090     displayItem[n].text[9] = ' ';
00091     if (displayValue>99) displayItem[n].text[9]='1';
00092     displayItem[n].text[10] = ' ';
00093     if (displayValue>9) displayItem[n].text[10]='0' + ((displayValue / 10) % 10);
00094     displayItem[n].text[11]='0' + (displayValue % 10);
00095     
00096 }
00097 
00098 
00099 
00100 extern bit lyricsDisplay;
00101 extern xdata unsigned char lyrics[40];
00102 unsigned char PlayerTaskHandler();
00103 
00104 
00106 void UpdateDisplay(unsigned char n){
00107   char i;
00108   static xdata char poly[16];
00109   
00110   PlayerTaskHandler();
00111   LcdLocateHome();
00112  
00113   if (n<1) {
00114 #if 0
00115     LcdPutConstantString("  *VS1103*  ");
00116 #else
00117     for (i=0; i<15; i++){
00118       unsigned char nn;
00119       temp.i = 1641 + i*19;
00120       Mp3WriteRegister(SCI_WRAMADDR, temp.b.b1, temp.b.b0);
00121       nn = Mp3ReadRegister(SCI_WRAM);
00122       if (nn){  
00123         if (nn>poly[i]){
00124           LcdPutChar(0xff);
00125         } else {
00126           LcdPutChar('0'+((i+1)%10));
00127         }      
00128       }else{
00129         LcdPutChar(' ');
00130       }
00131       poly[i]=nn;
00132     }   
00133     LcdPutConstantString("    ");
00134 #endif    
00135   }else{
00136     for (i=0; i<12; i++){
00137       PlayerTaskHandler();
00138       LcdPutChar(displayItem[n-1].title[i]);
00139     }
00140   }
00141 
00142   if (displayTimeCount & 0x10){
00143     //LcdPutConstantString("\xa2\xff");
00144     LcdPutConstantString(" \xff");
00145   }else{
00146     //LcdPutConstantString("\xa2 ");
00147     LcdPutConstantString("  ");
00148   }
00149 
00150   for (i=0; i<12; i++){
00151     PlayerTaskHandler();
00152     LcdPutChar(displayItem[n].title[i]);
00153   }
00154   //LcdPutConstantString(" \x7c");
00155   LcdPutConstantString("  ");
00156 
00157   if (n==0) {
00158     LcdPutConstantString("     ");
00159   }else{
00160     if (n>UI_END_OF_MODES-2) {
00161       LcdPutConstantString("            ");
00162     }else{
00163       for (i=0; i<12; i++){
00164         LcdPutChar(displayItem[n+1].title[i]);
00165       }
00166     }
00167   }
00168 
00169 
00170   PlayerTaskHandler();
00171   LcdLocateLine2();
00172   PlayerTaskHandler();
00173 
00174 
00175   if (lyricsDisplay){
00176     for (i=0; i<40; i++){
00177       PlayerTaskHandler();
00178       LcdPutChar(lyrics[i]);
00179     }
00180   } else {
00181     
00182     if (n<1) {
00183 
00184 
00185 #if 1
00186       LcdPutConstantString("^Channel Activity^ ");
00187 #else
00188     for (i=8; i<16; i++){
00189       unsigned char n;
00190       temp.i = 1641 + i*19;
00191       Mp3WriteRegister(SCI_WRAMADDR, temp.b.b1, temp.b.b0);
00192       n = Mp3ReadRegister(SCI_WRAM);
00193       if (n>poly[i]){
00194         LcdPutChar('0'+((i+1)%10));
00195       }else{
00196         LcdPutChar(' ');
00197       }
00198       poly[i]=n;
00199     }   
00200     LcdPutConstantString("    ");
00201 #endif    
00202 
00203     }else{
00204       for (i=0; i<12; i++){
00205         PlayerTaskHandler();
00206         LcdPutChar(displayItem[n-1].text[i]);
00207       }
00208     }
00209     if (displayTimeCount & 0x10){
00210       //    LcdPutConstantString("\x7c ");
00211       LcdPutConstantString("  ");
00212     }else{
00213       //    LcdPutConstantString("\x7c\xff");
00214       LcdPutConstantString(" \xff");
00215     }
00216     
00217     
00218     
00219     for (i=0; i<12; i++){
00220       PlayerTaskHandler();
00221       LcdPutChar(displayItem[n].text[i]);
00222     }
00223     //LcdPutConstantString(" \xa3");
00224     LcdPutConstantString("  ");
00225     if (n==0) {
00226       LcdPutConstantString("..-->");
00227     }else{
00228       if (n>UI_END_OF_MODES-2) {
00229         LcdPutConstantString("            ");
00230       }else{
00231         for (i=0; i<12; i++){
00232           PlayerTaskHandler();
00233           LcdPutChar(displayItem[n+1].text[i]);
00234         }
00235       }
00236     }
00237   }  
00238 
00239 }

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.