Printing Temp on Brain

So i have the following:

while (true) {
  Brain.Screen.printAt(0, 20, "Battery Capacity %d percent", Brain.Battery.capacity());
  Brain.Screen.printAt(0, 40, "Battery Temperature %lf", Brain.Battery.temperature());
  Brain.Screen.printAt(0, 60 ,"Letft Back Temp %f " , left_back.temperature(percentUnits::pct));
  Brain.Screen.printAt(0, 80 ,"Left Front Temp %f " , left_front.temperature(percentUnits::pct));
  Brain.Screen.printAt(0, 100 ,"Right Front Temp %f " , right_front.temperature(percentUnits::pct));
  Brain.Screen.printAt(0, 120 ,"Right Back Temp %f " , right_back.temperature(percentUnits::pct));
  Brain.Screen.printAt(0, 140 ,"Lift Left Temp %f " , lift_left.temperature(percentUnits::pct));
  Brain.Screen.printAt(0, 160 ,"Lift Right Temp %f " , lift_right.temperature(percentUnits::pct));
  Brain.Screen.printAt(0, 180 ,"Hook Temp %f " , hook.temperature(percentUnits::pct));  }

How would I get the brain to update the values every 5 seconds? Also, how would I have the brain change the font color of the text depending on if the temp is higher than a certain degree?

To get the brain to update value every 5 seconds, you could use:

wait(5,seconds);

Putting that inside the while loop will slow it down so it only updates every 5 seconds

For changing text color you can use:

Brain.Screen.setPenColor(red);

This will change what color the text is drawn in. Put that inside a few if statements and you can adjust the text color based on the value of the tepratures.

6 Likes