void Num_Test(void) { uint8_t i=0; Lcd_Clear(GRAY0); Gui_DrawFont_GBK16(16,20,RED,GRAY0,"Num Test"); delay_ms(1000); Lcd_Clear(GRAY0); for(i=0;i<10;i++){ Gui_DrawFont_Num32((i%3)*40,32*(i/3)+30,RED,GRAY0,Num[i+1]); delay_ms(100); } }
void main(void) { unsigned int a; char *ptr; char str[3] = "LCD"; char str2[] = "MPLAB C18"; TRISD = 0x00; while(1) { Lcd_Clear(); Lcd_Set_Cursor(1,1); ptr = &str[0]; Lcd_Write_String(ptr); Lcd_Set_Cursor(2,1); ptr = &str2[0]; Lcd_Write_String(ptr); Delay10KTCYx(200); Lcd_Clear(); Lcd_Set_Cursor(1,1); Lcd_Write_String("Developed By"); Lcd_Set_Cursor(2,1); Lcd_Write_String("Faintree"); Delay10KTCYx(200); Lcd_Clear(); Lcd_Set_Cursor(1,1); Lcd_Write_String("something"); for(a=0; a<15; a++) { Delay10KTCYx(30); Lcd_Shift_Left(); } for(a=0; a<15; a++) { Delay10KTCYx(30); Lcd_Shift_Right(); } Lcd_Clear(); Lcd_Set_Cursor(2,1); Lcd_Write_Char('e'); Lcd_Write_Char('S'); Delay10KTCYx(300); } }
void ResetCodeDataProc() // 소프트 리셋 { BUTTON KeyIn; LCD_Clear(); strcpy(st, " SYSTEM RESET OK? "); PrintLCD(0,0,st); strcpy(st, " YES = PRESS [RUN]"); PrintLCD(2,3,st); while( 1 ){ KeyIn = GetKey(); if( KeyIn == BTN_RUN){ Lcd_Clear(); Lcd_x_posi = 0, Lcd_y_posi = 0; strcpy(gSciTxBuf,"9:4:902:5.000e-0"); // SYSTEM INIT SendSciString( gSciTxBuf ); machine_state = STATE_MONITOR_MODE; return; } else if ( KeyIn == BTN_STOP){ machine_state = STATE_SET_MODE; return; } } }
void SystemInitProc() // 시스템 초기화 { BUTTON KeyIn; int loopCtrl = 1; LCD_Clear(); strcpy(st, "SYSTEM INIT OK?"); PrintLCD(0,0,st); strcpy(st, "PRESS RUN RESET"); PrintLCD(2,3,st); while( loopCtrl ){ KeyIn = GetKey(); if( KeyIn == BTN_RUN){ Lcd_Clear(); Lcd_x_posi = 0, Lcd_y_posi = 0; strcpy(gSciTxBuf,"9:4:902:5.000e-0"); // SYSTEM TRDRY SendSciString( gSciTxBuf ); machine_state = STATE_EDIT_MODE; return; } else if ( KeyIn == BTN_STOP){ machine_state = STATE_EDIT_MODE; return; } } }
void RecordClearProc() // Trip Record All Clear { BUTTON KeyIn; int loopCtrl =1; strcpy(st, " REC CLEAR ALL! OK? "); PrintLCD(0,0,st); strcpy(st, " YES NO "); PrintLCD(2,3,st); while(loopCtrl){ KeyIn = GetKey(); if( KeyIn == BTN_RUN){ Lcd_x_posi = 0; Lcd_y_posi = 0; Lcd_Clear(); strcpy(Trip_Message, " "); strcpy(gSciTxBuf,"9:4:904:2.000e-0"); SendSciString( gSciTxBuf ); delay_ms(50); } else if ( KeyIn == BTN_STOP){ machine_state = STATE_EDIT_MODE; return; } } }
static void Lcd_Example(void){ Lcd_Clear(); Lcd_Cursor(0,0); chprintf((BaseSequentialStream *)&myLCD,"STM32"); Lcd_Cursor(0,1); chprintf((BaseSequentialStream *)&myLCD,"TF ITS"); }
int main(void) { Thread *shelltp = NULL; halInit(); chSysInit(); palSetPadMode(GPIOA,9,PAL_MODE_STM32_ALTERNATE_PUSHPULL); palSetPadMode(GPIOA,10,PAL_MODE_INPUT); sdStart(&SD1, NULL); shellInit(); palSetPadMode(GPIOA,8,PAL_MODE_OUTPUT_PUSHPULL); chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); Lcd_Init(); Lcd_Clear(); Lcd_Example(); while (TRUE) { if (!shelltp){ shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);} else if (chThdTerminated(shelltp)) { chThdRelease(shelltp); shelltp = NULL; } chThdSleepMilliseconds(500); } }
//============================================================================== void ICACHE_FLASH_ATTR Lcd_Init(void){ //P3DIR |= (BIT0 | BIT1 | BIT2 | BIT3); easygpio_pinMode(pinSclk, EASYGPIO_NOPULL, EASYGPIO_OUTPUT); easygpio_pinMode(pinSdin, EASYGPIO_NOPULL, EASYGPIO_OUTPUT); easygpio_pinMode(pinSce, EASYGPIO_NOPULL, EASYGPIO_OUTPUT); easygpio_pinMode(pinReset, EASYGPIO_NOPULL, EASYGPIO_OUTPUT); cs(0);// = 0; rst(0);// = 0; os_delay_us(10000); // 5mS so says the stop watch(less than 5ms will not work) rst(1);// = 1; // STE2007 controller initialization spi(CMD, 0x2F);//Включение дисплея spi(CMD, 0x38);//Включение термокомпенсации spi(CMD, 0xA0);//Инверсия отображения spi(CMD, 0xA6);//0xA7 - инверсия отображения spi(CMD, 0x9f);//Установка контраста spi(CMD, 0xEC);//Установка частоты обновления 80 Гц //spi(CMD,0xC8); // mirror Y axis (about X axis) //spi(CMD,0xA1); spi(CMD, 0xAF);//Разрешение работы LCD spi(CMD, 0xA4);//Очистка экрана Lcd_Clear(); // clear LCD //LINES(); }
//////////////////////////////////////////////////////////// // MAIN //////////////////////////////////////////////////////////// void main(void) { // Configura el Oscilador interno a 8Mhz OSCCONbits.IRCF = 0b111; // InitAllLEDs PORTA = 0x00; TRISAbits.TRISA0 = 1; // 1 input TRISAbits.TRISA1 = 1; // 1 input TRISAbits.TRISA2 = 1; // 1 input TRISAbits.TRISA3 = 1; // 1 input // FOR ADC TRISAbits.TRISA4 = 1; // 1 input TRISAbits.TRISA5 = 1; // 1 input // ICSP VPP TRISAbits.TRISA6 = 1; // 1 input // OSCILATOR TRISAbits.TRISA7 = 1; // 1 input // OSCILATOR PORTB = 0x00; //TRISB = 0x00; // 0x00 all as output TRISBbits.TRISB0 = 0; // 0 output TRISBbits.TRISB1 = 0; // 0 output TRISBbits.TRISB2 = 0; // 0 output // FOR LCD_D4 TRISBbits.TRISB3 = 0; // 0 output // FOR LCD_D5 TRISBbits.TRISB4 = 0; // 0 output // FOR LCD_D6 TRISBbits.TRISB5 = 0; // 0 output // FOR LCD_D7 TRISBbits.TRISB6 = 0; // 0 output // PGD (1 is value on POR) & LCD_RS TRISBbits.TRISB7 = 0; // 0 output // PGC (1 is value on POR) & LCD_E //PORTB = 0x00; initADC(); Lcd_Init(); //CMCON = 0x07; while(1) { // INIT ADC CONVERSION initADCConversion(); while(isADCConversionReady() == 0) { ; } int result = getADC10bitResult(); // result = 0-1023 float minValue = 0.0; float maxValue = 5.0; float unitValue = (maxValue-minValue)/1024; // 5.0 / 1024 // Si el voltaje alcanza el máximo valor (Vref+) currentValue=5 y si se queda en el mínimo valor (Vref-) currentValue=0. float currentValue = result * unitValue; //setBCDsText(ftoa(currentValue, (int *) 0)); //setBCDCharacterNumber(integ); Lcd_Clear(); Lcd_Set_Cursor(1,1); Lcd_Write_String(ftoa(currentValue, (int *) 0)); } }
void InitDso(void) { Lcd_Clear(CL_BLUE); DsoInitParam(); Init_DSO(&g_DsoA); // FrameDisp(); // ChInfoDisp(); }
/* * Simply a function that prints out a standard welcome message on startup. */ void welcome(void){ Lcd_Clear(); Lcd_Set_Cursor(1,1); Lcd_Write_String(w0); Lcd_Set_Cursor(2,1); Lcd_Write_String(w1); delays(2); }
void LCD_init(void){ Lcd_Init(); Lcd_Clear(); Lcd_Set_XY(0,0); Lcd_Write_String(0,0,"Rw_ECG"); Lcd_Write_String(0,1,"Hello! Your heart rate is: "); Lcd_Write_String(0,4,"---"); }
//********************************************************************** // LCD 初始化 //********************************************************************** void Lcd_Reset() { Lcd_WriteCmd(0x30); //选择基本指令集 Lcd_WriteCmd(0x01); //清除显示,并且设定地址指针为00H Lcd_WriteCmd(0x0c); //开显示(无游标、不反白) Lcd_Clear(); //清除液晶GDRAM中的数据 Lcd_WriteCmd(0x01); //清除显示,并且设定地址指针为00H Lcd_WriteCmd(0x06); //在资料的读取及写入时游标自动右移 }
//相关初始化 void Init_sth(void) { Lcd_Init(); __HAL_UART_ENABLE_IT(&huart2, UART_IT_IDLE); HAL_GPIO_WritePin(GPIOA,GPIO_PIN_0,GPIO_PIN_SET); Lcd_Clear(GREEN); showimage_farsight(gImage_logo); Gui_DrawFont_GBK16(28,40,BLUE,GREEN,(uint8_t *)"Touch ID"); }
//show clock int main() { /* Setup the microcontroller system. Initialize the Embedded Flash Interface, initialize the PLL and update the SystemFrequency variable. */ xSysCtlClockSet(72000000, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_8MHZ); xSysCtlDelay(10000); delay_init(72); Lcd_Init(); Lcd_Clear(GRAY0); Gui_DrawFont_GBK16(30,50,BLUE,GRAY0,"Show Clock"); Gui_DrawFont_GBK16(36,70,BLUE,GRAY0,"@ CooCox"); delay_ms(2000); Lcd_Clear(GRAY0); while(1){ Show_Clock(); } }
/*This function takes in 2 arguments, corresponding to what should be displayed on * the 1st and 2nd lines of the LCD screen. * title_item selects which string to display as the title to the menu position. * value_item selects which string to display while changing the submenu item value. */ void LCD_disp(int title_item, int value_item) { char string[LCDL]; Lcd_Clear(); Lcd_Set_Cursor(1,1); Lcd_Write_String(menutitle[title_item]); //Checks if in Manual or Factory mode if (menu_ref_1<=1){ //possibly need to change order of phrases to //include a check for user assist mode, in which case //we check if menu_ref_1 <= 2 // Leo: we don't need to, it does it automatically if (menu_ref_2<=2){ Lcd_Set_Cursor(2,1); sprintf(string, "%s%d%", stringtab[value_item],values[value_item]); Lcd_Write_String(string); } //Statistics //Average: takes the mean of values stored in the IR array else if(menu_ref_2==7){ // unsigned char i; // int total; // int average; // for (i=values[IRSAMPE];i>0;i--){ // total=+IR_samps[i]; //IR_samps defines the array not yet present // } // values[IRAVG]=total/values[IRSAMPE]; // sprintf(string,"%s%d", stringtab[IRAVG], values[IRAVG]); // Lcd_Write_String(string); } else { Lcd_Set_Cursor(2,1); sprintf(string, "%s%d", stringtab[value_item],values[value_item]);//no % symbol Lcd_Write_String(string); } } //To do: Semi auto should have a display of cm from tilt //############################# }
void CheckSumErrorProc() { BUTTON KeyIn; int loopCtrl =1; strcpy(st, " BACKUP RESTORE OK?"); strcpy(st, " INIT RESTORE OK? "); PrintLCD(0,0,st); strcpy(st, " YES NO "); PrintLCD(2,3,st); while(loopCtrl){ KeyIn = GetKey(); if ( KeyIn == BTN_ESC){ if(Flag_Set == 1 && Flag_Start == 1) DisplayChar(2, Flag_Set + 1, ' ' ); else if(Flag_Set == 2 && Flag_Start == 1) DisplayChar(2, Flag_Set + 8, ' ' ); if(Flag_Start != 3) Flag_Set++; } else if ( KeyIn == BTN_RIGHT){ if(Flag_Set == 1 && Flag_Start == 1) DisplayChar(2, Flag_Set + 1, ' ' ); else if(Flag_Set == 2 && Flag_Start == 1) DisplayChar(2, Flag_Set + 8, ' ' ); if(Flag_Start != 3) Flag_Set--; } else if ( KeyIn == BTN_STOP){ machine_state = STATE_EDIT_MODE; return; } else if ( KeyIn == BTN_RUN){ Flag_Btn = 2; if(Flag_Set == 1 && Flag_Start != 3) { Flag_Start = 3; strcpy(Trip_Message, " "); Lcd_Clear(); Lcd_x_posi = 0, Lcd_y_posi = 0; if(Flag_Page == 3) strcpy(gSciTxBuf,"9:4:907:0.000e-0"); else if(Flag_Page == 4) strcpy(gSciTxBuf,"9:4:907:1.000e-0"); SendSciString( gSciTxBuf ); } } if(Flag_Set > 2) Flag_Set = 1; else if(Flag_Set < 1) Flag_Set = 2; if(Flag_Set == 1 && Flag_Start == 1) DisplayChar(2, Flag_Set + 1, '*' ); else if(Flag_Set == 2 && Flag_Start == 1) DisplayChar(2, Flag_Set + 8, '*' ); } }
/********************************* * 主函数 **********************************/ void main() { //uchar i; Init_IO(); //I/O口初始化, Init_MCU(); //主函数初始化,T0定时器工作在方式1初始化,显示"请稍等,初始化中",GATE=0, Init_RAM(); //位变量初始化 Init_Para(); //参数初始化,初始化参数,从IIC读取阈值等信息赋予给参量 Init_Buf(); //并口通讯数组初始化 // Select_Mast(); //判断主从机 Init_Time0(); //开启定时器0。定时器0初始化,工作在方式一,定时初值:H:0xDC,L:0x00;中断计数初始化?定时5ms,NumT0=0; Lcd_Clear(); //LCD清屏 Lcd_Start(); //显示"清华大学/n核能与新能源技术研究院" EX0=1; //只允许外部0中断,中断0为键盘 IT0=1; //外部中断0 while(1) { // BackUp_Display(); Select_Mast(); //判断主从机,写入主从机标志Flag_Mast=1(主机)0(从机) key_function(); //按键功能,在while循环中不断检测按键标志,按键标志由按键外部中断来更改 if(Flag_Tim0) //8253计数定时结束时,读取探头的计数,刚开始Flag_Tim0=0,仅当Flag8253Counting计数定时标识为1,且计数器中断次数大于设定的中断次数时,Flag_timo才会等于1 { //Flag_Tim0为计数器结束标志,初始为0,开机打开定时器中断后,定时器5ms中断一次,检查Flag_Tim0一次,为一表示计数器计时结束 Flag_Tim0 = 0; //定时标志清0 Flag_Warn = 0; //报警标志清0 GetAndDisdata(); //从8253的锁存器得到测量计数器结果,存入至buf数组 ShowData(); //显示测量数据 shortdelay(1000); // Transfer(); //并行传输数据 // bakeup_conv_data(); Init_8253(); //初始化8253 //定时结束时,立刻又开始初始化进行计数 } if(Flag_Tim0 == 0) //开启8253计数过程中,处理报警中断,报警有中断吗? { if(Flag_Warn_Flash == 1) //主机LED指示灯闪烁间隔定时,Flag_Warn_Flash为LED灯闪烁标志 { Flag_Warn_Flash = 0; Led_Flash(); } if((Flag_Warn_Led==1) && (PCOLSIG==0)) //屏幕上红灯闪烁间隔定时,程序中没有找到PCOLSIG=0的程序段 { Flag_Warn_Led = 0; RedLed_Flash(); //灯闪烁 } } } }
void LCD_disp(int x, int y) { //Probably most important array in commander, note the order int values[7]={max_speed, pid_gain, max_yaw, ir_samp_e, ir_samp_r, ir_raw, ir_avg}; char string[LCDL]; Lcd_Clear(); Lcd_Set_Cursor(1,1); Lcd_Write_String(menutitle[x]); //Display as _string:_value'%'_ sprintf(string, "%s%d%", stringtab[y],values[y]); Lcd_Set_Cursor(2,1); Lcd_Write_String(string); //############################# }
// Digital Compass int main(void) { uint8_t Res; int16_t Com_Data[3]; uint16_t x0, y0; unsigned long angle = 0; double radian; /* Setup the microcontroller system. Initialize the Embedded Flash Interface, initialize the PLL and update the SystemFrequency variable. */ xSysCtlClockSet(72000000, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_8MHZ); xSysCtlDelay(10000); delay_init(72); Lcd_Init(); HMC5883L_Init(); HMC5883L_Cfg(MODE_SIG | GAIN_1090 | SAMPLE_8 | DATA_RATE_15); Lcd_Clear(GRAY0); // Gui_Circle(64, 80, 50, BLUE); Gui_DrawFont_GBK16(64,14,BLUE,GRAY0,"N"); Gui_DrawFont_GBK16(64,132,BLUE,GRAY0,"S"); Gui_DrawFont_GBK16(5,80,BLUE,GRAY0,"W"); Gui_DrawFont_GBK16(116,80,BLUE,GRAY0,"E"); while(1){ Res = HMC5883L_DataGet(&Com_Data[0], &Com_Data[1], &Com_Data[2]); if(Res) break; angle = (unsigned long) (atan2((double)Com_Data[0],(double)Com_Data[1])*(180/3.14159265)+180); //angle = rand()%360; radian = angle * 3.1415926 / 180; if(angle <= 180){ x0 = 64 + (int16_t)(40 * sin(radian)); y0 = 80 - (int16_t)(40 * cos(radian)); } else { x0 = 64 + (int16_t)(40 * sin(radian)); y0 = 80 - (int16_t)(40 * cos(radian)); } Gui_DrawLine(64, 80, x0, y0, BLUE); delay_ms(500); Gui_DrawLine(64, 80, x0, y0, GRAY0); } return 0; }
void Redraw_Mainmenu(void) { Lcd_Clear(GRAY0); Gui_DrawFont_GBK16(16,0,BLUE,GRAY0,"EPI @ CooCox"); Gui_DrawFont_GBK16(16,120,BLUE,GRAY0,"S1:Move. "); Gui_DrawFont_GBK16(16,140,RED,GRAY0, "S2:Sellect "); Gui_DrawFont_Num32(100,125,RED,GRAY0,Num[5]); delay_ms(1000); Gui_DrawFont_Num32(100,125,RED,GRAY0,Num[4]); delay_ms(1000); Gui_DrawFont_Num32(100,125,RED,GRAY0,Num[3]); delay_ms(1000); Gui_DrawFont_Num32(100,125,RED,GRAY0,Num[2]); delay_ms(1000); Gui_DrawFont_Num32(100,125,RED,GRAY0,Num[1]); delay_ms(1000); Gui_DrawFont_Num32(100,125,RED,GRAY0,Num[0]); }
void Color_Test(void) { uint8_t i = 2; Lcd_Clear(GRAY0); Gui_DrawFont_GBK16(20,10,BLUE,GRAY0,"Color Test"); delay_ms(1000); while(i--){ Lcd_Clear(WHITE); Lcd_Clear(BLACK); Lcd_Clear(RED); Lcd_Clear(GREEN); Lcd_Clear(BLUE); } }
void main() { void brdInit(); // Enable development board SetPortAOut(); // Set port A as output port WrPortI(PBDDR, &PBDDRShadow, 0xFF); // Set port B as output port Lcd_Config(); pause(5); LcdWriteStr(1,"Rabbit-RCM4010:"); pause(5); LcdWriteStr(2,"[\"Hello World!\"]"); pause(10); Lcd_Clear(); Lcd_noCursor_On(); LcdWriteStr(1,"LCD off in 5 sec"); LcdCommandWr(0xA8); MsDelay(300); LcdPutChar('5'); MsDelay(300); LcdPutChar('.'); MsDelay(300); LcdPutChar('.'); MsDelay(300); LcdPutChar('4'); MsDelay(300); LcdPutChar('.'); MsDelay(300); LcdPutChar('.'); MsDelay(300); LcdPutChar('3'); MsDelay(300); LcdPutChar('.'); MsDelay(300); LcdPutChar('.'); MsDelay(300); LcdPutChar('2'); MsDelay(300); LcdPutChar('.'); MsDelay(300); LcdPutChar('.'); MsDelay(300); LcdPutChar('1'); MsDelay(300); LcdPutChar('.'); MsDelay(300); LcdPutChar('.'); MsDelay(300); LcdPutChar('0'); MsDelay(300); Lcd_Off(); }
void settime() { Flag_RefrInput=0; //探头个数按键再次按下标志 Flag_RefrPara=0; //输入参数按键再次按下标志 Flag_RefrRight=0; //右移按键再次按下标志 Inctime++; //按时间输入键,则测量时间改变5s或者60s /*显示设置时间 秒*/ if(Flag_RefrTime==0) { Flag_RefrTime=1; Clear(); Lcd_Clear(); Txtext(128,216,"时间设置:"); Tnumber(368,216,0); //时间修改到5秒,修改时间2012.6.15 Tnumber(416,216,0); Tnumber(464,216,5); Txtext(512,216,"秒"); Redrawtime=5; } else { if((Inctime == 1)||(Inctime >= 11)) //修改时间2012.6.15 { Inctime = 1; Redrawtime = 5; Tnumber(368,216,0); Tnumber(416,216,0); Tnumber(464,216,5); //刷新时间为5秒 } else if(Inctime == 2) { Redrawtime = 10; Tnumber(368,216,0); Tnumber(416,216,1); Tnumber(464,216,0); } else if(Inctime == 3) { Redrawtime = 20; Tnumber(368,216,0); Tnumber(416,216,2); Tnumber(464,216,0); } else if(Inctime == 4) { Redrawtime = 30; Tnumber(368,216,0); Tnumber(416,216,3); Tnumber(464,216,0); } else if(Inctime == 5) { Redrawtime = 40; Tnumber(368,216,0); Tnumber(416,216,4); Tnumber(464,216,0); } else if(Inctime == 6) { Redrawtime = 50; Tnumber(368,216,0); Tnumber(416,216,5); Tnumber(464,216,0); } else if(Inctime == 7) { Redrawtime = 60; Tnumber(368,216,0); Tnumber(416,216,6); Tnumber(464,216,0); } else if(Inctime == 8) { Redrawtime = 120; Tnumber(368,216,1); Tnumber(416,216,2); Tnumber(464,216,0); } else if(Inctime == 9) { Redrawtime = 240; Tnumber(368,216,2); Tnumber(416,216,4); Tnumber(464,216,0); } else if(Inctime == 10) { Redrawtime = 480; Tnumber(368,216,4); Tnumber(416,216,8); Tnumber(464,216,0); } } }