/* ** ** Updates area of the display. Writes data from "framebuffer" ** RAM to the lcd display controller RAM. ** ** Arguments Used: ** top top line of area to update. ** bottom bottom line of area to update. ** from MJK-Code ** */ void lcd_update(const unsigned char top, const unsigned char bottom) { unsigned char x; unsigned char y; unsigned char yt; unsigned char yb; unsigned char *colptr; /* setup bytes of range */ yb = bottom >> 3; yt = top >> 3; for(y = yt; y <= yb; y++) { lcd_out_ctl(LCD_SET_PAGE+y,3); /* set page */ // lcd_out_ctl(LCD_SET_COL+LCD_STARTCOL_REVERSE,3); lcd_out_ctl(LCD_SET_COL+0,3); colptr = &l_display_array[y][0]; for (x=0; x < LCD_X_BYTES; x++) { if ( x < LCD_X_BYTES/2 ) lcd_out_dat(*colptr++,1); else lcd_out_dat(*colptr++,2); } } }
/* fills complete area with pattern - direct to LCD-RAM */ void lcd_test(const unsigned char pattern) { unsigned char page, col; for (page=0; page<LCD_Y_BYTES; page++) { lcd_out_ctl(LCD_SET_PAGE+page,3); lcd_out_ctl(LCD_SET_COL+LCD_STARTCOL_REVERSE,3); // ! for (col=0; col<LCD_X_BYTES/2; col++) lcd_out_dat(pattern,3); } }
/* fill buffer and LCD with pattern */ void lcd_fill(const unsigned char pattern) { unsigned char page, col; lcd_init(); lcd_out_ctl(LCD_DISP_OFF,3); for (page=0; page<LCD_Y_BYTES; page++) { for (col=0; col<LCD_X_BYTES; col++) l_display_array[page][col]=pattern; } lcd_update_all(); lcd_out_ctl(LCD_DISP_ON,3); }
/* ** ** routine to initialize the operation of the LCD display subsystem ** */ void lcd_init(void) { //IODIR0 = MR|SHCP|DS|STCP1|STCP2; //IOSET0 = MR; //GPIO_SetBits(GPIOA,GPIO_Pin_15); lcd_out_ctl(0,3); lcd_out_ctl(LCD_RESET,3); //delay_ms(1);//3 lcd_out_ctl(LCD_DISP_ON,3); lcd_out_ctl(LCD_SET_ADC_NOR,3); // ! lcd_out_ctl(LCD_SET_LINE+16,3); lcd_out_ctl(LCD_SET_PAGE+0,3); lcd_out_ctl(LCD_SET_COL,3); /* lcd_out_ctl(0,3); lcd_out_ctl(LCD_RESET,3); lcd_out_ctl(LCD_DISP_ON,3); lcd_out_ctl(LCD_SET_ADC_REV,3); // ! lcd_out_ctl(LCD_SET_LINE+0,3); lcd_out_ctl(LCD_SET_PAGE+0,3); lcd_out_ctl(LCD_SET_COL+LCD_STARTCOL_REVERSE,3); */ }
/* ** ** routine to initialize the operation of the LCD display subsystem ** */ void lcd_init(void) { LCDDATADDR = 0xff; /* all output */ LCDCTRLDDR |= ( (1<<LCDCMDPIN) | (1<<LCDE1PIN) | (1<<LCDE2PIN) ); lcd_out_ctl(0,3); lcd_out_ctl(LCD_RESET,3); lcd_long_delay(); lcd_out_ctl(LCD_DISP_ON,3); lcd_out_ctl(LCD_SET_ADC_REV,3); // ! lcd_out_ctl(LCD_SET_LINE+0,3); lcd_out_ctl(LCD_SET_PAGE+0,3); lcd_out_ctl(LCD_SET_COL+LCD_STARTCOL_REVERSE,3); }
/* Close Disp -- add by nathan */ void lcd_mute(void) { lcd_out_ctl(0,3); lcd_out_ctl(LCD_RESET,3); //delay_ms(1);//3 lcd_out_ctl(LCD_SET_ADC_NOR,3); // ! lcd_out_ctl(LCD_SET_LINE+16,3); lcd_out_ctl(LCD_SET_PAGE+0,3); lcd_out_ctl(LCD_SET_COL,3); lcd_out_ctl(LCD_DISP_OFF,3); ControlBitShift(RST0|0x0|0x20); // Q6 背光 Q5 灯 }
/* raw write to LCD-RAM - used for debugging */ void lcd_raw(const unsigned char page, const unsigned char col, const unsigned char nctrl, const unsigned char pattern) { lcd_out_ctl(LCD_SET_PAGE+page,nctrl); lcd_out_ctl(LCD_SET_COL+col,nctrl); lcd_out_dat(pattern,nctrl); }