示例#1
0
 /*******************************************************************************
 *  Function Name: LCD_Char_1_PrintInt8
 ********************************************************************************
 *
 * Summary:
 *  Print a byte as two ASCII characters.
 *
 * Parameters:
 *  value: The byte to be printed out as ASCII characters.
 *
 * Return:
 *  None.
 *
 *******************************************************************************/
 void LCD_Char_1_PrintInt8(uint8 value) 
 {
     static char8 const CYCODE LCD_Char_1_hex[16u] = "0123456789ABCDEF";
     
     LCD_Char_1_PutChar((char8) LCD_Char_1_hex[value >> LCD_Char_1_BYTE_UPPER_NIBBLE_SHIFT]);
     LCD_Char_1_PutChar((char8) LCD_Char_1_hex[value & LCD_Char_1_BYTE_LOWER_NIBBLE_MASK]);
 }
示例#2
0
int main()
{    
    uint8 ch;           /* Data sent on the serial port */
    uint8 count = 0u;    /* Initializing the count value */
    uint8 pos = 0u;

    CyGlobalIntEnable; 

    isr_1_Start();      /* Initializing the ISR */
    UART_1_Start();     /* Enabling the UART */
    LCD_Char_1_Start(); /* Enabling the LCD */

        
    for(ch = START_CHAR_VALUE; ch <= END_CHAR_VALUE; ch++)
    {
        UART_1_WriteTxData(ch); /* Sending the data */

        count++;        
        if(count % LCD_NUM_COLUMNS == 0u) /* If the count value reaches the count 16 start from first location */
        {
            pos = 0u;  /* resets the count value */
            LCD_Char_1_WriteControl(LCD_Char_1_CLEAR_DISPLAY); /* Display will be cleared when reached count value 16 */
        }    

        LCD_Char_1_Position(0u, pos++);   /* LCD position to the count++ */
        LCD_Char_1_PutChar(ch);         /* print the value in the LCD */
                
        LCD_Char_1_Position(1u, 0u);
        LCD_Char_1_PrintInt8(count);    /* prints the count in the LCD */
        CyDelay(200u);
    }

    for(;;) {}
}
示例#3
0
/*******************************************************************************
* 显示数据到显示屏
********************************************************************************/
void updateDisplay (uint16 tempture)
{
    //LCD_Char_1_ClearDisplay();//清除显示    
    LCD_Char_1_PrintString("Tempture:");/* 打印提示信息 */
    
	LCD_Char_1_Position(0,9); /* 把光标移动到1行,10列 */
	LCD_Char_1_PrintNumber(tempture/10); /* 打印小数点前面的数据 */
    LCD_Char_1_PutChar('.');
    LCD_Char_1_PrintNumber(tempture%10); /* 打印小数点后面的数据 */
    
    LCD_Char_1_PrintString(" ");
    //LCD_Char_1_PutChar(LCD_Char_1_CUSTOM_7);
    LCD_Char_1_PrintString("C");
    
}
示例#4
0
/*******************************************************************************
* Function Name: main
********************************************************************************
*
* Summary:
*  Main function performs following functions:
*   1: Initializes the LCD
*   2: Get the temperature of the Die
*   3: Print the Die Temperature value in LCD
*   4: Print the Status value in the LCD
*
* Parameters:
*  None.
*
* Return:
*  None.
*
*******************************************************************************/
int main()
{
    cystatus Status;
    int16 temperature;

    /* Initializing the LCD */
    LCD_Char_1_Start();

    while(1)
    {
        /* Providing some delay */
        CyDelay(50);

        /* Reading the Die Temperature value */
        Status = DieTemp_1_GetTemp(&temperature);
       

        /* Displaying the Die Temperature value on the LCD */
        LCD_Char_1_Position(0u, 0u);
        LCD_Char_1_PrintString("Temp = ");

        if (temperature >= 0)
        {
            LCD_Char_1_PrintString("+");
        }
        else
        {
            /* If the temperature value is negative, display "-" sign and make value positive */
            LCD_Char_1_PrintString("-");
            temperature = (uint16)(~temperature + 1u);
        }
        
        LCD_Char_1_PrintNumber((uint16) (temperature));
        LCD_Char_1_PrintString(" ");
        
        LCD_Char_1_PutChar(LCD_Char_1_CUSTOM_7);
        LCD_Char_1_PrintString("C");

        /* Displaying the status value on the LCD */
        LCD_Char_1_Position(1u, 0u);
        LCD_Char_1_PrintString("Status = ");
        LCD_Char_1_PrintInt8((uint8) Status);
    }
}
示例#5
0
int main()
{
    init();
    while(1)
    {   
        //LCD_Char_1_PrintNumber(RxSize);
        if(RxSize>4)//来自PC的数据,应该进行解析
        {       
            int i = 0;
            //LCD_Char_1_PrintNumber(RxSize);
            if(RxBuffer[RxSize-1] == 'e' && RxBuffer[0] == 's')
            {
                uint8 config = 0;
                switch(RxBuffer[3])//获取针对节点的信息
                {
                    case 'a' :
                    {
                        config += 3;
                        break;
                    }
                    case '0' :
                    {
                        config += 0;
                        break;
                    }
                    case '1' :
                    {
                        config += 1;
                        break;
                    }
                    case '2' :
                    {
                        config += 2;
                        break;
                    }
                    default :
                    {
                        config = 20;
                        break;
                    }
                }
                switch(RxBuffer[1])
                {                    
                    case 'c' : //设置节点
                    {  
                        if(RxBuffer[2] == 'o')//打开
                        {
                            ;                           
                        }
                        else if(RxBuffer[2] == 'c')//关闭
                        {
                            config += 10; 
                        }
                        
                        configNode(config);
                        break;
                    }
                    case 's' :
                    {
                        if(RxBuffer[2] == 'h')//打开
                        {
                            ;                           
                        }
                        else if(RxBuffer[2] == 'l')//关闭
                        {
                            config += 10; 
                        }                        
                        setNode(config);
                        break;
                    }
                    case 'p' :
                    {
                        setPeriod(config);
                        break;
                    }
                    default :
                    {
                        break;
                    }
                }
                for(i = 0; i < RxSize; ++i)//处理完 清指令队列
                {
                    RxBuffer[RxSize] = '\0';
                }
                RxSize = 0;
                
            }
            else if(RxBuffer[RxSize-1] == 'e' && RxBuffer[0] != 's')//指令出错
            {                
                LCD_Char_1_PrintString("e0");
                for(i = 0; i < RxSize; ++i)//错误指令 清指令队列
                {
                    RxBuffer[RxSize] = '\0';
                }
                RxSize = 0;
            }
            else if(RxSize > 10)
            {
                LCD_Char_1_PrintString("c0");
                for(i = 0; i < RxSize; ++i)//错误指令 清指令队列
                {
                    RxBuffer[i] = '\0';
                }
                RxSize = 0;
            }
            
        }
        
        if(Rx_1_Size > 2)//来自结点1的数据,应该转发给电脑
        {
            uint8 i = 0;                 
            if(Rx_1_Buffer[Rx_1_Size-1] == 'e' && Rx_1_Buffer[0] == 's')
            {
                LCD_Char_1_PrintString(Rx_1_Buffer);
                if(Rx_1_Buffer[1] == 't') //转发温度,加上节点号
                {
                    char tem[9]; 
                    tem[0] = 's';
                    tem[1] = 't';
                    tem[2] = '1';//节点号
                    tem[3] = Rx_1_Buffer[2];
                    tem[4] = Rx_1_Buffer[3];
                    tem[5] = Rx_1_Buffer[4];
                    tem[6] = 'e';
                    tem[7] = '\0';
                    UART_PutString(tem);
                }
                else if(Rx_1_Buffer[1] == 'h') //转发温度过高
                {
                    LCD_Char_1_PutChar('l');
                    UART_PutString("sh1he");
                }
                else if(Rx_1_Buffer[1] == 'l') //转发温度过低
                {
                    UART_PutString("sh1le");
                }
                for(i = 0; i < Rx_1_Size; ++i)//处理完 清指令队列
                {
                    Rx_1_Buffer[i] = '\0';
                }
                Rx_1_Size = 0;
            }
            
            else if(Rx_1_Buffer[Rx_1_Size-1] == 'e' && Rx_1_Buffer[0] != 's')//指令出错
            {                
                LCD_Char_1_PrintString("e");
                for(i = 0; i < Rx_1_Size; ++i)//错误指令 清指令队列
                {
                    Rx_1_Buffer[i] = '\0';
                }
                Rx_1_Size = 0;
            }
            else if(Rx_1_Size > 10)
            {
                LCD_Char_1_PrintString("c");
                for(i = 0; i < Rx_1_Size; ++i)//错误指令 清指令队列
                {
                    Rx_1_Buffer[i] = '\0';
                }
                Rx_1_Size = 0;
            }
        }
        
        if(Rx_2_Size > 4)//来自结点2的数据,应该转发给电脑
        {
            uint8 i = 0;                 
            if(Rx_2_Buffer[Rx_2_Size-1] == 'e' && Rx_2_Buffer[0] == 's')
            {
                if(Rx_2_Buffer[1] == 't') //转发温度,加上节点号
                {
                    char tem[9]; 
                    tem[0] = 's';
                    tem[1] = 't';
                    tem[2] = '2';//节点号
                    tem[3] = Rx_2_Buffer[2];
                    tem[4] = Rx_2_Buffer[3];
                    tem[5] = Rx_2_Buffer[4];
                    tem[6] = 'e';
                    tem[7] = '\0';
                    UART_PutString(tem);
                }
                else if(Rx_2_Buffer[1] == 'h') //转发温度过高
                {
                    UART_PutString("sh2he");
                }
                else if(Rx_2_Buffer[1] == 'l') //转发温度过低
                {
                    UART_PutString("sh2le");
                }
                for(i = 0; i < Rx_2_Size; ++i)//处理完 清指令队列
                {
                    Rx_2_Buffer[i] = '\0';
                }
                Rx_2_Size = 0;
            }
            
            else if(Rx_2_Buffer[Rx_2_Size-1] == 'e' && Rx_2_Buffer[0] != 's')//指令出错
            {                
                LCD_Char_1_PrintString("e");
                for(i = 0; i < Rx_2_Size; ++i)//错误指令 清指令队列
                {
                    Rx_2_Buffer[i] = '\0';
                }
                Rx_2_Size = 0;
            }
            else if(Rx_2_Size > 10)
            {
                LCD_Char_1_PrintString("c");
                for(i = 0; i < Rx_2_Size; ++i)//错误指令 清指令队列
                {
                    Rx_2_Buffer[i] = '\0';
                }
                Rx_2_Size = 0;
            }
        }
        
    }
}