Hi.
I am constructing a simple clock using a ILI9341 as my screen. I am using the TFT_ILI9341-master Library. TFT_ILI9341 Master Lib
I have used Arduino Timezone Library Copyright (C) 2018 by Jack Christensen Example to pull most of the needed code from.Timezone Library
The clock and display are working great together.
My issue is not being able to print the Time Zone "tz" after the second. or anyware for that matter.
// format and print a time_t value, with a time zone appended.
void printDateTime(time_t t, const char *tz)
{
char buf[32];
char m[4]; // temporary storage for month string (DateStrings.cpp uses shared buffer)
strcpy(m, monthShortStr(month(t)));
sprintf(buf, "%.2d:%.2d:%.2d %s %.2d %s %d %s",
hour(t), minute(t), second(t), dayShortStr(weekday(t)), day(t), m, year(t), tz);
Serial.println(buf);
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
tft.setTextColor(TFT_GREEN, TFT_BLACK);// invisable text
if (pirState == LOW) {
// we have just turned on
Serial.println("Motion detected!");
// We only want to print on the output change, not state
pirState = HIGH;
}
} else {
tft.setTextColor(TFT_BLACK, TFT_BLACK);// normal text
if (pirState == HIGH) {
// we have just turned of
Serial.println("Motion ended!");
// We only want to print on the output change, not state
pirState = LOW;
}
}
tft.setTextSize(1);// = Chars 12.8 mm high MAX
tft.drawNumber( hour(t), 40, 50, 7);// no decimal points
tft.drawString(";", 1200, 50, 2);
tft.drawNumber(minute(t), 118, 50, 7);// no decimal points
tft.drawString(";", 188, 50, 2);
tft.drawNumber(second(t), 195, 50, 7);// no decimal points
//tft.drawString(tz), 40, 50, 7);// no decimal points ******************Help here **********
hum = dht.readHumidity();
temp = dht.readTemperature();
tft.setTextSize(2);
tft.drawString("Humidity : ", 10, 120, 2);
tft.drawFloat(hum, 2, 140, 120, 2);// with decimal points
tft.drawString("%", 220, 120, 2);
tft.drawString("Tempature : ", 10, 150, 2);
tft.drawFloat(temp, 2,165, 150, 2); // with decimal points
tft.drawString("C", 250, 150, 2);
}
The original code uses this part of the code to Serial print it.
sprintf(buf, "%.2d:%.2d:%.2d %s %.2d %s %d %s",
hour(t), minute(t), second(t), dayShortStr(weekday(t)), day(t), m, year(t), tz);
But I am unable to get it working.
The Library examples show no variable being used on the screen. Also looked at the Keywords and none seam to fit what I need to do.
Will post complete listing if wanted.
Advice please.
Regards Antony.