LCD Display

Hello all!
I have recently acquired an LCD display an my team has been messing around with it. We are trying to display the Primary battery level and whether a boolean is true of false. I had a quick question as a programming novice, what did we do wrong? All it shows on the lcd display is:


Battery:
Fly:  7cccc

Here is out LCD display code:


void battAndFlyLCD() {
	bLCDBacklight = true;
	clearLCDLine(0);  //clear line 1 (0) on the LCD
	clearLCDLine(1);	//clear line 2 (1) on the LCD
	string mainBattery;
	string flywheelStable;
	displayLCDString(0, 0, "Battery: ");
	displayLCDString(1, 0, "Fly: ");
	sprintf(mainBattery, "%1.2f%c", nImmediateBatteryLevel/1000.0,'V'); //Build the value to be displayed
	if (checkStable() == true) {
		sprintf(flywheelStable, "cccc", "READY");
	}
	if (checkStable() == false) {
		sprintf(flywheelStable, "cccc", "NOT READY");
	}
	displayNextLCDString(mainBattery);
	displayLCDString(1, 6, flywheelStable);

Any and all help would be fantastic. Please don’t be shy from telling us what we did wrong, we can get all the help we can get. Thanks!

P.S.- this is my first post on the vex forum :smiley:

Welcome

The code is pretty close, the main issue is trying to display “READY” and “NOT READY”. The statement


sprintf(flywheelStable, "cccc", "READY");

Will copy the string “cccc” to flywheelStable, what you wanted to do is give a format sting that would use the string parameter (READY or NOT READY) to be copied. You use the “%s” to specify this.


sprintf(flywheelStable, "%s", "READY");

There’s also a problem using displayNextLCDString, that will print on the second line as that was the last place you had accessed, some revised code below.

void battAndFlyLCD() {
	bLCDBacklight = true;
	clearLCDLine(0);  //clear line 1 (0) on the LCD
	clearLCDLine(1);	//clear line 2 (1) on the LCD
	string mainBattery;
	string flywheelStable;
	displayLCDString(0, 0, "Battery: ");
	displayLCDString(1, 0, "Fly: ");
	sprintf(mainBattery, "%1.2f%c", nImmediateBatteryLevel/1000.0,'V'); //Build the value to be displayed
	if (checkStable() == true) {
		sprintf(flywheelStable, "%s", "READY");
	}
	if (checkStable() == false) {
		sprintf(flywheelStable, "%s", "NOT READY");
	}
	displayLCDString(0, 9, mainBattery);
	displayLCDString(1, 9, flywheelStable);
}

Thank you so much. I assumed it would take a few days for anyone to reply, but in under an hour, the VP Technology of Robomatter replied! I will definitely start using the vex forums more often.