Problem solved!
Herzlichen Dank für eure Hilfe.
Aus dem setup() habe ich die Befehlszeile :
tft.setTextColor(TFT_BLUE); // TFT_WHITE = Black - TFT_BLUE = White
entfernt. Das hat die Farben durcheinander gewürfelt. Weißer Hintergrund mit schwarzer Schrift funktioniert.
Ich nutze dieses Display: https://eckstein-shop.de/Mega-2560-3...d-fuer-Arduino
Es liest zwei Dallas-DS18B20 Temperatursensoren aus. http://playground.arduino.cc/Learning/OneWire
Auf beiden Seiten findet ihr die zugehörige library.
Hier nun der funktionierende Code:
Code:/* Test the tft.print() viz the libraries embedded write() function Make sure all the required fonts are loaded by editting the User_Setup.h file in the TFT_ILI9341 library folder. ######################################################################### ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ###### ######################################################################### changed by dh4mbm 2016.11.06 uses Dallas DS18B20 temperature sensor and MEGA 2560 */ #include <OneWire.h> #include <DallasTemperature.h> #define ONE_WIRE_BUS_1 2 // use Arduino Pin 2 #define ONE_WIRE_BUS_2 4 // use Arduino Pin 4 OneWire oneWire_in(ONE_WIRE_BUS_1); OneWire oneWire_out(ONE_WIRE_BUS_2); DallasTemperature sensor_inhouse(&oneWire_in); DallasTemperature sensor_outhouse(&oneWire_out); #include <TFT_HX8357.h> // Hardware-specific library byte fontSize4 = 4; // 26 px, FontSize 4, 6, 7, 8 byte fontSize6 = 6; // 48 px TFT_HX8357 tft = TFT_HX8357(); // Invoke custom library int timer1 = (3000); void setup(void) { tft.init(); tft.setRotation(1); sensor_inhouse.begin(); sensor_outhouse.begin(); /* Fill screen with colour so we can see the effect of printing with and without code color */ tft.fillScreen(TFT_BLACK); // TFT_YELLOW = Blue - TFT_BLUE = YELLOW - TFT_BLACK = White tft.setCursor(40, 48, fontSize4); //shift Cursor in Pixel (Collum, Row, Fontsize) tft.setTextFont(fontSize4); tft.println("Dallas TwoPin_DS18B20"); // (cursor will move to next line automatically during printing with 'tft.println' // or stay on the line is there is room for the text with tft.print) tft.setCursor(40, 172, fontSize4); //shift Cursor in Pixel (Collum, Row, Fontsize) tft.print("Inhouse: "); tft.setCursor(380, 172, fontSize4); //shift Cursor in Pixel (Collum, Row, Fontsize) tft.print("Degree "); tft.setCursor(40, 248, fontSize4); tft.print("Outhouse: "); tft.setCursor(380, 248, fontSize4); //shift Cursor in Pixel (Collum, Row, Fontsize) tft.print("Degree "); } void loop() { tft.setCursor(40, 98, fontSize4); // Spalte, Zeile, Font tft.println("Requesting temperatures..."); sensor_inhouse.requestTemperatures(); sensor_outhouse.requestTemperatures(); tft.setCursor(190, 172, fontSize6); //shift Cursor in Pixel (Collum, Row, Fontsize) tft.setCursor(190, 172, fontSize6); tft.print(sensor_inhouse.getTempCByIndex(0)); tft.setCursor(190, 172, fontSize6); tft.setCursor(190, 248, fontSize6); tft.print(sensor_outhouse.getTempCByIndex(0)); }







Zitieren


Lesezeichen