void DisplayLCD(char string[], char string1[], char string2[]){ int number = 0; for(;;){ LCD_display(*string); string += 0x01; if(number == 16){ LCD_instruction(0xC0); } if( *string == 0 ){ break; } } for(;;){ LCD_display(*string); string1 += 0x01; if(number == 16){ LCD_instruction(0xC0); } if( *string1 == 0 ){ break; } } for(;;){ LCD_display(*string); string2 += 0x01; if(number == 16){ LCD_instruction(0xC0); } if( *string2 == 0 ){ break; } } }
/**********************************************************************//** * @brief Display Main Menu, choose next option * * @param none * * @return mode - choice selected *************************************************************************/ unsigned char MainMenu(void) { unsigned char appChoice = APP_MAIN_MENU; while (!select) { // Get left slider position CTS_getReading(); // Highlight/scroll based on cap touch position if (sliderPos[0] < 12) { appChoice = APP_CELL_BALANCE; } else if (sliderPos[0] < 18) { appChoice = APP_TEMPERATURE; } else if (sliderPos[0] < 24) { appChoice = APP_STATE_OF_CHARGE; } else if (sliderPos[0] < 30) { appChoice = APP_PACK_VOLTAGE; } else { appChoice = APP_CELL_VOLTAGE; } LCD_displayMainMenu(appChoice); LCD_display(); } select = 0; return appChoice; }
void main() { flag= 0; sys_init(); Timer0Init(); Timer0Init_50ms(); IO_init(); PWM_Init(); clear(); while(1) { key(); conver_nu(); LCD_display(); } }
void LCD_Begin(uint8_t rows, uint8_t cols, uint8_t dotSize) { if(rows > 1) Lcd_Conf.dispFunc |= LCD_2LINE; if((dotSize != 0) && (rows == 1)) Lcd_Conf.dispFunc |= LCD_5x10DOTS; delayMicroseconds(50000); GPIO_ResetBits(Lcd_Conf.gpio, Lcd_Conf.rs); GPIO_ResetBits(Lcd_Conf.gpio, Lcd_Conf.enable); if(Lcd_Conf.rw != 255) GPIO_ResetBits(Lcd_Conf.gpio, Lcd_Conf.rw); if(!(Lcd_Conf.dispFunc & LCD_8BITMODE)) { writeBits(0x03, 4); delayMicroseconds(4500); writeBits(0x03, 4); delayMicroseconds(4500); writeBits(0x03, 4); delayMicroseconds(150); writeBits(0x02, 4); } else { send(LCD_FUNCTIONSET | Lcd_Conf.dispFunc, LOW); delayMicroseconds(4500); send(LCD_FUNCTIONSET | Lcd_Conf.dispFunc, LOW); delayMicroseconds(150); send(LCD_FUNCTIONSET | Lcd_Conf.dispFunc, LOW); } send(LCD_FUNCTIONSET | Lcd_Conf.dispFunc, LOW); Lcd_Conf.dispCtrl = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; LCD_display(); LCD_clear(); Lcd_Conf.dispMode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT; send(LCD_ENTRYMODESET | Lcd_Conf.dispMode, LOW); }
uint8 LCD_init(){ i2c_master_start(); i2c_master_writeByte(LCD_ADDRESS << 1); if (!i2c_master_checkAck()) { i2c_master_stop(); return 0; } i2c_master_stop(); _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; if (LCD_ROW > 1) { _displayfunction |= LCD_2LINE; } _numlines = LCD_ROW; // for some 1 line displays you can select a 10 pixel high font if ((LCD_DOTSIZE != 0) && (LCD_ROW == 1)) { _displayfunction |= LCD_5x10DOTS; } // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! // according to datasheet, we need at least 40ms after power rises above 2.7V // before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50 os_delay_us(50000); // Now we pull both RS and R/W low to begin commands LCD_expanderWrite(0); // reset expanderand turn backlight off os_delay_us(1000000); //put the LCD into 4 bit mode // this is according to the hitachi HD44780 datasheet // figure 24, pg 46 // we start in 8bit mode, try to set 4 bit mode LCD_write4bits(0x30); os_delay_us(4500); // wait min 4.1ms // second try LCD_write4bits(0x30); os_delay_us(4500); // wait min 4.1ms // third go! LCD_write4bits(0x30); os_delay_us(150); // finally, set to 4-bit interface LCD_write4bits(0x20); // set # lines, font size, etc. LCD_command(LCD_FUNCTIONSET | _displayfunction); // turn the display on with no cursor or blinking default _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; LCD_display(); // clear it off LCD_clear(); // Initialize to default text direction (for roman languages) _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT; // set the entry mode LCD_command(LCD_ENTRYMODESET | _displaymode); LCD_home(); return 1; }
//print array of character //all character that will be printed into LCD will call this function void printString(int speedValue, int temp){ //All words below will be printed into LCD char *speed="Speed: "; char *temperature="Temp: "; char *kmperhour="RPS"; char *celsius="'F"; int i=0;//intitialize for loop //store digit of speed char stringSpeed[4]; //store digit of temperature char stringTemp[3]; //fill stringSpeed[4] with value of speed convertSpeedToChar(stringSpeed,speedValue); //fill stringTemp[2] with value of temperature convertTempToChar(stringTemp,temp); //Start display into LCD //Initialize LCD Lcd2PP_Init(); //print "Speed: ****RPS" for(i=0;i<7;i++) { LCD_display(speed[i]); } for(i=0;i<4;i++) { LCD_display(stringSpeed[i]); } for(i=0;i<3;i++) { LCD_display(kmperhour[i]); } //moves next line of LCD LCD_instruction(0xc0); //print "Temp: ***'F" for(i=0;i<6;i++) { LCD_display(temperature[i]); } for(i=0;i<3;i++) { LCD_display(stringTemp[i]); } for(i=0;i<2;i++) { LCD_display(celsius[i]); } }