Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Development / Re: Problem including Wire library within my library on: July 30, 2010, 04:10:43 pm
@GordonEndersby:  Now that you mention it, that does sound reasonable.  I also read somewhere that when you include one of the included libraries inside of a personal library, it only includes the .h file and not the .cpp file.  I'm not sure if this is entirely true, but it would explain the errors.

EDIT: I would still like to know how to succesfully do what I was trying to do, just for the sake of learning.
2  Forum 2005-2010 (read only) / Development / Re: Problem including Wire library within my library on: July 30, 2010, 12:40:20 pm
@Coding Badly:  For simplicity of use.  If you have to include a library in your sketch, you shoudn't have to include another library in order for the first one to work.  It should already be done for you.
3  Forum 2005-2010 (read only) / Development / Re: Problem including Wire library within my library on: July 30, 2010, 11:11:29 am
@GordonEndersby:  The thing is, I don't want to have to #include Wire.h in my sketch.
4  Forum 2005-2010 (read only) / Development / Re: Problem including Wire library within my library on: July 30, 2010, 10:20:15 am
@Coding Badly: I already did what was suggested in that post.

top of my .cpp file
Code:
#include "WProgram.h"
#include "DS1307.h"
#include "../Wire/Wire.h"

@leppie: I cant find anything in the DateTime library that mentions the DS1307.  In the DateTime playground page, it says that the library uses no exteral circuitry.

One sure way to get my library to work would be to include the actual Wire code in my .cpp file, and make them private functions.

In a link that was on one of the pages that Coding Badly linked to, I read that this used to work in Arduino 0015, but no longer works in Arduino 0018.  If this is true and any of the people that write the IDE updates read this, please consider fixing this.

Again, any and all help is appreciated.
5  Forum 2005-2010 (read only) / Development / Problem including Wire library within my library on: July 30, 2010, 12:17:46 am
I am creating a library that talks to a DS1307 RTC that uses functions from the Wire library.  I am having troubles getting my .cpp file to include Wire.h correctly.

my .h file
Code:
#ifndef DS1307_h
#define DS1307_h
 
#include "WProgram.h"

#define DS1307_ADDR 0x68
 
//masks
#define CH_BIT 0x7F
#define TIME_STYLE_24H 0x3F
#define IF_SQ_OFF_MASK 0x80
#define FREQ_CLEAR 0xFC
#define SQWE_MASK 0x10

//square wave values
#define SQ_1HZ 0x10
#define SQ_4KHZ 0x11
#define SQ_8KHZ 0x12
#define SQ_32KHZ 0x13
#define SQ_OFF_LOW 0x00
#define SQ_OFF_HIGH 0x80
 
class DS1307 {
  public:
    DS1307 ();
    void begin ();
    void begin (boolean);
    void begin (boolean, int);
    
    void setDate (byte, byte, byte, byte, byte, byte, byte);
    void getDate (byte*, byte*, byte*, byte*, byte*, byte*, byte*);
    
    void setSecond (byte);
    void setMinute (byte);
    void setHour (byte);
    void setDayOfWeek (byte);
    void setDayOfMonth (byte);
    void setMonth (byte);
    void setYear (byte);
    
    byte getSecond ();
    byte getMinute ();
    byte getHour ();
    byte getDayOfWeek ();
    byte getDayOfMonth ();
    byte getMonth ();
    byte getYear ();
    boolean getAMPM ();
    
    void outputIfSquareOff (boolean);
    void squareChangeFreq (int);
    void squareOnOff (boolean);
    void setSquare (boolean, boolean, int);
  private:
    void _init (boolean, boolean, int);
    byte _decToBcd (byte);
    byte _bcdToDec (byte);
    
    byte _originalHour;
    byte _squareVal;
    boolean _hourStyle12;
};

extern DS1307 RTC;

#endif

my .cpp file (since its long, I'm only showing functions that include Wire functions, and the functions included in those functions)
Code:
#include "WProgram.h"
#include "DS1307.h"
#include "../Wire/Wire.h"

DS1307::DS1307 () {}

void DS1307::_init (boolean hourStyle12, boolean SQWE, int freq) {
  Wire.begin ();
  
  _squareVal = SQ_OFF_LOW;
  _hourStyle12 = hourStyle12;
  
  if (SQWE) {
    switch (freq) {
      case 1:
        _squareVal = SQ_1HZ;
        break;
      case 4:
        _squareVal = SQ_4KHZ;
        break;
      case 8:
        _squareVal = SQ_8KHZ;
        break;
      case 32:
        _squareVal = SQ_32KHZ;
        break;
      default:
        _squareVal = SQ_1HZ;
        break;
    }
  }
}

byte DS1307::_decToBcd (byte val) {
  return ((val / 10 * 16) + (val % 10));
}

byte DS1307::_bcdToDec (byte val) {
  return ((val / 16 * 10) + (val % 16));
}

void DS1307::setDate (byte second, byte minute, byte hour,
                    byte dayOfWeek, byte dayOfMonth, byte month, byte year) {
  
  Wire.beginTransmission (DS1307_ADDR);
  
  Wire.send (0);
  Wire.send (_decToBcd(second) & CH_BIT); //0 to bit 7 starts the clock
  Wire.send (_decToBcd(minute));
  Wire.send (_decToBcd(hour));
  Wire.send (_decToBcd(dayOfWeek));
  Wire.send (_decToBcd(dayOfMonth));
  Wire.send (_decToBcd(month));
  Wire.send (_decToBcd(year));
  Wire.send (_squareVal);
  
  Wire.endTransmission();
}

void DS1307::getDate (byte *second, byte *minute, byte *hour,
                    byte *dayOfWeek, byte *dayOfMonth, byte *month, byte *year) {
  
  Wire.beginTransmission (DS1307_ADDR);
  Wire.send (0);
  Wire.endTransmission ();
  
  Wire.requestFrom (DS1307_ADDR, 7);
  *second = _bcdToDec (Wire.receive() & CH_BIT);
  *minute = _bcdToDec (Wire.receive());
  *hour = _bcdToDec (Wire.receive() & TIME_STYLE_24H);
  _originalHour = *hour;
  if (_hourStyle12) {
    if (*hour == 0) {
      *hour = 12;
    }
    else if (*hour >= 13) {
      *hour -= 12;
    }
  }
  *dayOfWeek = _bcdToDec (Wire.receive());
  *dayOfMonth = _bcdToDec (Wire.receive());
  *month = _bcdToDec (Wire.receive());
  *year = _bcdToDec (Wire.receive());
}

DS1307 RTC = DS1307();

my error (I'm "------"ing out file paths that include personal info in the path name)
Code:
C:\Users\------\AppData\Local\Temp\build2087115825781654835.tmp\DS1307\DS1307.cpp.o: In function `DS1307::getDate(unsigned char*, unsigned char*, unsigned char*, unsigned char*, unsigned char*, unsigned char*, unsigned char*)':

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:136: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:136: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:136: undefined reference to `TwoWire::beginTransmission(int)'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:137: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:137: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:137: undefined reference to `TwoWire::send(int)'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:138: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:138: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:138: undefined reference to `TwoWire::endTransmission()'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:140: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:140: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:140: undefined reference to `TwoWire::requestFrom(int, int)'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:141: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:141: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:141: undefined reference to `TwoWire::receive()'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:142: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:142: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:142: undefined reference to `TwoWire::receive()'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:143: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:143: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:143: undefined reference to `TwoWire::receive()'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:153: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:153: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:153: undefined reference to `TwoWire::receive()'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:154: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:154: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:154: undefined reference to `TwoWire::receive()'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:155: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:155: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:155: undefined reference to `TwoWire::receive()'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:156: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:156: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:156: undefined reference to `TwoWire::receive()'

C:\Users\------\AppData\Local\Temp\build2087115825781654835.tmp\DS1307\DS1307.cpp.o: In function `DS1307::_init(unsigned char, unsigned char, int)':

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:27: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:27: undefined reference to `Wire'

C:\Program Files\arduino-0018\libraries\DS1307/DS1307.cpp:27: undefined reference to `TwoWire::begin()'

Any and all help would be appreciated.

By the way, my sketch that impliments this works right if I have a #include <Wire.h> at the top of the sketch.  It's weird, because it should work exactly the same whether you include Wire.h once or twice.
6  Forum 2005-2010 (read only) / Development / Re: Which Bootloader Should I Use? on: January 13, 2011, 07:58:00 am
This is kind of getting off topic, but if my application will not be doing anything with analog inputs, how should I leave AREF; floating or decoupled to GND(or other option)?
7  Forum 2005-2010 (read only) / Development / Re: Which Bootloader Should I Use? on: January 12, 2011, 11:14:06 pm
Thank you for your input.  I had heard of Adaboot, but I didn't know that she had a download sitting somewhere.  

About AREF, I had been wondering what to do if I didn't want to use it.  I couldn't find out by the datasheet, so I tied it to +5.  Thank you for telling me to leave it floating, because I wouldn't want to risk frying my fairly expensive(relative to my usual budget) project.
8  Forum 2005-2010 (read only) / Development / Which Bootloader Should I Use? on: January 12, 2011, 09:53:50 pm
I am in the middle of a project in which I will be embedding an almost exact Arduino clone.  This project will be using an ATMega382P-AU in a TQFP package for the microcontroller, and an FT232RL for serial communications, wired in the exact same way as the Arduino Duemilanove. The only differences in the two schematics are that mine has the USB V+ pin not connected, as I plan to only use an external power supply, and AREF is tied to +5V.  The ATMega382 will be coming straight from Digikey, with no bootloader.

There are a few bootloaders to chose from, and I don't want to permanently mess up my chip after I solder it in (It is SMD).  My questions are:

1: Does the latest version of the Arduino IDE have the Duemilanove bootloader(with the faster timeout), and would it work correctly in my application?
2: Does the latest version of the Arduino IDE have the Optiboot bootloader, and would it work correctly in my application (without the notorious "flash amnessia")?
3: Are there any better bootloaders than these that would work correctly in my application?

Also, I saw in the notes for ArduinoISP that
Quote
Windows users should consider WinAVR's avrdude instead of the avrdude included with Arduino software.
Should I take this into consideration, because I am running Windows Vista 32-bit.

Thanks.
9  Forum 2005-2010 (read only) / Interfacing / Re: Graphic LCD (KS0108) library now available on: June 08, 2010, 04:58:01 pm
Hi all.

Are there any instructions out there that explain how to use the FontCreator software?
Pages: [1]