Example #1
0
/**
 * \brief Read data from LCD Register.
 *
 * \param uc_reg register address.
 *
 * \return register value.
 */
static uint16_t ili9325_read_register(uint8_t uc_reg)
{
	LCD_IR(0);
	LCD_IR(uc_reg);

	return ili9325_lcd_get_16();
}
Example #2
0
/**
 * \brief Write data to LCD Register.
 *
 * \param uc_reg register address.
 * \param us_data data to be written.
 */
static void ili9325_write_register(uint8_t uc_reg, uint16_t us_data)
{
	LCD_IR(0);
	LCD_IR(uc_reg);
	LCD_WD((us_data >> 8) & 0xFF);
	LCD_WD(us_data & 0xFF);
}
Example #3
0
File: LCD.c Project: LouizLai/mg
char LCD_Busy()
{
	char data;

	//D4 - D7 = PORTA 4-7
	//RS(PC7) = 0, RW(PC6) = 1, E(PC0)
	LCD_IR();
	LCD_R();
	
	//Tu beremo zgornje 4 bite
	LCD_E_set();
	asm("nop");
	asm("nop");
	data = LCD_DataPin; //preberi zgornje stiri bite
	LCD_E_clr();
	asm("nop");
	asm("nop");
	
	//Tu beremo spodnje 4 bite (samo da jih v bistvu ignoriramo)
	LCD_E_set();
	asm("nop");
	asm("nop");
	LCD_E_clr();
	
	if (data & 0x80)	return 1;	// if busy flag is 1, its busy
	else return 0;	// LCD is ready to do your bidding
}
Example #4
0
File: LCD.c Project: LouizLai/mg
//************************************
// Method:    LCD_Write
// FullName:  LCD_Write
// Access:    public 
// Returns:   void
// Qualifier: Funkcija vpiše podatek v LCD
// Parameter: enum LCD_Register reg
// Parameter: char data
//************************************
void LCD_Write(enum LCD_Register reg, char data)
{
	char temp;
	
	LCD_BusyWait(1000);
	
	//D4 - D7 = PORTA 4-7

	if (reg == Instr) LCD_IR(); // piši v inštrukcijski register
	else LCD_DR(); // piši v podatkovni register
	
	LCD_W();
	LCD_E_set();
	
	// write high nibble
	temp = data>>4;	 // dddd 0000 -> 0000 dddd
	LCD_Write_Nibble(temp);

	LCD_E_clr();
	asm("nop");
	asm("nop");
	
	LCD_E_set();
	
	// write low nibble
	temp = data & 0x0F;	 //  0000 dddd
	LCD_Write_Nibble(temp);
	
	LCD_E_clr();
}
Example #5
0
/**
 * \brief Draw a bitmap image.
 * Expected file format is 320x240, 24 bits, RGB888.
 *
 * \param bmpImage Pointer to the bmp file image.
 */
static void gfx_draw_bmpfile(const uint8_t *bmpImage)
{
	struct bmpfile_header *bmp_header;
	uint32_t length;
	uint32_t i = 0;
	uint32_t offset;

	bmp_header = (struct bmpfile_header *) bmpImage;
	length = bmp_header->height * bmp_header->width * 3;
	offset = sizeof(struct bmpfile_header);

	if (ili93xx_device_type() == DEVICE_TYPE_ILI9325) {
		ili93xx_set_cursor_position(0, 0);

		/* Prepare to write in GRAM. */
		LCD_IR(0);
		LCD_IR(ILI9325_GRAM_DATA_REG);
		for (i = offset; i < length; i += 3) {
			/* Invert red and blue. */
			LCD_WD(bmpImage[i + 2]);
			LCD_WD(bmpImage[i + 1]);
			LCD_WD(bmpImage[i]);
		}
	}
	else if (ili93xx_device_type() == DEVICE_TYPE_ILI9341) {
		ili93xx_set_window(0, 0, bmp_header->width - 15, bmp_header->height);
		LCD_IR(ILI9341_CMD_MEMORY_WRITE); /* memory write command (R2Ch) */
		LCD_IR(ILI9341_CMD_WRITE_MEMORY_CONTINUE);

		/* The original image is mirrored. */
		for (i = bmp_header->height - 1 ; (i * bmp_header->width * 3) > offset ; i -= 1)
			for (uint16_t j = 45; j < (bmp_header->width * 3); j += 3) {
				LCD_WD(bmpImage[i * bmp_header->width * 3 + j + 2]);
				LCD_WD(bmpImage[i * bmp_header->width * 3 + j + 1]);
				LCD_WD(bmpImage[i * bmp_header->width * 3 + j]);
			}
	}
}
Example #6
0
File: LCD.c Project: LouizLai/mg
//************************************
// Method:    LCD_Init
// FullName:  LCD_Init
// Access:    public 
// Returns:   void
// Qualifier: Funkcija inicializira LCD
//************************************
void LCD_Init()
{
	
	//nastavi ustrezne pine kot izhode
	LCD_E_Dir |= LCD_E_Mask;
	LCD_RS_Dir |= LCD_RS_Mask;
	LCD_RW_Dir |= LCD_RW_Mask;
	LCD_DataDir |= LCD_DataMask;
	LCD_Backlight_Dir |= LCD_Backlight_Mask;
	
	LCD_Backlight_ON();
	_delay_ms(15);
	LCD_IR();
	LCD_W();
	LCD_E_set();
	LCD_Write_Nibble(3);
	LCD_E_clr();
	_delay_ms(5);
	LCD_E_set();
	LCD_Write_Nibble(3);
	LCD_E_clr();
	_delay_ms(100);
	LCD_E_set();
	LCD_Write_Nibble(3);
	LCD_E_clr();
	
	LCD_BusyWait(1000);
	LCD_E_set();
	LCD_Write_Nibble(2);
	LCD_E_clr();
	
	LCD_Write(Instr,0x28); //4-bit interface (bit4)
	LCD_Write(Instr,0x08);
	LCD_Write(Instr,0x01);
	LCD_Write(Instr,0x06); //B1=1(Left to Right?) B0=0(no display shift)
	
	LCD_Write(Instr,0x0F); //Display, cursor, blink, all on. 
}
Example #7
0
/**
 * \brief Prepare to read GRAM data.
 */
static void ili9325_read_ram_prepare(void)
{
	LCD_IR(0);
	LCD_IR(ILI9325_GRAM_DATA_REG); /* Write Data to GRAM (R22h) */
}