Pages: [1]   Go Down
Author Topic: Arduino: Using the tmElements_t structure  (Read 1387 times)
0 Members and 1 Guest are viewing this topic.
Europe, Malta
Offline Offline
Newbie
*
Karma: 0
Posts: 46
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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:
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;

Logged

East Anglia (UK)
Online Online
Faraday Member
**
Karma: 114
Posts: 4236
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Europe, Malta
Offline Offline
Newbie
*
Karma: 0
Posts: 46
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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?
« Last Edit: February 05, 2013, 06:14:45 am by Davste » Logged

Europe, Malta
Offline Offline
Newbie
*
Karma: 0
Posts: 46
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Quote
#include <Arduino.h>
Logged

Pages: [1]   Go Up
Jump to: