The serial.begin was to initially print time to serial monitor. I just forgot to take the code back out. below is the working lines that print to serial monitor. I was figurin on 00,00,00 hour, min, sec for 6 char in buffer. Should it be bigger than six?
OK so I was able to find an updated cpp file which had a displayInteger() function that I was able to add to my cpp file. This test code prints out my hour.
So printing out the hour, min, and second are finally done! The problem is now, how do you format this output so that it is nice and tight on the lcd. Right now this print the time out accordingly but with an empty space between output. Any Ideas?
int hr = RTC.hour;
int minu = RTC.minute;
int sec = RTC.second;
unsigned char colon[] = ":";
LCDA.displayInteger(0,0,hr);
LCDA.DisplayString(0,1,colon,1);
LCDA.displayInteger(0,2,minu);
LCDA.DisplayString(0,3,colon,1);
LCDA.displayInteger(0,4,sec);
I know it does not sound right, but without the array there is a conversion error for some reason.
Thank you very much for your feedback, it is greatly appreciated!
The provided code gives me a conversion error:
invalid conversion from unsigned char* to const char*
and
error intializing argument 1 of 'size_t strlen(const char*)'
Signed char, unsigned char, const signed char, and const unsigned char are all the same size. If a function expects one type, and you have another, lie to the function. Tell it that the type you have IS the type it expects.
If strlen() expects a const char *, and you have a unsigned char *, lie to it:
Thank you, but I was unable to make that code work. I have working code that displays hour, minute, and second as integer, but I cannot format it on the lcd. I would like the output to be formatted nice and tight across lcd.
Thank you, but I was unable to make that code work.
This compiles:
#include "LCD12864RSPI.h"
void setup()
{
LCDA.Initialise(); // INIT SCREEN
int hour = 12;
int minute = 47;
int second = 23;
unsigned char timeString[12];
sprintf((char *)timeString, "%02d:%02d:%02d", hour, minute, second);
LCDA.DisplayString(0,1,timeString, strlen((char *)timeString));
}
void loop()
{
}
I should have suspected earlier that the library was from dfrobot. I wouldn't buy anything from them if it was free. They provide no support for Arduino.
Thank you very much for that code. It works great! What hardware manufacturer would you reccomend that would be easier to work with throughout this project?
The RTC you are using probably has a setting that tells it whether you want the time in 12 hour or 24 hour format. I don't know what RTC that is, though, so I can't tell you what that setting is.
I am in Ohio, USA, but I order all my hardware from internet.
Sparkfun is on the internet. They pissed me, and a whole lot of other people, off with their "free day" fiasco a couple of years ago, but when I want something that I know will work and I want it now, I order from them.