void lcd_setup_for_data(LCD_dev_info_t * dev)
{
	/* lcd_enable_ce(false); */

	lcd_ResetStartAddr(dev);

	/* start writing again */
	WRITE_LCD_INDEX(LCD_OUT(0x0022));

}
Пример #2
0
void main() {
unsigned int hold;

char txt[7];

Lcd_Init();

TRISD = 0x00; //PORTB as output
TRISA = 0xFF; //PORTA as input
ADCON1 = 0x0E; // Set AN0 channel pin as analog
CMCON |= 7; // Disable comparators
//ADCON0 = 0b00000000;
//ADCON1 = 0b00001110;
//ADCON2 = 0b00001000;
//ADCON0.ADON = 0x01;
ADC_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);


while (1){
//ADCON0.GO_DONE=1;
//while(ADCON0.GO_DONE!=0);
//hold = ((unsigned int)ADRESH)<<8|(ADRESL);
hold = ADC_READ(0);

LCD_Chr(1,1,5*hold/1024+48);
LCD_Chr(1,2,46);
LCD_Chr(1,3,(50*hold/1024)%10+48);
LCD_Chr(1,4,(20*hold/41)%10+48); //20/41 =~ 500/1024
LCD_Chr(1,5,86);
inttostr(hold,txt);
LCD_OUT(2,0,TXT);
//IntToStr(hold, txt);

//Lcd_Out(1,1,txt);

delay_ms(180);

}
}
void lcd_ResetStartAddr(LCD_dev_info_t * dev)
{
	/* set Column Start/End address */
	WRITE_LCD_INDEX(LCD_OUT(0x02));
	WRITE_LCD_PARAM(LCD_OUT((dev->col_start >> 8) & 0x00FF));	/* Display start column (ms addr) */
	WRITE_LCD_INDEX(LCD_OUT(0x03));
	WRITE_LCD_PARAM(LCD_OUT(dev->col_start & 0x00FF));	/*            (ls addr) */
	WRITE_LCD_INDEX(LCD_OUT(0x04));
	WRITE_LCD_PARAM(LCD_OUT((dev->col_end >> 8) & 0x00FF));	/* Display end column  (ms addr) */
	WRITE_LCD_INDEX(LCD_OUT(0x05));
	WRITE_LCD_PARAM(LCD_OUT(dev->col_end & 0x00FF));	/*            (ls addr) */

	/* set Row Start/End address */
	WRITE_LCD_INDEX(LCD_OUT(0x06));
	WRITE_LCD_PARAM(LCD_OUT((dev->row_start >> 8) & 0x00FF));	/* Display start row   (ms addr) */
	WRITE_LCD_INDEX(LCD_OUT(0x07));
	WRITE_LCD_PARAM(LCD_OUT(dev->row_start & 0x00FF));	/*            (ls addr) */
	WRITE_LCD_INDEX(LCD_OUT(0x08));
	WRITE_LCD_PARAM(LCD_OUT((dev->row_end >> 8) & 0x00FF));	/* Display end row    (ms addr) */
	WRITE_LCD_INDEX(LCD_OUT(0x09));
	WRITE_LCD_PARAM(LCD_OUT(dev->row_end & 0x00FF));	/*            (ls addr) */

	/* Should we write the address column and row address counters as well? */
	/* 0x80, 0x81 and 0x82, 0x83 */
	/* Reset column counter */
	WRITE_LCD_INDEX(LCD_OUT(0x80));
	WRITE_LCD_PARAM(LCD_OUT((dev->col_start >> 8) & 0x00FF));	/* Display end row    (ms addr) */
	WRITE_LCD_INDEX(LCD_OUT(0x81));
	WRITE_LCD_PARAM(LCD_OUT(dev->col_start & 0x00FF));	/*            (ls addr) */

	WRITE_LCD_INDEX(LCD_OUT(0x82));
	WRITE_LCD_PARAM(LCD_OUT((dev->row_start >> 8) & 0x00FF));	/* Display end row    (ms addr) */
	WRITE_LCD_INDEX(LCD_OUT(0x83));
	WRITE_LCD_PARAM(LCD_OUT(dev->row_start & 0x00FF));	/*            (ls addr) */
}
	WRITE_PAUSE,
	WRITE_FULL_SCREEN,
	READ_INDEX,
	READ_DATA,
	STOP
} Init_Cmd_t;

typedef struct {
	Init_Cmd_t type;
	u32 data;
} Init_Seq_t;

/* ---- Private Variables ------------------------------------------------ */
static Init_Seq_t Init_Seq[] = {

	{WRITE_INDEX, LCD_OUT(0x00FF)}, {WRITE_DATA, LCD_OUT(0x0000)},	/* Page 0 select. */

	{WRITE_INDEX, LCD_OUT(0x00E5)}, {WRITE_DATA, LCD_OUT(0x0030)},	/* Power saving registers */
	{WRITE_INDEX, LCD_OUT(0x00E7)}, {WRITE_DATA, LCD_OUT(0x0030)},
	{WRITE_INDEX, LCD_OUT(0x00E8)}, {WRITE_DATA, LCD_OUT(0x0050)},	/* I DONT SEE THIS IN DATASHEET */
	{WRITE_INDEX, LCD_OUT(0x00EC)}, {WRITE_DATA, LCD_OUT(0x0009)},
	{WRITE_INDEX, LCD_OUT(0x00ED)}, {WRITE_DATA, LCD_OUT(0x006C)},

	{WRITE_INDEX, LCD_OUT(0x00E2)}, {WRITE_DATA, LCD_OUT(0x0011)},	/* Power control 1 register */

	{WRITE_INDEX, LCD_OUT(0x0016)}, {WRITE_DATA, LCD_OUT(0x0018)},	/* Memory access control */
	{WRITE_INDEX, LCD_OUT(0x0017)}, {WRITE_DATA, LCD_OUT(0x0060)},	/* COLMOD control color=18bit per pixel */
	{WRITE_INDEX, LCD_OUT(0x001A)}, {WRITE_DATA, LCD_OUT(0x0002)},	/* Power control */
	{WRITE_INDEX, LCD_OUT(0x0001)}, {WRITE_DATA, LCD_OUT(0x0002)},	/* Display mode control */

	{WRITE_INDEX, LCD_OUT(0x0023)}, {WRITE_DATA, LCD_OUT(0x0074)},	/* VMF */