Ejemplo n.º 1
0
void glcd_draw_bitmap(const unsigned char *data)
{

#if 0
	/* Testing purposes only: Writing to the LCD right away (not for AVR) */
	/* Normally, we do not do this, we just write to the screen buffer */
	uint8_t *original_buffer;

	/* Save the location of original screen buffer */
	original_buffer = glcd_buffer_selected;
	
	/* Use bitmap location as screen buffer (this won't work when using AVR8 PGM_P) */
	glcd_select_screen((uint8_t *)data, glcd_bbox_selected);
	
	/* Make sure we write the entre display */
	glcd_bbox_refresh(); 
	glcd_write();
	
	/* Restore the screen buffer back to original */
	glcd_select_screen(original_buffer, glcd_bbox_selected);	
#endif
	
	/* Copy bitmap data to the screen buffer */
#if defined(GLCD_DEVICE_AVR8)
	memcpy_P(glcd_buffer_selected, data, (GLCD_LCD_WIDTH * GLCD_LCD_HEIGHT / 8));
#else
	memcpy(glcd_buffer_selected, data, (GLCD_LCD_WIDTH * GLCD_LCD_HEIGHT / 8));
#endif

	glcd_bbox_refresh(); 
}
Ejemplo n.º 2
0
void glcd_init(void)
{
    /* Initialization of lib */
	glcd_select_screen((uint8_t *)&glcd_buffer,&glcd_bbox);
    /* Initialization of device */
    glcd_init_device();
   	glcd_clear();
}
Ejemplo n.º 3
0
void glcd_init(void)
{

#if defined(GLCD_CONTROLLER_PCD8544)
	/*
	 * Set up SPI (SSP)
	 * Note: Max allowed SPI clock is 4 MHz from datasheet.
	 */

	/* Select SSP/SPI port */
	SSP_IOConfig( CONTROLLER_SPI_PORT_NUMBER );

	/* Initialise SSP/SPI port */
	SSP_Init( CONTROLLER_SPI_PORT_NUMBER );

	/* Above functions take care of SPI pins */

	/* Set SS, DC and RST pins to output */
	CONTROLLER_SS_PORT->DIR  |= (1 << CONTROLLER_SS_PIN);
	CONTROLLER_DC_PORT->DIR  |= (1 << CONTROLLER_DC_PIN);
	CONTROLLER_RST_PORT->DIR |= (1 << CONTROLLER_RST_PIN);

	/* Deselect LCD */
	//GLCD_DESELECT();

	/* Reset the display */
	glcd_reset();

	/* Get into the EXTENDED mode! */
	glcd_command(PCD8544_FUNCTION_SET | PCD8544_EXTENDED_INSTRUCTION);

	/* LCD bias select (4 is optimal?) */
	glcd_command(PCD8544_SET_BIAS | 0x2);

	/* Set VOP */
	glcd_command(PCD8544_SET_VOP | 50); // Experimentally determined

	/* Back to standard instructions */
	glcd_command(PCD8544_FUNCTION_SET);

	/* Normal mode */
	glcd_command(PCD8544_DISPLAY_CONTROL | PCD8544_DISPLAY_NORMAL);

	glcd_select_screen(glcd_buffer,&glcd_bbox);

	glcd_clear();

#else /* GLCD_CONTROLLER_PCD8544 */
	#error "Controller not supported by LPC111x"
#endif

}
Ejemplo n.º 4
0
void glcd_init(void)
{

#if defined(GLCD_CONTROLLER_PCD8544)
	// Set up SPI (SSP)
	// Note: Max allowed SPI clock is 4 MHz from datasheet.

	// select SSP/SPI port
	SSP_IOConfig( PCD8544_SPI_PORT_NUMBER );

	// initialise SSP/SPI port
	SSP_Init( PCD8544_SPI_PORT_NUMBER );

	// above functions take care of SPI pins

	// set SS, DC and RST pins to output
	PCD8544_SS_PORT->DIR  |= (1 << PCD8544_SS_PIN);
	PCD8544_DC_PORT->DIR  |= (1 << PCD8544_DC_PIN);
	PCD8544_RST_PORT->DIR |= (1 << PCD8544_RST_PIN);

	// deselect LCD
	//GLCD_DESELECT();

	// reset the display
	glcd_reset();

	// get into the EXTENDED mode!
	glcd_command(PCD8544_FUNCTION_SET | PCD8544_EXTENDED_INSTRUCTION);

	// LCD bias select (4 is optimal?)
	glcd_command(PCD8544_SET_BIAS | 0x2);

	// set VOP
	glcd_command(PCD8544_SET_VOP | 50); // Experimentally determined

	// back to standard instructions
	glcd_command(PCD8544_FUNCTION_SET);

	// normal mode
	glcd_command(PCD8544_DISPLAY_CONTROL | PCD8544_DISPLAY_NORMAL);

	glcd_select_screen((uint8_t *)&glcd_buffer,&glcd_bbox);

	glcd_clear();

#else /* GLCD_CONTROLLER_PCD8544 */
	#error Controller not supported.
#endif

}
Ejemplo n.º 5
0
void glcd_init(void)
{
	
#if defined(GLCD_CONTROLLER_PCD8544)

	/* Set pin directions */
	
	/*
	 * Set up SPI for AVR8
	 * Note: AVR's SS pin must be set to output, regardless of whether we
	 * actually use it. This is a requirement of SPI mster mode.
	 */
	sbi(DDR(AVR_SS_PORT),AVR_SS_PIN);
	
	/*
	 *  Set MOSI, Master SS, SCK to output (otherwise SPI won't work)
	 *  Must be done even if native SS pin not used
	 */
	sbi(DDR(CONTROLLER_MOSI_PORT),CONTROLLER_MOSI_PIN);
	sbi(DDR(CONTROLLER_SS_PORT),CONTROLLER_SS_PIN);
	sbi(DDR(CONTROLLER_SCK_PORT),CONTROLLER_SCK_PIN);
		
	/* Set SS, DC and RST pins to output */
	sbi( DDR(CONTROLLER_SS_PORT), CONTROLLER_SS_PIN );
	sbi( DDR(CONTROLLER_DC_PORT), CONTROLLER_DC_PIN );
	sbi( DDR(CONTROLLER_RST_PORT), CONTROLLER_RST_PIN );
	
	/* Deselect LCD */
	GLCD_DESELECT();

	/*
	 * Max allowed SPI clock is 4 MHz from datasheet.
	 * Enable SPI, set master mode and clock rate to /4 (4MHz with F_CPU=8MHz)
	 */
	SPCR = (1<<SPE)|(1<<MSTR);
	SPSR = 0;
	
	glcd_PCD8544_init();

	/* Select screen buffer */
	glcd_select_screen(glcd_buffer,&glcd_bbox);
	
	/* Clear screen, we are now ready to go */
	
	glcd_clear();

#elif defined(GLCD_CONTROLLER_ST7565R)

	/* Set up GPIO directions */
	
	/*
	 * Set up SPI for AVR8
	 * Note: AVR's SS pin must be set to output, regardless of whether we
	 * actually use it. This is a requirement of SPI mster mode.
	 */
	sbi(DDR(AVR_SS_PORT),AVR_SS_PIN);
	
	/* Set SCK and MOSI as output */
	sbi(DDR(CONTROLLER_SCK_PORT),CONTROLLER_SCK_PIN);
	sbi(DDR(CONTROLLER_MOSI_PORT),CONTROLLER_MOSI_PIN);
	
	/*
	 * Set MISO as input with pullup. This needs to be set for
	 * SPI to work, even though we never use or read it.
	 */
	cbi(DDR(CONTROLLER_MISO_PORT),CONTROLLER_MISO_PIN); // B3 MISO as input
	sbi(CONTROLLER_MISO_PORT,CONTROLLER_MISO_PIN);
	
	/* Set pin to controller SS as output */
	sbi(DDR(CONTROLLER_SS_PORT),CONTROLLER_SS_PIN); // A5

	/* Set LCD A0 pin as output */
	sbi(DDR(CONTROLLER_A0_PORT),CONTROLLER_A0_PIN); // A6
		
	/* Init SS pin high (i.e LCD deselected) */
	sbi(CONTROLLER_SS_PORT,CONTROLLER_SS_PIN);

	/* Deselect LCD */
	GLCD_DESELECT();

	/* MSB first, double speed, SPI mode 0 */
	SPCR = (1<<SPE) | (1<<MSTR) | (0<<CPOL) | (0<<CPHA);	
	sbi(SPSR,SPI2X);
	
	/* Enable interrupts */
	sei();
		
	delay_ms(30); /* Example in datasheet does this (20ms) */

	glcd_ST7565R_init();

	glcd_all_on();
	
	delay_ms(500);
	glcd_normal();

	glcd_set_start_line(0);
	glcd_clear_now();
			
	glcd_select_screen(glcd_buffer,&glcd_bbox);
	
	glcd_clear();	
	
#else
	#error "Controller not supported"
#endif /* GLCD_CONTROLLER_* */
	
}
Ejemplo n.º 6
0
Archivo: AVR8.c Proyecto: cj1324/glcd
void glcd_init(void)
{
	
#if defined(GLCD_CONTROLLER_PCD8544)

	/* Set pin directions */
	
	/*
	 * Set up SPI for AVR8
	 * Note: AVR's SS pin must be set to output, regardless of whether we
	 * actually use it. This is a requirement of SPI mster mode.
	 */
	sbi(DDR(AVR_SS_PORT),AVR_SS_PIN);
	
	/*
	 *  Set MOSI, Master SS, SCK to output (otherwise SPI won't work)
	 *  Must be done even if native SS pin not used
	 */
	sbi(DDR(CONTROLLER_MOSI_PORT),CONTROLLER_MOSI_PIN);
	sbi(DDR(CONTROLLER_SS_PORT),CONTROLLER_SS_PIN);
	sbi(DDR(CONTROLLER_SCK_PORT),CONTROLLER_SCK_PIN);
		
	/* Set SS, DC and RST pins to output */
	sbi( DDR(CONTROLLER_SS_PORT), CONTROLLER_SS_PIN );
	sbi( DDR(CONTROLLER_DC_PORT), CONTROLLER_DC_PIN );
	sbi( DDR(CONTROLLER_RST_PORT), CONTROLLER_RST_PIN );
	
	/* Deselect LCD */
	GLCD_DESELECT();

	/*
	 * Max allowed SPI clock is 4 MHz from datasheet.
	 * Enable SPI, set master mode and clock rate to /4 (4MHz with F_CPU=8MHz)
	 */
	SPCR = (1<<SPE)|(1<<MSTR);
	SPSR = 0;
	
	glcd_reset();
	
	/* Get into the EXTENDED mode! */
	glcd_command(PCD8544_FUNCTION_SET | PCD8544_EXTENDED_INSTRUCTION);

	/* LCD bias select (4 is optimal?) */
	glcd_command(PCD8544_SET_BIAS | 0x2);
	
	/* Set VOP */
	glcd_command(PCD8544_SET_VOP | 50); // Experimentally determined
	
	/* Back to standard instructions */
	glcd_command(PCD8544_FUNCTION_SET); 
	
	/* Normal mode */
	glcd_command(PCD8544_DISPLAY_CONTROL | PCD8544_DISPLAY_NORMAL);

	/* Select screen buffer */
	glcd_select_screen(glcd_buffer,&glcd_bbox);
	
	/* Clear screen, we are now ready to go */
	glcd_clear();

#elif defined(GLCD_CONTROLLER_ST7565R)

	/* Set up GPIO directions */
	
	/*
	 * Set up SPI for AVR8
	 * Note: AVR's SS pin must be set to output, regardless of whether we
	 * actually use it. This is a requirement of SPI mster mode.
	 */
	sbi(DDR(AVR_SS_PORT),AVR_SS_PIN);
	
	/* Set SCK and MOSI as output */
	sbi(DDR(CONTROLLER_SCK_PORT),CONTROLLER_SCK_PIN);
	sbi(DDR(CONTROLLER_MOSI_PORT),CONTROLLER_MOSI_PIN);
	
	/*
	 * Set MISO as input with pullup. This needs to be set for
	 * SPI to work, even though we never use or read it.
	 */
	cbi(DDR(CONTROLLER_MISO_PORT),CONTROLLER_MISO_PIN); // B3 MISO as input
	sbi(CONTROLLER_MISO_PORT,CONTROLLER_MISO_PIN);
	
	/* Set pin to controller SS as output */
	sbi(DDR(CONTROLLER_SS_PORT),CONTROLLER_SS_PIN); // A5
	/* Set LCD A0 pin as output */
	sbi(DDR(CONTROLLER_A0_PORT),CONTROLLER_A0_PIN); // A6
		
	/* Init SS pin high (i.e LCD deselected) */
	sbi(CONTROLLER_SS_PORT,CONTROLLER_SS_PIN);

	/* Deselect LCD */
	GLCD_DESELECT();

	/* MSB first, double speed, SPI mode 0 */
	SPCR = (1<<SPE) | (1<<MSTR) | (0<<CPOL) | (0<<CPHA);	
	sbi(SPSR,SPI2X);
	
	/* Enable interrupts */
	sei();
		
	delay_ms(30); // example in datasheet does this (20ms)

	glcd_command(ST7565R_RESET); // internal reset
	glcd_command(0xa2); // 1/9 bias
	glcd_command(0xa0); // ADC select, normal
	glcd_command(0xc8); // com output reverse
	glcd_command(0xa4); // display all points normal
	glcd_command(0x40); // display start line set
	glcd_command(0x25); // internal resistor ratio
	glcd_command(0x81); // electronic volume mode set
	//glcd_command(0x10); // electronic volume - datasheet's contrast example doesn't work
	glcd_command(45); // this works better
	glcd_command(0x2f); // power controller set
	glcd_command(0xaf); // display on
	
	glcd_all_on();
	
Ejemplo n.º 7
0
void glcd_init(void)
{

#if defined(GLCD_CONTROLLER_PCD8544)
	/* Initialisation for PCD8544 controller */

	/* Declare GPIO and SPI init structures */
	GPIO_InitTypeDef GPIO_InitStructure;
	SPI_InitTypeDef  SPI_InitStructure;
  //NVIC_InitTypeDef NVIC_InitStructure;
	
	/* Initialise structures (which we will overide later) */
	GPIO_StructInit(&GPIO_InitStructure);
	SPI_StructInit(&SPI_InitStructure);
	
	/* Need to make start up the correct peripheral clocks */
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);

	/* SS pin */
	GPIO_InitStructure.GPIO_Pin   = CONTROLLER_SPI_SS_PIN;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_3;
	GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_OUT;
	GPIO_Init(CONTROLLER_SPI_SS_PORT, &GPIO_InitStructure);
	
	/* DC pin */
	GPIO_InitStructure.GPIO_Pin = CONTROLLER_SPI_DC_PIN;
	GPIO_Init(CONTROLLER_SPI_DC_PORT, &GPIO_InitStructure);

	/* RESET pin */
	GPIO_InitStructure.GPIO_Pin = CONTROLLER_SPI_RST_PIN;
	GPIO_Init(CONTROLLER_SPI_RST_PORT, &GPIO_InitStructure);

	/* Make sure chip is de-selected by default */
	GLCD_DESELECT();

	/* Set up GPIO for SPI pins */
	GPIO_InitStructure.GPIO_Pin   = CONTROLLER_SPI_SCK_PIN | CONTROLLER_SPI_MISO_PIN | CONTROLLER_SPI_MOSI_PIN;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_3;
	GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;
	GPIO_Init(CONTROLLER_SPI_PORT, &GPIO_InitStructure);

	/* Configure alternate function mode for SPI pins */
	GPIO_PinAFConfig(GPIOA,CONTROLLER_SPI_SCK_PINSRC,GPIO_AF_0);
	GPIO_PinAFConfig(GPIOA,CONTROLLER_SPI_MOSI_PINSRC,GPIO_AF_0);
	GPIO_PinAFConfig(GPIOA,CONTROLLER_SPI_MISO_PINSRC,GPIO_AF_0);

	/* Initialise SPI */
	SPI_InitStructure.SPI_Direction         = SPI_Direction_2Lines_FullDuplex;
	SPI_InitStructure.SPI_Mode              = SPI_Mode_Master;
	SPI_InitStructure.SPI_DataSize          = SPI_DataSize_8b;
	SPI_InitStructure.SPI_CPOL              = SPI_CPOL_Low;
	SPI_InitStructure.SPI_CPHA              = SPI_CPHA_2Edge;
	SPI_InitStructure.SPI_NSS               = SPI_NSS_Soft;
	SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_32; /* Set clock speed! */
	SPI_InitStructure.SPI_FirstBit          = SPI_FirstBit_MSB;
	SPI_InitStructure.SPI_CRCPolynomial     = 7;
	SPI_Init(CONTROLLER_SPI_NUMBER, &SPI_InitStructure);

	/* Enable SPI interupts */
	/*
	SPI_I2S_ITConfig(CONTROLLER_SPI_NUMBER, SPI_I2S_IT_TXE, ENABLE);
	NVIC_InitStructure.NVIC_IRQChannel = SPI1_IRQn;
	NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
	NVIC_InitStructure.NVIC_IRQChannelPriority = 0x00;
	NVIC_Init(&NVIC_InitStructure);
	*/
	
	/* Enable SPI */
	SPI_Cmd(CONTROLLER_SPI_NUMBER, ENABLE);

	/* Initialisation sequence of controller */
	glcd_reset();

	/* Get into the EXTENDED mode! */
	glcd_command(PCD8544_FUNCTION_SET | PCD8544_EXTENDED_INSTRUCTION);

	/* LCD bias select (4 is optimal?) */
	glcd_command(PCD8544_SET_BIAS | 0x2);

	/* Set VOP */
	glcd_command(PCD8544_SET_VOP | 50); // Experimentally determined

	/* Back to standard instructions */
	glcd_command(PCD8544_FUNCTION_SET);

	/* Normal mode */
	glcd_command(PCD8544_DISPLAY_CONTROL | PCD8544_DISPLAY_NORMAL);

	glcd_select_screen((uint8_t *)&glcd_buffer,&glcd_bbox);

	glcd_set_contrast(50);

	glcd_clear();


#else
	#error "Controller not supported by STM32F0xx"
#endif

}
Ejemplo n.º 8
0
void glcd_init(void)
{

#if defined(GLCD_CONTROLLER_PCD8544)
	/*
	 * Set up SPI (SSP)
	 * Note: Max allowed SPI clock is 4 MHz from datasheet.
	 */

	/* Select SSP/SPI port */
	SSP_IOConfig( CONTROLLER_SPI_PORT_NUMBER );

	/* Initialise SSP/SPI port */
	SSP_Init( CONTROLLER_SPI_PORT_NUMBER );

	/* Above functions take care of SPI pins */

	/* Set SS, DC and RST pins to output */
	CONTROLLER_SS_PORT->DIR  |= (1 << CONTROLLER_SS_PIN);
	CONTROLLER_DC_PORT->DIR  |= (1 << CONTROLLER_DC_PIN);
	CONTROLLER_RST_PORT->DIR |= (1 << CONTROLLER_RST_PIN);

	/* Deselect LCD */
	GLCD_DESELECT();

	/* Reset the display */
	glcd_reset();

	/* Get into the EXTENDED mode! */
	glcd_command(PCD8544_FUNCTION_SET | PCD8544_EXTENDED_INSTRUCTION);

	/* LCD bias select (4 is optimal?) */
	glcd_command(PCD8544_SET_BIAS | 0x2);

	/* Set VOP */
	glcd_command(PCD8544_SET_VOP | 50); // Experimentally determined

	/* Back to standard instructions */
	glcd_command(PCD8544_FUNCTION_SET);

	/* Normal mode */
	glcd_command(PCD8544_DISPLAY_CONTROL | PCD8544_DISPLAY_NORMAL);

	glcd_select_screen(glcd_buffer,&glcd_bbox);

	glcd_clear();

#elif defined(GLCD_CONTROLLER_NT75451)
	/* Parallel interface controller used on NGX BlueBoards */
	
	/* Set 4x control lines pins as output */
	LPC_GPIO->DIR[CONTROLLER_LCD_EN_PORT] |= (1U<<CONTROLLER_LCD_EN_PIN);
	LPC_GPIO->DIR[CONTROLLER_LCD_RW_PORT] |= (1U<<CONTROLLER_LCD_RW_PIN);
	LPC_GPIO->DIR[CONTROLLER_LCD_RS_PORT] |= (1U<<CONTROLLER_LCD_RS_PIN);
	LPC_GPIO->DIR[CONTROLLER_LCD_CS_PORT] |= (1U<<CONTROLLER_LCD_CS_PIN);
	
	/* Don't worry about setting default RS/RW/CS/EN, they get set during use */
	
#ifdef CONTROLLER_LCD_DATA_PORT	
	/* Set data pins as output */
	LPC_GPIO->DIR[CONTROLLER_LCD_D0_PORT] |= GLCD_PARALLEL_MASK;
#else
	#error "Support of parallel data pins on different ports not supported."
#endif

	/* Initialise sequence - code by NGX Technologies */
	glcd_command(0xE2);  /*	S/W RESWT               */
	glcd_command(0xA0);  /*	ADC select              */
	glcd_command(0xC8);  /*	SHL Normal              */
	glcd_command(0xA3);  /*	LCD bias                */
	glcd_command(0x2F);  /*	Power control           */
	glcd_command(0x22);  /*	reg resistor select     */
	glcd_command(0x40);  /*	Initial display line 40 */
	glcd_command(0xA4);  /*	Normal display          */
	glcd_command(0xA6);  /*	Reverce display a7      */
	glcd_command(0x81);  /*	Ref vg select mode      */
	glcd_command(0x3f);  /*	Ref vg reg select       */
	glcd_command(0xB0);  /*	Set page address        */
	glcd_command(0x10);  /*	Set coloumn addr MSB    */
	glcd_command(0x00);  /*	Set coloumn addr LSB    */
	glcd_command(0xAF);  /*	Display ON              */

	/* Select default screen buffer */
	glcd_select_screen(glcd_buffer,&glcd_bbox);

	/* Clear the screen buffer */
	glcd_clear();
	
#else /* GLCD_CONTROLLER_PCD8544 */
	#error "Controller not supported by LPC111x"
#endif

}