/* * 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); }
/*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 //############################# }
//////////////////////////////////////////////////////////// // 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 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); //############################# }
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); } }