Ä¿¹Â´ÏƼ>°øÁö»çÇ×
   
   
 
    TFT ÅÍÄ¡ LCD Interface   2018.12.04
    TFT ÅÍÄ¡ LCD Interface
    Background.png
 

7" TFT LCD¸¦ ÀÌ¿ëÇÑ ÇÁ·ÎÁ§Æ®ÀÔ´Ï´Ù. #include #include #include #include #include "stm32f3xx_hal.h" #include "stm32f3xx.h" #include "stm32f3xx_it.h" #include "lcdcommand.h" #include "tm_stm32_delay.h" #include "ads1232.h" #include "temperktype.h" const int8_t FanButton[]="bt3\0"; const int8_t Fan1Dan[]="1\0"; const int8_t Fan2Dan[]="2\0"; const int8_t Fan3Dan[]="3\0"; const int8_t Fan4Dan[]="4\0"; const int8_t Fan5Dan[]="5\0"; const int8_t FanOff[]="Off\0"; extern UART_HandleTypeDef huart3; extern TIM_HandleTypeDef htim14; #define LCDQUESIZE 4 tLcdRxD LcdRxD[LCDQUESIZE]; bool bSetMode,BlinkOnOff; bool bTxLcdComplete; uint8_t ucPageNumber,ucRxCount; uint8_t ucLcdTxCommand[50],ucWorkBuff[20]; uint8_t ucTemperSkinBuff[20],ucWorkTimeBuff[20],ucTemperTankBuff[20]; uint8_t ucWorkMinute,ucWorkSec; uint8_t ucWorkSetMinute,ucWorkSetSec; uint8_t ucWorkCurrMinute,ucWorkCurrSec; uint16_t uiN2GasWeightLevel; uint16_t uiSkinTemperLevel; uint16_t uiElapTimeLevel; uint16_t uiTankTemperLevel; uint8_t ucSetPosion; uint8_t LcdQueueHead,LcdQueueTail; void SendLcdPage(uint8_t ucPage); void SendLcdPicture(uint8_t uiObjName,uint8_t uiPicNumber); void SendLcdText(uint8_t *Item,uint8_t *str); void SendLcdNumeric(uint8_t uiObjName,int16_t uiNumber); void SendLcdCheckBox(uint8_t uiObjName,uint8_t ucNumber); void SendLcdWaveform(uint8_t uiObjName,uint8_t ucCh,uint8_t ucNumber); void SendLcdItemOnOff(uint8_t uiObjName,uint8_t ucKind,uint8_t ucOnOff); void SendLcdBlank(uint8_t *Item); void SendLcdProgressBar(uint8_t uiObjName,uint16_t uiNumber); void DisplayWorkTime(uint8_t m,uint8_t s); void DisTemperSkin(float fTemperature); void DisTemperTank(int16_t iTemperature); void RxLcdDataProc(void); void FanLevelDis(void); const uint8_t LCDIMG[]={ AlphaBlank,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,AlphaPicB,0x80,0x00, AlphaPic0,AlphaPic1,AlphaPic2,AlphaPic3,AlphaPic4,AlphaPic5,AlphaPic6,AlphaPic7,AlphaPic8,AlphaPic9,0x00,0x00,0x00,0x48,0x00,0x00, 0x00,0x77,0x7c,0x58,0x5e,0x79,0x71,0x00,0x76,0x06,0x00,0x00,0x38,0x55,0x54,0x5c, 0x73,0x00,0x50,0x6d,0x78,0x1c,0x1c,0x1d,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00 }; const uint8_t TblWorkingObj[]={ CurrJobMin10,CurrJobMin1,CurrJobSec10,CurrJobSec1 }; const uint8_t TblTemperSkinObj[]={ FullJobH100,FullJobH10,FullJobH1 }; const uint8_t TblTemperTankObj[]={ TEMPERTANK1000,TEMPERTANK100,TEMPERTANK10,TEMPERTANK1 }; void SendLcdPage(uint8_t ucPage) { ucPageNumber=ucPage; memset(ucLcdTxCommand,0,sizeof(ucLcdTxCommand)); sprintf((char *)&ucLcdTxCommand[0],"page %d\xff\xff\xff\0",ucPage); HAL_UART_Transmit(&huart3,(uint8_t *)&ucLcdTxCommand[0],strlen((char*)ucLcdTxCommand),30); } void SendLcdPicture(uint8_t uiObjName,uint8_t uiPicNumber) { // char buf[10] = {0}; // itoa(uiPicNumber,WorkBuf); memset(ucLcdTxCommand,0,sizeof(ucLcdTxCommand)); sprintf((char *)&ucLcdTxCommand[0],"p%d.pic=%d\xff\xff\xff\0",uiObjName,uiPicNumber); HAL_UART_Transmit(&huart3,(uint8_t *)&ucLcdTxCommand[0],strlen((char*)ucLcdTxCommand),30); } void SendLcdText(uint8_t *Item,uint8_t *str) { memset(ucLcdTxCommand,0,sizeof(ucLcdTxCommand)); sprintf((char*)&ucLcdTxCommand[0],"%s.txt=\x22%s\x22\xff\xff\xff\0",Item,str); HAL_UART_Transmit(&huart3,(uint8_t *)&ucLcdTxCommand[0],strlen((char*)ucLcdTxCommand),30); } void SendLcdNumeric(uint8_t uiObjName,int16_t uiNumber) { // char buf[10] = {0}; // itoa(uiPicNumber,WorkBuf); memset(ucLcdTxCommand,0,sizeof(ucLcdTxCommand)); sprintf((char *)&ucLcdTxCommand[0],"n%d.val=%d\xff\xff\xff\0",uiObjName,uiNumber); HAL_UART_Transmit(&huart3,(uint8_t *)&ucLcdTxCommand[0],strlen((char*)ucLcdTxCommand),30); } //SendLcdWaveform(11,0,40); void SendLcdWaveform(uint8_t uiObjName,uint8_t ucCh,uint8_t ucNumber) { memset(ucLcdTxCommand,0,sizeof(ucLcdTxCommand)); sprintf((char *)&ucLcdTxCommand[0],"add %d,%d,%d\xff\xff\xff\0",uiObjName,ucCh,ucNumber); HAL_UART_Transmit(&huart3,(uint8_t *)&ucLcdTxCommand[0],strlen((char*)ucLcdTxCommand),30); } void SendLcdCheckBox(uint8_t uiObjName,uint8_t ucNumber) { //0=un check 1=check memset(ucLcdTxCommand,0,sizeof(ucLcdTxCommand)); sprintf((char *)&ucLcdTxCommand[0],"c%d.val=%d\xff\xff\xff\0",uiObjName,ucNumber); HAL_UART_Transmit(&huart3,(uint8_t *)&ucLcdTxCommand[0],strlen((char*)ucLcdTxCommand),30); } void SendLcdItemOnOff(uint8_t uiObjName,uint8_t ucKind,uint8_t ucOnOff) { memset(ucLcdTxCommand,0,sizeof(ucLcdTxCommand)); if(ucKind==PICTURE){ sprintf((char *)&ucLcdTxCommand[0],"vis p%d,%d\xff\xff\xff\0",uiObjName,ucOnOff); } if(ucKind==NUMERIC){ sprintf((char *)&ucLcdTxCommand[0],"vis n%d,%d\xff\xff\xff\0",uiObjName,ucOnOff); } if(ucKind==TEXTCHAR){ sprintf((char *)&ucLcdTxCommand[0],"vis t%d,%d\xff\xff\xff\0",uiObjName,ucOnOff); } HAL_UART_Transmit(&huart3,(uint8_t *)&ucLcdTxCommand[0],strlen((char*)ucLcdTxCommand),30); } void SendLcdProgressBar(uint8_t uiObjName,uint16_t uiNumber) { memset(ucLcdTxCommand,0,sizeof(ucLcdTxCommand)); sprintf((char *)&ucLcdTxCommand[0],"j%d.val=%d\xff\xff\xff\0",uiObjName,uiNumber); HAL_UART_Transmit(&huart3,(uint8_t *)&ucLcdTxCommand[0],strlen((char*)ucLcdTxCommand),30); } void SendLcdBlank(uint8_t *Item) { sprintf((char *)&ucWorkBuff[0]," \0"); SendLcdText(Item,ucWorkBuff); } void PageChangeProc(uint8_t ucPage) { ucPageNumber=ucPage; //È­¸é¿¡ ºÎ¸± ³»¿ëÀ» ´Ù½Ã »Ñ¸°´Ù. if(ucPageNumber==PAGE_MAIN){ // DisTemperSkin(fSkinTemperature); ucWorkMinute=0; ucWorkSec=0; DisplayWorkTime(ucWorkMinute,ucWorkSec); ucFireForce=2; FanLevelDis(); HAL_GPIO_WritePin(L_PDWN_GPIO_Port,L_PDWN_Pin,GPIO_PIN_SET); ads1232_init(); Temper_init(); } } void DisplayWorkTime(uint8_t m,uint8_t s) { uint8_t const *ptr; uint8_t i,j; if(ucPageNumber !=PAGE_MAIN){ return; } sprintf((char*)&ucWorkBuff[0],"%02u%02u\0",m,s); ptr=&LCDIMG[0]; if(ucWorkBuff[0]==0x30){ ucWorkBuff[0]=0x20; } for(i=0;i<4;i++){ if(ucWorkBuff[i] !=ucWorkTimeBuff[i]){ j=ucWorkBuff[i]; j-=0x20; SendLcdPicture(TblWorkingObj[i],*(ptr+j)); HAL_Delay(5); } } memcpy(ucWorkTimeBuff,ucWorkBuff,4); } void DisTemperSkin(float fTemperature) { uint8_t const *ptr; uint8_t i,j,k; if(ucPageNumber !=PAGE_MAIN){ return; } sprintf((char*)&ucWorkBuff[0],"%2.1f\0",fTemperature); ptr=&LCDIMG[0]; k=0; for(i=0;i<4;i++){ // if(ucWorkBuff[i] !=ucTemperSkinBuff[i]){ if(ucWorkBuff[i] !='.'){ j=ucWorkBuff[i]; j-=0x20; SendLcdPicture(TblTemperSkinObj[k],*(ptr+j)); HAL_Delay(5); k++; } // } } memcpy(ucTemperSkinBuff,ucWorkBuff,4); } void DisTemperTank(int16_t iTemperature) { uint8_t const *ptr; uint8_t i,j; bool bBlankCheck; if(ucPageNumber !=PAGE_MAIN){ return; } sprintf((char*)&ucWorkBuff[0],"%04d\0",iTemperature); bBlankCheck=0; for(i=0;i<4;i++){ if(ucWorkBuff[i]==0x30){ ucWorkBuff[i]=0x20; } else{ break; } } ptr=&LCDIMG[0]; for(i=0;i<4;i++){ if(ucWorkBuff[i] !=ucTemperTankBuff[i]){ j=ucWorkBuff[i]; j-=0x20; SendLcdPicture(TblTemperTankObj[i],*(ptr+j)); HAL_Delay(5); } } memcpy(ucTemperTankBuff,ucWorkBuff,4); } void LcdCommnadProc(void) { uint8_t ch; while (rx_rd_index3 !=rx_wr_index3 ){ ch=GetLcdData(); if(ch==STARTF){ ucRxCount=0; } aLcdRxCommand[0]=aLcdRxCommand[1]; aLcdRxCommand[1]=aLcdRxCommand[2]; aLcdRxCommand[2]=aLcdRxCommand[3]; aLcdRxCommand[3]=ch; ucRxCount++; if((ch==ENDF) || (ucRxCount>=4)){ if(aLcdRxCommand[0]==STARTF){ memcpy((uint8_t *)&LcdRxD[LcdQueueTail].ucStartFlag,(uint8_t *)&aLcdRxCommand[0],4); if(++LcdQueueTail>=LCDQUESIZE){ LcdQueueTail=0; } } ucRxCount=0; aLcdRxCommand[0]=0; } } } void FanLevelDis(void) { switch(ucFireForce){ case 1: SendLcdProgressBar(3,20); break; case 2: SendLcdProgressBar(3,40); break; case 3: SendLcdProgressBar(3,60); break; case 4: SendLcdProgressBar(3,80); break; case 5: SendLcdProgressBar(3,100); break; default: // HAL_TIM_Base_Stop_IT(&htim14); //Timer 14 Stop SendLcdProgressBar(3,0); // HAL_GPIO_WritePin(HeatOnOff_GPIO_Port,HeatOnOff_Pin,GPIO_PIN_SET); //Heater Off break; } } void IncProc(void) { if(bSetMode){ if(ucSetPosion){ //sec if(ucWorkSetSec<59){ ucWorkSetSec++; } } else{ if(ucWorkSetMinute<59){ ucWorkSetMinute++; } } ucBlinkTimes=0; BlinkOnOff=true; DisplayWorkTime(ucWorkSetMinute,ucWorkSetSec); } else{ //¿Âµµ Áõ°¨ if(ucFireForce<5){ ucFireForce++; if(ucFireForce==5){ HAL_TIM_Base_Stop_IT(&htim14); HAL_GPIO_WritePin(HeatOnOff_GPIO_Port,HeatOnOff_Pin,GPIO_PIN_RESET); //Heater On } } FanLevelDis(); } } void DecProc(void) { if(bSetMode){ if(ucSetPosion){ //sec if(ucWorkSetSec){ ucWorkSetSec--; } } else{ if(ucWorkSetMinute){ ucWorkSetMinute--; } } ucBlinkTimes=0; BlinkOnOff=true; DisplayWorkTime(ucWorkSetMinute,ucWorkSetSec); } else{ //¿Âµµ Áõ°¨ if(ucFireForce){ ucFireForce--; } FanLevelDis(); } } void ShiftProc(void) { if(bSetMode){ if(++ucSetPosion>1){ ucSetPosion=0; } ucBlinkTimes=0; BlinkOnOff=true; DisplayWorkTime(ucWorkSetMinute,ucWorkSetSec); } } void BlinkProc(void) { uint8_t i; if(bSetMode){ if(++ucBlinkTimes>=150){ ucBlinkTimes=0; if(BlinkOnOff){ BlinkOnOff=false; } else{ BlinkOnOff=true; } if(BlinkOnOff){ DisplayWorkTime(ucWorkSetMinute,ucWorkSetSec); } else{ if(ucSetPosion){ for(i=2;i<4;i++){ SendLcdPicture(TblWorkingObj[i],AlphaBlank); HAL_Delay(5); ucWorkTimeBuff[i]=0; } } else{ for(i=0;i<2;i++){ SendLcdPicture(TblWorkingObj[i],AlphaBlank); HAL_Delay(5); ucWorkTimeBuff[i]=0; } } } } } } void RxLcdDataProc(void) { uint8_t ucCommand; if(LcdQueueHead !=LcdQueueTail){ LcdRxD[LcdQueueHead].ucStartFlag; ucCommand=LcdRxD[LcdQueueHead].ucPage; if((ucCommand=='P') || (ucPageNumber !=PAGE_MAIN)){ PageChangeProc(PAGE_MAIN); } else{ switch(ucCommand){ case 'B': //+,- if(LcdRxD[LcdQueueHead].ucButton=='+'){ IncProc(); } else if(LcdRxD[LcdQueueHead].ucButton=='-'){ DecProc(); } else if(LcdRxD[LcdQueueHead].ucButton=='S'){ //shift ShiftProc(); } else if(LcdRxD[LcdQueueHead].ucButton=='R'){ // ½Ã°£ ¸®¼Â ucWorkCurrSec=ucWorkSec; ucWorkCurrMinute=ucWorkMinute; } break; case 'S': //start/stop 1=start,0=stop if(LcdRxD[LcdQueueHead].ucButton==0x01){ if(bTankEmpty==false){ //¹Î¾à ¼³Á¤ ÁßÀ̶ó¸é °ª ÀúÀåÇÏ°í ½ÃÀÛ if(bSetMode){ bSetMode=false; ucWorkSec=ucWorkSetSec; ucWorkMinute=ucWorkSetMinute; DisplayWorkTime(ucWorkMinute,ucWorkSec); memset(ucLcdTxCommand,0,sizeof(ucLcdTxCommand)); sprintf((char *)&ucLcdTxCommand[0],"bt2.val=%d\xff\xff\xff\0",0); HAL_UART_Transmit(&huart3,(uint8_t *)&ucLcdTxCommand[0],strlen((char*)ucLcdTxCommand),30); } bRunStop=true; SetTemperPCB(RAZER_ON|DCT_TEMPER_ON); ucWorkCurrSec=ucWorkSec; ucWorkCurrMinute=ucWorkMinute; //Ãâ·Â ·¹º§¿¡ ¸Â´Â Heater On } } else{ bRunStop=false; SetTemperPCB(DCT_TEMPER_ON); HAL_GPIO_WritePin(HeatOnOff_GPIO_Port,HeatOnOff_Pin,GPIO_PIN_SET); HAL_TIM_Base_Stop_IT(&htim14); //Heater Fire Stop } break; case 'T': //time setting 1,0 if(LcdRxD[LcdQueueHead].ucButton==0x01){ //time setting ucWorkSetMinute=ucWorkMinute; ucWorkSetSec=ucWorkSec; bSetMode=true; } else{ ucWorkSec=ucWorkSetSec; ucWorkMinute=ucWorkSetMinute; bSetMode=false; DisplayWorkTime(ucWorkMinute,ucWorkSec); } break; default: break; } } if(++LcdQueueHead>=LCDQUESIZE){ LcdQueueHead=0; } } }

 
 
   
 
ÁÖ¼Ò: ÀÎõ±¤¿ª½Ã ¼­±¸ ºÀ¼ö´ë·Î 141 °¡Á½ùü°ø´Ü Bµ¿ 505È£    ´ëÇ¥ÀÚ : ±è½Ã¼®    ÀüÈ­¹øÈ£ : 032)672-2966    Æѽº¹øÈ£ : 032)672-2965
»ç¾÷ÀÚµî·Ï ¹øÈ£ : 225-14-00080    ÄÜÆ®·Ñ·¯°³¹ß,ÀüÀÚÁ¦Ç°°³¹ß ¾ÆÅ×Å©