I'm trying to display the current time on the OLED board attached to my Particle Photon.
void loop() {
time_t time = Time.now();
Time.format(time, '%Y-%m-%dT%H:%M:%S%z');
displayString(time);
}
int displayString(String text) {
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println(text);
display.display();
return 1;
}
I have confirmed that displayString
works. As it is an embedded device, you don't have access to the regular time library, however the Photon has it's own.
https://docs.particle.io/reference/firmware/core/#time
I'm getting the error Invalid conversion from int to const char*
.
Edit: For anyone else who comes across this, I discovered that while undocumented, if you do not provide a time it will use the current time, so you can just do:
String time = Time.format("%d/%m/%y %H:%M:%S");
The uppercase String
type is intentional, see String class.