Buenas tardes, pido de su ayuda, tengo un proyecto en mano, estoy poniendo la temperatura ambiente y temperatura de funcionamiento de un cotrolador de velocidad, quisiera visualizar la temperatura indicada en la pantalla tft lcd de diferentes colores dependiendo del valor de esta, espero me entiendan...gracias por su ayuda.
// display temperature numerically in header box
tft.setTextColor(YELLOW, RED);
tft.setTextSize(2);
tft.setCursor(70, 20);
tft.print(displayTemp, 1); // show temperature with 1 decimal place
tft.setTextSize(2); // show temperature with 1 decimal place
tft.print((char)247); // degree symbol
if (showDegC)
tft.print("C ");
else
tft.print("F ");
Gracias por su interes, digamos que abajo de 20 grados el numero de la temperatura fuera de color verde, de 20 a 30 en amarillo y arriba de 30 en rojo, no encuentro como hacerlo, estaba tratando de implementar el siguiente codigo pero no lo hago funcionar.
if((TempControlador< 20)){ // identifica el color a ser
tft.setTextColor(VGA_GREEN);} // displayer temperatura motor
else
{
if((TempControlador>= 20) && (TempControlador< 30)){
tft.setTextColor(VGA_YELLOW);
}
else
{tft.setTextColor(VGA_RED);
}
}
if (TempControlador < 20) { // identifica el color a ser
tft.setTextColor(VGA_GREEN); // displayer temperatura motor
}
else if ((TempControlador >= 20) && (TempControlador < 30)) {
tft.setTextColor(VGA_YELLOW);
}
else { // >= 30
tft.setTextColor(VGA_RED);
}
Gracias, pongo el siguiente codigo y no me muestra nada en la pantalla desaparece la indicacion de temperatura
// tft.drawStr( 75, 51, "TA"); // Codigo para la temperatura abiente
if (TempControlador < 20) { // identifica el color a ser
tft.setTextColor(GREEN); // displayer temperatura motor
}
else if ((TempControlador >= 20) && (TempControlador < 30)) {
tft.setTextColor(YELLOW);
}
else { // >= 30
tft.setTextColor(RED);
}
tft.setCursor(50, 20);
tft.setTextSize(2);
dtostrf(tempC1, 2, 1, temp_string1);
tft.println(temp_string1); // show temperature with 1 decimal place
tft.setTextSize(3);
Muchas gracias por tu ayuda, ahora funciona de maravilla el codigo se hacen perfectamente el cambio de color de acuerdo a la temperatura. el codigo final quedo asi:
// tft.drawStr( 75, 51, "TA"); // Codigo para la temperatura abiente
if (tempC1 < 20) { // identifica el color a ser
tft.setTextColor(GREEN, RED); // displayer temperatura motor
}
else if ((tempC1 >= 20) && (tempC1 < 30)) {
tft.setTextColor(BLUE, RED);
}
else { // >= 30
tft.setTextColor(ORANGE, RED );
}
tft.setCursor(50, 20);
tft.setTextSize(2);
dtostrf(tempC1, 2, 1, temp_string1);
tft.println(temp_string1); // show temperature with 1 decimal place
tft.setTextSize(3);
cambiando TemoControlador por TempC1 que es la condicional para postrar la temperatura en la pantalla, muchas gracias por su ayuda.