Exemple #1
0
void showCalendar_time(uint8_t hour, uint8_t min, uint8_t sec)
{
	vTaskDelay(5);
	LCD_CMD(0xC1);			//(row,column)=(2,2)
	vTaskDelay(5);
	LCD_DATA(table[hour/10]);	
	vTaskDelay(5);
	LCD_DATA(table[hour%10]);
	vTaskDelay(5);

	LCD_CMD(0xC5);			//(row,column)=(2,6)
	vTaskDelay(5);
	LCD_DATA(table[min/10]);	
	vTaskDelay(5);
	LCD_DATA(table[min%10]);
	vTaskDelay(5);

	LCD_CMD(0xC9);			//(row,column)=(2,10)
	vTaskDelay(5);		 
	LCD_DATA(table[sec/10]);	
	vTaskDelay(5);
	LCD_DATA(table[sec%10]);
	vTaskDelay(5);

	LCD_CMD(0xC3);			//(row,column)=(2,4)
	vTaskDelay(5);
	LCD_DATA(0x3A); 		//':'	
	vTaskDelay(5);
	LCD_CMD(0xC7);			//(row,column)=(2,8)	
	vTaskDelay(5);	
	LCD_DATA(0x3A);			//':'
	vTaskDelay(5);

}
void LCD_INIT(void) 
{
	LCD_CMD(0x38);
	LCD_CMD(0x38);
	LCD_CMD(0x38);
	LCD_CMD(0x0C);
	LCD_CMD(0x06);
}
void counter_display(unsigned char number)
{
 unsigned char temp;
 temp=number/10;
 LCD_CMD(0xC7);
 LCD_CHAR(temp+48);
 temp=number%10;
 LCD_CMD(0xC8);
 LCD_CHAR(temp+48);
}
Exemple #4
0
void Init_LCD()		       
{
	vTaskDelay(100);	         
	LCD_CMD(0x003f);       
	vTaskDelay(10);
	LCD_CMD(0x000c); 
	vTaskDelay(10);         
	LCD_CMD(0x0001);          
	vTaskDelay(10);
}
Exemple #5
0
void LCD_Display_conf( void) {
	// Function set command 0x28
	LCD_CMD(0x28);
	// Entry Mode Set command, 0x06
	LCD_CMD(0x06);
	// Display On/Off command, 0x0C,
	LCD_CMD(0x0c);
	// Clear Display command, 0x01 y 1.64ms
	LCD_CMD(0x01);
	_delay_ms(1.64);
}
Exemple #6
0
void Init_LCD(void)
{
LCD_CMD(0x02);	 //Dat che do giao tiep 4-bit, man hinh 2 dong
Delay1KTCYx(1);
LCD_CMD(0x28);	 //Tat man hinh
Delay1KTCYx(1);
LCD_CMD(0x0C);	 //Che do nhap du lieu binh thuong
Delay1KTCYx(1);
LCD_CMD(0x06 );	 //Bat man hinh, hien con tro nhap nhay
Delay1KTCYx(1);
//LCD_CMD(0x01);	 //Xoa man hinh
Delay1KTCYx(1);
}
//main function
void main(void)
{
    unsigned char st1[]="STARTING";
    unsigned char st2[]=".";

    //pins for drive LCD
    TRISB = 0x80;

    //Initialize modules
    Init_LCD();
    i2c_config();

    set_ds1307_time(AM,0,0,6);
    set_ds1307_day(8,11,8,13);

    lcd_putstr(st1);

    for(i=0;i<7;i++)
    {
        lcd_putstr(st2);
        Delay1KTCYx(200);
    }
    LCD_CMD(LCD_clear);
    
    while(1)
    {
        lcd_gotoxy(1,1);//hang 1, cot 1.
        Display_time(get_ds1307_time());

        lcd_gotoxy(1,2);//hang 2, cot 1
        Display_day(get_ds1307_day());

        Delay10KTCYx(70);
    };
}
Exemple #8
0
/*******************************************************************************
* Function: LCD_Cursor_Pos(UINT8 x, UINT8 y)                                                                     
*                                                                               
* Variables:                                                                    
* x -> The x-position of the cursor on the LCD                                  
* y -> The y-position of the cursor on the LCD                                                                           
*                                                                               
* Description:                                                                  
* This function can be used to set the LCD cursors position at the location (x,y).                                                                              
*******************************************************************************/
void LCD_Cursor_Pos(UINT8 x, UINT8 y)
{
  //Calculate the DDRAM location (0x40 is line 2 in DDRAM)
  x += (y * 0x40);
  
  //Set the cursor position at the (x,y) coordinate
  LCD_CMD(LCD_SET_DDRAM_ADDR | x);
}
Exemple #9
0
//-----------Chuong trinh con nhay den cot x, dong y-------------------------------------------------------------------
void lcd_gotoxy(int x, int y)
{
	int address;
	if(y != 1) address = lcd_line_two;
	else address=0;
	address += x-1;
	LCD_CMD(0x80|address);
	Delay1KTCYx(2);
}
/******************************************************************************
 * Writes one command byte
 * cmd           - the command byte
 */
void lcd_command(uint8_t cmd) {
  LCD_SELECT();
  LCD_CMD();
   
  spi_write(cmd);
  
  
  //LCD_UNSELECT();
  while(!(SPSR & (1<<SPIF)));
  PORT_CS |= _BV(PIN_CS);
  }
Exemple #11
0
unsigned char dispMenu(void) {
	menuItem* tempMenu,*tempMenu2;

	LCD_CMD (1);//clrscr
	//delay=10000; while (delay--){}
	LCD_CMD (1);//clrscr
	LCD_CMD (1);//clrscr
	LCD_CMD (1);//clrscr
	// первая строка - заголовок. Или пункт меню верхнего уровня
	//delay=10000; while (delay--){}
	LCD_GOTO (1,0);
	tempMenu = selectedMenuItem->Parent;
	if ((void*)tempMenu == (void*)&NULL_ENTRY)
	{ // мы на верхнем уровне
		LCD_STRING ("MENU:");
	}

	else
	{
		 LCD_STRING ((char *)tempMenu->Text);
	}

	//lcd_clrscr(2);
	//
	LCD_GOTO (2,5);
	tempMenu2=selectedMenuItem->Previous;
	LCD_STRING ((char *)tempMenu2->Text);

	LCD_GOTO (3,4);
	LCD_PUTCHAR ('>');

	LCD_GOTO (3,5);
	LCD_STRING ((char *)selectedMenuItem->Text);
	LCD_GOTO (4,5);
	tempMenu2=selectedMenuItem->Next;
	LCD_STRING ((char *)tempMenu2->Text);

	return (1);
}
void main(void)
{
 unsigned char count=0;	// Counter variable
 LCD_INIT();
 LCD_CMD(LINE1);
 LCD_WRITE("**BALL-COUNTER**");
 LCD_CMD(DON_COFF);
 counter_display(count);

 while(1)
 {
	 if(touch_sensor==0)//If Touch detected
	 {
	 count++;  //Counter incremented
	 counter_display(count); //Display Number
	 buzzer=0;	//Buzzer ON
	 delay_ms(1000); //Delay for correction if any
	 }
	 else
	 {
	  buzzer=1;	//Buzzer OFF
	 }
 } 
}
Exemple #13
0
/*******************************************************************************
* Function: LCD_Create_Character(UINT8 symbol[8], UINT8 loc)                                                                     
*                                                                               
* Variables:                                                                    
* symbol -> The 5x7 character/symbol that is to be generated                                                                          
* loc -> The location where the symbol is stored
*                                                                              
* Description:                                                                  
* This function will create a symbol and save it in the LCD RAM. The LCD allows
* one to create 8 symbols and store them in RAM at the same time.                                                                              
*******************************************************************************/
void LCD_Create_Character(UINT8 symbol[8], UINT8 loc)
{
  UINT8 i;
  
  //Navigate to the address where the character will be stored
  LCD_CMD(LCD_SET_CGRAM_ADDR + (loc * 8));
  Delay_us(60);
  
  //Write the character into the RAM
  for (i = 0;i < 8;i++)
    LCD_Send(symbol[i]);
  
  //Allow the operation to finish  
  Delay_us(37);
}
Exemple #14
0
void LCD_GotoXY(uint8_t x, uint8_t y) {   //Mueve el cursor a la posicion X Y

   register uint8_t DDRAMAddr;
   // Mapea en la direccion real
   switch(y)
   {
   case 0: DDRAMAddr = LCD_LINE0_DDRAMADDR+x; break;
   case 1: DDRAMAddr = LCD_LINE1_DDRAMADDR+x; break;
   case 2: DDRAMAddr = LCD_LINE2_DDRAMADDR+x; break;
   case 3: DDRAMAddr = LCD_LINE3_DDRAMADDR+x; break;
   default: DDRAMAddr = LCD_LINE0_DDRAMADDR+x;
   }
   // Envia la direccion
   LCD_CMD(1<<LCD_DDRAM | DDRAMAddr);
   
}
Exemple #15
0
void lcd_clear(void)
{
	LCD_CMD(0x01);
}
void LCD_CLEAR(void)
{
	LCD_CMD(0x01);
	tme_tempo(1.6);
}
Exemple #17
0
/*******************************************************************************
* Function: LCD_Init(void)                                                                     
*                                                                               
* Variables:                                                                    
* N/A                                                                           
*                                                                               
* Description:                                                                   
* This function is set to initialize the LCD display with a 4-bit data bus,  
* cursor off and 16x2 screen.
*******************************************************************************/
void LCD_Init(void)
{
	//Allow LCD to stabilize
  Delay_ms(20);
  
  //Send specified startup sequence
  LCD_CMD(LCD_STARTUP_4BIT);
  Delay_ms(5);
  
  //Send specified startup sequence
  LCD_CMD(LCD_STARTUP_4BIT);
  Delay_ms(5);
  
  //Send specified startup sequence
  LCD_CMD(LCD_STARTUP_4BIT);
  Delay_ms(5);
  
  //Return home
  LCD_CMD(LCD_RETURN_HOME);
  Delay_ms(5);
  
  //Send Return Home again
  LCD_CMD(LCD_RETURN_HOME);
  Delay_ms(5);
  
  //Turn off all Display Control features for startup
  LCD_CMD(LCD_DISPLAY_CONTROL);
  Delay_ms(5);
  
  //Clear LCD Display
  LCD_CMD(LCD_RETURN_HOME);
  Delay_ms(5);
  
  //Set Entry Mode and cursor shifting
  LCD_CMD(LCD_ENTRY_MODE_SET | LCD_INCREMENT);
  Delay_ms(5);
  
  //Finish initializing with your settings
  LCD_CMD(LCD_FUNCTION_SET | LCD_DATA_4BITS | LCD_TWO_LINES);
  Delay_ms(5);
  
  //This was already set above. If you want to make a change, do it here.
  LCD_CMD(LCD_ENTRY_MODE_SET | LCD_INCREMENT);
  Delay_ms(5);
  
  //Display On, Cursor Off, Blinking Off
  LCD_CMD(LCD_DISPLAY_CONTROL | LCD_DISPLAY_ON | LCD_CURSOR_OFF | LCD_BLINK_OFF);
  Delay_ms(5);
}
void LCD_HOME(void)
{
	LCD_CMD(0x02);
	tme_tempo(1.6);
}
Exemple #19
0
/******************************************************************************
 * Writes one command byte
 * cmd           - the command byte
 */
void lcd_command(uint8_t cmd) {
  LCD_SELECT();
  LCD_CMD();
  spi_write(cmd);
  LCD_UNSELECT();
  }
Exemple #20
0
void LcdCmd(u8 cmd) {
    LCD_CMD();
    LCD_CS_L();
    spi_xfer(SPI1, cmd);
    LCD_CS_H();
}