Hi,
I got a pb calling function from a dedicated class.
This is my main program:
/*
CoreSystem
Manage Main Loop to control some electrical feature
*/
#include <inttypes.h>
#include <Time.h>
#include <TimeAlarms.h>
#include <Utils.h>
#include <Traces.h>
#include <PushButton.h>
#include <PinManager.h>
#include <FunctionalProcess.h>
#include <Wire.h>
#include <LiquidCrystal.h>
#include <DS1307.h> // written by mattt on the Arduino forum and modified by D. Sjunnesson
extern Traces Tracer ;
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
//
// SETUP
//
void setup() {
// SERIAL
Serial.begin(9600);
// LCD
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.clear();
delay(2000);
Tracer.Print("ecran initialise");
//
// GESTION DES ALLUMAGES/EXTINCTION DES LIGNES
//
Tracer.setLcd(&lcd);
Alarm.timerRepeat(4, FunctionalProcess::AfficheDate);
}
//
// LOOP
//
void loop() {
Alarm.delay(0); // wait one second between clock display
}
This is the Traces class :
/*
Traces.cpp for traces output.
*/
#include "WProgram.h"
#include "Traces.h"
#include "Time.h"
#include <Wire.h>
#include <Utils.h>
#include <DS1307.h>
#include <LiquidCrystal.h>
//=============================================================================
/* Constructor & Destructor {{{1 */
Traces::Traces()
{
b_clearEntireLine=true;
l_lastIndexPositionWritten=0;
l_selectedLine=0;
}
Traces::~Traces()
{
}
Traces::Traces( const Traces &cpy )
{
}
/* }}}1 */
//=============================================================================
/* Accessors {{{1 */
void Traces::setLcd(LiquidCrystal *lcdPtr) {
if ( lcdPtr != NULL )
{
_lcdPtr = lcdPtr;
Traces::Print("Le module de trace contient un pointeur vers le LCD OK!");
delay(500);
}
else
{
Traces::Print("Erreur pointeur nul sur le module de trace");
}
}
/* }}}1 */
//=============================================================================
/* Serial Print Feature {{{1 */
void Traces::Print(String pstr) {
Serial.println(Date()+pstr);
}
void Traces::BeginPrint(String pstr) {
Serial.print(Date()+pstr);
}
void Traces::EndPrint(String pstr) {
Serial.println(pstr);
}
/* }}}1 */
//=============================================================================
/* LCD Print Methods {{{1 */
//=============================================================================
// Print methods on LCD Top Line {{{2
void Traces::LcdPrintTopLine(String pstr) {
l_selectedLine=0;
_lcdPtr->home();
_lcdPtr->print(strutils::CompleteString(pstr));
}
void Traces::LcdPrintTopLineFromLeft(String pstr) {
l_selectedLine=0;
Traces::LcdPrintFromLeft(pstr);
}
void Traces::LcdPrintTopLineFromRight(String pstr) {
l_selectedLine=0;
Traces::LcdPrintFromRight(pstr);
}
// }}}2
//=============================================================================
// Print methods on LCD Bottom Line {{{2
void Traces::LcdPrintBottomLine(String pstr) {
l_selectedLine=1;
_lcdPtr->home();
_lcdPtr->print(strutils::CompleteString(pstr));
}
void Traces::LcdPrintBottomLineFromLeft(String pstr) {
l_selectedLine=1;
Traces::LcdPrintFromLeft(pstr);
}
void Traces::LcdPrintBottomLineFromRight(String pstr) {
l_selectedLine=1;
Traces::LcdPrintFromRight(pstr);
}
// }}}2
//=============================================================================
// Print methods to write from left or right direction {{{2
void Traces::LcdPrintFromLeft(String pstr) {
// _lcdPtr->home();
_lcdPtr->setCursor(0,0);
// write message
for (int i=0; i<pstr.length(); ++i)
{
_lcdPtr->setCursor(i,0);
_lcdPtr->print(pstr.charAt(i));
// delay(150);
}
}
void Traces::LcdPrintFromRight(String pstr) {
//
_lcdPtr->setCursor(16,l_selectedLine);
// write message
int pos = 16;
for (int i=pstr.length(); i>=0; --i)
{
_lcdPtr->setCursor(pos,l_selectedLine);
_lcdPtr->print(pstr.charAt(i));
pos--;
// delay(150);
}
}
// }}}2
// }}}1
//=============================================================================
// LCD Clear Methods {{{1
void Traces::LcdClearLine(int noLine) {
_lcdPtr->home();
for (int i=0; i<16; ++i)
{
_lcdPtr->setCursor(i,noLine);
_lcdPtr->print(" ");
delay(10);
}
}
void Traces::LcdClearTopLine() {
Traces::LcdClearLine(0);
}
void Traces::LcdClearBottomLine() {
Traces::LcdClearLine(1);
}
void Traces::LcdClearScreen() {
Traces::LcdClearTopLine();
Traces::LcdClearBottomLine();
}
// }}}1
//=============================================================================
/* Utils Private Methods {{{1 */
String Traces::Date(){
String str ;
str+=convert::ToTwoDigits(RTC.get(DS1307_HR, true))+":"+convert::ToTwoDigits(RTC.get(DS1307_MIN, false))+":"+convert::ToTwoDigits(RTC.get(DS1307_SEC , false))+"_";
return str;
}
/* }}}1 */
//=============================================================================
Traces Tracer = Traces() ;
/* set fdm=marker */
And this is the class that contains all Functional Methods:
/*
FunctionalProcess.cpp manage some utility own tasks to provide
in my domotik managment
*/
#include "WProgram.h"
#include <Wire.h>
#include <Traces.h>
#include <FunctionalProcess.h>
#include <PinManager.h>
#include <DS1307.h> // written by mattt on the Arduino forum and modified by D. Sjunnesson
#include <Utils.h>
// MANAGER
//static PinManager PinMng;
extern Traces Tracer;
//=============================================================================
/* Constructor & Destructor {{{1 */
FunctionalProcess::FunctionalProcess()
{
}
/* }}}1 */
//=============================================================================
/* {{{1 TIME MANAGMENT */
void FunctionalProcess::setRealTimeClock() {
//setTime(22,15,00,01,18,2010);
Tracer.Print("Heures du systeme embarque mise a jour.");
// MODULE HORLOGE TEMPS REEL EMBARQUEE
RTC.stop();
// REGLAGE HEURE
RTC.set(DS1307_HR , horodatage::getHours()); // set the hours
RTC.set(DS1307_MIN , horodatage::getMinutes()); // set the minutes
RTC.set(DS1307_SEC , horodatage::getSeconds()); // set the seconds
// REGLAGE DATE
RTC.set(DS1307_DATE , 12); // set the date
RTC.set(DS1307_MTH , 11); // set the month
RTC.set(DS1307_YR , 10); // set the year
RTC.set(DS1307_DOW , 4 ); // set the day of the week
RTC.start();
}
void FunctionalProcess::getRealTimeClock() {
Tracer.BeginPrint(RTC.get(DS1307_HR , true )); //read the hour and also update all the values by pushing in true
Serial.print(":");
Serial.print(RTC.get(DS1307_MIN , false)); //read minutes without update (false)
Serial.print(":");
Serial.print(RTC.get(DS1307_SEC , false)); //read seconds
Serial.print(" "); // some space for a more happy life
Serial.print(RTC.get(DS1307_DATE, false)); //read date
Serial.print("/");
Serial.print(RTC.get(DS1307_MTH , false)); //read month
Serial.print("/");
Serial.print(RTC.get(DS1307_YR , false)); //rea d year
Serial.println();
}
void FunctionalProcess::displayRealTimeClock() {
Tracer.BeginPrint(RTC.get(DS1307_HR , true )); //read the hour and also update all the values by pushing in true
Tracer.BeginPrint(":");
Tracer.BeginPrint(RTC.get(DS1307_MIN , false)); //read minutes without update (false)
Tracer.BeginPrint(":");
Tracer.EndPrint(RTC.get(DS1307_SEC , false)); //read seconds
}
/* }}}1 */
//=============================================================================
/* {{{1 AFFICHAGE INFOS HORODATAGE */
//
void FunctionalProcess::AfficheInfo(const int p_Info) {
Tracer.LcdPrintTopLineFromLeft(horodatage::currentTime());
switch ( p_Info )
{
// time
case 1 :
Tracer.LcdPrintTopLineFromLeft(horodatage::currentTime());
break;
// temperature
case 2 :
Tracer.LcdPrintTopLineFromRight("18.9 C");
break;
// date
case 3 :
Tracer.LcdPrintBottomLineFromRight(horodatage::currentDate());
break;
default:
Tracer.Print(horodatage::currentTime());
Tracer.LcdPrintTopLineFromLeft(horodatage::currentTime());
Tracer.LcdPrintTopLineFromRight("18.9 C");
Tracer.LcdPrintBottomLineFromRight(horodatage::currentDate());
break;
break;
}
}
void FunctionalProcess::AfficheTemperature() {
Tracer.LcdPrintTopLineFromRight("18.9 C");
}
void FunctionalProcess::AfficheDate() {
Tracer.Print("Date");
Tracer.LcdPrintBottomLineFromRight(horodatage::currentDate());
}
/* }}}1 */
FunctionalProcess FuncTask = FunctionalProcess() ;
// vim:fdm=marker:nowrap:ts=4:expandtab:
The problem is that no characters persists on my LCD screen.
When I do not use TimeAlarm class it works well.
Thank you for help