Go Down

Topic: Arduino: Using the tmElements_t structure (Read 1 time) previous topic - next topic

Davste

I'm still a novice to C, so this is probably a silly mistake.
I'm trying to use the tmElements_t structure in the Time class.


Code: [Select]
#ifndef RTCTime_h
#define RTCTime_h

#include <Time.h>

class RTCTime
{
public:
RTCTime();
void setTime(tmElements_t t);
tmElements_t getTime();
}

#endif


I get this error:
Quote
RTCTime.h : 'tmElements_t' has not been declared
RTCTime.h : 'tmElements_t' does not name a type


I am confused. Shouldn't this work? I'm importing <Time.h> at the top and Time.h contains the structure here:
Code: [Select]
typedef struct  {
 uint8_t Second;
 uint8_t Minute;
 uint8_t Hour;
 uint8_t Wday;   // day of week, sunday is day 1
 uint8_t Day;
 uint8_t Month;
 uint8_t Year;   // offset from 1970;
} tmElements_t, TimeElements, *tmElementsPtr_t;



UKHeliBob

It would be better if you uploaded the whole program, or a complete program that shows the problem.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Davste

#2
Feb 05, 2013, 12:12 pm Last Edit: Feb 05, 2013, 12:14 pm by Davste Reason: 1

It would be better if you uploaded the whole program, or a complete program that shows the problem.


This demonstrates the problem, it does not compile:

Code: [Select]
#include <Time.h>

void setup()
{
 tm_Elements_t test;
}

void loop() {}


Quote

sketch_feb05a.ino: In function 'void setup()':
sketch_feb05a:6: error: 'tm_Elements_t' was not declared in this scope
sketch_feb05a:6: error: expected `;' before 'test'


tm_Elements_t exists in the Time class but it will not find it even though it's imported. "Not declared."

On the other hand, if I use time_t, it does find it:

Quote
#include <Time.h>

void setup()
{

  time_t test;
}

void loop() {}


I need a time structure for my purposes though, that has hours, minutes, seconds, days months and years. Maybe I should just create one myself instead of trying to use the structure in the time class?

Davste

Ok, found the problem... I had to declare

Quote
#include <Arduino.h>

Go Up