/* Modified by Lauren version 0.3 Any suggestions are welcome. Editors : Lauren from DFRobot Stanley Huang Date : Feb. 11, 2012 * Added LCD_putchar for basic console display * Have the back light under control. * Update the library and sketch to compatible with IDE V1.0 and earlier */ #include "LCD4884.h" #include "font_6x8.h" #include "font_big.h" #if defined(ARDUINO) && ARDUINO >= 100 #include "Arduino.h" #else #include "WProgram.h" #include "WConstants.h" #endif extern "C" { #include #include } #define NUM_COL 14 #define NUM_ROW 5 LCD4884::LCD4884():prev_char(0),char_mode(MENU_NORMAL) {}; LCD4884 lcd = LCD4884(); void LCD4884::backlight(unsigned char dat) { if(dat==1) digitalWrite(LCD_BL,HIGH); else digitalWrite(LCD_BL,LOW); } void LCD4884::LCD_init(void) { for(unsigned char i = 2; i < 8; i++) { pinMode(i,OUTPUT); digitalWrite(i,LOW); } digitalWrite(LCD_RST,LOW); delayMicroseconds(1); digitalWrite(LCD_RST,HIGH); digitalWrite(SPI_CS,LOW); delayMicroseconds(1); digitalWrite(SPI_CS,HIGH); delayMicroseconds(1); digitalWrite(LCD_BL,HIGH); LCD_write_byte(0x21, 0); LCD_write_byte(0xc0, 0); LCD_write_byte(0x06, 0); LCD_write_byte(0x13, 0); LCD_write_byte(0x20, 0); LCD_clear(); LCD_write_byte(0x0c, 0); digitalWrite(SPI_CS,LOW); } void LCD4884::LCD_write_byte(unsigned char dat, unsigned char dat_type) { digitalWrite(SPI_CS,LOW); if (dat_type == 0) digitalWrite(LCD_DC,LOW); else digitalWrite(LCD_DC,HIGH); for(unsigned char i=0; i<8; i++) { if(dat & 0x80) { digitalWrite(SPI_MOSI,HIGH); } else { digitalWrite(SPI_MOSI,LOW); } digitalWrite(SPI_SCK,LOW); dat = dat << 1; digitalWrite(SPI_SCK,HIGH); } digitalWrite(SPI_CS,HIGH); } void LCD4884::LCD_draw_bmp_pixel(unsigned char X,unsigned char Y,unsigned char *map, unsigned char Pix_x,unsigned char Pix_y) { unsigned int i,n; unsigned char row; if (Pix_y%8==0) row=Pix_y/8; else row=Pix_y/8+1; for (n=0;n