LCD shield and/or LCD serial backpack

Here's a basic code to display text, lines and dots. Original c code came from Massimo. I already posted it to the forum, but thing get easily lost here. i know it should be up on the playground. but me too got distracted from it by other projects. The circuit i use never got updated, like i planned, using a proper 3,3v regulator for the display. i'm doing other stuff lately with arduino running on 3.3v so i might get back to it.

here the lazy circuit NOKIADISPLAYvsARDUINO | display taken from a nokia 3310 whic… | Flickr using 4 diodes to reduce voltage to appr. 3.2v and voltage dividers for communication.
here's a basic version of the code [again here, and not on the playground, so maybe we could clean it up build a library from it together]:

//  arduino pinout for LCD.
int CONTROL_LED=12;
int LCD_POWER_PIN      =       11;
int LCD_DC_PIN         =        2; //  PB0  4  Data Command
int LCD_CE_PIN         =        3; //  PB2  5  /CS   active low chip select ??
int SPI_MOSI_PIN       =        4; //  PB3  3  Serial   line
int LCD_RST_PIN        =        5; //  PB4  8   /RES RESET
int SPI_CLK_PIN        =        6; //  PB5  2  CLOCK


#define LCD_X_RES                  84
#define LCD_Y_RES                  48



#define LCD_CACHE_SIZE             ((LCD_X_RES * LCD_Y_RES) / 8)

/*--------------------------------------------------------------------------------------------------
 Type definitions
 --------------------------------------------------------------------------------------------------*/



#define    LCD_CMD  0
#define    LCD_DATA  1

#define    PIXEL_OFF   0
#define    PIXEL_ON    1
#define    PIXEL_XOR   2

#define    FONT_1X  1
#define    FONT_2X  2


typedef unsigned int               word;

// Public function prototypes

void LcdInit       ( void );
void LcdClear      ( void );
void LcdUpdate     ( void );
void LcdGotoXY     ( byte x, byte y );
void LcdChr        ( int size, byte ch );
void LcdStr        ( int size, char *dataPtr );
void LcdPixel      ( byte x, byte y, int mode );
void LcdLine       ( byte x1, byte y1, byte x2, byte y2, int mode );
void LcdSendCmd ( byte data, int cd );


// This table defines the standard ASCII characters in a 5x7 dot format.


// Global Variables

byte  LcdCache [ LCD_CACHE_SIZE ];

int   LcdCacheIdx;
int   LoWaterMark;

int   HiWaterMark;
boolean  UpdateLcd;
 char sign;

// This table defines the standard ASCII characters in a 5x7 dot format.
static const byte FontLookup [][5] =
{
  { 
    0x7E, 0x11, 0x11, 0x11, 0x7E     }
  ,   // A
  { 
    0x7F, 0x49, 0x49, 0x49, 0x36     }
  ,   // B
  { 
    0x3E, 0x41, 0x41, 0x41, 0x22     }
  ,   // C
  { 
    0x7F, 0x41, 0x41, 0x22, 0x1C     }
  ,   // D
  { 
    0x7F, 0x49, 0x49, 0x49, 0x41     }
  ,   // E
  { 
    0x7F, 0x09, 0x09, 0x09, 0x01     }
  ,   // F
  { 
    0x3E, 0x41, 0x49, 0x49, 0x7A     }
  ,   // G
  { 
    0x7F, 0x08, 0x08, 0x08, 0x7F     }
  ,   // H
  { 
    0x00, 0x41, 0x7F, 0x41, 0x00     }
  ,   // I
  { 
    0x20, 0x40, 0x41, 0x3F, 0x01     }
  ,   // J
  { 
    0x7F, 0x08, 0x14, 0x22, 0x41     }
  ,   // K
  { 
    0x7F, 0x40, 0x40, 0x40, 0x40     }
  ,   // L
  { 
    0x7F, 0x02, 0x0C, 0x02, 0x7F     }
  ,   // M
  { 
    0x7F, 0x04, 0x08, 0x10, 0x7F     }
  ,   // N
  { 
    0x3E, 0x41, 0x41, 0x41, 0x3E     }
     // O

  ,   // Y
  { 
    0x61, 0x51, 0x49, 0x45, 0x43     }
    //Z
};
/*--------------------------------------------------------------------------------------------------
 
 Name         :  LcdSendCmd
 
 Description  :  Sends data to display controller.
 
 Argument(s)  :  data -> Data to be sent
 cd   -> Command or data (see/use enum)
 
 Return value :  None.
 
 --------------------------------------------------------------------------------------------------*/
void LcdSendCmd ( byte data, int cd )
{


  byte i = 8;

  byte mask;



  //

  if ( cd == LCD_DATA )
  {
    digitalWrite(LCD_DC_PIN,HIGH);
  }
  else
  {
    digitalWrite(LCD_DC_PIN,LOW) ;
  }




  while(0 < i) {

    mask = 0x01 << --i; // get bitmask and move to least significant bit
    // cause edge to fall
    digitalWrite(SPI_CLK_PIN,LOW); // tick
    delayMicroseconds(400);
    // set out byte
    if(data & mask){ // choose bit

      digitalWrite(SPI_MOSI_PIN,HIGH); // send 1

    }
    else{

      digitalWrite(SPI_MOSI_PIN,LOW); // send 0

    }

    // cause edge to rise

    digitalWrite(SPI_CLK_PIN,HIGH); // tock
    delayMicroseconds(400);





  }


}

//end of part 1