Пример #1
0
void LCDInit()
{
	LCD_PinInit();
	Delay_ms(20);
	GPIO_ResetBits(RS_Port, RS_Pin);
	LCD_Send(0x3);
	Delay_ms(5);
	LCD_Send(0x2);
	Delay_ms(5);
	LCD_Send(0x0);
	LCD_Command(0x28);
	LCD_Command(0x08);
	LCD_Command(0x01);
	LCD_Command(0x06);
	LCD_Command(0x0c);
}
Пример #2
0
void 
LCD_Write_String (const char ptr[])
{
    while(*ptr){
        LCD_Send(0, *ptr);
        ptr++;
    }
}
Пример #3
0
/*******************************************************************************
* Function: LCD_Text(UINT8 x, UINT8 y, char text[32])                                                                     
*                                                                               
* Variables:                                     
* x -> The x-position of the cursor on the LCD                                  
* y -> The y-position of the cursor on the LCD                                                                 
* text -> The text that is to be displayed on the LCD                                                                         
*                                                                               
* Description:                                                                  
* This function is used to display text at an (x,y) coordinate on the LCD.                                                                               
*******************************************************************************/
void LCD_Text(UINT8 x, UINT8 y, char text[32])
{
  UINT8 i = 0;
  
  //Set the LCD cursor position
  LCD_Cursor_Pos(x,y);
  
  //Write the full string to the LCD display
  while (text[i] != '\0')
  {
    LCD_Send(text[i]);
    i++;
  }  
}
Пример #4
0
void 
LCD_Init(void)
{
    LCD_DATA_DDR = LCD_DATA;    //Data port to output
    LCD_CTRK_DDR = LCD_E|LCD_RW|LCD_RS;    //Ctrl port to output

    _delay_ms(50);              //Initializing wait

    LCD_CTRL_PORT &= ~LCD_RW;   //RW = 0
    LCD_CTRL_PORT &= ~LCD_RS;   //RS = 0

    LCD_DATA_PORT = 0x38;       //Initial signal. 8bit data,
                                //2 line display, 5*8 dot fonts.
    register uint8_t i = 20;
    while(i--){  
//        _delay_us(10);               //make sure the device fully initial.
        LCD_CTRL_PORT |= LCD_E;
        _delay_us(10);
        LCD_CTRL_PORT &= ~LCD_E;
    }

    LCD_Send(1,0x0e);           //Display On, No Cursor, No Blinking
    LCD_Send(1,0x01);           //Display Clear
}
Пример #5
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);
}
Пример #6
0
void LCD_Command(char cmd)
{
	GPIO_ResetBits(EN_Port, EN_Pin);
	GPIO_ResetBits(RS_Port, RS_Pin);
	Delay_ms(2);
	LCD_Send(cmd >> 4);
	GPIO_SetBits(EN_Port, EN_Pin);
	Delay_ms(2);
	GPIO_ResetBits(EN_Port, EN_Pin);
	Delay_ms(6);
	LCD_Send(cmd & 0xf);
	GPIO_SetBits(EN_Port, EN_Pin);
	Delay_ms(2);
	GPIO_ResetBits(EN_Port, EN_Pin);
	Delay_ms(5);
}
Пример #7
0
void putchCP(char ch)
{
	GPIO_ResetBits(EN_Port, EN_Pin);
	GPIO_SetBits(RS_Port, RS_Pin);
	Delay_ms(2);
	LCD_Send(ch >> 4);
	GPIO_SetBits(EN_Port, EN_Pin);
	Delay_ms(2);
	GPIO_ResetBits(EN_Port, EN_Pin);
	Delay_ms(2);
	LCD_Send(ch & 0xf);
	Delay_ms(2);
	GPIO_SetBits(EN_Port, EN_Pin);
	Delay_ms(2);
	GPIO_ResetBits(EN_Port, EN_Pin);
	Delay_ms(2);
}
Пример #8
0
Файл: work.c Проект: ADTL/remote
/* main work function */
void work(void) {
    unsigned short i, j;
    unsigned char mailbox_num = 0;
    volatile ProtoIOMBox * mbox;
    /* setup status */
    status_setup();
    /* setup serial console */
    usart1_setup();
    /* setup proto */
    proto_setup();
    mbox = proto_srv_dat.mailboxes[mailbox_num];
    /* setup button */
    buttons_setup();
    /* lcd setup */
    LCD_Setup();
    LCD_Clear(BLACK);
    
    for (i = 0; i < 10; i++) {
        for (j = 0; j < 10; j++) {
            LCD_Pixel(j + 10, i + 10, test.data[i * 10 + j]);
        }
    }
    LCD_Window(0, 0, 9, 9);
    LCD_RS_LOW;
    LCD_SELECT;
    for (i = 0; i < 100; i++) {
        LCD_Send(test.data[i] >> 8);
        LCD_Send(test.data[i] & 0x00ff);
    }
    LCD_Cursor(0, 0);
    LCD_DESEL;
    
    /* check status */
    check_status();
    /* send ping */
    mbox->outbox->header = 'C'; /* Command */
    mbox->outbox->size = 0x00; /* 0 for ping request */
    mbox->outbox_s = PROTO_IO_MBOX_READY; /* Box ready */
    mbox->inbox->size = 64; /* buffer len for control */
    mbox->inbox_s = PROTO_IO_MBOX_READY; /* Box ready */
    /* wait connection estabilished */
    while (status == 0);
    /* send ping message */
    proto_send_msg(mailbox_num);
    /* wait to send message */
    while (mbox->outbox_s <= PROTO_IO_MBOX_SEND);
    if (mbox->outbox_s == PROTO_IO_MBOX_COMPLETE)
        LCD_String("Con", 36, 6, 1, WHITE, GLASSY);
    else
        LCD_String("Un", 36, 6, 1, RED, GLASSY);
    /* get ping message */
    /* FIXME wtf? this not work or work parity */
    //proto_get_msg(mailbox_num);
    /* wait to get message */
    while (mbox->inbox_s <= PROTO_IO_MBOX_SEND);
    if (mbox->inbox_s == PROTO_IO_MBOX_COMPLETE) {
        LCD_String("OK", 36 + 3 * 7, 6, 1, GREEN, GLASSY);
        for (i = 0; i < mbox->inbox->size; i++)
            LCD_Char(mbox->inbox->message[i], 70 + i * 6, 6, 1, WHITE, GLASSY);
    }
    else
        LCD_String("ERR", 36 + 3 * 7, 6, 1, RED, GLASSY);
    /* infinity loop */
    while (1) {
        if (button_state.state[B_LGHT] == B_CLICK) {
            sender('+');
            button_state.state[B_LGHT] = B_RELEASE;
        }
        if (button_state.state[B_MOD] == B_CLICK) {
            sender('m');
            button_state.state[B_MOD] = B_RELEASE;
        }
        if (button_state.state[B_SET] == B_CLICK) {
            sender('-');
            button_state.state[B_SET] = B_RELEASE;
        }
        if (button_state.state[B_UP] == B_CLICK) {
            sender('<');
            button_state.state[B_UP] = B_RELEASE;
        }
        if (button_state.state[B_SU] == B_CLICK) {
            sender('p');
            button_state.state[B_SU] = B_RELEASE;
        }
        if (button_state.state[B_DWN] == B_CLICK) {
            sender('>');
            button_state.state[B_DWN] = B_RELEASE;
        }
    }
}
Пример #9
0
/*******************************************************************************
* Function: LCD_Char(char symbol)                                                                     
*                                                                               
* Variables:                                                                    
* symbol -> the character that is to be displayed on the LCD                                                                           
*                                                                               
* Description:                                                                  
* This function will display one character on the LCD display.                                                                              
*******************************************************************************/
void LCD_Char(char symbol)
{
  //Send the character to the LCD display
  LCD_Send(symbol);  
}