Error
Arduino: 1.8.5 (Windows 10), Board: "Arduino Due (Programming Port)"
C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino: In function 'void setup()':
C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:55:43: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
printText("TEMPERATURE", GREEN,30,65,1); // Temperature Static Text
^
C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:56:34: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
printText("MAX", RED,18,130,1);
^
C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:57:35: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
printText("MIN", BLUE,95,130,1);
^
C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino: In function 'void loop()':
C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:102:33: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
printText("o", WHITE,90,75,2);
^
C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:103:34: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
printText("C", WHITE,105,80,3);
^
RTCTFT160:108: error: 'dtostrf' was not declared in this scope
dtostrf(maxTemperature,4, 1, charMaxTemperature); //float,string var incl dec,digits,array to store the results)
^
C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:111:36: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
printText("o", WHITE,35,140,1);
^
C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:112:36: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
printText("C", WHITE,41,145,1);
^
RTCTFT160:118: error: 'dtostrf' was not declared in this scope
dtostrf(minTemperature,4, 1, charMinTemperature);
^
C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:121:37: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
printText("o", WHITE,112,140,1);
^
C:\Users\Johan Prinsloo\Documents\Arduino\RTCTFT160\RTCTFT160.ino:122:37: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
printText("C", WHITE,118,145,1);
^
exit status 1
'dtostrf' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
[b]Code[/b]
[code]
#include <Adafruit_GFX.h>
#include <Wire.h>
#include "Sodaq_DS3231.h"
#include <SPI.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
//Color Definitons
#define BLACK 0x0000
#define BLUE 0x001F
#define GREY 0xCE79
#define LIGHTGREY 0xDEDB
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
float maxTemperature=0;
float minTemperature=200;
char charMinTemperature[10];
char charMaxTemperature[10];
char timeChar[100];
char dateChar[50];
char temperatureChar[10];
float temperature = 0;
float previousTemperature = 0;
String dateString;
int minuteNow=0;
int minutePrevious=0;
void setup ()
{
Serial.begin(57600);
tft.reset();
uint16_t identifier = tft.readID();
tft.begin(identifier);
tft.setRotation (2);
tft.fillScreen(BLACK);
Wire.begin();
rtc.begin();
printText("TEMPERATURE", GREEN,30,65,1); // Temperature Static Text
printText("MAX", RED,18,130,1);
printText("MIN", BLUE,95,130,1);
setRTCTime();
}
uint32_t old_ts;
void loop ()
{
float temperature = rtc.getTemperature();
DateTime now = rtc.now(); //get the current date-time
uint32_t ts = now.getEpoch();
if (old_ts == 0 || old_ts != ts) {
old_ts = ts;
minuteNow = now.minute();
if(minuteNow!=minutePrevious)
{
dateString = getDayOfWeek(now.dayOfWeek())+", ";
dateString = dateString+String(now.date())+"/"+String(now.month());
dateString= dateString+"/"+ String(now.year());
minutePrevious = minuteNow;
String hours = String(now.hour());
if(now.minute()<10)
{
hours = hours+":0"+String(now.minute());
}else
{
hours = hours+":"+String(now.minute());
}
hours.toCharArray(timeChar,100);
tft.fillRect(10,0,160,65,BLACK);
printText(timeChar, WHITE,20,25,3);
dateString.toCharArray(dateChar,50);
printText(dateChar, GREEN,8,5,1);
}
if(temperature != previousTemperature)
{
previousTemperature = temperature;
String temperatureString = String(temperature,1);
temperatureString.toCharArray(temperatureChar,10);
tft.fillRect(10,80,128,30,BLACK);
printText(temperatureChar, WHITE,10,80,3);
printText("o", WHITE,90,75,2);
printText("C", WHITE,105,80,3);
if(temperature>maxTemperature)
{
maxTemperature = temperature;
dtostrf(maxTemperature,4, 1, charMaxTemperature); //float,string var incl dec,digits,array to store the results)
tft.fillRect(3,142,33,20,BLACK);
printText(charMaxTemperature, WHITE,3,145,1);
printText("o", WHITE,35,140,1);
printText("C", WHITE,41,145,1);
}
if(temperature < minTemperature)
{
minTemperature = temperature;
dtostrf(minTemperature,4, 1, charMinTemperature);
tft.fillRect(75,140,36,18,BLACK);
printText(charMinTemperature, WHITE,80,145,1);
printText("o", WHITE,112,140,1);
printText("C", WHITE,118,145,1);
setRTCTime();
}
}
}
delay(1000);
}
void setRTCTime()
{
DateTime dt(2018, 6, 11, 15, 40, 30, 1); // Year, Month, Day, Hour, Minutes, Seconds, Day of Week
rtc.setDateTime(dt); //Adjust date-time as defined 'dt' above
}void printText(char *text, uint16_t color, int x, int y,int textSize)
{
tft.setCursor(x, y);
tft.setTextColor(color);
tft.setTextSize(textSize);
tft.setTextWrap(true);
tft.print(text);
}
String getDayOfWeek(int i)
{
switch(i)
{
case 1: return "Monday";break;
case 2: return "Tuesday";break;
case 3: return "Wednesday";break;
case 4: return "Thursday";break;
case 5: return "Friday";break;
case 6: return "Saturday";break;
case 7: return "Sunday";break;
default: return "Monday";break;
}
}
Ive read the ‘dtostrf’ on this forum and others and it seems like its still not working. I’m not sure if its maybe the printText ?
Any case I need professional help as Ive been stuck on this for a long time. Thanks[/code]