Mathieu: Another LCD backpack

From DP

Revision as of 09:08, 7 October 2010 by Ian (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation , search

Contents

Protocol

0x00 reset LCD

i initialize LCD

v version string

c contrast

Requires 3 bytes.

Byte one is the contrast, default 0x24, only that seems to have effect on current LCD.

  • VOLCTR - contrast/brightness for EPSON
    • B1 - VOLCTR 1 contrast setting
    • B2 - VOLCTR 2 internal resistor ratio (no effect)
  • SETCON - contrast/brightness for PHILLIPS
    • B3 - no effect

b set bounding box

           case 'v': //VERSION:
                 if( mUSBUSARTIsTxTrfReady() ){ //it's always ready, but this could be done better
                   b[0]='V';//answer OK
                   b[1]='1';
                   b[2]='0';//FIRMWARE_VERSION_H;
                   b[3]='0';//FIRMWARE_VERSION_L;
                   putUnsignedCharArrayUsbUsart(b,4);
               }               
               break;
           case 'c'://CONTRAST:
               b[0]=waitforbyte();
               b[1]=waitforbyte();
               b[2]=waitforbyte();
               LCD_command(VOLCTR);      // electronic volume, this is the contrast/brightness(EPSON)
               LCD_data(b[0]);       // volume (contrast) setting - fine tuning, original
               LCD_data(b[1]);       // internal resistor ratio - coarse adjustment
               LCD_command(SETCON);    //Set Contrast(PHILLIPS)
               LCD_data(b[2]);   
               break;
           case 'b'://SETBOX:
               xs=waitforbyte();
               ys=waitforbyte();
               xe=waitforbyte();
               ye=waitforbyte();
               fillbox_current();
               break;
           case 'p'://DATA:
               //calculate the number of pixels in the current box
               //loop and push the pixels
               for(i=0; i<ENDPAGE; i++){
                   for(m=0;m<ENDCOL;m=m+2){
                       color=waitforbyte();
                       color=color<<8;
      
                       color|=(waitforbyte()&0x00ff);
      
                       LCD_data((color>>4)&0x00FF);
                       LCD_data(((color&0x0F)<<4)|(color>>8));
                       LCD_data(color&0x0FF);
                   }   
               }
               break;   
           case 't'://TEST
               while(1){
                   //draw screen with colors from the clr pallet...
                   for(j=0;j<3;j++){
                       if(checkforbyte()) goto test_end;//exit on any char
                       fillbox_whole();
                       for(i=0; i<ENDPAGE; i++){
                           for(m=0;m<ENDCOL;m=m+2){
                               //pset(clr[j],i,m);
                               #define color clr[j]
                               LCD_data((color>>4)&0x00FF);
                               LCD_data(((color&0x0F)<<4)|(color>>8));
                               LCD_data(color&0x0FF);      // nop(EPSON)       
                               #undef color
                           }
                       }
                       //for (k = 0; k < 300000; k++);    //delay_ms(100);
                   }
              
               }   

test_end:

               break;   
           case 'T'://TEST