Hello everyone,
I am relatively new to the world of arduino coding. My current project I am working on is an RTC clock that displays the time on a ks0108 graphic LCD.
The project isn't finished yet, but I have run into a bit of a problem with at least displaying the time in some fashion. There may be some things missing which would lead to an ugly looking display as I have just converted the code in the void loop from the previous 16x2 text lcd to the new ks0108 glcd I have.
Anyway, the problem I have is that when I verify the code, I get an error stating
no matching function for call to 'glcd::Puts(byte&, int)'
I don't have any idea what is causing this problem. If someone could guide me onto the right path, that would be great.
Here is the entire code:
// Connections:
// LCD pin 1 to Arduino GND
// LCD pin 2 to Arduino 5v
// LCD pin 3 (Contrast) to GND
// rs (LCD pin 4) to Arduino pin 12
// rw (LCD pin 5) to Arduino pin 11
// enable (LCD pin 6) to Arduino pin 10
// LCD pin 15 to Arduino pin 13
// LCD pin 16 to Arduino GND
// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2
//Tested with DS1307 Breakout from Sparkfun
//pin SDA to Arduino Analog pin 4
//pin SCL to Arduino Analog pin 5
//pin GND to Arduino GND
//pin VCC to Arduino 5v
#include <Wire.h>
#define DS1307_I2C_ADDRESS 0x68
#include <glcd.h>
#include "fonts/Code.h" // proportional font
// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
return ( (val/10*16) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
return ( (val/16*10) + (val%16) );
}
// 1) Sets the date and time on the ds1307
// 2) Starts the clock
// 3) Sets hour mode to 24 hour clock
// Assumes you're passing in valid numbers
void setDateDs1307(byte second, // 0-59
byte minute, // 0-59
byte hour, // 1-23
byte dayOfWeek, // 1-7
byte dayOfMonth, // 1-28/29/30/31
byte month, // 1-12
byte year) // 0-99
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.write(0);
Wire.write(decToBcd(second)); // 0 to bit 7 starts the clock
Wire.write(decToBcd(minute));
Wire.write(decToBcd(hour));
Wire.write(decToBcd(dayOfWeek));
Wire.write(decToBcd(dayOfMonth));
Wire.write(decToBcd(month));
Wire.write(decToBcd(year));
Wire.write(0x10); // sends 0x10 (hex) 00010000 (binary) to control register - turns on square wave
Wire.endTransmission();
}
// Gets the date and time from the ds1307
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
// Reset the register pointer
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.write(0);
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
// A few of these need masks because certain bits are control bits
*second = bcdToDec(Wire.read() & 0x7f);
*minute = bcdToDec(Wire.read());
*hour = bcdToDec(Wire.read() & 0x3f); // Need to change this if 12 hour am/pm
*dayOfWeek = bcdToDec(Wire.read());
*dayOfMonth = bcdToDec(Wire.read());
*month = bcdToDec(Wire.read());
*year = bcdToDec(Wire.read());
}
void setup()
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
Wire.begin();
Serial.begin(9600);
// Change these values to what you want to set your clock to.
// You probably only want to set your clock once and then remove
// the setDateDs1307 call.
//setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
}
void loop()
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
GLCD.ClearScreen(); // clear LCD screen
GLCD.SelectFont(Code);
GLCD.GotoXY(0, 20);
GLCD.Puts(" ");
switch(hour){
case 0:
GLCD.Puts("12");
break;
case 13:
GLCD.Puts("1");
break;
case 14:
GLCD.Puts("2");
break;
case 15:
GLCD.Puts("3");
break;
case 16:
GLCD.Puts("4");
break;
case 17:
GLCD.Puts("5");
break;
case 18:
GLCD.Puts("6");
break;
case 19:
GLCD.Puts("7");
break;
case 20:
GLCD.Puts("8");
break;
case 21:
GLCD.Puts("9");
break;
case 22:
GLCD.Puts("10");
break;
case 23:
GLCD.Puts("11");
break;
}
GLCD.Puts(":");
if (minute<10)
{
GLCD.Puts("0");
}
GLCD.Puts(minute, DEC);
GLCD.Puts(":");
if (second<10)
{
GLCD.Puts("0");
}
GLCD.Puts(second, DEC);
lcd.setCursor(0,1);
GLCD.Puts(" ");
switch(dayOfWeek){
case 1:
GLCD.Puts("Sun");
break;
case 2:
GLCD.Puts("Mon");
break;
case 3:
GLCD.Puts("Tue");
break;
case 4:
GLCD.Puts("Wed");
break;
case 5:
GLCD.Puts("Thu");
break;
case 6:
GLCD.Puts("Fri");
break;
case 7:
GLCD.Puts("Sat");
break;
}
GLCD.Puts(" ");
GLCD.Puts(month, DEC);
GLCD.Puts("/");
GLCD.Puts(dayOfMonth, DEC);
GLCD.Puts("/20");
GLCD.Puts(year, DEC);
delay(1000);
GLCD.ClearScreen
}