Esempio n. 1
0
void 
LCDI2C4Bit::init( void ) 
{
  lcd_mcp.init();
  lcd_in_use_flag = 1;    // set a mutex so that the IR isr won't do anything while we are doing lcd i/o
  dataPlusMask = 0;
  lcd_mcp.set(MCP_REG_IOCON, 0x0C);
  delay(50);
  lcd_mcp.set(MCP_REG_IODIR, myInputKeysMask);
  delay(50);
  lcd_mcp.set(MCP_REG_GPPU, myInputKeysMask);
  delay(50);

  SendToLCD(0x03); 
  delay(5);

  SendToLCD(0x03);
  delayMicroseconds(100);

  SendToLCD(0x03);
  delay(5);

  SendToLCD(0x02);
  WriteLCDByte(0x28);
  WriteLCDByte(0x08);
  WriteLCDByte(0x0C); // turn on, cursor off, no blinking
  delayMicroseconds(60);

  WriteLCDByte(0x01); // clear display
  delay(5);  

  lcd_in_use_flag = 0;    // clear that mutex (so that the IR isr CAN now do things)
}
Esempio n. 2
0
void InitLCD()
{
  // Software reset
  SendToLCD(0x0001); 
  // Sleep out
  SendToLCD(0x0011);
  // Partial off
  SendToLCD(0x0013);
  // Display inversion off
  // Memory data access control
  SendToLCD(0x0036);
    SendToLCD(0x01C0);
  // Scroll start address of RAM
  //SendToLCD(0x0037);
  //  SendToLCD(0x0100);
  //  SendToLCD(0x0100);
  // Idle mode off
  SendToLCD(0x0038);
  // Interface pixel format
  SendToLCD(0x003A); 
    SendToLCD(0x0105);
  // Display on
  SendToLCD(0x0029);  
  
}
Esempio n. 3
0
void 
LCDI2C4Bit::WriteLCDByte( uint8_t bdata ) 
{
  lcd_in_use_flag = 1;    // set a mutex so that the IR isr won't do anything while we are doing lcd i/o

  SendToLCD( bdata >> 4 );
  SendToLCD( bdata & 0x0F );

  lcd_in_use_flag = 0;    // clear that mutex (so that the IR isr CAN now do things)
}
Esempio n. 4
0
void DrawFillRectangle(char XRect,char YRect,char WidthRect,char HeightRect,unsigned long ColorRect)
{
  // Column address set
  SendToLCD(0x2A);
    SendToLCD(0x100+XRect); 
    SendToLCD(0x100+XRect+WidthRect-1); 
  // Row address set
  SendToLCD(0x2B);
    SendToLCD(0x100+YRect);
    SendToLCD(0x100+YRect+HeightRect-1); 
  // Memory write
  //Convert 24-bit color to 16-bit color
  char b = ColorRect;
  char g = ColorRect>>8;
  char r = ColorRect>>16;
  unsigned int i,CountPixels;
  SendToLCD(0x2C);
  CountPixels=(HeightRect)*(WidthRect);
  for (i=1;i<=CountPixels;i++){
        SendToLCD(0x0100+((r&0xF8)|(g>>5)));
        SendToLCD(0x0100+(((g<<3)&0xE0)|(b>>3))); 
  }
}