Pages: 1 [2]   Go Down
Author Topic: Real Time Clock code update to Arduino 1.0  (Read 2031 times)
0 Members and 1 Guest are viewing this topic.
Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 610
Posts: 49044
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This:
Code:
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"

#else
#include "WProgram.h"
#include "WConstants.h"
#endif
goes AFTER this:
Code:
#ifndef DS1307_h
#define DS1307_h
Where the #include statements were before.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

File DS1307.h:
Code:
  DS1307.h - library for DS1307 rtc
*/


// ensure this library description is only included once
#ifndef DS1307_h
#define DS1307_h

#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"

#else
#include "WProgram.h"
#include "WConstants.h"
#endif


// include types & constants of Wire ic2 lib
#include <../Wire/Wire.h>

#define DS1307_SEC 0
#define DS1307_MIN 1
#define DS1307_HR 2
#define DS1307_DOW 3
#define DS1307_DATE 4
#define DS1307_MTH 5
#define DS1307_YR 6

#define DS1307_BASE_YR 2000

#define DS1307_CTRL_ID B1101000  //DS1307

 // Define register bit masks
#define DS1307_CLOCKHALT B10000000

#define DS1307_LO_BCD  B00001111
#define DS1307_HI_BCD  B11110000

#define DS1307_HI_SEC  B01110000
#define DS1307_HI_MIN  B01110000
#define DS1307_HI_HR   B00110000
#define DS1307_LO_DOW  B00000111
#define DS1307_HI_DATE B00110000
#define DS1307_HI_MTH  B00110000
#define DS1307_HI_YR   B11110000

// library interface description
class DS1307
{
  // user-accessible "public" interface
  public:
    DS1307();
    void get(int *, boolean);
    int get(int, boolean);
void set(int, int);
    void start(void);
    void stop(void);

  // library-accessible "private" interface
  private:
    byte rtc_bcd[7]; // used prior to read/set ds1307 registers;
void read(void);
void save(void);
};

extern DS1307 RTC;

#endif
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Error message:
In file included from C:\Users\user\Desktop\arduino-1.0\hardware\arduino\cores\arduino/Print.h:26,
                 from C:\Users\user\Desktop\arduino-1.0\hardware\arduino\cores\arduino/Stream.h:26,
                 from C:\Users\user\Desktop\arduino-1.0\libraries\DHT/../Wire/Wire.h:24,
                 from C:\Users\user\Desktop\arduino-1.0\libraries\DS1307\DS1307.cpp:3:
C:\Users\user\Desktop\arduino-1.0\hardware\arduino\cores\arduino/WString.h:116: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, const char*)' conflicts with
C:\Users\user\Desktop\arduino-1.0\hardware\arduino\cores\arduino/WString.h:115: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const String&)' here
C:\Users\user\Desktop\arduino-1.0\hardware\arduino\cores\arduino/WString.h:117: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, char)' conflicts with
C:\Users\user\Desktop\arduino-1.0\hardware\arduino\cores\arduino/WString.h:116: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const char*)' here
C:\Users\user\Desktop\arduino-1.0\hardware\arduino\cores\arduino/WString.h:118: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, unsigned char)' conflicts with
C:\Users\user\Desktop\arduino-1.0\hardware\arduino\cores\arduino/WString.h:117: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, char)' here
C:\Users\user\Desktop\arduino-1.0\hardware\arduino\cores\arduino/WString.h:119: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, int)' conflicts with
C:\Users\user\Desktop\arduino-1.0\hardware\arduino\cores\arduino/WString.h:118: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, unsigned char)' here
C:\Users\user\Desktop\arduino-1.0\hardware\arduino\cores\arduino/WString.h:120: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, unsigned int)' conflicts with
C:\Users\user\Desktop\arduino-1.0\hardware\arduino\cores\arduino/WString.h:119: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, int)' here
C:\Users\user\Desktop\arduino-1.0\hardware\arduino\cores\arduino/WString.h:121: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, long int)' conflicts with
C:\Users\user\Desktop\arduino-1.0\hardware\arduino\cores\arduino/WString.h:120: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, unsigned int)' here
C:\Users\user\Desktop\arduino-1.0\hardware\arduino\cores\arduino/WString.h:122: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, long unsigned int)' conflicts with
C:\Users\user\Desktop\arduino-1.0\hardware\arduino\cores\arduino/WString.h:121: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, long int)' here
C:\Users\user\Desktop\arduino-1.0\libraries\DS1307\DS1307.cpp: In member function 'void DS1307::read()':
C:\Users\user\Desktop\arduino-1.0\libraries\DS1307\DS1307.cpp:23: error: call of overloaded 'write(int)' is ambiguous
C:\Users\user\Desktop\arduino-1.0\libraries\DHT/../Wire/Wire.h:55: note: candidates are: virtual size_t TwoWire::write(uint8_t)
C:\Users\user\Desktop\arduino-1.0\hardware\arduino\cores\arduino/Print.h:49: note:                 size_t Print::write(const char*)
C:\Users\user\Desktop\arduino-1.0\libraries\DS1307\DS1307.cpp:31: error: 'class TwoWire' has no member named 'receive'
C:\Users\user\Desktop\arduino-1.0\libraries\DS1307\DS1307.cpp: In member function 'void DS1307::save()':
C:\Users\user\Desktop\arduino-1.0\libraries\DS1307\DS1307.cpp:39: error: call of overloaded 'write(int)' is ambiguous
C:\Users\user\Desktop\arduino-1.0\libraries\DHT/../Wire/Wire.h:55: note: candidates are: virtual size_t TwoWire::write(uint8_t)
C:\Users\user\Desktop\arduino-1.0\hardware\arduino\cores\arduino/Print.h:49: note:                 size_t Print::write(const char*)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


This library DS1307.h is modified  for v1.0:
http://arduino.cc/forum/index.php?topic=93077.0
Logged

Pages: 1 [2]   Go Up
Jump to: