On a new computer running Win 10 I have installed Atmel Studio and Visual Micro and copied over all my old projects.
One of which have compiled fin before. But now I get these compiler errors
Compiling 'TestPrecRTCClock' for 'Arduino Mega w/ ATmega2560 (Mega 2560)'
DateStrings.cpp:41:22: error: variable 'monthNames_P' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
DateStrings.cpp:58:20: error: variable 'dayNames_P' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
DateStrings.cpp:59:24: error: variable 'dayShortNames_P' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
DefaultFonts.c:21:14: error: variable 'SmallFont' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
DefaultFonts.c:125:14: error: variable 'BigFont' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
DefaultFonts.c:234:14: error: variable 'SevenSegNumFont' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
SevenSegmentFull.c:8:9: error: variable 'SevenSegmentFull' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
Error compiling
And the program is listed below
//140708 Fungerar (works fine)
#include <UTFT.h>
#include <memorysaver.h>
#include <Wire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <memorysaver.h>
extern uint8_t BigFont[];
extern uint8_t SevenSegmentFull[];
UTFT myGLCD(ITDB32S,38,39,40,41);
const char *monthName[12] =
{
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
tmElements_t tm; //Declare tmElements object to store time & date from DS3231
void setup()
{
bool parse=false;
bool config=false;
/* add setup code here */
Serial.begin(9600);
myGLCD.InitLCD(LANDSCAPE);
myGLCD.clrScr();
myGLCD.fillScr(255,255,255);
myGLCD.setBackColor(255, 255, 255);
myGLCD.setColor(0, 0, 255);
Serial.println("Testing precision clock");
Serial.println("Date and Time");
// get the date and time the compiler was run
if (getDate(__DATE__) && getTime(__TIME__))
{
parse = true;
// and configure the RTC with this info
if (RTC.write(tm))
{
config = true;
}
}
while (!Serial) ; // wait for Arduino Serial Monitor
delay(200);
if (parse && config)
{
Serial.print("DS1307 configured Time=");
Serial.print(__TIME__);
Serial.print(", Date=");
Serial.println(__DATE__);
}
else if (parse)
{
Serial.println("DS1307 Communication Error :-{");
Serial.println("Please check your circuitry");
}
else
{
Serial.print("Could not parse info from the compiler, Time=\"");
Serial.print(__TIME__);
Serial.print("\", Date=\"");
Serial.print(__DATE__);
Serial.println("\"");
}
myGLCD.setFont(BigFont);
myGLCD.print("Klockan",CENTER,1);
myGLCD.setFont(SevenSegmentFull);
}
void loop()
{
/* add main program code here */
if(RTC.read(tm)) //Read the time & date from DS3231, if success, print time & date on LCD
{
myGLCD.printNumI(tm.Hour/10 ,32,19);
myGLCD.printNumI(tm.Hour%10 ,64,19);
myGLCD.print(":",96,19);
myGLCD.printNumI(tm.Minute/10,128,19);
myGLCD.printNumI(tm.Minute%10,160,19);
myGLCD.print(":",192,19);
myGLCD.printNumI(tm.Second/10,224,19);
myGLCD.printNumI(tm.Second%10,256,19);
myGLCD.print(monthName[tm.Month-1],1,68);
}
else if (RTC.chipPresent())
Serial.println("Chip present\n\r");
else
Serial.println("Error");
myGLCD.setFont(SevenSegmentFull);
}
bool getTime(const char *str)
{
int Hour, Min, Sec;
if (sscanf(str, "%d:%d:%d", &Hour, &Min, &Sec) != 3) return false;
tm.Hour = Hour;
tm.Minute = Min;
tm.Second = Sec;
return true;
}
bool getDate(const char *str)
{
char Month[12];
int Day, Year;
uint8_t monthIndex;
if (sscanf(str, "%s %d %d", Month, &Day, &Year) != 3) return false;
for (monthIndex = 0; monthIndex < 12; monthIndex++) {
if (strcmp(Month, monthName[monthIndex]) == 0) break;
}
if (monthIndex >= 12) return false;
tm.Day = Day;
tm.Month = monthIndex + 1;
tm.Year = CalendarYrToTm(Year);
Serial.print("Year=");
Serial.println(tm.Year);
return true;
}