*SOLVED* Executing SimpleTimer from within a library

This is driving me nutts, I know its doable. But I'm not very familiar with C++ and pointers and stuff. This is my first attempt at writing a library, the code works just fine if I run in directly in the arduino code, so I know its a pointer issue, but I'm having a heck of a time wrapping my head around pointers.

I'm trying to write a library, that user the SimpleTimer library. What it does is simulate a sunset with an RGB strip for my aquarium.

I cant get around "error: no matching function for call to 'SunSet::setTimer(int, , int)'"
Here is the striped down code showing just what is relavant to the isssue, I hope.

Sunset.h

#include "SimpleTimer.h"

class SunSet
{
  public:
     void Tick();
  private:
     SimpleTimer _t;
     void SetTimer(int targ);

SunSet.cpp

void SunSet::SetTimer(int targ){
	_t.setTimer((int)(Target_Dur[targ]*60000)/255, Tick, 255); //ERROR popsup on this line
	}

void SunSet::Tick(){
    //do stuff here
}

(Target_Dur[targ]*60000)/255

Think you have an overflow issue here as intermediate results do not fit in an int.

Your SunSet.h code is not complete. What does the rest of it look like?

Think you have an overflow issue here as intermediate results do not fit in an int.

Nope works just fine in normal code.

Here is my header file

#ifndef SunSet_h
#define SunSet_h

#include "Arduino.h"
#include "SimpleTimer.h"

class SunSet
{
  public:
    SunSet(int Rpin,int Gpin,int Bpin, boolean Defaults);
    void SetDefault();
    void SetTarget(int Target, int Red, int Green, int Blue, float Dur);
    void Begin();
    void Update();
    void Tick();
    
	 float current[4];
   
    int Target_1[4];
    int Target_2[4];
    int Target_3[4];
    
    
   
    
  private:
  	 void SetTimer(int targ);
    int _tick;
    int pin[4];
    double _Duration;
    float Target_Dur[4];
    float Target_1_tick[4];float Target_2_tick[4];float Target_3_tick[4];
    
    SimpleTimer _t;
    
 
    
};

#endif

And my cpp

#include "SunSet.h"

SunSet::SunSet(int Rpin,int Gpin,int Bpin, boolean Defaults){
  pinMode(Rpin, OUTPUT);pinMode(Gpin, OUTPUT);pinMode(Bpin, OUTPUT);
  current[1] = 255;current[2] = 255;current[3] = 255;
  pin[1] = Rpin;pin[2] = Gpin;pin[3] = Bpin;
  _tick = 0;
  if(Defaults){
    analogWrite(pin[1], current[1]);analogWrite(pin[2], current[2]);analogWrite(pin[3], current[3]);
    SetDefault();
  }
}

void SunSet::SetDefault(){
  SetTarget(1, 255,150,170,.2); // Target #, Red, Green, Blue, Time minutes
  SetTarget(2, 150,0,150,.2);
  SetTarget(3, 0,0,50,.2);
  
}

void SunSet::SetTarget(int Target, int Red, int Green, int Blue, float Dur){
  int* _Target;
  
  if(Target == 1){_Target = Target_1;}
  else if (Target == 2){_Target = Target_2;}
  else if (Target == 3){_Target = Target_3;}
  Target_Dur[Target] = Dur;
  _Target[1] = Red;_Target[2] = Green;_Target[3] = Blue;
}


void SunSet::Begin(){
  //calculate Target ticks
  for(int x=1;x<4;x++){
    Target_1_tick[x] = (current[x] - Target_1[x])/255;
    Serial.print("Target 1 ");Serial.print(x);Serial.print(" : ");Serial.println(Target_1_tick[x]);
  }
  SetTimer(1);
  
}

void SunSet::Update(){
  _t.run();
}



void SunSet::SetTimer(int targ){
	_t.setTimer((int)(Target_Dur[targ]*60000)/255, Tick, 255);
	}

void SunSet::Tick(){
  
  _tick ++;   
  //Serial.println(_tick);
   if(_tick <255){//target 1
     
     for(int x=1;x<4;x++){//calculate new current
        current[x] -= Target_1_tick[x];
     }
   }else if(_tick <510){//target 2
     if( _tick == 255){
       SetTimer(2);
        for(int x=1;x<4;x++){
          Target_2_tick[x] = (current[x] - Target_2[x])/255;
          //Serial.print("Target 2 ");Serial.print(x);Serial.print(" : ");Serial.println(Target_2_tick[x]);
        }
     }
      for(int x=1;x<4;x++){//calculate new current
        current[x] -= Target_2_tick[x];
       }
   }else if(_tick <765){//target 3
     if( _tick == 510){
       SetTimer(3);
        for(int x=1;x<4;x++){
          Target_3_tick[x] = (current[x] - Target_3[x])/255;
          //Serial.print("Target 3 ");Serial.print(x);Serial.print(" : ");Serial.println(Target_3_tick[x]);
        }
     }
     for(int x=1;x<4;x++){//calculate new current
        current[x] -= Target_3_tick[x];
     }
   }
 
 
   for(int x=1;x<4;x++){//write each new current to pins
        //Serial.print(" Current ");Serial.print(x);Serial.print(" : ");Serial.print(current[x]);
        analogWrite(pin[x], (int) current[x]);
    }
  
}
    float Target_1_tick[4];float Target_2_tick[4];float Target_3_tick[4];

Is your enter key broken? One statement per line!

What does your sketch look like?

Is your enter key broken? One statement per line!

.

Just makes for less code to scroll through

Just makes for less code to scroll through

So does not posting the sketch. But, if you really want help, ...

I got it figured.
Tracked down a modified simpletimer.h that uses a deligate system

Just had to modify the new simpletimer code for arduino 1.0 by changing Wprogram.h to Arduino.h

Very good solution, no help whats so ever from you guys, especial Mr. PaulS there.

Good to hear it is solved,

To keep the library backwards compatible you could use this construct

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

This way the compiler can select the right #include based upon the Arduino version.

Similar code constructs exists based upon board type.

Very good solution, no help whats so ever from you guys, especial Mr. PaulS there.

Well, you're welcome.

You know, in any given situation when you have a problem, you can hope that someone else has figured out a solution, or you can learn to fix it yourself.

In this case, you got lucky, and someone else had solved the problem for you. But, you didn't learn squat.

Next time, you'll be up the creek and still won't have a paddle.

What we were trying to do was to teach you how to make a paddle, instead of buying one off ebay.

If you are not interested in learning to make a paddle, fine. Saying that up front would have had a lot of us just ignoring you, instead of wasting your time.

I did learn exactly how to solve my problem, just not from this thread. I do not just take open source code and cut paste and forget, I try to understand it, and almost always modify it to my particular needs. When I come across this problem again, and I'm sure I will, I will simply incorporate the fast delegate system, so I have learned exactly what I needed to learn.
I greatly appreciate any help I can find, and constructive criticism is always welcomed. I don't want to bash this forum, as searching it has helped me with a lot of issues, I did find the solution on this forum. However, as paul pointed out, I did learn nothing from this thread, I do not see that as my fault. I know the standard is one statement per line, and if I were to post full functioning code I would standardise it and comment the heck out of it, and thank you for that tip, you could be abit more polite in pointing it out tho. I would like to make a quick point, that irrelevant comments also tend to get a thread side tracked, difficult to follow and help no one.
I rarely post on forums in general, because someone else has always had a similar problem, and google can always find it. So why duplicate an issue. In this case I was getting frustrated and decided to ask for help, that only lead to more frustration.

IMO. You posted a well formed Initial Problem Statement and supplied almost all the needed information. Your code was well written and formatted. By and large you followed the posting guidelines. Much much better than many questions this forum receives!!! Even those that contribute mightily to a forum or industry cannot speak for "all of us" in it. Glad you got it working!

Cheers,
John