/** * Prints the given message on the given line. * The line are cleared before print. * * @param msg The string to print * @param msg The line number */ static void setStatus(const char * msg, uint8_t line) { LCD_GotoXY(0, line); LCD_PutString(" "); LCD_GotoXY(0, line); LCD_PutString(msg); }
void showMenuItem(uchar index,bit selected){ ClrScreen(); LCD_PutString(3,1,"设置"); LCD_PutString(2,2,configMenuStrArr[index]); if(selected){ LCD_PutChar(1,2,26);//输出"->" } }
void showMenuItem(uchar index,bit selected){ ClrScreen(); if(configValueArr[CONFIG_DEBUG]!=0){ LCD_PutString(0,0,"调试"); } LCD_PutString(3,0,"设置"); LCD_PutString(2,1,configMenuStrArr[index]); if(selected){ LCD_PutChar(1,2,26);//输出"->" } }
void displayStaffInfo(){ uchar m,indexi=0,indexj=0,count=0,isChinese=0; if(inSetting){ return; } ClrScreen(); for(m=0;m<FIELD_COUNT;m++){ LCD_PutString(0,m+1,fieldName[m]); LCD_PutString(3,m+1,staffInfoBuf[m]); } }
/************************************************************* * 函数名称:LCD_DrawCir * 功 能:在指定位置画圆 * 参 数: * x: 窗体中圆心坐标 * y: 窗体中圆心坐标 * r: 圆的半径 * Colour:圆的颜色 * 返 回 值:无 *************************************************************/ void LCD_DrawCir(u16 x,u16 y,u16 r,u16 Colour) { u16 i,j; if(horizontal_or_vertical) //横屏显示时 { if(x+r>320||r-x>0) LCD_PutString(19,190,"ERRO!",Red,Black); if(r+y>240||r-y>0) LCD_PutString(19,190,"ERRO!",Red,Black); LCD_WR_CMD(0x0044,(y+r-1)<<8); LCD_WR_CMD(0x004e,y-r); //设置X方向初始值 /*R45、R46 垂直方向的起、止点*/ LCD_WR_CMD(0x0045,x-r); LCD_WR_CMD(0x0046,x+r-1); LCD_WR_CMD(0x004f,x-r); //设置y方向初始值 } else //竖屏显示时 { if(x+r>240||r-x>0) LCD_PutString(19,190,"ERRO!",Red,Black);; if(r+y>320||r-y>0) LCD_PutString(19,190,"ERRO!",Red,Black);; LCD_WR_CMD(0x0044,((x+r-1)<<8)+x-r); LCD_WR_CMD(0x004e,x-r); //设置X方向初始值 /*R45、R46 垂直方向的起、止点*/ LCD_WR_CMD(0x0045,y-r); LCD_WR_CMD(0x0046,y+r-1); LCD_WR_CMD(0x004f,y-r); //设置y方向初始值 } LCD_WR_ADD(0x0022); for(i=0;i<2*r;i++) for(j=0;j<2*r;j++) { if((abs(r-i)*abs(r-i)+abs(r-j)*abs(r-j))<=r*r) LCD_WR_DATA(Colour); else { LCD_WR_DATA(Red); } } }
void dispDigit(){ digiDispBuf[0]='0'+digiBuf[0]; digiDispBuf[1]='0'+digiBuf[1]; digiDispBuf[2]='0'+digiBuf[2]; digiDispBuf[3]='\0'; LCD_PutString(3,2,digiDispBuf); }
void main (void) { /*开硬件浮点*/ SCB->CPACR |=((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */ uint16 flag; uint16 i,j; DisableInterrupts; LCD_init(1); Disp_single_colour(Black); LCD_PutString(10, 50,"Frequency: ", White, Black); LCD_PutString(145, 50," KHz", White, Black); LCD_PutString(10, 80,"Power: ", White, Black); LCD_PutString(145, 80," W", White, Black); LCD_PutString(10, 110,"Amplify: ", White, Black); LCD_PutString(165, 110,"Restrain: ", White, Black); init_ADC(); init_DAC(); init_DMA(); init_PDB(); init_PIT(); init_gpio_PE24(); EnableInterrupts; LPLD_LPTMR_DelayMs(100); flag = Result_flag; uint16 ShowAFlag = 0; uint16 ShowBFlag = 0; uint16 ShowCFlag = 0; arm_fir_init_f32(&S, NUM_TAPS, (float32_t *)&firCoeffs32[0], &firStateF32[0], blockSize); while(1) { if( flag==Result_flag && Result_flag == 0) { if(++ShowAFlag<10) { for(j = 0;j<LENGTH;j++) testInput_x[j*2] = Result_A[j]; for(j = 0;j<LENGTH;j++) testInput_x[j*2+1] = 0; arm_cfft_f32(&arm_cfft_sR_f32_len2048, testInput_x, ifftFlag, doBitReverse); /* Process the data through the Complex Magnitude Module for calculating the magnitude at each bin */ arm_cmplx_mag_f32(testInput_x, testOutput, fftSize); testOutput[0] = 0; /* Calculates maxValue and returns corresponding BIN value */ arm_max_f32(testOutput, fftSize, &maxValue, &testIndex); } else { ShowAFlag = 0; if(starfir !=2 ) LCD_Put_Float(100, 50,"",testIndex*40.0/2048, White, Black); } if(starfir == 1) { PTE24_O = 1; for(j = 0;j<LENGTH;j++) firInput[j] = Result_A[j]; inputF32 = &firInput[0]; outputF32 = &firOutput[0]; for(i=0; i < numBlocks; i++) arm_fir_f32(&S, inputF32 + (i * blockSize), outputF32 + (i * blockSize), blockSize); for(j = 0;j<LENGTH;j++) Result_A[j] = firOutput[j]; PTE24_O = 0; } flag = 1; } else if(flag==Result_flag && Result_flag == 1) { if(starfir !=2 ) { if(++ShowBFlag<10) { power = 0; for(i=0;i<LENGTH;i++) power+=((Result_B[i] - OFFEST)/1241.0)*((Result_B[i] - OFFEST)/1241.0)*90*MyDb/8.0; power = power/LENGTH; } else { ShowBFlag = 0; LCD_Put_Float(100, 80,"",power, White, Black); } } else { for(i = 0;i<160;i++) { FFT_RESULT_NEW[i] = testOutput[i*6]/FFT_VALUE; if(FFT_RESULT_NEW[i]>239) FFT_RESULT_NEW[i] = 239; } } // { // for(j = 0;j<LENGTH;j++) // testInput_x[j*2] = Result_B[j]; // for(j = 0;j<LENGTH;j++) // testInput_x[j*2+1] = 0; // // arm_cfft_f32(&arm_cfft_sR_f32_len2048, testInput_x, ifftFlag, doBitReverse); // // /* Process the data through the Complex Magnitude Module for // calculating the magnitude at each bin */ // arm_cmplx_mag_f32(testInput_x, testOutput, fftSize); // // testOutput[0] = 0; // /* Calculates maxValue and returns corresponding BIN value */ // arm_max_f32(testOutput, fftSize, &maxValue, &testIndex); // } if(starfir == 1) { PTE24_O = 1; for(j = 0;j<LENGTH;j++) firInput[j] = Result_B[j]; inputF32 = &firInput[0]; outputF32 = &firOutput[0]; for(i=0; i < numBlocks; i++) arm_fir_f32(&S, inputF32 + (i * blockSize), outputF32 + (i * blockSize), blockSize); for(j = 0;j<LENGTH;j++) Result_B[j] = firOutput[j]; PTE24_O = 0; } flag = 2; } else if(flag==Result_flag && Result_flag == 2) { // // { // for(j = 0;j<LENGTH;j++) // testInput_x[j*2] = Result_C[j]; // for(j = 0;j<LENGTH;j++) // testInput_x[j*2+1] = 0; // // arm_cfft_f32(&arm_cfft_sR_f32_len2048, testInput_x, ifftFlag, doBitReverse); // // /* Process the data through the Complex Magnitude Module for // calculating the magnitude at each bin */ // arm_cmplx_mag_f32(testInput_x, testOutput, fftSize); // // testOutput[0] = 0; // /* Calculates maxValue and returns corresponding BIN value */ // arm_max_f32(testOutput, fftSize, &maxValue, &testIndex); // } if(starfir == 1) { // PTE24_O = 1; for(j = 0;j<LENGTH;j++) firInput[j] = Result_C[j]; inputF32 = &firInput[0]; outputF32 = &firOutput[0]; for(i=0; i < numBlocks; i++) arm_fir_f32(&S, inputF32 + (i * blockSize), outputF32 + (i * blockSize), blockSize); for(j = 0;j<LENGTH;j++) Result_C[j] = firOutput[j]; // PTE24_O = 0; } if(starfir != 2) { if(++ShowCFlag<5) { } else { if(ShowMenu) { Disp_single_colour(Black); LCD_PutString(10, 50,"Frequency: ", White, Black); LCD_PutString(145, 50," KHz", White, Black); LCD_PutString(10, 80,"Power: ", White, Black); LCD_PutString(145, 80," W", White, Black); LCD_PutString(10, 110,"Amplify: ", White, Black); LCD_PutString(165, 110,"Restrain: ", White, Black); ShowMenu = 0; } LCD_Put_Float(100, 110,"",MyDb/0.5, White, Black); if(starfir) LCD_PutString(260, 110,"On ", White, Black); else LCD_PutString(260, 110,"Off", White, Black); } } else { if(ShowMenu) { Disp_single_colour(Black); ShowMenu = 0; } draw_fft(); } flag = 0; } } }
//================================================================================================ // 函数名称: 主函数 // 实现功能: 控制TFT实现汉字,字符显示. // 参数: 无 // 返回值: 无 //================================================================================================ main() { // unsigned char run_computer,direction_index_computer; unsigned int x,y,z,di; float total,angle; Device_code=0x9320; //TFT控制IC型号 TFT_Initial(); //初始化LCD PCON=0x80; //设置波特率及串口中断 SCON=0x50; TMOD=0x20; //T0方式1 TH1=0xF3; TL1=0xF3; IT0=1; IT1=1; TR1=1; EX1=1; EX0=1; ES=1; EA=1; direction=1; Show_RGB(0,240,0,320,Blue); LCD_PutString(0,16," 中 国 科 学 院 ",White,Blue); LCD_PutString(0,40," 安徽光学精密机械研究所 ",White,Blue); LCD_PutString(0,72,"当前角度 ",White,Blue); LCD_PutString(110,72,"度",White,Blue); LCD_PutString(0,88,"当前值",White,Blue); LCD_PutString(0,120,"方向",White,Blue); LCD_PutString(0,152,"模式",White,Blue); LCD_PutString(0,184,"状态",White,Blue); LCD_PutString(0,304,"version 1,aiofm,hfcas",White,Blue); while(1) { LCD_PutChar(70,88,rec_line[11],White,Blue); LCD_PutChar(78,88,rec_line[12],White,Blue); LCD_PutChar(86,88,rec_line[13],White,Blue); LCD_PutChar(94,88,rec_line[14],White,Blue); total=(float)(((int)num[0])*1000+((int)num[1])*100+num[2]*10+((int)num[3])); //显示当前读数 angle=total/4095.0*360.0; x=((int)angle)/100; y=((int)angle)/10%10; z=((int)angle)%10; di=((int)(angle*10))%10; LCD_PutChar(70,72,display1[x],White,Blue); //显示当前角度 LCD_PutChar(78,72,display1[y],White,Blue); LCD_PutChar(86,72,display1[z],White,Blue); LCD_PutChar(94,72,'.',White,Blue); LCD_PutChar(102,72,display1[di],White,Blue); if(boardorcomputer==1) { if(run==0) { LCD_PutString(40,184,"运行",White,Blue); TH0 = (8192 - 200)/32 ; //给计数器装初值 TL0 = (8192 - 200)%32 ; ET0=1; TR0=1; } else { LCD_PutString(40,184,"停止",White,Blue); ET0 = 0; TR0 = 0; motor=0; } if(direction_index==1) { LCD_PutString(40,120,"逆时针",White,Blue); direction=0; } else { LCD_PutString(40,120,"顺时针",White,Blue); direction=1; } if(modekey==1) { LCD_PutString(40,152,"常规",White,Blue); } else { LCD_PutString(40,152,"微调",White,Blue); } } else { switch(computer_char) { case 0xff: { LCD_PutString(40,184,"运行",White,Blue); TH0 = (8192 - 200)/32 ; //给计数器装初值 TL0 = (8192 - 200)%32 ; ET0=1; TR0=1; break; } case 0x00: { LCD_PutString(40,184,"停止",White,Blue); ET0 = 0; TR0 = 0; motor=0; break; } case 0xf0: { LCD_PutString(40,120,"逆时针",White,Blue); direction=0; break; } case 0x0f: { LCD_PutString(40,120,"顺时针",White,Blue); direction=1; break; } case 0x30: { computermode=0; LCD_PutString(40,152,"常规",White,Blue); break; } case 0x03: { computermode=1; LCD_PutString(40,152,"微调",White,Blue); break; } defult:break; } } } }
void Ir_work(void) { switch (IRcord[2]){ //600us计时模式下 case IR_CHANNEL: if(setState==SET_STATE_NONE) { startSetting=1; } break; case IR_EQ: if(setState==SET_STATE_INIT){ setState=SET_STATE_MENU; curMenuIndex=0; showMenuItem(curMenuIndex,1); } else if(setState==SET_STATE_MENU){ setState=SET_STATE_MENU_ITEM_SEL; curSelBit=0; showMenuItem(curMenuIndex,1); digiBuf[0]=configValueArr[curMenuIndex]/100; digiBuf[1]=(configValueArr[curMenuIndex]%100)/10; digiBuf[2]=configValueArr[curMenuIndex]%10; dispDigit(); } else if(setState==SET_STATE_MENU_ITEM_SEL){ setState=SET_STATE_MENU_ITEM_BIT_SEL; showMenuItem(curMenuIndex,0); LCD_PutChar(2,3,26);//输出"->" dispDigit(); curSelBit=0; LCD_PutPosition(3+curSelBit,3); } else if(setState==SET_STATE_MENU_ITEM_BIT_SEL){ if(curMenuIndex==CONFIG_EXIT){ // setState=SET_STATE_NONE; // inSetting=0; } else{ configValueArr[curMenuIndex]=digiBuf[0]*100+digiBuf[1]*10+digiBuf[2]; saveConfig(); LCD_PutString(2,4,"设置完毕!"); setState=SET_STATE_MENU_ITEM_FINISHED; } } break; case IR_CHANNEL_MINUS: if(setState==SET_STATE_MENU||setState==SET_STATE_INIT){ setState=SET_STATE_NONE; clearInfraredFlag(); ClrScreen();//强行清屏 inSetting=0; } else if(setState==SET_STATE_MENU_ITEM_SEL){ setState=SET_STATE_MENU; showMenuItem(curMenuIndex,1); } else if(setState==SET_STATE_MENU_ITEM_BIT_SEL){ setState=SET_STATE_MENU; showMenuItem(curMenuIndex,1); } else if(setState==SET_STATE_MENU_ITEM_FINISHED){ setState=SET_STATE_MENU_ITEM_BIT_SEL; showMenuItem(curMenuIndex,0); LCD_PutChar(2,3,26);//输出"->" dispDigit(); curSelBit=0; LCD_PutPosition(3+curSelBit,3); } break; case IR_NEXT: if(setState==SET_STATE_MENU){ curMenuIndex=(curMenuIndex+1)%MENU_LEN; // curMenu=curMenuArr[curMenuIndex]; showMenuItem(curMenuIndex,1); } else if(setState==SET_STATE_MENU_ITEM_BIT_SEL){ curSelBit=(curSelBit+1)%BITS_COUNT; LCD_PutPosition(3+curSelBit,3); } break; case IR_PREV: if(setState==SET_STATE_MENU){ curMenuIndex=(curMenuIndex+MENU_LEN-1)%MENU_LEN; // curMenu=curMenuArr[curMenuIndex]; showMenuItem(curMenuIndex,1); } else if(setState==SET_STATE_MENU_ITEM_BIT_SEL){ curSelBit=(curSelBit+BITS_COUNT-1)%BITS_COUNT; LCD_PutPosition(3+curSelBit,3); } break; case IR_VOL_ADD: if(setState==SET_STATE_MENU){ curMenuIndex=(curMenuIndex+1)%MENU_LEN; // curMenu=curMenuArr[curMenuIndex]; showMenuItem(curMenuIndex,1); } else if(setState==SET_STATE_MENU_ITEM_BIT_SEL){ digiBuf[curSelBit]=(digiBuf[curSelBit]+1)%10; dispDigit(); } break; case IR_VOL_MINUS: if(setState==SET_STATE_MENU){ curMenuIndex=(curMenuIndex+MENU_LEN-1)%MENU_LEN; // curMenu=curMenuArr[curMenuIndex]; showMenuItem(curMenuIndex,1); }else if(setState==SET_STATE_MENU_ITEM_BIT_SEL){ digiBuf[curSelBit]=(digiBuf[curSelBit]+10-1)%10; dispDigit(); } break; case IR_ZERO: if(setState==SET_STATE_MENU_ITEM_BIT_SEL){ digiBuf[curSelBit]=0; dispDigit(); } break; case IR_ONE: if(setState==SET_STATE_MENU_ITEM_BIT_SEL){ digiBuf[curSelBit]=1; dispDigit(); } break; case IR_TWO: if(setState==SET_STATE_MENU_ITEM_BIT_SEL){ digiBuf[curSelBit]=2; dispDigit(); } break; case IR_THREE: if(setState==SET_STATE_MENU_ITEM_BIT_SEL){ digiBuf[curSelBit]=3; dispDigit(); } break; case IR_FOUR: if(setState==SET_STATE_MENU_ITEM_BIT_SEL){ digiBuf[curSelBit]=4; dispDigit(); } break; case IR_FIVE: if(setState==SET_STATE_MENU_ITEM_BIT_SEL){ digiBuf[curSelBit]=5; dispDigit(); } break; case IR_SIX: if(setState==SET_STATE_MENU_ITEM_BIT_SEL){ digiBuf[curSelBit]=6; dispDigit(); } break; case IR_SEVEN: if(setState==SET_STATE_MENU_ITEM_BIT_SEL){ digiBuf[curSelBit]=7; dispDigit(); } break; case IR_EIGHT: if(setState==SET_STATE_MENU_ITEM_BIT_SEL){ digiBuf[curSelBit]=8; dispDigit(); } break; case IR_NINE: if(setState==SET_STATE_MENU_ITEM_BIT_SEL){ digiBuf[curSelBit]=9; dispDigit(); } break; default: break; } }